package org.opendaylight.transportpce.networkmodel.util;
import com.google.common.collect.ImmutableMap;
-import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.Nullable;
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.rev220114.mapping.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.OtnLinkType;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.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;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.networks.network.node.XpdrAttributesBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.networks.network.node.termination.point.TpSupportedInterfacesBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.networks.network.node.termination.point.XpdrTpPortConnectionAttributesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If100GE;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If100GEODU4;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If10GE;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If10GEODU2;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If10GEODU2e;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If1GE;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If1GEODU0;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If400GE;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOCH;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOCHOTU4ODU4;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOTUCnODUCn;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOtsiOtsigroup;
import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.SupportedIfCapability;
import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.xponder.rev211210.xpdr.otn.tp.attributes.OdtuTpnPool;
import org.opendaylight.yang.gen.v1.http.org.openroadm.xponder.rev211210.xpdr.otn.tp.attributes.OdtuTpnPoolBuilder;
-import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.OtnLinkType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
Uint32.valueOf(10), ODTU4TsAllocated.class,
Uint32.valueOf(100), ODTUCnTs.class);
- private static Map<String, Class<? extends SupportedIfCapability>> supIfCapaMap = Map.ofEntries(
- new AbstractMap.SimpleEntry<>("IfOtsiOtsigroup", IfOtsiOtsigroup.class),
- new AbstractMap.SimpleEntry<>("IfOTUCnODUCn", IfOTUCnODUCn.class),
- new AbstractMap.SimpleEntry<>("IfOCHOTU4ODU4", IfOCHOTU4ODU4.class),
- new AbstractMap.SimpleEntry<>("IfOCH", IfOCH.class),
- new AbstractMap.SimpleEntry<>("If100GEODU4", If100GEODU4.class),
- new AbstractMap.SimpleEntry<>("If10GEODU2e", If10GEODU2e.class),
- new AbstractMap.SimpleEntry<>("If10GEODU2", If10GEODU2.class),
- new AbstractMap.SimpleEntry<>("If1GEODU0", If1GEODU0.class),
- new AbstractMap.SimpleEntry<>("If400GE", If400GE.class),
- new AbstractMap.SimpleEntry<>("If100GE", If100GE.class),
- new AbstractMap.SimpleEntry<>("If10GE", If10GE.class),
- new AbstractMap.SimpleEntry<>("If1GE", If1GE.class));
-
private OpenRoadmOtnTopology() {
}
for (Link link : suppOtuLinks) {
if (link.augmentation(Link1.class) == null
|| link.augmentation(
- org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.Link1.class) == null) {
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630
+ .Link1.class) == null) {
LOG.error(OTN_PARAMS_ERROR, link.getLinkId().getValue());
return new TopologyShard(null, null, null);
}
OtnLinkType otnLinkType = link.augmentation(
- org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.Link1.class).getOtnLinkType();
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.Link1.class)
+ .getOtnLinkType();
if (!OTNLINKTYPE_OTU_BW_MAP.containsKey(otnLinkType)) {
//TODO shouldn't other link type listed in OTNLINKTYPE_BW_MAP be handled too ?
LOG.warn("Unexpected otn-link-type {} for link {}", otnLinkType, link.getLinkId());
List<Link> links = new ArrayList<>();
String nodeATopo = formatNodeName(nodeA, tpA);
String nodeZTopo = formatNodeName(nodeZ, tpZ);
- org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.Link1 tpceLink1
- = new org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.Link1Builder()
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.Link1 tpceLink1
+ = new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.Link1Builder()
.setOtnLinkType(linkType).build();
Link1Builder otnLink1Bldr = new Link1Builder()
.setUsedBandwidth(Uint32.valueOf(0));
XpdrTpPortConnectionAttributesBuilder xtpcaBldr =
new XpdrTpPortConnectionAttributesBuilder(otnTp1Bldr.getXpdrTpPortConnectionAttributes());
if (addingTsTpnPoolTermination) {
- List<Uint16> tsPool = new ArrayList<>();
+ Set<Uint16> tsPool = new HashSet<>();
for (int i = 1; i <= NB_TRIB_SLOTS; i++) {
tsPool.add(Uint16.valueOf(i));
}
xtpcaBldr.setTsPool(tsPool);
- List<Uint16> tpnPool = new ArrayList<>();
+ Set<Uint16> tpnPool = new HashSet<>();
int nbTribPort = NB_TRIB_PORTS;
if (OtnLinkType.ODUC4.equals(linkType)) {
nbTribPort = 4;
XpdrTpPortConnectionAttributesBuilder xtpcaBldr =
new XpdrTpPortConnectionAttributesBuilder(
tpBldr.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes());
- List<Uint16> tsPool = new ArrayList<>(xtpcaBldr.getTsPool());
+ Set<Uint16> tsPool = new HashSet<>(xtpcaBldr.getTsPool());
if (isDeletion) {
for (int i = minTribSlotNb; i <= maxTribSlotNb; i++) {
tsPool.add(Uint16.valueOf(i));
}
}
xtpcaBldr.setTsPool(tsPool);
- List<Uint16> tpnPool;
+ Set<Uint16> tpnPool;
List<OdtuTpnPool> odtuTpnPoolValues = new ArrayList<>(xtpcaBldr.getOdtuTpnPool().values());
if (odtuTpnPoolValues.get(0).getTpnPool() == null) {
- tpnPool = new ArrayList<>();
+ tpnPool = new HashSet<>();
} else {
- tpnPool = new ArrayList<>(odtuTpnPoolValues.get(0).getTpnPool());
+ tpnPool = new HashSet<>(odtuTpnPoolValues.get(0).getTpnPool());
if (isDeletion) {
tpnPool.add(Uint16.valueOf(tribPortNb));
} else {
// TODO: will need to be completed
Map<NonBlockingListKey, NonBlockingList> nbMap = new HashMap<>();
for (int i = 1; i <= node.getNbTpClient(); i++) {
- List<TpId> tpList = new ArrayList<>();
+ Set<TpId> tpList = new HashSet<>();
tpList.add(new TpId("XPDR" + node.getXpdrNb() + CLIENT + i));
tpList.add(new TpId("XPDR" + node.getXpdrNb() + "-NETWORK1"));
NonBlockingList nbl = new NonBlockingListBuilder()
private static Node createSwitch(OtnTopoNode node) {
- List<TpId> tpl = new ArrayList<>();
+ Set<TpId> tpl = new HashSet<>();
for (int i = 1; i <= node.getNbTpClient(); i++) {
tpl.add(new TpId("XPDR" + node.getXpdrNb() + CLIENT + i));
}
mapping.getLogicalConnectionPoint(), node.getNodeId());
} else {
XpdrTpPortConnectionAttributesBuilder xtpcaBldr = new XpdrTpPortConnectionAttributesBuilder();
- for (Class<? extends org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327
- .SupportedIfCapability> supInterCapa : mapping.getSupportedInterfaceCapability()) {
+ for (Class<? extends SupportedIfCapability> supInterCapa : mapping.getSupportedInterfaceCapability()) {
SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
- .withKey(new SupportedInterfaceCapabilityKey(convertSupIfCapa(supInterCapa.getSimpleName())))
- .setIfCapType(convertSupIfCapa(supInterCapa.getSimpleName()))
+ .withKey(new SupportedInterfaceCapabilityKey(supInterCapa))
+ .setIfCapType(supInterCapa)
.build();
supIfMap.put(supIfCapa.key(), supIfCapa);
}
new TpId(mapping.getLogicalConnectionPoint()),
tpType,
otnTp1Bldr.build(),
- new org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.TerminationPoint1Builder(),
mapping);
}
}
private static void setclientNwTpAttr(Map<TerminationPointKey, TerminationPoint> tpMap, OtnTopoNode node, TpId tpId,
- OpenroadmTpType tpType, TerminationPoint1 otnTp1,
- org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.TerminationPoint1Builder tpceTp1Bldr,
- Mapping mapping) {
-
+ OpenroadmTpType tpType, TerminationPoint1 otnTp1, Mapping mapping) {
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder cnTP1BLdr
+ = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210
+ .TerminationPoint1Builder();
switch (tpType) {
case XPONDERNETWORK:
if (node.getXpdrNetConnectionMap().get(tpId.getValue()) != null) {
- tpceTp1Bldr.setAssociatedConnectionMapPort(node.getXpdrNetConnectionMap().get(tpId.getValue()));
+ cnTP1BLdr.setAssociatedConnectionMapTp(Set.of(
+ new TpId(node.getXpdrNetConnectionMap().get(tpId.getValue()))));
}
SupportingTerminationPoint stp = new SupportingTerminationPointBuilder()
.setNetworkRef(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))
.setTpRef(tpId)
.build();
TerminationPoint ietfTpNw =
- buildIetfTp(tpceTp1Bldr, otnTp1, tpType, tpId, Map.of(stp.key(), stp), mapping);
+ buildIetfTp(cnTP1BLdr, otnTp1, tpType, tpId, Map.of(stp.key(), stp), mapping);
tpMap.put(ietfTpNw.key(),ietfTpNw);
break;
case XPONDERCLIENT:
if (node.getXpdrCliConnectionMap().get(tpId.getValue()) != null) {
- tpceTp1Bldr.setAssociatedConnectionMapPort(node.getXpdrCliConnectionMap().get(tpId.getValue()));
+ cnTP1BLdr.setAssociatedConnectionMapTp(Set.of(
+ new TpId(node.getXpdrCliConnectionMap().get(tpId.getValue()))));
}
- TerminationPoint ietfTpCl = buildIetfTp(tpceTp1Bldr, otnTp1, tpType, tpId, null, mapping);
+ TerminationPoint ietfTpCl = buildIetfTp(cnTP1BLdr, otnTp1, tpType, tpId, null, mapping);
tpMap.put(ietfTpCl.key(),ietfTpCl);
break;
default:
}
}
- private static Class<? extends OduRateIdentity> fixRate(List<Class<? extends
- org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability>> list) {
+ private static Class<? extends OduRateIdentity> fixRate(Set<Class<? extends SupportedIfCapability>> list) {
- for (Class<? extends org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability>
- class1 : list) {
+ for (Class<? extends SupportedIfCapability> class1 : list) {
if (RATE_MAP.containsKey(class1.getSimpleName())) {
return RATE_MAP.get(class1.getSimpleName());
}
}
private static TerminationPoint buildIetfTp(
- org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.TerminationPoint1Builder tpceTp1Bldr,
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder cnTP1BLdr,
TerminationPoint1 otnTp1, OpenroadmTpType tpType, TpId tpId,
Map<SupportingTerminationPointKey, SupportingTerminationPoint> supportTpMap, Mapping mapping) {
TerminationPointBuilder ietfTpBldr = new TerminationPointBuilder();
- if (tpceTp1Bldr.getAssociatedConnectionMapPort() != null) {
- ietfTpBldr.addAugmentation(tpceTp1Bldr.build());
- }
if (supportTpMap != null) {
ietfTpBldr.setSupportingTerminationPoint(supportTpMap);
}
.setTpId(tpId)
.withKey(new TerminationPointKey(tpId))
.addAugmentation(otnTp1)
- .addAugmentation(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder()
- .setTpType(tpType)
+ .addAugmentation(cnTP1BLdr.setTpType(tpType)
.setAdministrativeState(TopologyUtils.setNetworkAdminState(mapping.getPortAdminState()))
.setOperationalState(TopologyUtils.setNetworkOperState(mapping.getPortOperState()))
.build())
- .build();
+ .build();
}
private static String formatNodeName(String nodeName, String tpName) {
? nodeName
: new StringBuilder(nodeName).append("-").append(tpName.split("-")[0]).toString();
}
-
- private static Class<? extends SupportedIfCapability> convertSupIfCapa(String ifCapType) {
- if (!supIfCapaMap.containsKey(ifCapType)) {
- return null;
- }
- return supIfCapaMap.get(ifCapType);
- }
}