import org.opendaylight.transportpce.common.NetworkUtils;
import org.opendaylight.transportpce.networkmodel.dto.OtnTopoNode;
import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.network.Nodes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
return new TopologyShard(null, links);
}
+ public static TopologyShard createOtnLinks(
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp
+ .Link notifLink,
+ OtnLinkType linkType) {
+
+ return new TopologyShard(null, initialiseOtnLinks(notifLink.getATermination().getNodeId(),
+ notifLink.getATermination().getTpId(), notifLink.getZTermination().getNodeId(),
+ notifLink.getZTermination().getTpId(), linkType));
+ }
+
+ public static TopologyShard createOtnLinks(
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp
+ .Link notifLink,
+ List<Link> supportedOtu4links,
+ List<TerminationPoint> supportedTPs,
+ OtnLinkType linkType) {
+
+ List<Link> links;
+ switch (linkType) {
+ case OTU4:
+ case OTUC4:
+ links = initialiseOtnLinks(
+ notifLink.getATermination().getNodeId(), notifLink.getATermination().getTpId(),
+ notifLink.getZTermination().getNodeId(), notifLink.getZTermination().getTpId(), linkType);
+ return new TopologyShard(null, links);
+ case ODTU4:
+ case ODUC4:
+ links = initialiseOtnLinks(
+ notifLink.getATermination().getNodeId(), notifLink.getATermination().getTpId(),
+ notifLink.getZTermination().getNodeId(), notifLink.getZTermination().getTpId(), linkType);
+ links.addAll(updateOtnLinkBwParameters(supportedOtu4links, linkType));
+ List<TerminationPoint> updatedTPs = new ArrayList<>();
+ for (TerminationPoint tp : supportedTPs) {
+ updatedTPs.add(updateTp(tp, true, linkType));
+ }
+ return new TopologyShard(null, links, updatedTPs);
+ default:
+ return null;
+ }
+ }
+
public static TopologyShard createOtnLinks(List<Link> suppOtuLinks, List<TerminationPoint> oldTps,
OtnLinkType linkType) {
List<Link> links = new ArrayList<>();
}
}
+ public static TopologyShard updateOtnLinks(List<Link> suppOtuLinks, boolean isDeletion) {
+ List<Link> links = new ArrayList<>();
+ for (Link link : suppOtuLinks) {
+ if (link.augmentation(Link1.class) == null
+ || link.augmentation(Link1.class).getAvailableBandwidth() == null
+ || link.augmentation(Link1.class).getUsedBandwidth() == null) {
+ LOG.error("Error with otn parameters of supported link {}", link.getLinkId().getValue());
+ } else {
+ if (isDeletion) {
+ links.add(updateOtnLinkBwParameters(link, Long.valueOf(100000), Long.valueOf(0)));
+ } else {
+ links.add(updateOtnLinkBwParameters(link, Long.valueOf(0), Long.valueOf(100000)));
+ }
+ }
+ }
+ if (links.isEmpty()) {
+ LOG.error("unable to update otn links");
+ return new TopologyShard(null, null, null);
+ } else {
+ return new TopologyShard(null, links, null);
+ }
+ }
+
public static TopologyShard deleteOtnLinks(List<Link> suppOtuLinks, List<TerminationPoint> oldTps,
OtnLinkType linkType) {
List<Link> links = new ArrayList<>();
for (TerminationPoint tp : oldTps) {
tps.add(updateTp(tp, false, linkType));
}
- if (links.size() == 2 && tps.size() == 2) {
+ if (!links.isEmpty() && !tps.isEmpty()) {
return new TopologyShard(null, links, tps);
} else {
return new TopologyShard(null, null, null);
return updatedLinkBldr.build();
}
+ private static List<Link> updateOtnLinkBwParameters(List<Link> supportedLinks, OtnLinkType linkType) {
+ LOG.debug("in updateOtnLinkBwParameters with supportedLinks = {}, linkType = {}", supportedLinks, linkType);
+ Uint32 usedBw;
+ switch (linkType) {
+ case ODTU4:
+ usedBw = Uint32.valueOf(100000);
+ break;
+ case ODUC4:
+ usedBw = Uint32.valueOf(400000);
+ break;
+ default:
+ usedBw = Uint32.valueOf(0);
+ break;
+ }
+ List<Link> updatedlinks = new ArrayList<>();
+ for (Link link : supportedLinks) {
+ LinkBuilder updatedLinkBldr = new LinkBuilder(link);
+ updatedLinkBldr.addAugmentation(new Link1Builder(link.augmentation(Link1.class))
+ .setAvailableBandwidth(Uint32.valueOf(0))
+ .setUsedBandwidth(usedBw)
+ .build());
+ updatedlinks.add(updatedLinkBldr.build());
+ }
+ return updatedlinks;
+ }
+
private static TerminationPoint updateTp(TerminationPoint originalTp, boolean addingTsTpnPoolTermination,
OtnLinkType linkType) {
LOG.debug("in updateTp");
.setSupportedInterfaceCapability(supIfMap)
.build();
otnTp1Bldr.setTpSupportedInterfaces(tpSupIf);
+ //TODO: It is not logical to assign a priori one of the possible rate to the TP.
+ //Would be worth assigning per default "unallocated" at the tp creation step,
+ //and updating it with correct rate when it supports a specific service.
if (withRate) {
- xtpcaBldr.setRate(fixRate(mapping.getSupportedInterfaceCapability().get(0)));
+ xtpcaBldr.setRate(fixRate(mapping.getSupportedInterfaceCapability()));
otnTp1Bldr.setXpdrTpPortConnectionAttributes(xtpcaBldr.build());
}
} else {
}
}
- private static Class<? extends OduRateIdentity> fixRate(Class<? extends
- SupportedIfCapability> ifCapType) {
- switch (ifCapType.getSimpleName()) {
- case "If100GEODU4":
- case "IfOCHOTU4ODU4":
- return ODU4.class;
- case "If1GEODU0":
- return ODU0.class;
- case "If10GEODU2":
- return ODU2.class;
- case "If10GEODU2e":
- return ODU2e.class;
- default:
- return null;
+ private static Class<? extends OduRateIdentity> fixRate(List<Class<? extends SupportedIfCapability>> list) {
+ Map<String, Class<? extends OduRateIdentity>> rateMap = Map.of(
+ "If100GEODU4", ODU4.class,
+ "IfOCHOTU4ODU4", ODU4.class,
+ "If1GEODU0", ODU0.class,
+ "If10GEODU2", ODU2.class,
+ "If10GEODU2e", ODU2e.class);
+ for (Class<? extends SupportedIfCapability> class1 : list) {
+ if (rateMap.containsKey(class1.getSimpleName())) {
+ return rateMap.get(class1.getSimpleName());
+ }
}
+ return null;
}
private static Map<SupportingNodeKey,SupportingNode> createSupportingNodes(OtnTopoNode node) {