X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fswitchmanager%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fswitchmanager%2FSpanConfig.java;h=eeccf1080baa66f9e92424a3e691e7015ec36338;hb=9255eb1b0531be05266f52175044464fee30a969;hp=83cb8b1cc9786f42757e1f609dedf724943c0f19;hpb=6ceede511bb60f9ec6aa883c60df8c5242813b61;p=controller.git diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java index 83cb8b1cc9..eeccf1080b 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java @@ -14,10 +14,9 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; -import org.opendaylight.controller.sal.core.ConstructionException; +import org.opendaylight.controller.configuration.ConfigurationObject; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; -import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType; import org.opendaylight.controller.sal.utils.GUIField; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +24,7 @@ import org.slf4j.LoggerFactory; /** * The class represents a Span Port configuration for a network node. */ -public class SpanConfig implements Serializable { +public class SpanConfig extends ConfigurationObject implements Serializable { protected static final Logger logger = LoggerFactory .getLogger(SpanConfig.class); private static final long serialVersionUID = 1L; @@ -75,23 +74,30 @@ public class SpanConfig implements Serializable { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } SpanConfig other = (SpanConfig) obj; if (nodeId == null) { - if (other.nodeId != null) + if (other.nodeId != null) { return false; - } else if (!nodeId.equals(other.nodeId)) + } + } else if (!nodeId.equals(other.nodeId)) { return false; + } if (spanPort == null) { - if (other.spanPort != null) + if (other.spanPort != null) { return false; - } else if (!spanPort.equals(other.spanPort)) + } + } else if (!spanPort.equals(other.spanPort)) { return false; + } return true; } @@ -116,32 +122,12 @@ public class SpanConfig implements Serializable { } public ArrayList getPortArrayList() { - Node node = Node.fromString(nodeId); ArrayList portList = new ArrayList(); String[] elemArray = spanPort.split(","); for (String elem : elemArray) { - if (elem.contains("-")) { - String[] limits = elem.split("-"); - for (short j = Short.valueOf(limits[0]); j <= Short - .valueOf(limits[1]); j++) { - try { - portList.add(new NodeConnector( - NodeConnectorIDType.OPENFLOW, Short.valueOf(j), - node)); - } catch (ConstructionException e) { - logger.error("",e); - } - } - } else { - try { - portList.add(new NodeConnector( - NodeConnectorIDType.OPENFLOW, Short.valueOf(elem), - node)); - } catch (NumberFormatException e) { - logger.error("",e); - } catch (ConstructionException e) { - logger.error("",e); - } + NodeConnector nodeConnector = NodeConnector.fromString(elem); + if (nodeConnector != null) { + portList.add(nodeConnector); } } return portList; @@ -153,6 +139,6 @@ public class SpanConfig implements Serializable { @Override public String toString() { - return ("Span Config [nodeId=" + nodeId + " spanPort=" + spanPort + "]"); + return ("SpanConfig [nodeId=" + nodeId + ", spanPort=" + spanPort + "]"); } }