blob: e80836af8c836a6cc3d82ea17b2515db1ad03d5d [file] [log] [blame]
Simon Hunt5f6dbf82016-03-30 08:53:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Simon Hunt5f6dbf82016-03-30 08:53:33 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.ui.model.topo;
18
Simon Huntc0f20c12016-05-09 09:30:20 -070019import org.onosproject.net.DeviceId;
Simon Hunt23fb1352016-04-11 12:15:19 -070020import org.onosproject.net.Host;
Simon Hunt642bc452016-05-04 19:34:45 -070021import org.onosproject.net.HostId;
Simon Huntc0f20c12016-05-09 09:30:20 -070022import org.onosproject.net.PortNumber;
23
24import static com.google.common.base.MoreObjects.toStringHelper;
Simon Hunt23fb1352016-04-11 12:15:19 -070025
Simon Hunt5f6dbf82016-03-30 08:53:33 -070026/**
27 * Represents an end-station host.
28 */
29public class UiHost extends UiNode {
Simon Hunt23fb1352016-04-11 12:15:19 -070030
Simon Huntc0f20c12016-05-09 09:30:20 -070031 private final UiTopology topology;
32 private final Host host;
33
34 // Host location
35 private DeviceId locDevice;
36 private PortNumber locPort;
37
38 private UiLinkId edgeLinkId;
39
40 /**
41 * Creates a new UI host.
42 *
43 * @param topology parent topology
44 * @param host backing host
45 */
46 public UiHost(UiTopology topology, Host host) {
47 this.topology = topology;
48 this.host = host;
49 }
50
51// @Override
52// protected void destroy() {
53// }
Simon Hunt23fb1352016-04-11 12:15:19 -070054
55 @Override
Simon Huntc0f20c12016-05-09 09:30:20 -070056 public String toString() {
57 return toStringHelper(this)
58 .add("id", id())
59 .add("dev", locDevice)
60 .add("port", locPort)
61 .toString();
Simon Hunt23fb1352016-04-11 12:15:19 -070062 }
Simon Hunt642bc452016-05-04 19:34:45 -070063
64 /**
65 * Returns the identity of the host.
66 *
67 * @return host ID
68 */
69 public HostId id() {
70 return host.id();
71 }
72
73 @Override
74 public String idAsString() {
75 return id().toString();
76 }
Simon Huntc0f20c12016-05-09 09:30:20 -070077
78 /**
79 * Sets the host's current location.
80 *
81 * @param deviceId ID of device
82 * @param port port number
83 */
84 public void setLocation(DeviceId deviceId, PortNumber port) {
85 locDevice = deviceId;
86 locPort = port;
87 }
88
89 /**
90 * Sets the ID of the edge link between this host and the device to which
91 * it connects.
92 *
93 * @param id edge link identifier to set
94 */
95 public void setEdgeLinkId(UiLinkId id) {
96 this.edgeLinkId = id;
97 }
98
99 /**
100 * Returns the host instance backing this UI host.
101 *
102 * @return the backing host instance
103 */
104 public Host backingHost() {
105 return host;
106 }
107
108 /**
109 * Identifier for the edge link between this host and the device to which
110 * it is connected.
111 *
112 * @return edge link identifier
113 */
114 public UiLinkId edgeLinkId() {
115 return null;
116 }
Simon Hunt5f6dbf82016-03-30 08:53:33 -0700117}