X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnorthbound%2Fhosttracker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fhosttracker%2Fnorthbound%2FHostConfig.java;fp=opendaylight%2Fnorthbound%2Fhosttracker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fhosttracker%2Fnorthbound%2FHostConfig.java;h=b66da3423613922e028a1445ecad6464d3c72b9c;hb=296919c20754371474fcc4518aa1bd6ba99d6573;hp=0000000000000000000000000000000000000000;hpb=45359d534b96d408ba495b7a53d9ca859b0190fd;p=controller.git diff --git a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostConfig.java b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostConfig.java new file mode 100644 index 0000000000..b66da34236 --- /dev/null +++ b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostConfig.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.hosttracker.northbound; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.controller.sal.packet.address.DataLinkAddress; +import org.opendaylight.controller.sal.packet.address.EthernetAddress; + +/** + * Configuration Java Object which represents a Host configuration information + * for HostTracker. + */ +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public class HostConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @XmlElement + public String dataLayerAddress; + @XmlElement + private String nodeType; + @XmlElement + private String nodeId; + @XmlElement + private String nodeConnectorType; + @XmlElement + private String nodeConnectorId; + @XmlElement + private String vlan; + @XmlElement + private boolean staticHost; + @XmlElement + private String networkAddress; + + public HostConfig() { + + } + + protected String getDataLayerAddress() { + return this.dataLayerAddress; + } + + protected String getNodeType() { + return this.nodeType; + } + + protected String getNodeId() { + return this.nodeId; + } + + protected String getNodeConnectorType() { + return this.nodeConnectorType; + } + + protected String getNodeConnectorId() { + return this.nodeConnectorId; + } + + protected String getVlan() { + return this.vlan; + } + + protected boolean isStaticHost() { + return staticHost; + } + + protected String getNetworkAddress() { + return networkAddress; + } + + public static HostConfig convert(HostNodeConnector hnc) { + if(hnc == null) { + return null; + } + HostConfig hc = new HostConfig(); + DataLinkAddress dl = hnc.getDataLayerAddress(); + if(dl instanceof EthernetAddress) { + EthernetAddress et = (EthernetAddress) dl; + hc.dataLayerAddress = et.getMacAddress(); + } else { + hc.dataLayerAddress = dl.getName(); + } + NodeConnector nc = hnc.getnodeConnector(); + if(nc != null) { + hc.nodeConnectorType = nc.getType(); + hc.nodeConnectorId = nc.getNodeConnectorIDString(); + Node n = hnc.getnodeconnectorNode(); + if(n != null) { + hc.nodeType = n.getType(); + hc.nodeId = n.getNodeIDString(); + } + } + hc.vlan = String.valueOf(hnc.getVlan()); + hc.staticHost = hnc.isStaticHost(); + hc.networkAddress = hnc.getNetworkAddressAsString(); + return hc; + } +}