2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.hosttracker.northbound;
11 import java.io.Serializable;
13 import javax.xml.bind.annotation.XmlAccessType;
14 import javax.xml.bind.annotation.XmlAccessorType;
15 import javax.xml.bind.annotation.XmlElement;
16 import javax.xml.bind.annotation.XmlRootElement;
18 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
19 import org.opendaylight.controller.sal.core.Node;
20 import org.opendaylight.controller.sal.core.NodeConnector;
21 import org.opendaylight.controller.sal.packet.address.DataLinkAddress;
22 import org.opendaylight.controller.sal.packet.address.EthernetAddress;
25 * Configuration Java Object which represents a Host configuration information
29 @XmlAccessorType(XmlAccessType.NONE)
30 public class HostConfig implements Serializable {
31 private static final long serialVersionUID = 1L;
34 public String dataLayerAddress;
36 private String nodeType;
38 private String nodeId;
40 private String nodeConnectorType;
42 private String nodeConnectorId;
46 private boolean staticHost;
48 private String networkAddress;
54 protected String getDataLayerAddress() {
55 return this.dataLayerAddress;
58 protected String getNodeType() {
62 protected String getNodeId() {
66 protected String getNodeConnectorType() {
67 return this.nodeConnectorType;
70 protected String getNodeConnectorId() {
71 return this.nodeConnectorId;
74 protected String getVlan() {
78 protected boolean isStaticHost() {
82 protected String getNetworkAddress() {
83 return networkAddress;
86 public static HostConfig convert(HostNodeConnector hnc) {
90 HostConfig hc = new HostConfig();
91 DataLinkAddress dl = hnc.getDataLayerAddress();
92 if(dl instanceof EthernetAddress) {
93 EthernetAddress et = (EthernetAddress) dl;
94 hc.dataLayerAddress = et.getMacAddress();
96 hc.dataLayerAddress = dl.getName();
98 NodeConnector nc = hnc.getnodeConnector();
100 hc.nodeConnectorType = nc.getType();
101 hc.nodeConnectorId = nc.getNodeConnectorIDString();
102 Node n = hnc.getnodeconnectorNode();
104 hc.nodeType = n.getType();
105 hc.nodeId = n.getNodeIDString();
108 hc.vlan = String.valueOf(hnc.getVlan());
109 hc.staticHost = hnc.isStaticHost();
110 hc.networkAddress = hnc.getNetworkAddressAsString();