import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODTUCnTs;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.TerminationPoint1;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.networks.network.node.SwitchingPools;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.networks.network.node.termination.point.XpdrTpPortConnectionAttributes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
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.tpAvailableTribSlot.clear();
checkAvailableTribSlot();
this.clientPort = clientPort;
- if (node == null || nodeId == null || nodeType == null || !VALID_NODETYPES_LIST.contains(nodeType)) {
+ if (node == null
+ || nodeId == null
+ || nodeType == null
+ || !VALID_NODETYPES_LIST.contains(nodeType)) {
LOG.error("PceOtnNode: one of parameters is not populated : nodeId, node type");
this.valid = false;
}
+ if (!SERVICE_TYPE_ETH_CLASS_MAP.containsKey(serviceType)
+ && !SERVICE_TYPE_ODU_LIST.contains(serviceType)) {
+ LOG.error("PceOtnNode: unsupported OTN Service Type {}", serviceType);
+ this.valid = false;
+ }
}
public void initXndrTps(String mode) {
return;
}
for (TerminationPoint tp : allTps) {
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1 ocnTp1
- = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
+ .TerminationPoint1 ocnTp1
+ = tp.augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
.TerminationPoint1.class);
if (ocnTp1 == null) {
LOG.warn("null ocn TP {}", tp);
continue;
}
+ TerminationPoint1 ontTp1 = tp.augmentation(TerminationPoint1.class);
+ if (ontTp1 == null) {
+ continue;
+ }
//TODO many nested structures below, this needs to be reworked
switch (ocnTp1.getTpType()) {
case XPONDERNETWORK:
- if (tp.augmentation(TerminationPoint1.class) == null) {
- continue;
- }
- TerminationPoint1 ontTp1 = tp.augmentation(TerminationPoint1.class);
- if (SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)
- || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)) {
- // TODO verify the capability of network port to support ODU4 CTP interface creation
- if (!checkTpForOdtuTermination(ontTp1)) {
- LOG.error("TP {} of {} does not allow ODU4 termination creation",
- tp.getTpId().getValue(), node.getNodeId().getValue());
- continue;
- }
- } else if (SERVICE_TYPE_ETH_TS_NB_MAP.containsKey(this.otnServiceType)) {
- if (!checkOdtuTTPforLoOduCreation(
- ontTp1, SERVICE_TYPE_ETH_TS_NB_MAP.get(this.otnServiceType))) {
- LOG.error("TP {} of {} does not allow {} termination creation",
- tp.getTpId().getValue(),
- SERVICE_TYPE_ETH_ODU_STRING_MAP.get(this.otnServiceType),
- node.getNodeId().getValue());
- continue;
- }
+ String notCreatedServiceType = xpdrNetTpCreation(ontTp1);
+ if (notCreatedServiceType == null) {
+ LOG.info("TP {} of XPONDER {} is validated",
+ tp.getTpId(),
+ node.getNodeId().getValue());
+ this.availableXpdrNWTps.add(tp.getTpId());
} else {
- LOG.error("TP {} of {} does not allow any termination creation",
- tp.getTpId().getValue(), node.getNodeId().getValue());
- continue;
+ LOG.error("TP {} of {} does not allow {} termination creation",
+ tp.getTpId().getValue(),
+ node.getNodeId().getValue(),
+ notCreatedServiceType);
}
- LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
- this.availableXpdrNWTps.add(tp.getTpId());
break;
case XPONDERCLIENT:
- if (SERVICE_TYPE_ETH_CLASS_MAP.containsKey(otnServiceType)) {
- if (tp.augmentation(TerminationPoint1.class) == null) {
- continue;
- }
- if (checkClientTp(tp.augmentation(TerminationPoint1.class))) {
- LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
- this.availableXpdrClientTps.add(tp.getTpId());
- } else {
- LOG.error("TP {} of {} does not allow lo-ODU (ODU2e or ODU0) termination creation",
- tp.getTpId().getValue(), node.getNodeId().getValue());
- }
+ if (!SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType)) {
+ continue;
+ }
+ if (checkClientTp(ontTp1)) {
+ LOG.info("TP {} of XPONDER {} is validated",
+ tp.getTpId(),
+ node.getNodeId().getValue());
+ this.availableXpdrClientTps.add(tp.getTpId());
+ } else {
+ LOG.error("TP {} of {} does not allow lo-ODU (ODU2e or ODU0) termination creation",
+ tp.getTpId().getValue(),
+ node.getNodeId().getValue());
}
break;
LOG.debug("unsupported ocn TP type {}", ocnTp1.getTpType());
}
}
- this.valid = SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)
- || SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType)
- && isAzOrIntermediateAvl(availableXpdrClientTps, availableXpdrNWTps,
- StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
- ? availableXpdrClientTps
- : null);
- //TODO check whether it makes sense to pass twice availableXpdrClientTps tp isAzOrIntermediateAvl
- // and to differentiate SERVICE_TYPE_100GE_S case
- // better pass otnServiceType -> this should probably be refactored
- }
-
- private boolean isAzOrIntermediateAvl(List<TpId> clientTps, List<TpId> netwTps, List<TpId> clientTps0) {
+ this.valid = checkSwPool(availableXpdrNWTps, availableXpdrClientTps);
+ }
+
+ private String xpdrNetTpCreation(TerminationPoint1 ontTp1) {
+ if (SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)
+ || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)) {
+ // TODO verify the capability of network port to support ODU4 CTP interface creation
+ if (checkTpForOdtuTermination(ontTp1)) {
+ //success
+ return null;
+ }
+ return "ODU4";
+ }
+ if (SERVICE_TYPE_ETH_TS_NB_MAP.containsKey(this.otnServiceType)) {
+ if (checkOdtuTTPforLoOduCreation(
+ ontTp1,
+ SERVICE_TYPE_ETH_TS_NB_MAP.get(this.otnServiceType))) {
+ //success
+ return null;
+ }
+ return SERVICE_TYPE_ETH_ODU_STRING_MAP.get(this.otnServiceType);
+ }
+ //failure
+ return "any";
+ }
+
+ private boolean checkSwPool(List<TpId> netwTps, List<TpId> clientTps) {
+
+ if (SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType)) {
+ return true;
+ }
+ if (!SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType)) {
+ return false;
+ }
+ if (netwTps == null) {
+ return false;
+ }
+ Node1 node1 = node.augmentation(Node1.class);
+ if (node1 == null) {
+ return false;
+ }
+ List<NonBlockingList> nblList = new ArrayList<>(
+ node1.getSwitchingPools().nonnullOduSwitchingPools()
+ .values().stream().findFirst().get()
+ .getNonBlockingList().values());
+ if (nblList == null) {
+ return false;
+ }
+ netwTps.sort(Comparator.comparing(TpId::getValue));
+
switch (modeType) {
+
case "intermediate":
- return checkSwPool(clientTps0, netwTps, 0, 2);
+ return checkIntermediateSwPool(nblList, netwTps);
case "AZ":
- return checkSwPool(clientTps, netwTps, 1, 1);
+ if (clientTps == null) {
+ return false;
+ }
+ clientTps.sort(Comparator.comparing(TpId::getValue));
+ return checkAzSwPool(nblList, netwTps, clientTps);
default:
- LOG.error("unknown mode type {}", modeType);
+ LOG.error("Unsupported mode type {}", modeType);
return false;
}
}
- private boolean checkSwPool(List<TpId> clientTps, List<TpId> netwTps, int nbClient, int nbNetw) {
- if (netwTps == null) {
- return false;
- }
- if (clientTps != null && nbClient == 1 && nbNetw == 1) {
- clientTps.sort(Comparator.comparing(TpId::getValue));
- netwTps.sort(Comparator.comparing(TpId::getValue));
+
+ private boolean checkIntermediateSwPool(List<NonBlockingList> nblList, List<TpId> netwTps) {
+ for (NonBlockingList nbl: nblList) {
for (TpId nwTp : netwTps) {
- for (TpId clTp : clientTps) {
- for (NonBlockingList nbl : new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
- .nonnullOduSwitchingPools().values().stream().findFirst().get()
- .getNonBlockingList().values())) {
- if (nbl.getTpList().contains(clTp) && nbl.getTpList().contains(nwTp)) {
- usableXpdrClientTps.add(clTp);
- usableXpdrNWTps.add(nwTp);
- }
- if (usableXpdrClientTps.size() >= 1 && usableXpdrNWTps.size() >= 1
- //since nbClient == 1 && nbNetw == 1...
- && (this.clientPort == null || this.clientPort.equals(clTp.getValue()))) {
- clientPerNwTp.put(nwTp.getValue(), clTp.getValue());
- return true;
- }
- }
+ if (nbl.getTpList().contains(nwTp)) {
+ usableXpdrNWTps.add(nwTp);
+ }
+ if (usableXpdrNWTps.size() >= 2) {
+ return true;
}
}
}
- if (nbClient == 0 && nbNetw == 2) {
- netwTps.sort(Comparator.comparing(TpId::getValue));
- //TODO compared to above, nested loops are inverted below - does it make really sense ?
- // there is room to rationalize things here
- for (NonBlockingList nbl : new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
- .nonnullOduSwitchingPools().values().stream().findFirst().get()
- .getNonBlockingList().values())) {
- for (TpId nwTp : netwTps) {
- if (nbl.getTpList().contains(nwTp)) {
+ return false;
+ }
+
+
+ private boolean checkAzSwPool(List<NonBlockingList> nblList, List<TpId> netwTps, List<TpId> clientTps) {
+ for (NonBlockingList nbl: nblList) {
+ for (TpId nwTp : netwTps) {
+ for (TpId clTp : clientTps) {
+ if (nbl.getTpList().contains(clTp)
+ && nbl.getTpList().contains(nwTp)) {
+ usableXpdrClientTps.add(clTp);
usableXpdrNWTps.add(nwTp);
}
- if (usableXpdrNWTps.size() >= 2) {
- //since nbClient == 0 && nbNetw == 2...
+ if (usableXpdrClientTps.size() >= 1
+ && usableXpdrNWTps.size() >= 1
+ && (this.clientPort == null || this.clientPort.equals(clTp.getValue()))) {
+ clientPerNwTp.put(nwTp.getValue(), clTp.getValue());
return true;
}
}
}
private boolean checkTpForOdtuTermination(TerminationPoint1 ontTp1) {
- for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()
- .values()) {
+ for (SupportedInterfaceCapability sic :
+ ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values()) {
LOG.info("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
if ((sic.getIfCapType().equals(IfOCHOTU4ODU4.class) || sic.getIfCapType().equals(IfOtsiOtsigroup.class))
- && (ontTp1.getXpdrTpPortConnectionAttributes() == null
- || ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() == null)) {
+ && (ontTp1.getXpdrTpPortConnectionAttributes() == null
+ || ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() == null)) {
return true;
}
}
}
private boolean checkClientTp(TerminationPoint1 ontTp1) {
- for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()
- .values()) {
+ for (SupportedInterfaceCapability sic :
+ ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values()) {
LOG.debug("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
// we could also check the administrative status of the tp
- if (SERVICE_TYPE_ETH_CLASS_MAP.containsKey(otnServiceType)
- && sic.getIfCapType().equals(SERVICE_TYPE_ETH_CLASS_MAP.get(otnServiceType))) {
+ if (sic.getIfCapType().equals(SERVICE_TYPE_ETH_CLASS_MAP.get(otnServiceType))) {
return true;
}
}
if (!isValid()) {
return;
}
- if (this.nodeId.getValue().equals(anodeId) || (this.nodeId.getValue().equals(znodeId))) {
+ if (this.nodeId.getValue().equals(anodeId)
+ || (this.nodeId.getValue().equals(znodeId))) {
initXndrTps("AZ");
} else if (OpenroadmNodeType.SWITCH.equals(this.nodeType)) {
initXndrTps("intermediate");
if (this.nodeType != OpenroadmNodeType.TPDR) {
return true;
}
- Node1 node1 = node.augmentation(Node1.class);
- SwitchingPools sp = node1.getSwitchingPools();
- List<OduSwitchingPools> osp = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
- for (OduSwitchingPools ospx : osp) {
- List<NonBlockingList> nbl = new ArrayList<>(ospx.nonnullNonBlockingList().values());
- for (NonBlockingList nbll : nbl) {
- if (nbll.getAvailableInterconnectBandwidth().toJava() >= neededBW && nbll.getTpList() != null
- && nbll.getTpList().contains(tp1.getTpId()) && nbll.getTpList().contains(tp2.getTpId())) {
+ for (OduSwitchingPools ospx :
+ node.augmentation(Node1.class)
+ .getSwitchingPools()
+ .nonnullOduSwitchingPools().values()) {
+ for (NonBlockingList nbll : ospx.nonnullNonBlockingList().values()) {
+ if (nbll.getAvailableInterconnectBandwidth().toJava() >= neededBW
+ && nbll.getTpList() != null
+ && nbll.getTpList().contains(tp1.getTpId())
+ && nbll.getTpList().contains(tp2.getTpId())) {
LOG.debug("validateSwitchingPoolBandwidth: couple of tp {} x {} valid for crossconnection",
tp1.getTpId(), tp2.getTpId());
return true;
public void checkAvailableTribSlot() {
for (TerminationPoint tp :
node.augmentation(
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .Node1.class)
.getTerminationPoint().values().stream()
.filter(type -> type
.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
+ .TerminationPoint1.class)
.getTpType().equals(OpenroadmTpType.XPONDERNETWORK))
.collect(Collectors.toList())
) {
}
public boolean isValid() {
- if (nodeId == null || nodeType == null
- || this.getSupNetworkNodeId() == null || this.getSupClliNodeId() == null) {
+ if (nodeId == null
+ || nodeType == null
+ || this.getSupNetworkNodeId() == null
+ || this.getSupClliNodeId() == null) {
LOG.error("PceNode: one of parameters is not populated : nodeId, node type, supporting nodeId");
valid = false;
}