-
- // if atleast 1 link exists for the srcPort and atleast 1 link exists
- // for the dstPort
- // that makes it ineligible for the Manual link addition
- // This is just an extra protection to avoid mis-programming.
- boolean srcLinkExists = false;
- boolean dstLinkExists = false;
- // TODO check a way to validate the port with inventory services
- // if (srcSw.getPorts().contains(srcPort) &&
- // dstSw.getPorts().contains(srcPort) &&
- if (!srcLinkExists && !dstLinkExists) {
- Node sNode = null;
- Node dNode = null;
- NodeConnector sPort = null;
- NodeConnector dPort = null;
- linkTuple = null;
- String srcNodeIDType = link.getSrcNodeIDType();
- String srcNodeConnectorIDType = link.getSrcNodeConnectorIDType();
- String dstNodeIDType = link.getDstNodeIDType();
- String dstNodeConnectorIDType = link.getDstNodeConnectorIDType();
- try {
- if (srcNodeIDType.equals(NodeIDType.OPENFLOW)) {
- sNode = new Node(srcNodeIDType, link.getSrcSwitchIDLong());
- } else {
- sNode = new Node(srcNodeIDType, link.getSrcSwitchId());
- }
-
- if (dstNodeIDType.equals(NodeIDType.OPENFLOW)) {
- dNode = new Node(dstNodeIDType, link.getDstSwitchIDLong());
- } else {
- dNode = new Node(dstNodeIDType, link.getDstSwitchId());
- }
-
- if (srcNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) {
- Short srcPort = Short.valueOf((short) 0);
- if (!link.isSrcPortByName()) {
- srcPort = Short.parseShort(link.getSrcPort());
- }
- sPort = new NodeConnector(srcNodeConnectorIDType, srcPort,
- sNode);
- } else {
- sPort = new NodeConnector(srcNodeConnectorIDType,
- link.getSrcPort(), sNode);
- }
-
- if (dstNodeConnectorIDType.equals(NodeConnectorIDType.OPENFLOW)) {
- Short dstPort = Short.valueOf((short) 0);
- if (!link.isDstPortByName()) {
- dstPort = Short.parseShort(link.getDstPort());
- }
- dPort = new NodeConnector(dstNodeConnectorIDType, dstPort,
- dNode);
- } else {
- dPort = new NodeConnector(dstNodeConnectorIDType,
- link.getDstPort(), dNode);
- }
- linkTuple = new Edge(sPort, dPort);
- } catch (ConstructionException cex) {
- log.warn("Caught exception ", cex);
- }
- return linkTuple;
- }
-
- if (srcLinkExists && dstLinkExists) {
- link.setStatus(TopologyUserLinkConfig.STATUS.INCORRECT);