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;
/**
* 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;
@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;
}
}
public ArrayList<NodeConnector> getPortArrayList() {
- Node node = Node.fromString(nodeId);
ArrayList<NodeConnector> portList = new ArrayList<NodeConnector>();
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;
@Override
public String toString() {
- return ("Span Config [nodeId=" + nodeId + " spanPort=" + spanPort + "]");
+ return ("SpanConfig [nodeId=" + nodeId + ", spanPort=" + spanPort + "]");
}
}