Minor changes in the topology extraction for GNPy
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / gnpy / ExtractTopoDataStoreImpl.java
index 692451f94f2ef85b96a472dc607506abe764052d..5c0d4031bff25cbe78d16132e97c9f306023b634 100644 (file)
@@ -68,7 +68,7 @@ import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.Syn
 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.SynchronizationBuilder;
 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.Svec;
 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.SvecBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.AmplifiedLink;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.Span;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.ila.Ila;
@@ -127,11 +127,12 @@ public class ExtractTopoDataStoreImpl {
         } else {
             elements = null;
         }
-        if (map.containsKey("Elements")) {
+        if (map.containsKey("Connections")) {
             connections = (List<Connections>) map.get("Connections");
         } else {
             connections = null;
         }
+
         pathRequest = extractPathRequest(input, atoz, requestId);
         synchronization = extractSynchronization(requestId);
     }
@@ -145,7 +146,7 @@ public class ExtractTopoDataStoreImpl {
         } else {
             elements = null;
         }
-        if (map.containsKey("Elements")) {
+        if (map.containsKey("Connections")) {
             connections = (List<Connections>) map.get("Connections");
         } else {
             connections = null;
@@ -243,7 +244,7 @@ public class ExtractTopoDataStoreImpl {
                     int idFiber = 0;
                     int nbEDFA = 0;
                     if (!linksList.isEmpty()) {
-                        LOG.warn("The link list is not empty");
+                        LOG.debug("The link list is not empty");
                         for (Link link : linksList) {
                             Link1 link1 = link.augmentation(Link1.class);
                             int linkType = link1.getLinkType().getIntValue();
@@ -317,19 +318,20 @@ public class ExtractTopoDataStoreImpl {
                                         mapFiberIp.put(clfi, ipFiber);
                                         idFiber++;
 
-                                        double attIn = span.getSpanlossCurrent().getValue().doubleValue();
-                                        double lossCoef = 0.2;
+                                        double attIn = 0;
                                         double connIn = 0;
                                         double connOut = 0;
                                         String typeVariety = "SSMF";
 
-                                        double length = 0; //convert to kilometer
+                                        double length = 0;
                                         // Compute the length of the link
                                         List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
                                         for (LinkConcatenation linkConcatenation : linkConcatenationList) {
                                             double srlgLength = linkConcatenation.getSRLGLength();
-                                            length += srlgLength / convertKmM; //convert to kilometer
+                                            //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,
@@ -576,7 +578,7 @@ public class ExtractTopoDataStoreImpl {
     public List<Synchronization> extractSynchronization(Long requestId) {
         // Create RequestIdNumber
         List<Long> requestIdNumber = new ArrayList<>();
-        requestIdNumber.add(0, new Long(0));
+        requestIdNumber.add(requestId);
         // Create a synchronization
         Svec svec = new SvecBuilder().setRelaxable(true).setDisjointness(new TePathDisjointness(true, true, false))
                 .setRequestIdNumber(requestIdNumber).build();
@@ -624,9 +626,8 @@ public class ExtractTopoDataStoreImpl {
                 .setOutVoa(outVoa).build();
         Edfa edfa = new EdfaBuilder()
                 .setOperational(operational).build();
-        Elements element1 = new ElementsBuilder().setUid(uidEdfa) // Choose an
-                                                                  // ip
-                                                                  // address
+        Elements element1 = new ElementsBuilder().setUid(uidEdfa)
+                // Choose an ip address
                 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
                 .setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
         return element1;