- // Create the list of connections
- Network1 nw1 = openRoadmTopo.get().augmentation(Network1.class);
- List<Link> linksList = nw1.getLink();
- // 1:EXPRESS-LINK 2:ADD-LINK 3:DROP-LINK
- // 4:ROADM-To-ROADM 5:XPONDER-INPUT 6:XPONDER-OUTPUT
- int[] externalLink = {4,5,6};
- int idFiber = 0;
- int nbEDFA = 0;
- if (!linksList.isEmpty()) {
- LOG.debug("The link list is not empty");
- for (Link link : linksList) {
- Link1 link1 = link.augmentation(Link1.class);
- org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
- .Link1 openroadmNetworkLink1 = link.augmentation(org.opendaylight.yang.gen.v1.http.org
- .openroadm.network.topology.rev181130.Link1.class);
- int linkType = link1.getLinkType().getIntValue();
- // the previous line generates a warning
- // but the following cast in comment makes the gnpy tox test fail
- // ((org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1) link1)
- if (IntStream.of(externalLink).anyMatch(x -> x == linkType)) {
- // Verify if the node is a ROADM
- String srcId = mapDisgNodeRefNode.get(link.getSource().getSourceNode().getValue());
- IpAddress srcIp = mapNodeRefIp.get(srcId);
- String clfi = link1.getClfi();
- String destId = null;
- IpAddress destIp = null;
- // Add the links between amplifiers
- OMSAttributes omsAttributes = null;
- if (linkType == 4) {
- omsAttributes = openroadmNetworkLink1.getOMSAttributes();
- }
- if (omsAttributes != null) {
- if (omsAttributes.getAmplifiedLink() != null) {
- List<AmplifiedLink> amplifiedLinkList = omsAttributes.getAmplifiedLink()
- .getAmplifiedLink();
- if (!amplifiedLinkList.isEmpty()) {
- for (AmplifiedLink amplifiedLink : amplifiedLinkList) {
- Elements element1 = null;
- if (amplifiedLink.getSectionElement()
- .getSectionElement() instanceof Ila) {
- Ila ila = (Ila) amplifiedLink.getSectionElement()
- .getSectionElement();
- String nodeId = ila.getNodeId().getValue();
- IpAddress ipEdfa = new IpAddress(
- new Ipv4Address("1.1.1." + nbEDFA));
- nbEDFA++;
- mapDisgNodeRefNode.put(nodeId, nodeId);
- mapNodeRefIp.put(nodeId, ipEdfa);
- element1 = addElementsEdfa(2, 0, "RLD", "Lannion_CAS",
- ila.getGain().getValue(), ila.getTilt().getValue(),
- ila.getOutVoaAtt().getValue(), "std_medium_gain",
- ipEdfa.getIpv4Address().getValue().toString());
- } else if (amplifiedLink.getSectionElement()
- .getSectionElement() instanceof Span) {
- // Create the location
- IpAddress ipFiber = new IpAddress(
- new Ipv4Address("2.2.2." + idFiber));
- mapLinkFiber.put(link.getLinkId().getValue(), clfi);
- mapFiberIp.put(clfi, ipFiber);
- idFiber++;
- element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
- ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0,
- "SSMF");
- }
- if (element1 != null) {
- topoElements.add(element1);
- destId = element1.getUid();
- destIp = null;
- // Create a new link
- if (srcId != destId) {
- Connections connection = createNewConnection(srcId, srcIp,
- destId, destIp);
- topoConnections.add(connection);
- srcId = destId;
- srcIp = destIp;
- }
- }
- }
- }
- } else if (omsAttributes.getSpan() != null) {
- IpAddress ipFiber = new IpAddress(new Ipv4Address("2.2.2." + idFiber));
- mapLinkFiber.put(link.getLinkId().getValue(), clfi);
- mapFiberIp.put(clfi, ipFiber);
- idFiber++;
- double attIn = 0;
- double connIn = 0;
- double connOut = 0;
- String typeVariety = "SSMF";
- double length = 0;
- // Compute the length of the link
- org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
- .networks.network.link.oms.attributes.@Nullable Span span =
- omsAttributes.getSpan();
- List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
- for (LinkConcatenation linkConcatenation : linkConcatenationList) {
- double srlgLength = linkConcatenation.getSRLGLength();
- //convert to kilometer
- length += srlgLength / convertKmM;
- }
- double lossCoef = span.getSpanlossCurrent().getValue().doubleValue() / length;
- Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
- ipFiber.getIpv4Address().getValue(), length, attIn, lossCoef, connIn,
- connOut, typeVariety);
- topoElements.add(element1);
- // Create a new link
- destId = element1.getUid();
- destIp = null;
- if (srcId != destId) {
- Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
- topoConnections.add(connection);
- srcId = destId;
- srcIp = destIp;
- }
- } else {
- // Add a fiber
- clfi = "Fiber" + idFiber;
- IpAddress ipFiber = new IpAddress(new Ipv4Address("2.2.2." + idFiber));
- mapLinkFiber.put(link.getLinkId().getValue(), clfi);
- mapFiberIp.put(clfi, ipFiber);
- idFiber++;
- // Create a new element
- Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
- ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0, "SSMF");
- topoElements.add(element1);
- // Create a new link
- destId = element1.getUid();
- destIp = null;
- if (srcId != destId) {
- Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
- topoConnections.add(connection);
- srcId = destId;
- srcIp = destIp;
- }
- }
- } else {
- LOG.warn("The oms attributes is null {} !",link1.getLinkType().getName());
- }
- // Create a new link
- destId = mapDisgNodeRefNode.get(link.getDestination().getDestNode().getValue());
- destIp = mapNodeRefIp.get(destId);
- Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
- topoConnections.add(connection);
- }
- }
- } else {
- LOG.warn("no links in the network");
+ if (openRoadmTopoNodeList.isEmpty() || openRoadmNetNodeList.isEmpty()) {
+ throw new GnpyException("In gnpyTopoImpl: no nodes in the openradm topology or openroadm network");
+ }
+ // Create elements
+ for (Node openRoadmTopoNode : openRoadmTopoNodeList) {
+ // Retrieve the supporting node and the type of the node in openRoadm network
+ List<SupportingNode> supportingNodeList = openRoadmTopoNode.getSupportingNode();
+ for (SupportingNode supportingNode : supportingNodeList) {
+ IpAddress ipAddress = null;
+ String nodeRef = supportingNode.getNodeRef().getValue();
+ // Retrieve the mapping between the openRoadm topology and openRoadm network
+ mapDisgNodeRefNode.put(openRoadmTopoNode.getNodeId().getValue(), nodeRef);
+ Node1 openRoadmNetNode1 = null;
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
+ .Node1 commonNetworkNode1 = null;
+ for (Node openRoadmNetNode : openRoadmNetNodeList) {
+ if (openRoadmNetNode.getNodeId().getValue().equals(nodeRef)) {
+ openRoadmNetNode1 = openRoadmNetNode.augmentation(Node1.class);
+ commonNetworkNode1 = openRoadmNetNode.augmentation(org.opendaylight.yang.gen.v1
+ .http.org.openroadm.common.network.rev181130.Node1.class);
+ ipAddress = openRoadmNetNode1.getIp();
+ mapNodeRefIp.put(nodeRef, ipAddress);
+ break;
+ }
+ }
+ if (commonNetworkNode1.getNodeType().getName().equals("ROADM")) {
+ if (!nodesList.contains(nodeRef)) {
+ Elements element = createElementsRoadm(LATITUDE, LONGITUTE, nodeRef,
+ openRoadmNetNode1.getShelf(),TARGET_PCH_OUT_DB, ipAddress.getIpv4Address().getValue()
+ .toString());
+ this.elements.add(element);
+ nodesList.add(nodeRef);
+ }
+ } else if (commonNetworkNode1.getNodeType().getName().equals("XPONDER")) {
+ if (!nodesList.contains(nodeRef)) {
+ Elements element = createElementsTransceiver(LATITUDE, LONGITUTE, nodeRef,
+ openRoadmNetNode1.getShelf(),ipAddress.getIpv4Address().getValue().toString());
+ this.elements.add(element);
+ nodesList.add(nodeRef);
+ trxList.add(nodeRef);