if (validateNodeConstraints(pceNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
return;
}
- if (endPceNode(nodeType, pceNode.getNodeId(), pceNode) && this.aendPceNode == null
- && isAZendPceNode(this.serviceFormatA, pceNode, anodeId, "A")) {
- this.aendPceNode = pceNode;
- }
- if (endPceNode(nodeType, pceNode.getNodeId(), pceNode) && this.zendPceNode == null
- && isAZendPceNode(this.serviceFormatZ, pceNode, znodeId, "Z")) {
- this.zendPceNode = pceNode;
+
+ if (endPceNode(nodeType, pceNode.getNodeId(), pceNode)) {
+ if (this.aendPceNode == null && isAZendPceNode(this.serviceFormatA, pceNode, anodeId, "A")) {
+ // Added to ensure A-node has a addlink in the topology
+ List<Link> links = this.allLinks.stream()
+ .filter(x -> x.getSource().getSourceNode().getValue().contains(pceNode.getNodeId().getValue()))
+ .collect(Collectors.toList());
+ if (links.size() > 0) {
+ this.aendPceNode = pceNode;
+ }
+ }
+ if (this.zendPceNode == null && isAZendPceNode(this.serviceFormatZ, pceNode, znodeId, "Z")) {
+ // Added to ensure Z-node has a droplink in the topology
+ List<Link> links = this.allLinks.stream()
+ .filter(x -> x.getDestination().getDestNode().getValue().contains(pceNode.getNodeId().getValue()))
+ .collect(Collectors.toList());
+ if (links.size() > 0) {
+ this.zendPceNode = pceNode;
+ }
+ }
}
allPceNodes.put(pceNode.getNodeId(), pceNode);
}
OpenroadmNodeType nodeType = node.augmentation(Node1.class).getNodeType();
-
- PceOtnNode pceOtnNode = new PceOtnNode(node, nodeType, node.getNodeId(), "otn", serviceType);
+ String clientPort = null;
+ if (node.getNodeId().getValue().equals(anodeId)
+ && this.aendPceNode == null
+ && input.getServiceAEnd() != null
+ && input.getServiceAEnd().getRxDirection() != null
+ && input.getServiceAEnd().getRxDirection().getPort() != null
+ && input.getServiceAEnd().getRxDirection().getPort().getPortName() != null) {
+ clientPort = input.getServiceAEnd().getRxDirection().getPort().getPortName();
+ } else if (node.getNodeId().getValue().equals(znodeId)
+ && this.zendPceNode == null
+ && input.getServiceZEnd() != null
+ && input.getServiceZEnd().getRxDirection() != null
+ && input.getServiceZEnd().getRxDirection().getPort() != null
+ && input.getServiceZEnd().getRxDirection().getPort().getPortName() != null) {
+ clientPort = input.getServiceZEnd().getRxDirection().getPort().getPortName();
+ }
+
+ PceOtnNode pceOtnNode = new PceOtnNode(node, nodeType, node.getNodeId(), "otn", serviceType, clientPort);
pceOtnNode.validateXponder(anodeId, znodeId);
if (!pceOtnNode.isValid()) {
private List<PceLink> outgoingLinks = new ArrayList<>();
private Map<String, String> clientPerNwTp = new HashMap<>();
+ private String clientPort;
- public PceOtnNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, String pceNodeType, String serviceType) {
+ public PceOtnNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, String pceNodeType, String serviceType,
+ String clientPort) {
this.node = node;
this.nodeId = nodeId;
this.nodeType = nodeType;
checkAvailableTribPort();
this.tpAvailableTribSlot.clear();
checkAvailableTribSlot();
+ this.clientPort = clientPort;
if (node == null || nodeId == null || nodeType != OpenroadmNodeType.MUXPDR
&& nodeType != OpenroadmNodeType.SWITCH && nodeType != OpenroadmNodeType.TPDR) {
LOG.error("PceOtnNode: one of parameters is not populated : nodeId, node type");
usableXpdrNWTps.add(nwTp);
}
if (usableXpdrClientTps.size() >= nbClient && usableXpdrNWTps.size() >= nbNetw) {
- clientPerNwTp.put(nwTp.getValue(), clTp.getValue());
- return true;
+ if (this.clientPort == null || this.clientPort.equals(clTp.getValue())) {
+ clientPerNwTp.put(nwTp.getValue(), clTp.getValue());
+ return true;
+ }
}
}
}
node = NodeUtils.getOTNNodeBuilder(NodeUtils.geSupportingNodes(), OpenroadmTpType.XPONDERNETWORK).build();
PceOtnNode pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.MUXPDR,
- new NodeId("optical"), ServiceFormat.OTU.getName(), "DEGREE");
+ new NodeId("optical"), ServiceFormat.OTU.getName(), "serviceType", null);
pceOtnNode.validateXponder("optical", "sl");
pceOtnNode.validateXponder("not optical", "sl");
pceOtnNode.initXndrTps("AZ");
PceOtnNode pceOtnNode2 = new PceOtnNode(node, OpenroadmNodeType.MUXPDR,
- new NodeId("optical2"), ServiceFormat.OTU.getName(), "DEGREE");
+ new NodeId("optical2"), ServiceFormat.OTU.getName(), "serviceType", null);
pceOtnNode2.validateXponder("optical", "sl");
pceOtnNode2.validateXponder("not optical", "sl");
pceOtnNode2.initXndrTps("AZ");
Assert.assertNotNull(node.augmentation(Node1.class));
// OpenroadmNodeType nodeType = node.augmentation(Node1.class).;
- PceOtnNode pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.SRG, node.getNodeId(), "otn", "serviceType");
+ PceOtnNode pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.SRG, node.getNodeId(), "otn", "serviceType",
+ null);
}
@Test
public void testInitXndrTpsODU4() {
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.MUXPDR,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_ODU4);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_ODU4, null);
pceOtnNode.initXndrTps("AZ");
pceOtnNode.checkAvailableTribPort();
pceOtnNode.checkAvailableTribSlot();
@Test
public void testInitXndrTps10GE() {
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.MUXPDR,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_10GE);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_10GE, null);
pceOtnNode.initXndrTps("mode");
pceOtnNode.checkAvailableTribPort();
pceOtnNode.checkAvailableTribSlot();
public void testInitXndrTps10GXponderClient1() {
node = getNodeBuilder(geSupportingNodes(), OpenroadmTpType.XPONDERCLIENT).build();
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.ROADM,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_10GE);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_10GE, null);
pceOtnNode.initXndrTps("mode");
pceOtnNode.checkAvailableTribPort();
pceOtnNode.checkAvailableTribSlot();
public void testInitXndrTps1GXponderClient() {
node = getNodeBuilder(geSupportingNodes(), OpenroadmTpType.XPONDERCLIENT).build();
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.MUXPDR,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_1GE);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_1GE, null);
pceOtnNode.initXndrTps("mode");
pceOtnNode.checkAvailableTribPort();
pceOtnNode.checkAvailableTribSlot();
@Test
public void testInitXndrTps10GXponderClient() {
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.MUXPDR,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_10GE);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_10GE, null);
pceOtnNode.validateXponder("optical", "sl");
pceOtnNode.validateXponder("not optical", "sl");
pceOtnNode.initXndrTps("AZ");
@Test
public void testIsPceOtnNodeValid() {
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.MUXPDR,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_10GE);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_10GE, null);
pceOtnNode.initXndrTps("AZ");
pceOtnNode.checkAvailableTribPort();
pceOtnNode.checkAvailableTribSlot();
@Test
public void testIsPceOtnNodeValidNode() {
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.DEGREE,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_100GE_M);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_100GE_M, null);
pceOtnNode.initXndrTps("AZ");
pceOtnNode.checkAvailableTribPort();
pceOtnNode.checkAvailableTribSlot();
@Test
public void testIsPceOtnNodeValidNodeTypeNull() {
pceOtnNode = new PceOtnNode(node, null,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_100GE_M);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_100GE_M, null);
pceOtnNode.initXndrTps("AZ");
pceOtnNode.checkAvailableTribPort();
pceOtnNode.checkAvailableTribSlot();
@Test
public void testIsPceOtnNodeValidNodeTypeDeg() {
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.DEGREE,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_100GE_M);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_100GE_M, null);
pceOtnNode.initXndrTps("AZ");
Assert.assertFalse("not valid node , its type isn't one of MUXPDR or SWITCH or TPDR" ,
pceOtnNode.isPceOtnNodeValid(pceOtnNode));
@Test
public void testIsPceOtnNodeValidTrue() {
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.MUXPDR,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_ODU4);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_ODU4, null);
pceOtnNode.initXndrTps("AZ");
pceOtnNode.checkAvailableTribPort();
pceOtnNode.checkAvailableTribSlot();
public void testIsPceOtnNodeValidChecksw() {
node = getNodeBuilder(geSupportingNodes(), OpenroadmTpType.XPONDERCLIENT).build();
pceOtnNode = new PceOtnNode(node, OpenroadmNodeType.MUXPDR,
- new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_1GE);
+ new NodeId("optical"), ServiceFormat.OMS.getName(), StringConstants.SERVICE_TYPE_1GE, null);
pceOtnNode.initXndrTps("mode");
Assert.assertFalse("not valid otn service Type" , pceOtnNode.isPceOtnNodeValid(pceOtnNode));
}
.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey,
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection>
connectionFullMap; // this variable is for complete connection objects
- private Map<String, Map<String, Boolean>> networkMap = new HashMap<>();
private final NetworkTransactionService networkTransactionService;
// TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01
String rxPortName = txPortName;
LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
- if (serviceFormat.equals(ServiceFormat.ODU)) {
- // TODO --> populate network map
- populateNetworkMap(nodeid, txPortName);
- }
- if (serviceFormat.equals(ServiceFormat.Ethernet)) {
- // TODO --> choose from network Map un network port which hasnt been used yet by another service.
- // Set boolean to true and update txportName and so on
- String updTxName = findFreeConfiguredNetworkPort(nodeid);
- if (updTxName != null) {
- txPortName = updTxName;
- rxPortName = txPortName;
- }
- }
// TODO --> get clli from datastore?
String clli = "NodeSC";
LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
String rxPortName = txPortName;
LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName);
- if (serviceFormat.equals(ServiceFormat.ODU)) {
- // TODO --> populate network map
- populateNetworkMap(nodeid, txPortName);
- }
- if (serviceFormat.equals(ServiceFormat.Ethernet)) {
- // TODO --> choose from network Map un network port which hasnt been used yet by another service.
- // Set boolean to true and update txportName and so on
- String updTxName = findFreeConfiguredNetworkPort(nodeid);
- if (updTxName != null) {
- txPortName = updTxName;
- rxPortName = txPortName;
- }
- }
// TODO --> get clli from datastore?
String clli = "NodeSA";
LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName);
return serviceAEndBuilder.build();
}
- private String findFreeConfiguredNetworkPort(String nodeid) {
- if (!this.networkMap.containsKey(nodeid)) {
- return null;
- }
- Map<String, Boolean> netMap = this.networkMap.get(nodeid);
- for (Map.Entry<String, Boolean> entry : netMap.entrySet()) {
- if (!entry.getValue()) {
- this.networkMap.get(nodeid).put(entry.getKey(), true);
- return entry.getKey();
- }
- }
- return null;
- }
-
- private void populateNetworkMap(String nodeid, String txPortName) {
- Map<String, Boolean> netMap = new HashMap<>();
- netMap.put(txPortName, false);
- if (!this.networkMap.containsKey(nodeid)) {
- this.networkMap.put(nodeid, netMap);
- } else if (!this.networkMap.get(nodeid).containsKey(txPortName)) {
- this.networkMap.get(nodeid).putAll(netMap);
- }
- }
-
private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
.onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint> endPoints) {
if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
self.cr_serv_sample_data["input"]["service-z-end"]["service-rate"] = "10"
self.cr_serv_sample_data["input"]["service-z-end"]["service-format"] = "Ethernet"
del self.cr_serv_sample_data["input"]["service-z-end"]["odu-service-rate"]
- self.cr_serv_sample_data["input"]["service-z-end"]["tx-direction"]["port"]["port-name"] = "XPDR1-NETWORK1"
- self.cr_serv_sample_data["input"]["service-z-end"]["rx-direction"]["port"]["port-name"] = "XPDR1-NETWORK1"
+ self.cr_serv_sample_data["input"]["service-z-end"]["tx-direction"]["port"]["port-name"] = "XPDR1-CLIENT1"
+ self.cr_serv_sample_data["input"]["service-z-end"]["rx-direction"]["port"]["port-name"] = "XPDR1-CLIENT1"
response = test_utils.service_create_request(self.cr_serv_sample_data)
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()