Merge "fix some sonar issues"
authorGuillaume Lambert <guillaume.lambert@orange.com>
Fri, 21 Jun 2019 14:14:26 +0000 (14:14 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 21 Jun 2019 14:14:26 +0000 (14:14 +0000)
31 files changed:
common/src/main/java/org/opendaylight/transportpce/common/crossconnect/CrossConnectImpl.java
common/src/main/java/org/opendaylight/transportpce/common/fixedflex/FixedFlexImpl.java
common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfacesImpl.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/InfoSubtree.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopology121.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopology22.java
olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtImpl.java
olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtVersion121.java
olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtVersion221.java
olm/src/main/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImpl.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceCalculation.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceConstraintsCalc.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceGraph.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceLink.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceNode.java
pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java
pce/src/main/java/org/opendaylight/transportpce/pce/gnpy/ExtractTopoDataStoreImpl.java
pce/src/main/java/org/opendaylight/transportpce/pce/gnpy/GnpyResult.java
pce/src/main/java/org/opendaylight/transportpce/pce/gnpy/ServiceDataStoreOperationsImpl.java
pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/NetworkModelWavelengthServiceImpl.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface221.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/OlmPowerSetupTask.java
renderer/src/test/java/org/opendaylight/transportpce/renderer/stub/OlmServiceStub.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraints.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingConstraints.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ModelMappingUtils.java
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java

index ec699ae97859c7366d2ce83a0421d0638ef8c1c4..463dabd9456473376f3d493f38a4ebdcc1b41628 100644 (file)
@@ -25,7 +25,6 @@ public class CrossConnectImpl implements CrossConnect {
 
     private static final Logger LOG = LoggerFactory.getLogger(CrossConnectImpl.class);
 
-    private final DeviceTransactionManager deviceTransactionManager;
     protected CrossConnect crossConnect;
     private final MappingUtils mappingUtils;
     private CrossConnectImpl121 crossConnectImpl121;
@@ -34,7 +33,6 @@ public class CrossConnectImpl implements CrossConnect {
     public CrossConnectImpl(DeviceTransactionManager deviceTransactionManager, MappingUtils mappingUtils,
                             CrossConnectImpl121 crossConnectImpl121,
                             CrossConnectImpl221 crossConnectImpl221) {
-        this.deviceTransactionManager = deviceTransactionManager;
         this.mappingUtils = mappingUtils;
         this.crossConnectImpl121 = crossConnectImpl121;
         this.crossConnectImpl221 = crossConnectImpl221;
index 06c2bb9fce4af43a6bb8d86fe385446e409f34fa..e7c57408d0e91a90a4cace98fb67cd83cef785e1 100644 (file)
@@ -8,11 +8,7 @@
 
 package org.opendaylight.transportpce.common.fixedflex;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public final class FixedFlexImpl implements FixedFlexInterface {
-    private static final Logger LOG = LoggerFactory.getLogger(FixedFlexImpl.class);
     private long index;
     private double centerFrequency;
     private double start;
index 5dbcbad85fc2e60aec10baf764a88feae59a676d..34b3d545cafbfa9a739ccc97041b4c7129a224be 100644 (file)
@@ -23,7 +23,6 @@ public class OpenRoadmInterfacesImpl implements OpenRoadmInterfaces {
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterfacesImpl.class);
 
-    private final DeviceTransactionManager deviceTransactionManager;
     OpenRoadmInterfacesImpl121 openRoadmInterfacesImpl121;
     OpenRoadmInterfacesImpl221 openRoadmInterfacesImpl221;
     MappingUtils mappingUtils;
@@ -31,7 +30,6 @@ public class OpenRoadmInterfacesImpl implements OpenRoadmInterfaces {
     public OpenRoadmInterfacesImpl(DeviceTransactionManager deviceTransactionManager, MappingUtils mappingUtils,
                                    OpenRoadmInterfacesImpl121 openRoadmInterfacesImpl121,
                                    OpenRoadmInterfacesImpl221 openRoadmInterfacesImpl221) {
-        this.deviceTransactionManager = deviceTransactionManager;
         this.mappingUtils = mappingUtils;
         this.openRoadmInterfacesImpl121 = openRoadmInterfacesImpl121;
         this.openRoadmInterfacesImpl221 = openRoadmInterfacesImpl221;
index bbbc57898b21be7240aa419e0623e763a5f48728..b870224c5081d401942ebfa9bb9693cf739feb01 100644 (file)
@@ -47,9 +47,9 @@ public class InfoSubtree {
     public boolean getDeviceInfo(String nodeId, DeviceTransactionManager deviceTransactionManager) {
         switch (this.openRoadmVersion) {
             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
-                return getDeviceInfo1_2_1(nodeId, deviceTransactionManager);
+                return getDeviceInfo121(nodeId, deviceTransactionManager);
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
-                return getDeviceInfo2_2_1(nodeId, deviceTransactionManager);
+                return getDeviceInfo221(nodeId, deviceTransactionManager);
             default:
                 LOG.info("Device version {} not supported",this.openRoadmVersion);
                 return false;
@@ -57,7 +57,7 @@ public class InfoSubtree {
 
     }
 
-    private boolean getDeviceInfo1_2_1(String nodeId, DeviceTransactionManager deviceTransactionManager) {
+    private boolean getDeviceInfo121(String nodeId, DeviceTransactionManager deviceTransactionManager) {
 
         //Read clli from the device
         InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
@@ -85,7 +85,7 @@ public class InfoSubtree {
 
     }
 
-    private boolean getDeviceInfo2_2_1(String nodeId, DeviceTransactionManager deviceTransactionManager) {
+    private boolean getDeviceInfo221(String nodeId, DeviceTransactionManager deviceTransactionManager) {
 
         //TODO : change back to operational when testing on real device
         //Read clli from the device
index 07de58816dd4145293a917fcff4107e73fc9ff30..3ce7215ec7a48a9d6fad73e8310a30ce43cff138 100644 (file)
@@ -267,10 +267,8 @@ public class OpenRoadmTopology121 {
             for (CircuitPacks cp : deviceObject.get().getCircuitPacks()) {
                 if (cp.getPorts() != null) {
                     for (Ports port : cp.getPorts()) {
-                        if (port.getPortQual() != null) {
-                            if (port.getPortQual().getIntValue() == 4) {
-                                client++;
-                            }
+                        if ((port.getPortQual() != null) && (port.getPortQual().getIntValue() == 4)) {
+                            client++;
                         }
                     }
                 }
index 9d7518c8df1a13ee89f47c8e77b2ad0827d430da..f6f214403015a9cb742076f3e75fe6c79bab21c8 100644 (file)
@@ -269,10 +269,8 @@ public class OpenRoadmTopology22 {
             for (CircuitPacks cp : deviceObject.get().getCircuitPacks()) {
                 if (cp.getPorts() != null) {
                     for (Ports port : cp.getPorts()) {
-                        if (port.getPortQual() != null) {
-                            if (port.getPortQual().getIntValue() == 4) {
-                                client++;
-                            }
+                        if ((port.getPortQual() != null) && (port.getPortQual().getIntValue() == 4)) {
+                            client++;
                         }
                     }
                 }
index d9e22d60908efdc9d8a8ddcc838fafaf173bdbe0..f751e346013f1f64609765fd2738926b19802dfc 100644 (file)
@@ -140,8 +140,7 @@ public class PowerMgmtImpl implements PowerMgmt {
                                 LOG.info("SRG Power Range not found");
                             }
                         } else {
-                            LOG.info("Tranponder range not available seting to default "
-                                    + "power for nodeId: {}", nodeId);
+                            LOG.info("Tranponder range not available setting to default power for nodeId: {}", nodeId);
                             String interfaceName = destTpId + "-" + input.getWaveNumber();
                             if (callSetTransponderPower(nodeId, interfaceName, new BigDecimal(-5),openroadmVersion)) {
                                 LOG.info("Transponder OCH connection: {} power updated ", interfaceName);
@@ -194,8 +193,14 @@ public class PowerMgmtImpl implements PowerMgmt {
                                 return false;
                             }
                             if (interfaceOpt.isPresent()) {
-                                spanLossTx = interfaceOpt.get().augmentation(Interface1.class).getOts()
-                                    .getSpanLossTransmit().getValue();
+                                if (interfaceOpt.get().augmentation(Interface1.class).getOts()
+                                    .getSpanLossTransmit() != null) {
+                                    spanLossTx = interfaceOpt.get().augmentation(Interface1.class).getOts()
+                                            .getSpanLossTransmit().getValue();
+                                    LOG.info("Spanloss TX is {}", spanLossTx);
+                                } else {
+                                    LOG.error("interface {} has no spanloss value", interfaceOpt.get().getName());
+                                }
                             } else {
                                 LOG.error("Interface {} on node {} is not present!", portMapping.getSupportingOts(),
                                     nodeId);
@@ -217,18 +222,39 @@ public class PowerMgmtImpl implements PowerMgmt {
                                 return false;
                             }
                             if (interfaceOpt.isPresent()) {
-                                spanLossTx = interfaceOpt.get().augmentation(org.opendaylight.yang.gen.v1.http.org
-                                    .openroadm.optical.transport.interfaces.rev181019.Interface1.class).getOts()
-                                    .getSpanLossTransmit().getValue();
+                                if (interfaceOpt.get().augmentation(org.opendaylight.yang.gen.v1.http.org
+                                        .openroadm.optical.transport.interfaces.rev181019.Interface1.class).getOts()
+                                        .getSpanLossTransmit() != null) {
+                                    spanLossTx = interfaceOpt.get().augmentation(org.opendaylight.yang.gen.v1.http.org
+                                            .openroadm.optical.transport.interfaces.rev181019.Interface1.class).getOts()
+                                            .getSpanLossTransmit().getValue();
+                                    LOG.info("Spanloss TX is {}", spanLossTx);
+                                } else {
+                                    LOG.error("interface {} has no spanloss value", interfaceOpt.get().getName());
+                                }
                             } else {
                                 LOG.error("Interface {} on node {} is not present!", portMapping.getSupportingOts(),
                                     nodeId);
                                 return false;
                             }
                         }
-                        LOG.info("Spanloss TX is {}", spanLossTx);
-                        BigDecimal powerValue = BigDecimal.valueOf(Math.min(spanLossTx.doubleValue() - 9, 2));
-                        LOG.info("Power Value is {}", powerValue);
+
+                        BigDecimal powerValue =  null;
+                        if (spanLossTx != null &&  spanLossTx.intValue() <= 28 && spanLossTx.intValue() > 0) {
+                            powerValue = BigDecimal.valueOf(Math.min(spanLossTx.doubleValue() - 9, 2));
+                            LOG.info("Power Value is {}", powerValue);
+                        } else if (spanLossTx.intValue() > 28) {
+                            LOG.error(
+                                "Power Value is null - spanLossTx > 28dB not compliant with openROADM specifications");
+                            return false;
+                        } else if (spanLossTx.intValue() <= 0) {
+                            LOG.error(
+                                "Power Value is null - spanLossTx <= 0 dB not compliant with openROADM specifications");
+                            return false;
+                        } else {
+                            LOG.error("Power Value is null - spanLossTx is null");
+                            return false;
+                        }
                         try {
                             Boolean setXconnPowerSuccessVal = crossConnect.setPowerLevel(nodeId,
                                     OpticalControlMode.Power, powerValue, connectionNumber);
@@ -353,8 +379,7 @@ public class PowerMgmtImpl implements PowerMgmt {
             }
             LOG.info("Transponder power range is fine");
             if (!txPowerRangeMap.isEmpty()) {
-                LOG.info("Transponder power range is not null {}, {}",
-                        nextNodeId,srgId);
+                LOG.info("Transponder power range is not null {}, {}", nextNodeId,srgId);
                 //Transponder range is not empty then check SRG Range
 
                 Optional<Mapping> mappingObjectSRG = OlmUtils.getNode(nextNodeId, db)
@@ -405,8 +430,7 @@ public class PowerMgmtImpl implements PowerMgmt {
                     return false;
                 }
             } else {
-                LOG.info("Tranponder range not available seting to default "
-                        + "power for nodeId: {}", nodeId);
+                LOG.info("Tranponder range not available seting to default power for nodeId: {}", nodeId);
                 String interfaceName = destTpId + "-" + waveLength;
                 if (callSetTransponderPower(nodeId,interfaceName,new BigDecimal(-5),
                         openroadmVersion)) {
@@ -528,13 +552,11 @@ public class PowerMgmtImpl implements PowerMgmt {
                                 OpticalControlMode.GainLoss, powerValue,connectionNumber);
                         return true;
                     } else {
-                        LOG.info("Set Power failed for Roadm-connection: {} on Node: {}", connectionNumber,
-                                nodeId);
+                        LOG.info("Set Power failed for Roadm-connection: {} on Node: {}", connectionNumber, nodeId);
                         return false;
                     }
                 } else {
-                    LOG.error("Interface {} on node {} is not present!", interfaceName,
-                            nodeId);
+                    LOG.error("Interface {} on node {} is not present!", interfaceName, nodeId);
                     return false;
                 }
             } else if (openroadmVersion.equals(Nodes.OpenroadmVersion._221)) {
@@ -559,15 +581,13 @@ public class PowerMgmtImpl implements PowerMgmt {
                                 OpticalControlMode.GainLoss, powerValue,connectionNumber);
                         return true;
                     } else {
-                        LOG.info("Set Power failed for Roadm-connection: {} on Node: {}", connectionNumber,
-                                nodeId);
+                        LOG.info("Set Power failed for Roadm-connection: {} on Node: {}", connectionNumber, nodeId);
                         return false;
                     }
                 }
             }
         } catch (OpenRoadmInterfaceException | InterruptedException ex) {
-            LOG.error("Error during power setup on Roadm nodeId: {} for connection: {}",
-                    nodeId, connectionNumber, ex);
+            LOG.error("Error during power setup on Roadm nodeId: {} for connection: {}", nodeId, connectionNumber, ex);
             return false;
         }
         return false;
index df6dced557a1236a566c6f96c0d125de2b0d9a40..2e1b56518f5cb3f3db72574ea1ab8f5173abc610 100644 (file)
@@ -42,7 +42,6 @@ import org.slf4j.LoggerFactory;
 
 public final class PowerMgmtVersion121 {
     private static final Logger LOG = LoggerFactory.getLogger(PowerMgmtVersion121.class);
-    private static final long DATA_STORE_READ_TIMEOUT = 120;
 
     private PowerMgmtVersion121() {
     }
index 66a0b5c530451f46a79dd9eaf2e97e0be1e2681a..48d9bfe15b06308bdaf6ebf98396e84a1ca9036a 100644 (file)
@@ -44,7 +44,6 @@ import org.slf4j.LoggerFactory;
 
 public final class PowerMgmtVersion221 {
     private static final Logger LOG = LoggerFactory.getLogger(PowerMgmtVersion221.class);
-    private static final long DATA_STORE_READ_TIMEOUT = 120;
 
     private PowerMgmtVersion221() {
     }
index 3d3889318e79bf2fde6181e93f5fcaeda2fd17fa..8b66b2ef8d01b0e13463770bf3fae321fceb8eb8 100644 (file)
@@ -65,8 +65,6 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmappi
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RatioDB;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Link1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.transport.interfaces.rev161014.Interface1;
@@ -127,7 +125,6 @@ public class OlmPowerServiceImpl implements OlmPowerService {
     public GetPmOutput getPm(GetPmInput pmInput) {
         org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping
             .rev170228.network.Nodes.OpenroadmVersion openroadmVersion;
-        //LOG.info("Version returbed by mapping util is "+ mappingUtils.getOpenROADMVersion(pmInput.getNodeId()));
         if (mappingUtils.getOpenRoadmVersion(pmInput.getNodeId())
             .equals(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1)) {
             LOG.info("Device version is 1.2.1");
@@ -148,7 +145,6 @@ public class OlmPowerServiceImpl implements OlmPowerService {
     public ServicePowerSetupOutput servicePowerSetup(ServicePowerSetupInput powerSetupInput) {
         ServicePowerSetupOutputBuilder powerSetupOutput = new ServicePowerSetupOutputBuilder();
         boolean successValPowerCalculation = powerMgmt.setPower(powerSetupInput);
-
         if (successValPowerCalculation) {
             powerSetupOutput.setResult(ResponseCodes.SUCCESS_RESULT);
         } else {
@@ -394,7 +390,6 @@ public class OlmPowerServiceImpl implements OlmPowerService {
      */
     private boolean setSpanLoss(String nodeId, String interfaceName, BigDecimal spanLoss, String direction) {
         String realNodeId = getRealNodeId(nodeId);
-        BigDecimal initialSpanloss = new BigDecimal(0);
         try {
             LOG.info("Setting Spanloss in device for {}, InterfaceName: {}", realNodeId, interfaceName);
             if (mappingUtils.getOpenRoadmVersion(realNodeId)
@@ -405,8 +400,6 @@ public class OlmPowerServiceImpl implements OlmPowerService {
                 Optional<Interface> interfaceObject;
                 interfaceObject = openRoadmInterfaces.getInterface(realNodeId, interfaceName);
                 if (interfaceObject.isPresent()) {
-                    InstanceIdentifier<Interface> interfacesIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
-                        .child(Interface.class, new InterfaceKey(interfaceName));
                     InterfaceBuilder interfaceBuilder = new InterfaceBuilder(interfaceObject.get());
                     OtsBuilder otsBuilder = new OtsBuilder();
                     Interface intf = interfaceObject.get();
@@ -432,8 +425,7 @@ public class OlmPowerServiceImpl implements OlmPowerService {
                     LOG.info("Spanloss Value update completed successfully");
                     return true;
                 } else {
-                    LOG.error("Interface not found for nodeId: {} and interfaceName: {}",
-                        nodeId,interfaceName);
+                    LOG.error("Interface not found for nodeId: {} and interfaceName: {}", nodeId, interfaceName);
                     return false;
                 }
             } else if (mappingUtils.getOpenRoadmVersion(realNodeId)
@@ -446,13 +438,6 @@ public class OlmPowerServiceImpl implements OlmPowerService {
                     .interfaces.grp.Interface> interfaceObject =
                         openRoadmInterfaces.getInterface(realNodeId, interfaceName);
                 if (interfaceObject.isPresent()) {
-                    InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019
-                        .interfaces.grp.Interface> interfacesIID =
-                        InstanceIdentifier.create(org.opendaylight.yang.gen.v1.http.org.openroadm
-                            .device.rev181019.org.openroadm.device.container.OrgOpenroadmDevice.class)
-                            .child(org.opendaylight.yang.gen.v1.http.org.openroadm
-                                .device.rev181019.interfaces.grp.Interface.class, new org.opendaylight.yang.gen
-                                .v1.http.org.openroadm.device.rev181019.interfaces.grp.InterfaceKey(interfaceName));
                     org.opendaylight.yang.gen.v1.http.org.openroadm.device
                         .rev181019.interfaces.grp.InterfaceBuilder interfaceBuilder =
                         new org.opendaylight.yang.gen.v1.http.org.openroadm.device
@@ -501,8 +486,7 @@ public class OlmPowerServiceImpl implements OlmPowerService {
                     LOG.info("Spanloss Value update completed successfully");
                     return true;
                 } else {
-                    LOG.error("Interface not found for nodeId: {} and interfaceName: {}",
-                        nodeId,interfaceName);
+                    LOG.error("Interface not found for nodeId: {} and interfaceName: {}", nodeId,interfaceName);
                     return false;
                 }
             }
@@ -543,19 +527,20 @@ public class OlmPowerServiceImpl implements OlmPowerService {
             OtsPmHolder destOtsPmHoler = getPmMeasurements(destNodeId, destTpId, "OpticalPowerInput");
             spanLoss = new BigDecimal(srcOtsPmHoler.getOtsParameterVal() - destOtsPmHoler.getOtsParameterVal())
                 .setScale(0, RoundingMode.HALF_UP);
-            LOG.info("Spanloss Calculated as :" + spanLoss + "=" + srcOtsPmHoler.getOtsParameterVal() + "-"
-                + destOtsPmHoler.getOtsParameterVal());
-            if ((spanLoss.doubleValue() < 28) && (spanLoss.doubleValue() > 0)) {
-                if (!setSpanLoss(sourceNodeId, srcOtsPmHoler.getOtsInterfaceName(), spanLoss, "TX")) {
-                    LOG.info("Setting spanLoss failed for " + sourceNodeId);
-                    return null;
-                }
-                if (!setSpanLoss(destNodeId, destOtsPmHoler.getOtsInterfaceName(), spanLoss, "RX")) {
-                    LOG.info("Setting spanLoss failed for " + destNodeId);
-                    return null;
-                }
-                map.put(link.getLinkId(), spanLoss);
+            LOG.info("Spanloss Calculated as :{}={}-{}",
+                spanLoss, srcOtsPmHoler.getOtsParameterVal(), destOtsPmHoler.getOtsParameterVal());
+            if (spanLoss.doubleValue() > 28) {
+                LOG.warn("Span Loss is out of range of OpenROADM specifications");
+            }
+            if (!setSpanLoss(sourceNodeId, srcOtsPmHoler.getOtsInterfaceName(), spanLoss, "TX")) {
+                LOG.info("Setting spanLoss failed for {}", sourceNodeId);
+                return null;
+            }
+            if (!setSpanLoss(destNodeId, destOtsPmHoler.getOtsInterfaceName(), spanLoss, "RX")) {
+                LOG.info("Setting spanLoss failed for {}", destNodeId);
+                return null;
             }
+            map.put(link.getLinkId(), spanLoss);
         }
         return map;
     }
index 177fb7323bfc007cb24d5aebb959d293ea6729fd..95a8cbed8a44c6ffc458254211201b141de78571 100644 (file)
@@ -71,7 +71,6 @@ public class PceCalculation {
         NONE, HARD_EXCLUDE, HARD_INCLUDE, HARD_DIVERSITY, SOFT_EXCLUDE, SOFT_INCLUDE, SOFT_DIVERSITY;
     }
 
-    // private static final String NETWORK_ID = "Transport Overlay";
     public PceCalculation(PathComputationRequestInput input, DataBroker dataBroker, PceConstraints pceHardConstraints,
             PceConstraints pceSoftConstraints, PceResult rc) {
         this.input = input;
index 97beb039fe04bca57663aff48eaf90f1037b4046..9a94a6662bc816fe8f206b0cf617e041dd9948ec 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.transportpce.pce;
 import com.google.common.base.Optional;
 import java.util.ArrayList;
 import java.util.List;
-//import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -145,11 +144,9 @@ public class PceConstraintsCalc {
         }
 
         Diversity diversity = tmpGeneral.getDiversity();
-        if (diversity != null) {
-            if (diversity.getExistingServiceApplicability().isNode()) {
-                LOG.info("in readGeneralContrains {}", diversity.toString());
-                readDiversityNodes(diversity.getExistingService(), constraints);
-            }
+        if ((diversity != null) && (diversity.getExistingServiceApplicability().isNode())) {
+            LOG.info("in readGeneralContrains {}", diversity.toString());
+            readDiversityNodes(diversity.getExistingService(), constraints);
         }
 
     }
@@ -208,8 +205,6 @@ public class PceConstraintsCalc {
                     result = Optional.of(path);
                 }
             }
-//            return pathDescReadTx.read(LogicalDatastoreType.CONFIGURATION, pathDescriptionIID)
-//                    .get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.warn(
                 "PCE diversity constraints: Exception while getting path description from datastore {} for service {}!",
index 89013ca2643dc46d4dcd00cbeccb7b29241862b1..08886ca87e2532c1216e69b554e9e6fbb8277273 100644 (file)
@@ -371,14 +371,12 @@ public class PceGraph {
 
         Long latencyConstraint = this.pceHardConstraints.getMaxLatency();
 
-        if (latencyConstraint > 0) {
-            if (this.tmpAtozLatency > latencyConstraint) {
-                this.foundButTooHighLatency = true;
-                this.pceResult.setLocalCause(LocalCause.TOO_HIGH_LATENCY);
-                LOG.info("In validateLatency: AtoZ path has too high LATENCY {} > {}", this.tmpAtozLatency,
-                        latencyConstraint);
-                return false;
-            }
+        if ((latencyConstraint > 0) && (this.tmpAtozLatency > latencyConstraint)) {
+            this.foundButTooHighLatency = true;
+            this.pceResult.setLocalCause(LocalCause.TOO_HIGH_LATENCY);
+            LOG.info("In validateLatency: AtoZ path has too high LATENCY {} > {}", this.tmpAtozLatency,
+                latencyConstraint);
+            return false;
         }
         LOG.info("In validateLatency: AtoZ path  is {}", this.pathAtoZ.toString());
         return true;
index 44e3fad451f48100d7eb60239a4ac16a55b18338..6320d9e5304bc214021efa5636c1b8bef331c468 100644 (file)
@@ -29,7 +29,6 @@ public class PceLink {
     /*
      * extension of Link to include constraints and Graph weight
      */
-    // double capacity = 1;
 
     double weight = 0;
 
@@ -209,7 +208,6 @@ public class PceLink {
         spanOsnrLu = Math.pow(10, (spanOsnrDb / 10.0));
         sum = PceConstraints.CONST_OSNR / spanOsnrLu;
         linkOsnrLu = sum;
-        //link_OSNR_dB = 10 * Math.log10(1 / sum);
         LOG.debug("In retrieveOSNR: link OSNR is {} dB", linkOsnrLu);
         return linkOsnrLu;
     }
index 91a1f8ceff61d5a2434946bd0524d96b78c7dcd8..57797640ea7e1bfe5bf26e0dc69a61afa79acf3c 100644 (file)
@@ -257,17 +257,11 @@ public class PceNode {
     }
 
     public boolean checkTP(String tp) {
-        if (this.usedXpndrNWTps.contains(tp)) {
-            return false;
-        }
-        return true;
+        return !(this.usedXpndrNWTps.contains(tp));
     }
 
     public boolean checkWL(long index) {
-        if (this.availableWLindex.contains(index)) {
-            return true;
-        }
-        return false;
+        return (this.availableWLindex.contains(index));
     }
 
     public boolean isValid() {
@@ -294,4 +288,4 @@ public class PceNode {
     public String toString() {
         return "PceNode type=" + this.nodeType + " ID=" + this.nodeId.getValue();
     }
-}
\ No newline at end of file
+}
index 1193b2db6452df72938749ad251fb69d2ca1d3c1..31486dbad38eceac666570a5396d4dbf34f1e98e 100644 (file)
@@ -127,7 +127,8 @@ public class PcePathDescription {
                     .build();
 
             // Resource
-            AToZKey srcTPKey = new AToZKey(index.toString());// tpName);
+            AToZKey srcTPKey = new AToZKey(index.toString());
+            // tpName);
             Resource tpResource1 = new ResourceBuilder().setResource(stp).build();
             AToZ stpResource = new AToZBuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build();
             index++;
index bd1afea073307a2179428a52c06249c5bb26f00e..319a4e0ab18e548eb699774f6252d6a5ef0aed70 100644 (file)
@@ -210,7 +210,6 @@ public class PceSendingPceRPCs {
         ConnectToGnpyServer connect = new ConnectToGnpyServer();
         String gnpyJsonModified = gnpyJson.replace("gnpy-eqpt-config:", "")
                 .replace("gnpy-path-computation-simplified:", "").replace("gnpy-network-topology:", "");
-        //sd.writeStringFile(gnpyJsonModified);
         String gnpyResponse = connect.gnpyCnx(gnpyJsonModified);
         return gnpyResponse;
     }
index 000f055a89779708d30954515f1915b034758d6e..f7dd74622382bd75411c43a142d49c4ff633f222 100644 (file)
@@ -21,8 +21,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.NetworkUtils;
-//import org.opendaylight.yang.gen.v1.gnpy.gnpy.eqpt.config.rev181119.EdfaVariety;
-//import org.opendaylight.yang.gen.v1.gnpy.gnpy.eqpt.config.rev181119.FiberVariety;
 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Coordinate;
 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Km;
 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.Operational;
@@ -106,8 +104,6 @@ import org.slf4j.LoggerFactory;
 public class ExtractTopoDataStoreImpl {
     private static final Logger LOG = LoggerFactory.getLogger(ExtractTopoDataStoreImpl.class);
     private final DataBroker dataBroker;
-    // private final OpenRoadmTopology openRoadmTopology;
-    // private final OpenRoadmInterfaces openRoadmInterfaces;
     private List<Elements> elements = new ArrayList<>();
     private List<Connections> connections = new ArrayList<>();
     private List<PathRequest> pathRequest = new ArrayList<>();
@@ -241,8 +237,8 @@ public class ExtractTopoDataStoreImpl {
                     // 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
+                    // 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;
@@ -276,8 +272,6 @@ public class ExtractTopoDataStoreImpl {
                                                     nbEDFA++;
                                                     mapDisgNodeRefNode.put(nodeId, nodeId);
                                                     mapNodeRefIp.put(nodeId, ipEdfa);
-                                                    // class std_medium_gain
-                                                    // implements EdfaVariety {}
                                                     element1 = addElementsEdfa(2, 0, "RLD", "Lannion_CAS",
                                                             ila.getGain().getValue(), ila.getTilt().getValue(),
                                                             ila.getOutVoaAtt().getValue(), "std_medium_gain",
@@ -293,8 +287,6 @@ public class ExtractTopoDataStoreImpl {
                                                     mapLinkFiber.put(link.getLinkId().getValue(), clfi);
                                                     mapFiberIp.put(clfi, ipFiber);
                                                     idFiber++;
-                                                    // class SSMF implements
-                                                    // FiberVariety {}
                                                     element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
                                                             ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0,
                                                             "SSMF");
@@ -362,7 +354,6 @@ public class ExtractTopoDataStoreImpl {
                                         mapFiberIp.put(clfi, ipFiber);
                                         idFiber++;
                                         // Create a new element
-                                        // class SSMF implements FiberVariety {}
                                         Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
                                                 ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0, "SSMF");
                                         topoElements.add(element1);
@@ -410,27 +401,15 @@ public class ExtractTopoDataStoreImpl {
         // List of A to Z
         List<AToZ> listAtoZ = atoz.getAToZ();
         int atozSize = listAtoZ.size();
-        // String modulationFormat = atoz.getModulationFormat();
         // Create the path request
         List<PathRequest> pathRequestList = new ArrayList<>();
-        // Define the instance identifier
-        // InstanceIdentifier<Network> nwInstanceIdentifier = InstanceIdentifier
-        // .builder(Network.class, new NetworkKey(new
-        // NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
-
-        // read the configuration part of the data broker that concerns the
-        // nodes ID and get all the nodes
-        // java.util.Optional<Network> networkObject = readOnlyTransaction
-        // .read(LogicalDatastoreType.CONFIGURATION,
-        // nwInstanceIdentifier).get().toJavaUtil();
+
         // 1.1 Create explicitRouteObjects
         // 1.1.1. create RouteObjectIncludeExclude list
         List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
         IpAddress ipAddressCurrent = null;
         Long index = (long) 0;
-        //ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction();
         for (int i = 0; i < atozSize; i++) {
-            // String idAtoZ = listAtoZ.get(i).getId();
             String nodeId = null;
             if (listAtoZ.get(i).getResource()
                     .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
@@ -445,7 +424,6 @@ public class ExtractTopoDataStoreImpl {
                     IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
                     for (Elements element : elements) {
                         if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
-                            String type = element.getType().getName();
                             if ((ipAddressCurrent == null) || (ipAddressCurrent != ipAddress)) {
                                 ipAddressCurrent = ipAddress;
                                 // Fill in routeObjectIncludeExcludes
@@ -460,14 +438,7 @@ public class ExtractTopoDataStoreImpl {
                 } else {
                     LOG.warn("node ID is null");
                 }
-            } else if (listAtoZ.get(i).getResource()
-                    .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
-                    .pathdescription.rev171017.pce.resource.resource.resource.TerminationPoint) {
-                org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
-                        .resource.resource.resource.TerminationPoint tp = (org.opendaylight.yang.gen.v1.http.org
-                        .transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource
-                        .TerminationPoint) listAtoZ.get(i).getResource().getResource();
-                // Not used in this version
+            //TODO else if termination point not implemented in this version
             } else if (listAtoZ.get(i).getResource()
                     .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
                     .pathdescription.rev171017.pce.resource.resource.resource.Link) {
@@ -491,13 +462,11 @@ public class ExtractTopoDataStoreImpl {
 
         // 1. Create the path request element 1
         // Find parameters
-        // String serviceName = input.getServiceName();
         String sourceNode = input.getServiceAEnd().getNodeId();
         String destNode = input.getServiceZEnd().getNodeId();
 
         // 1.2 Create a path constraints
         Long rate = atoz.getRate();
-        // Long wavelengthNumber = atoz.getAToZWavelengthNumber();
         // Create EffectiveFreqSlot
         List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
         EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
@@ -506,23 +475,12 @@ public class ExtractTopoDataStoreImpl {
         TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
                 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
                 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
-        // .setMaxNbOfChannel(new Long(80)).setOutputPower(new
-        // BigDecimal(0.0012589254117941673))
         PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
-        // PathRequest pathRequest1 = new
-        // PathRequestBuilder().setRequestId(new
-        // Long(0)).setSource(mapNodeRefIp.get(sourceNode))
-        // .setDestination(mapNodeRefIp.get(destNode)).setSrcTpId(input.getServiceAEnd().getTxDirection()
-        //      .getPort().getPortName().getBytes())
-        // .setDstTpId(input.getServiceAEnd().getRxDirection().getPort().getPortName().getBytes())
-        //      .setPathConstraints(pathConstraints)
-        // .setExplicitRouteObjects(explicitRouteObjects).build();
         PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
                 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
                 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
                 .setExplicitRouteObjects(explicitRouteObjects).build();
         pathRequestList.add(pathRequest1);
-        //readOnlyTransaction.close();
         return pathRequestList;
     }
 
@@ -530,27 +488,15 @@ public class ExtractTopoDataStoreImpl {
         // List of A to Z
         List<ZToA> listZToA = ztoa.getZToA();
         int ztoaSize = listZToA.size();
-        // String modulationFormat = ztoa.getModulationFormat();
         // Create the path request
         List<PathRequest> servicePathRequest = new ArrayList<>();
-        // Define the instance identifier
-        InstanceIdentifier<Network> nwInstanceIdentifier = InstanceIdentifier
-                .builder(Networks.class)
-                .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
-        //ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction();
 
-        // read the configuration part of the data broker that concerns the
-        // nodes ID and get all the nodes
-        // java.util.Optional<Network> networkObject = readOnlyTransaction
-        // .read(LogicalDatastoreType.CONFIGURATION,
-        // nwInstanceIdentifier).get().toJavaUtil();
         // 1.1 Create explicitRouteObjects
         // 1.1.1. create RouteObjectIncludeExclude list
         List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
         IpAddress ipAddressCurrent = null;
         Long index = (long) 0;
         for (int i = 0; i < ztoaSize; i++) {
-            // String idZtoA = listZToA.get(i).getId();
             String nodeId = null;
             if (listZToA.get(i).getResource()
                     .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
@@ -565,7 +511,6 @@ public class ExtractTopoDataStoreImpl {
                     IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
                     for (Elements element : elements) {
                         if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
-                            // String type = element.getType().getName();
                             if ((ipAddressCurrent == null) || (ipAddressCurrent != ipAddress)) {
                                 ipAddressCurrent = ipAddress;
                                 // Fill in routeObjectIncludeExcludes
@@ -580,14 +525,7 @@ public class ExtractTopoDataStoreImpl {
                 } else {
                     LOG.warn("node ID is null");
                 }
-            } else if (listZToA.get(i).getResource()
-                    .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
-                    .pathdescription.rev171017.pce.resource.resource.resource.TerminationPoint) {
-                org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
-                    .resource.resource.resource.TerminationPoint tp = (org.opendaylight.yang.gen.v1.http.org
-                    .transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource
-                    .TerminationPoint) listZToA.get(i).getResource().getResource();
-                // Not used in this version
+            //TODO else if termination point not implemented in this version
             } else if (listZToA.get(i).getResource()
                     .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
                     .pathdescription.rev171017.pce.resource.resource.resource.Link) {
@@ -611,13 +549,11 @@ public class ExtractTopoDataStoreImpl {
 
         // 1. Create the path request element 1
         // Find parameters
-        // String serviceName = input.getServiceName();
         String sourceNode = input.getServiceZEnd().getNodeId();
         String destNode = input.getServiceAEnd().getNodeId();
 
         // 1.2 Create a path constraints
         Long rate = ztoa.getRate();
-        // Long wavelengthNumber = ztoa.getZToAWavelengthNumber();
         // Create EffectiveFreqSlot
         List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
         EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
@@ -626,23 +562,12 @@ public class ExtractTopoDataStoreImpl {
         TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
                 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
                 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
-        // .setMaxNbOfChannel(new Long(80)).setOutputPower(new
-        // BigDecimal(0.0012589254117941673))
         PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
-        // PathRequest pathRequest1 = new
-        // PathRequestBuilder().setRequestId(new
-        // Long(0)).setSource(mapNodeRefIp.get(sourceNode))
-        // .setDestination(mapNodeRefIp.get(destNode)).setSrcTpId(input.getServiceAEnd().getTxDirection()
-        //      .getPort().getPortName().getBytes())
-        // .setDstTpId(input.getServiceAEnd().getRxDirection().getPort().getPortName().getBytes())
-        //      .setPathConstraints(pathConstraints)
-        // .setExplicitRouteObjects(explicitRouteObjects).build();
         PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
                 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
                 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
                 .setExplicitRouteObjects(explicitRouteObjects).build();
         servicePathRequest.add(pathRequest1);
-        //readOnlyTransaction.close();
         return servicePathRequest;
     }
 
@@ -678,7 +603,6 @@ public class ExtractTopoDataStoreImpl {
                 .setAttIn(new BigDecimal(attIn)).setLossCoef(new BigDecimal(lossCoef)).setConIn(new BigDecimal(connIn))
                 .setConOut(new BigDecimal(connOut)).build();
         Params params1 = new ParamsBuilder().setFiberroadm(fiber).build();
-        // TypeElement Fiber = ; //new TypeElement(Fiber);
         Elements element1 = new ElementsBuilder().setUid(clfi)
                 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Fiber.class)
                 .setTypeVariety(typeVariety).setMetadata(metadata1)
@@ -700,7 +624,6 @@ public class ExtractTopoDataStoreImpl {
         Operational operational = new OperationalBuilder().setGainTarget(gainTarget).setTiltTarget(tiltTarget)
                 .setOutVoa(outVoa).build();
         Edfa edfa = new EdfaBuilder()
-                // .setTypeVariety(typeVariety)
                 .setOperational(operational).build();
         Elements element1 = new ElementsBuilder().setUid(uidEdfa)
                 // Choose an ip address
@@ -763,14 +686,6 @@ public class ExtractTopoDataStoreImpl {
         return routeObjectIncludeExclude1;
     }
 
-    private String fromToNodeForConnection(String id, IpAddress ip) {
-        String fromToNode = id;
-        if (ip != null) {
-            fromToNode = ip.getIpv4Address().getValue().toString();
-        }
-        return (fromToNode);
-    }
-
     private Connections createNewConnection(String srcId, IpAddress srcIp, String destId, IpAddress destIp) {
         String fromNode = srcId;
         String toNode = destId;
@@ -817,16 +732,11 @@ public class ExtractTopoDataStoreImpl {
     }
 
     public List<PathRequest> createEmptyPathRequest(PathComputationRequestInput input, AToZDirection atoz) {
-        // List of A to Z
-        // List<AToZ> listAtoZ = atoz.getAToZ();
-        // int atozSize = listAtoZ.size();
-
         // Create the path request
         List<PathRequest> pathRequestList = new ArrayList<>();
 
         // 1. Create the path request element 1
         // Find parameters
-        // String serviceName = input.getServiceName();
         String sourceNode = input.getServiceAEnd().getNodeId();
         String destNode = input.getServiceZEnd().getNodeId();
 
index 0067102503899356f0ccd6202d627613618d5710..2767005e222a59e9a58afa93560dfabb152b264c 100644 (file)
@@ -11,9 +11,7 @@ package org.opendaylight.transportpce.pce.gnpy;
 import com.google.common.base.Preconditions;
 import com.google.gson.stream.JsonReader;
 
-import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
-import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -84,8 +82,6 @@ public class GnpyResult {
 
     public GnpyResult(String gnpyResponseString) throws Exception {
 
-        // try {
-        // Optional<DataObject> dataObject;
         // Create the schema context
         final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
         Iterable<? extends YangModuleInfo> moduleInfos;
@@ -257,28 +253,6 @@ public class GnpyResult {
         return schemaContext;
     }
 
-    private String readResultFromFile(String fileName) {
-        BufferedReader br = null;
-        FileReader fr = null;
-        StringBuilder sb = new StringBuilder();
-        String gnpyResponse;
-
-        try {
-            fr = new FileReader(fileName);
-            br = new BufferedReader(fr);
-            String currentLine;
-            while ((currentLine = br.readLine()) != null) {
-                LOG.info(currentLine);
-                sb.append(currentLine);
-            }
-            fr.close();
-        } catch (IOException e) {
-            LOG.warn("GNPy: exception {} occured during the reading of results", e.getMessage());
-        }
-        gnpyResponse = sb.toString();
-        return gnpyResponse;
-    }
-
     /**
      * Transforms the given input {@link NormalizedNode} into the given
      * {@link DataObject}.
index 4771b5c2da2210c1df824fb7183a48c8301f465e..c25f82d330c69e199d3782983f666a7eb1d5d7ab 100644 (file)
@@ -52,10 +52,8 @@ import org.slf4j.LoggerFactory;
 public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperations {
 
     private static final Logger LOG = LoggerFactory.getLogger(ServiceDataStoreOperationsImpl.class);
-    private final DataBroker dataBroker;
 
     public ServiceDataStoreOperationsImpl(DataBroker dataBroker) {
-        this.dataBroker = dataBroker;
     }
 
     public void createXMLFromDevice(DataStoreContext dataStoreContextUtil, OrgOpenroadmDevice device, String output) {
@@ -98,7 +96,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
             // Prepare the variables
             final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
             Iterable<? extends YangModuleInfo> moduleInfos = Collections
-                    .singleton(BindingReflections.getModuleInfo(object.getClass()));// TransportpceGnpyData.class));
+                    .singleton(BindingReflections.getModuleInfo(object.getClass()));
             moduleContext.addModuleInfos(moduleInfos);
             SchemaContext schemaContext = moduleContext.tryToCreateSchemaContext().get();
             BindingRuntimeContext bindingContext;
@@ -119,8 +117,6 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
             // The write part
             final BindingStreamEventWriter bindingWriter = codecRegistry.newWriter(id, domWriter);
             codecRegistry.getSerializer(id.getTargetType()).serialize(object, bindingWriter);
-            // file.write(writer.toString());
-            // file.close();
             writer.close();
         } catch (IOException e) {
             LOG.error("GNPy: writer error ");
@@ -128,8 +124,6 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
             LOG.warn("GNPy: exception {} occured during json file creation", e.getMessage(), e);
         } catch (ReactorException e) {
             LOG.warn("GNPy: exception {} occured during json file creation", e.getMessage(), e);
-//        } catch (Exception e) {
-//            LOG.warn("An error {} occured during json file creation", e.getMessage(), e);
         }
         return writer.toString();
     }
index b6da829b55e9676968cd0e8e2110fdfaf848f596..4ed561f1aff9051564a971bbc22341f910d83887 100644 (file)
@@ -141,7 +141,7 @@ public class PathComputationServiceImpl implements PathComputationService {
                 PathDescriptionBuilder path = null;
                 path = sendingPCE.getPathDescription();
                 LOG.info("PCE response: {} {}", message, responseCode);
-                if ((sendingPCE.getSuccess() == false) || (path == null)) {
+                if (!(sendingPCE.getSuccess()) || (path == null)) {
                     configurationResponseCommon.setAckFinalIndicator("Yes")
                             .setRequestId(input.getServiceHandlerHeader().getRequestId()).setResponseCode(responseCode)
                             .setResponseMessage(message);
index eef28d9e95a50049e186f45da98e546d213de758..72700afe311175c7380ad098327ac6889ae05bba 100644 (file)
@@ -523,18 +523,6 @@ public class NetworkModelWavelengthServiceImpl implements NetworkModelWavelength
                             .build());
                     break;
                 case XPONDERCLIENT:
-//                    XpdrClientAttributes xpdrClientAttributes = tp.getXpdrClientAttributes();
-//                    XpdrClientAttributesBuilder xpdrClientAttributesBuilder;
-//                    if (xpdrClientAttributes == null) {
-//                        xpdrClientAttributesBuilder = new XpdrClientAttributesBuilder();
-//                    } else {
-//                        xpdrClientAttributesBuilder = new XpdrClientAttributesBuilder(xpdrClientAttributes);
-//                    }
-//                    Wavelength usedXpdrClientWl = new WavelengthBuilder().setWidth(frequencyGHz)
-//                        .setFrequency(frequencyTHz).build();
-//                    tp1Builder.setXpdrClientAttributes(xpdrClientAttributesBuilder
-//                            .setWavelength(usedXpdrClientWl)
-//                            .build());
                     break;
                 case XPONDERPORT:
                     XpdrPortAttributes xpdrPortAttributes = tp.getXpdrPortAttributes();
index 7b59eaf5b7de60c48adee37ea1dfb6feb4eca26b..48d433c1ce7d919dfeb2fc9eb23bb12c906ae25b 100644 (file)
@@ -219,8 +219,6 @@ public class OpenRoadmInterface221 {
         OchBuilder ocIfBuilder = new OchBuilder();
 
         ocIfBuilder.setFrequency(FrequencyTHz.getDefaultInstance(String.valueOf(fixedFlex.getCenterFrequency())));
-        // ocIfBuilder.setWidth(FrequencyGHz.getDefaultInstance(String.valueOf(fixedFlex.getWavelength())));
-        // ocIfBuilder.setModulationFormat(ModulationFormat.DpQpsk);
         ocIfBuilder.setRate(R100G.class);
         ocIfBuilder.setTransmitPower(new PowerDBm(new BigDecimal("-5")));
 
index 2e0e3cb1e5438d9ca447ddc1235a127f1a43ea5e..3fd2e0d1c542181101b6c5aa55a406d8d1aa8f3d 100644 (file)
@@ -171,14 +171,6 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                                 this.crossConnect.postCrossConnect(nodeId, waveNumber, srcTp, destTp);
                         if (connectionNameOpt.isPresent()) {
                             nodesProvisioned.add(nodeId);
-//                            List<Ports> ports =
-//                                    this.crossConnect.getConnectionPortTrail(nodeId, waveNumber, srcTp, destTp);
-//                            if (ServicePathDirection.A_TO_Z.equals(direction)) {
-//                                topology.updateAtoZTopologyList(ports, nodeId);
-//                            }
-//                            if (ServicePathDirection.Z_TO_A.equals(direction)) {
-//                                topology.updateZtoATopologyList(ports, nodeId);
-//                            }
                             createdConnections.add(connectionNameOpt.get());
                         } else {
                             processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
@@ -463,8 +455,6 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
             writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
         } else {
             LOG.warn("Service {} does not exist - topology can not be updated", name);
-//            servicesBuilder = new ServicesBuilder();
-//            servicesBuilder.withKey(serviceKey);
         }
     }
 
index 2d012409255f2eebebbc8288c46849c9ba149ce5..a8052aa607a0c85fcdc5db192de5bbcb559dfbf4 100644 (file)
@@ -110,58 +110,6 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
         }
     }
 
-/*    @Override
-    public ServiceImplementationRequestOutput serviceImplementation(ServiceImplementationRequestInput input) {
-        LOG.info("Calling service impl request {} {}", input.getServiceName());
-        RollbackProcessor rollbackProcessor = new RollbackProcessor();
-
-        ServicePathInputData servicePathInputDataAtoZ
-                = ModelMappingUtils.rendererCreateServiceInputAToZ(input.getServiceName(),
-                        input.getPathDescription());
-        ServicePathInputData servicePathInputDataZtoA
-                = ModelMappingUtils.rendererCreateServiceInputZToA(input.getServiceName(),
-                        input.getPathDescription());
-        List<DeviceRenderingResult> renderingResults = deviceRendering(rollbackProcessor, servicePathInputDataAtoZ,
-                servicePathInputDataZtoA);
-        if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
-            return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
-        }
-
-        ServicePowerSetupInput olmPowerSetupInputAtoZ = ModelMappingUtils.createServicePowerSetupInput(
-                renderingResults.get(0).getOlmList(), input);
-        ServicePowerSetupInput olmPowerSetupInputZtoA = ModelMappingUtils.createServicePowerSetupInput(
-                renderingResults.get(1).getOlmList(), input);
-        olmPowerSetup(rollbackProcessor, olmPowerSetupInputAtoZ, olmPowerSetupInputZtoA);
-        if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
-            return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
-        }
-
-        // run service activation test twice - once on source node and once on destination node
-        List<Nodes> nodes = servicePathInputDataAtoZ.getServicePathInput().getNodes();
-        Nodes sourceNode = nodes.get(0);
-        Nodes destNode = nodes.get(nodes.size() - 1);
-
-        String srcNetworkTp;
-        String dstNetowrkTp;
-
-        if (sourceNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
-            srcNetworkTp = sourceNode.getDestTp();
-        } else {
-            srcNetworkTp = sourceNode.getSrcTp();
-        }
-        if (destNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
-            dstNetowrkTp = destNode.getDestTp();
-        } else {
-            dstNetowrkTp = destNode.getSrcTp();
-        }
-
-        if (!isServiceActivated(sourceNode.getNodeId(), srcNetworkTp)
-                || !isServiceActivated(destNode.getNodeId(), dstNetowrkTp)) {
-            rollbackProcessor.rollbackAll();
-            return ModelMappingUtils.createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED);
-        }
-    } */
-
     @Override
     public ListenableFuture<ServiceImplementationRequestOutput>
             serviceImplementation(ServiceImplementationRequestInput input) {
@@ -202,13 +150,11 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
                 Nodes destNode = nodes.get(nodes.size() - 1);
                 String srcNetworkTp;
                 String dstNetowrkTp;
-                //if (sourceNode.getDestTp().contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
                 if (sourceNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
                     srcNetworkTp = sourceNode.getDestTp();
                 } else {
                     srcNetworkTp = sourceNode.getSrcTp();
                 }
-                //if (destNode.getDestTp().contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
                 if (destNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)) {
                     dstNetowrkTp = destNode.getDestTp();
                 } else {
@@ -383,8 +329,6 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations
                     servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending,
                     "Device rendering was not successful! Rendering will be rolled back.");
             //FIXME we can't do rollback here, because we don't have rendering results.
-            //rollbackProcessor.addTask(new DeviceRenderingRollbackTask("AtoZDeviceTask", true));
-            //rollbackProcessor.addTask(new DeviceRenderingRollbackTask("ZtoADeviceTask", true));
             return renderingResults;
         }
 
index 5d4f3f72082ef62ba56e3c06edea6de5a4fe26a8..c64b5135ce9318bc5f3f12ecb5506a9054d71be5 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.transportpce.renderer.provisiondevice.tasks;
 
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
+
+import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.renderer.provisiondevice.OLMRenderingResult;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupOutput;
@@ -39,7 +41,7 @@ public class OlmPowerSetupTask implements Callable<OLMRenderingResult> {
         }
 
         LOG.debug("Result: {}", result.getResult());
-        if (result.isSuccessful()) {
+        if (ResponseCodes.SUCCESS_RESULT.equals(result.getResult().getResult())) {
             LOG.info("OLM power setup finished successfully");
             return OLMRenderingResult.ok();
         } else {
index 94d35a04e1b3e5a64ea9028428ef2989b962f735..bc78541b5dd9eff00ec763747db10962af08925b 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.transportpce.renderer.stub;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
+
+import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossBaseInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossBaseOutput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossCurrentInput;
@@ -61,6 +63,7 @@ public class OlmServiceStub implements TransportpceOlmService {
 
     @Override public ListenableFuture<RpcResult<ServicePowerSetupOutput>> servicePowerSetup(
             ServicePowerSetupInput input) {
-        return RpcResultBuilder.success(new ServicePowerSetupOutputBuilder().build()).buildFuture();
+        return RpcResultBuilder.success(new ServicePowerSetupOutputBuilder()
+            .setResult(ResponseCodes.SUCCESS_RESULT).build()).buildFuture();
     }
 }
index 639b662479ee8ce7bd5c758ea980755cc5c34227..d56f116f06d15e65f9ced6db35e011466f38306e 100644 (file)
@@ -106,7 +106,7 @@ public final class DowngradeConstraints {
         return result.build();
     }
 
-    private static Exclude updateExclude(Exclude hard, Exclude soft) throws NullPointerException {
+    private static Exclude updateExclude(Exclude hard, Exclude soft) {
         ExcludeBuilder result = new ExcludeBuilder(soft);
         if (hard != null) {
             result.getFiberBundle().addAll(hard.getFiberBundle());
@@ -117,7 +117,7 @@ public final class DowngradeConstraints {
         return result.build();
     }
 
-    private static Diversity updateDiveristy(Diversity hard, Diversity soft) throws NullPointerException {
+    private static Diversity updateDiveristy(Diversity hard, Diversity soft) {
         DiversityBuilder result = new DiversityBuilder(soft);
         if (hard != null) {
             result.getExistingService().addAll(hard.getExistingService());
@@ -141,7 +141,7 @@ public final class DowngradeConstraints {
         .or.general.co.routing.CoRouting updateCoCoRouting(org.opendaylight.yang.gen.v1.http.org.openroadm.routing
                 .constrains.rev161014.constraints.co.routing.or.general.co.routing.CoRouting hard, org.opendaylight
                     .yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.co
-                        .routing.CoRouting soft) throws NullPointerException {
+                        .routing.CoRouting soft) {
         org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general
             .co.routing.CoRoutingBuilder result = new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
                 .constrains.rev161014.constraints.co.routing.or.general.co.routing.CoRoutingBuilder(soft);
index a9f8749e36765af336268188e16ef7b4c00c169c..f05e58dd6b77fdcaac7f9bcb72450ec762f14e7f 100644 (file)
@@ -182,87 +182,7 @@ public class MappingConstraints {
      */
     public void serviceToServicePathConstarints() {
         LOG.info("Mapping Service Constraints to ServicePath Constraints");
-        //CoRoutingOrGeneral coRoutingOrGeneral = null;
         if (serviceHardConstraints  !=  null) {
-            /*HardConstraintsBuilder tempHard = new HardConstraintsBuilder();
-            coRoutingOrGeneral = serviceHardConstraints.getCoRoutingOrGeneral();
-            General tmpGeneral = null;
-            CoRouting tmpCoRouting = null;
-            if (coRoutingOrGeneral  !=  null) {
-                org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
-                    .rev171017.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
-                    new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
-                    .rev171017.constraints.sp.co.routing.or.general.GeneralBuilder();
-                org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
-                    .rev171017.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
-                    new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
-                    .rev171017.constraints.sp.co.routing.or.general.CoRoutingBuilder();
-                if (coRoutingOrGeneral instanceof General) {
-                    tmpGeneral = (General) coRoutingOrGeneral;
-                    if (tmpGeneral  !=  null) {
-                        Diversity tmpDiversity =  tmpGeneral.getDiversity();
-                        if (tmpDiversity  !=  null) {
-                            finalGeneral.setDiversity(
-                                    new DiversityBuilder()
-                                        .setExistingService(tmpDiversity.getExistingService())
-                                        .setExistingServiceApplicability(
-                                                new ExistingServiceApplicabilityBuilder()
-                                                .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
-                                                .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
-                                                .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
-                                                .build())
-                                        .build());
-                        }
-                        Exclude tmpExclude = tmpGeneral.getExclude();
-                        if (tmpExclude  !=  null) {
-                            finalGeneral.setExclude(
-                                    new ExcludeBuilder()
-                                        .setSupportingServiceName(tmpExclude.getSupportingServiceName())
-                                        .setClli(tmpExclude.getSite())
-                                        .setNodeId(tmpExclude.getNodeId())
-                                        //.setAffinity(value)
-                                        //.setSRLG(value)
-                                        .build());
-                        }
-                        Include tmpInclude = tmpGeneral.getInclude();
-                        if (tmpInclude  !=  null) {
-                            finalGeneral.setInclude(
-                                    new IncludeBuilder()
-                                        //.setOrderedHops()
-                                        .build());
-                        }
-                        Latency tmpLatency = tmpGeneral.getLatency();
-                        if (tmpLatency != null) {
-                            finalGeneral.setLatency(
-                                    new LatencyBuilder()
-                                        .setMaxLatency(tmpLatency.getMaxLatency())
-                                        .build());
-                        }
-                    }
-                    tempHard
-                        .setCoRoutingOrGeneral(finalGeneral.build())
-                        .setCustomerCode(serviceHardConstraints.getCustomerCode());
-                } else if (coRoutingOrGeneral instanceof CoRouting) {
-                    tmpCoRouting = (CoRouting)coRoutingOrGeneral;
-                    if (tmpCoRouting  !=  null) {
-                        org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
-                            .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
-                            tmpCoRouting.getCoRouting();
-                        if (tmpCoRoutingCoRouting  !=  null) {
-                            finalCoRouting.setCoRouting(
-                                    new CoRoutingBuilder()
-                                        .setExistingService(tmpCoRoutingCoRouting.getExistingService())
-                                        .build());
-                        }
-                    }
-                    tempHard
-                        .setCoRoutingOrGeneral(finalCoRouting.build())
-                        .setCustomerCode(serviceHardConstraints.getCustomerCode());
-
-                }
-            }
-            servicePathHardConstraints = tempHard.build();*/
-
             org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
                 .rev171017.routing.constraints.sp.HardConstraints tempHard = (org.opendaylight.yang.gen
                     .v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing
@@ -271,84 +191,6 @@ public class MappingConstraints {
                 servicePathHardConstraints = tempHard;
             }
         } else if (serviceSoftConstraints  !=  null) {
-            /*oftConstraintsBuilder tempSoft = new SoftConstraintsBuilder();
-            coRoutingOrGeneral = serviceSoftConstraints.getCoRoutingOrGeneral();
-            General tmpGeneral = null;
-            CoRouting tmpCoRouting = null;
-            if (coRoutingOrGeneral  !=  null) {
-                org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
-                    .rev171017.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral =
-                    new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
-                    .rev171017.constraints.sp.co.routing.or.general.GeneralBuilder();
-                org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
-                    .rev171017.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting =
-                    new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
-                    .rev171017.constraints.sp.co.routing.or.general.CoRoutingBuilder();
-                if (coRoutingOrGeneral instanceof General) {
-                    tmpGeneral = (General) coRoutingOrGeneral;
-                    if (tmpGeneral  !=  null) {
-                        Diversity tmpDiversity =  tmpGeneral.getDiversity();
-                        if (tmpDiversity  !=  null) {
-                            finalGeneral.setDiversity(
-                                    new DiversityBuilder()
-                                        .setExistingService(tmpDiversity.getExistingService())
-                                        .setExistingServiceApplicability(
-                                                new ExistingServiceApplicabilityBuilder()
-                                                .setClli(tmpDiversity.getExistingServiceApplicability().isSite())
-                                                .setNode(tmpDiversity.getExistingServiceApplicability().isNode())
-                                                .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg())
-                                                .build())
-                                        .build());
-                        }
-                        Exclude tmpExclude = tmpGeneral.getExclude();
-                        if (tmpExclude  !=  null) {
-                            finalGeneral.setExclude(
-                                    new ExcludeBuilder()
-                                        .setSupportingServiceName(tmpExclude.getSupportingServiceName())
-                                        .setClli(tmpExclude.getSite())
-                                        .setNodeId(tmpExclude.getNodeId())
-                                        //.setAffinity(value)
-                                        //.setSRLG(value)
-                                        .build());
-                        }
-                        Include tmpInclude = tmpGeneral.getInclude();
-                        if (tmpInclude  !=  null) {
-                            finalGeneral.setInclude(
-                                    new IncludeBuilder()
-                                        //.setOrderedHops()
-                                        .build());
-                        }
-                        Latency tmpLatency = tmpGeneral.getLatency();
-                        if (tmpLatency  !=  null) {
-                            finalGeneral.setLatency(
-                                    new LatencyBuilder()
-                                        .setMaxLatency(tmpLatency.getMaxLatency())
-                                        .build());
-                        }
-                    }
-                    tempSoft
-                        .setCoRoutingOrGeneral(finalGeneral.build())
-                        .setCustomerCode(serviceSoftConstraints.getCustomerCode());
-                } else if (coRoutingOrGeneral instanceof CoRouting) {
-                    tmpCoRouting = (CoRouting)coRoutingOrGeneral;
-                    if (tmpCoRouting != null) {
-                        org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014
-                            .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting =
-                            tmpCoRouting.getCoRouting();
-                        if (tmpCoRoutingCoRouting != null) {
-                            finalCoRouting.setCoRouting(
-                                    new CoRoutingBuilder()
-                                        .setExistingService(tmpCoRoutingCoRouting.getExistingService())
-                                        .build());
-                        }
-                    }
-                    tempSoft
-                        .setCoRoutingOrGeneral(finalCoRouting.build())
-                        .setCustomerCode(serviceSoftConstraints.getCustomerCode());
-
-                }
-            }
-            servicePathSoftConstraints = tempSoft.build();*/
             org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints
                 .rev171017.routing.constraints.sp.SoftConstraints tempSoft = (org.opendaylight.yang.gen
                     .v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.routing
index 53675d4b7ca7f247478d4cd158cb213dcdf25035..0d65c3e6bf61dfeb6fbb366a77d2ecb584e19015 100644 (file)
@@ -62,11 +62,8 @@ import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public final class ModelMappingUtils {
-    private static final Logger LOG = LoggerFactory.getLogger(ModelMappingUtils.class);
 
     private ModelMappingUtils() {
     }
index 3dd14172827a3ac270f7608f47146005bf3fb207..69cc71bd045f3c35bae562c4c871e424deb20ff6 100644 (file)
@@ -7,10 +7,17 @@
  */
 package org.opendaylight.transportpce.servicehandler.impl;
 
+import static org.mockito.ArgumentMatchers.any;
+
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -27,16 +34,15 @@ import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerIm
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
 import org.opendaylight.transportpce.servicehandler.utils.ServiceDataUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.*;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.delete.input.ServiceDeleteReqInfoBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-
-import static org.mockito.ArgumentMatchers.any;
-
 public class ServicehandlerImplTest extends AbstractTest  {
 
     @Mock
@@ -69,9 +75,11 @@ public class ServicehandlerImplTest extends AbstractTest  {
 
     @Test
     public void createServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
-        ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+        ServicehandlerImpl servicehandlerImpl =
+            new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
-        ListenableFuture<RpcResult<ServiceCreateOutput>> result =  servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build());
+        ListenableFuture<RpcResult<ServiceCreateOutput>> result =
+            servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build());
         result.addListener(new Runnable() {
             @Override
             public void run() {
@@ -83,14 +91,17 @@ public class ServicehandlerImplTest extends AbstractTest  {
         endSignal.await();
 
         RpcResult<ServiceCreateOutput> rpcResult = result.get();
-        Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
+        Assert.assertEquals(
+            ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
     }
 
     @Test
-    public void createServiceShouldBeSuccessfulWhenPreformPCESuccessful() throws ExecutionException, InterruptedException {
+    public void createServiceShouldBeSuccessfulWhenPreformPCESuccessful()
+        throws ExecutionException, InterruptedException {
         ServiceCreateInput input = ServiceDataUtils.buildServiceCreateInput();
         Mockito.when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
-        ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+        ServicehandlerImpl servicehandlerImpl =
+            new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
         ListenableFuture<RpcResult<ServiceCreateOutput>> result =  servicehandlerImpl.serviceCreate(input);
         result.addListener(new Runnable() {
@@ -104,14 +115,17 @@ public class ServicehandlerImplTest extends AbstractTest  {
         endSignal.await();
 
         RpcResult<ServiceCreateOutput> rpcResult = result.get();
-        Assert.assertEquals(ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
+        Assert.assertEquals(
+            ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
     }
 
     @Test
     public void deleteServiceShouldBeFailedWithEmptyInput() throws ExecutionException, InterruptedException {
-        ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+        ServicehandlerImpl servicehandlerImpl =
+            new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
-        ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(new ServiceDeleteInputBuilder()
+        ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
+             servicehandlerImpl.serviceDelete(new ServiceDeleteInputBuilder()
                 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("").build()).build());
         result.addListener(new Runnable() {
             @Override
@@ -124,13 +138,15 @@ public class ServicehandlerImplTest extends AbstractTest  {
         endSignal.await();
 
         RpcResult<ServiceDeleteOutput> rpcResult = result.get();
-        Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
+        Assert.assertEquals(
+            ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
     }
 
     @Test
     public void deleteServiceShouldBeFailedWithNonExistService() throws ExecutionException, InterruptedException {
         ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput();
-        ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
+        ServicehandlerImpl servicehandlerImpl =
+            new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
         ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(input);
         result.addListener(new Runnable() {
@@ -144,14 +160,16 @@ public class ServicehandlerImplTest extends AbstractTest  {
         endSignal.await();
 
         RpcResult<ServiceDeleteOutput> rpcResult = result.get();
-        Assert.assertEquals(ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
+        Assert.assertEquals(
+            ResponseCodes.RESPONSE_FAILED, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
     }
 
     @Test
     public void deleteServiceShouldBeSuccessForExistingService() throws ExecutionException, InterruptedException {
         DataBroker dataBroker = getNewDataBroker();
         Mockito.when(rendererServiceOperations.serviceDelete(any())).thenReturn(Futures.immediateFuture(any()));
-        ServicehandlerImpl servicehandlerImpl = new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
+        ServicehandlerImpl servicehandlerImpl =
+            new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, null);
         ServiceDataStoreOperationsImpl serviceDataStoreOperations = new ServiceDataStoreOperationsImpl(dataBroker);
         ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
@@ -169,6 +187,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         endSignal.await();
 
         RpcResult<ServiceDeleteOutput> rpcResult = result.get();
-        Assert.assertEquals(ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
+        Assert.assertEquals(
+            ResponseCodes.RESPONSE_OK, rpcResult.getResult().getConfigurationResponseCommon().getResponseCode());
     }
 }