OtnLinkType.ODUC4, 400000L,
OtnLinkType.ODUC3, 300000L,
OtnLinkType.ODUC2, 200000L);
+ private static Map<OtnLinkType, Long> otnOtuLinkTypeBwMap = Map.of(
+ OtnLinkType.OTU4, 100000L,
+ OtnLinkType.OTUC4, 400000L);
private static Map<Uint32, Long> serviceRateBwIncrMap = Map.of(
Uint32.valueOf(1), 1000L,
Uint32.valueOf(10), 10000L,
return new TopologyShard(
null,
- OtnLinkType.OTU4.equals(linkType) || OtnLinkType.OTUC4.equals(linkType)
+ otnOtuLinkTypeBwMap.containsKey(linkType)
? initialiseOtnLinks(nodeA, tpA, nodeZ, tpZ, linkType)
: null);
}
.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(
+ if (otnOtuLinkTypeBwMap.containsKey(linkType)) {
+ return new TopologyShard(
+ null,
+ 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);
- //TODO shouldn't other linkt type listed in otnLinkTypeBwMap be handled too ?
- default:
- return null;
+ notifLink.getZTermination().getNodeId(), notifLink.getZTermination().getTpId(), linkType));
+ } else if (otnLinkTypeBwMap.containsKey(linkType)) {
+ List<Link> 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);
+ } else {
+ return null;
}
}
tps.add(updateNodeTpTsPool(tp, serviceRate, tribPortNb, minTribSlotNb, maxTribSlotNb, isDeletion));
}
}
- if (!links.isEmpty() && !tps.isEmpty()) {
- return new TopologyShard(null, links, tps);
- } else {
+ if (links.isEmpty() || tps.isEmpty()) {
LOG.error("unable to update otn links");
return new TopologyShard(null, null, null);
+ } else {
+ return new TopologyShard(null, links, tps);
}
}
OtnLinkType linkType) {
List<Link> links = new ArrayList<>();
- OtnLinkType otnLinkType = null;
for (Link link : suppOtuLinks) {
if (link.augmentation(Link1.class) == null
|| link.augmentation(
LOG.error(OTN_PARAMS_ERROR, link.getLinkId().getValue());
return new TopologyShard(null, null, null);
}
- otnLinkType = link.augmentation(
+ OtnLinkType otnLinkType = link.augmentation(
org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.Link1.class).getOtnLinkType();
- if (OtnLinkType.OTU4.equals(otnLinkType)) {
- links.add(updateOtnLinkBwParameters(link, 100000L, 0L));
- } else if (OtnLinkType.OTUC4.equals(otnLinkType)) {
- links.add(updateOtnLinkBwParameters(link, 400000L, 0L));
- } else {
+ if (!otnOtuLinkTypeBwMap.containsKey(otnLinkType)) {
+ //TODO shouldn't other link type listed in otnLinkTypeBwMap be handled too ?
LOG.warn("Unexpected otn-link-type {} for link {}", otnLinkType, link.getLinkId());
+ continue;
}
- //TODO shouldn't other linkt type listed in otnLinkTypeBwMap be handled too ?
+ links.add(updateOtnLinkBwParameters(link, otnOtuLinkTypeBwMap.get(otnLinkType) , 0L));
}
List<TerminationPoint> tps = new ArrayList<>();
for (TerminationPoint tp : oldTps) {
.setOtnLinkType(linkType).build();
Link1Builder otnLink1Bldr = new Link1Builder()
.setUsedBandwidth(Uint32.valueOf(0));
- switch (linkType) {
- case OTU4:
- case ODTU4:
- otnLink1Bldr.setAvailableBandwidth(Uint32.valueOf(100000));
- break;
- case OTUC4:
- case ODUC4:
- otnLink1Bldr.setAvailableBandwidth(Uint32.valueOf(400000));
- break;
- default:
- LOG.error("unable to set available bandwidth to unknown link type");
- break;
- //TODO shouldn't other linkt type listed in otnLinkTypeBwMap be handled too ?
+ if (otnOtuLinkTypeBwMap.containsKey(linkType)) {
+ otnLink1Bldr.setAvailableBandwidth(Uint32.valueOf(otnOtuLinkTypeBwMap.get(linkType)));
+ } else if (otnLinkTypeBwMap.containsKey(linkType)) {
+ otnLink1Bldr.setAvailableBandwidth(Uint32.valueOf(otnLinkTypeBwMap.get(linkType)));
+ } else {
+ LOG.error("unable to set available bandwidth to unknown link type");
}
// create link A-Z
LinkBuilder ietfLinkAZBldr = TopologyUtils.createLink(nodeATopo, nodeZTopo, tpA, tpZ, linkType.getName());
private static Link updateOtnLinkBwParameters(Link link, Long availBw, Long usedBw) {
LOG.debug("in updateOtnLinkBwParameters with availBw = {}, usedBw = {}", availBw, usedBw);
- LinkBuilder updatedLinkBldr = new LinkBuilder(link);
- Link1Builder updatedLink1Bldr = new Link1Builder(link.augmentation(Link1.class))
- .setAvailableBandwidth(Uint32.valueOf(availBw))
- .setUsedBandwidth(Uint32.valueOf(usedBw));
- updatedLinkBldr.addAugmentation(updatedLink1Bldr.build());
- return updatedLinkBldr.build();
+ return new LinkBuilder(link)
+ .addAugmentation(
+ new Link1Builder(link.augmentation(Link1.class))
+ .setAvailableBandwidth(Uint32.valueOf(availBw))
+ .setUsedBandwidth(Uint32.valueOf(usedBw))
+ .build())
+ .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;
- }
- //TODO shouldn't other linkt type listed in otnLinkTypeBwMap be handled too ?
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)
+ .setUsedBandwidth(
+ otnLinkTypeBwMap.containsKey(linkType)
+ ? Uint32.valueOf(otnLinkTypeBwMap.get(linkType))
+ : Uint32.valueOf(0))
.build());
updatedlinks.add(updatedLinkBldr.build());
}