Merge "Updated OLM module to support 7.1 devices"
authorGuillaume Lambert <guillaume.lambert@orange.com>
Wed, 24 Mar 2021 12:51:03 +0000 (12:51 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 24 Mar 2021 12:51:03 +0000 (12:51 +0000)
olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtImpl.java
olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtVersion710.java [new file with mode: 0644]
olm/src/main/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImpl.java
olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java
olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils221.java [new file with mode: 0644]
olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils710.java [moved from olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils22.java with 74% similarity]
olm/src/test/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImplSpanLossBaseTest.java
olm/src/test/java/org/opendaylight/transportpce/olm/util/OlmPowerServiceRpcImplUtil.java
olm/src/test/java/org/opendaylight/transportpce/olm/util/OlmTransactionUtils.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface221.java

index b45f24dd8daca2b8e5c57a9f0b5be37e286ec9fe..b310ffbbaee35cd22cdd655b127478800f9f1bad 100644 (file)
@@ -40,6 +40,9 @@ public class PowerMgmtImpl implements PowerMgmt {
     private final OpenRoadmInterfaces openRoadmInterfaces;
     private final CrossConnect crossConnect;
     private final DeviceTransactionManager deviceTransactionManager;
+    private static final BigDecimal DEFAULT_TPDR_PWR_100G = new BigDecimal(-5);
+    private static final BigDecimal DEFAULT_TPDR_PWR_400G = new BigDecimal(0);
+
 
     public PowerMgmtImpl(DataBroker db, OpenRoadmInterfaces openRoadmInterfaces,
                          CrossConnect crossConnect, DeviceTransactionManager deviceTransactionManager) {
@@ -90,38 +93,66 @@ public class PowerMgmtImpl implements PowerMgmt {
                     java.util.Optional<Mapping> mappingObject = inputNode.nonnullMapping()
                             .values().stream().filter(o -> o.key()
                             .equals(new MappingKey(destTpId))).findFirst();
+                    boolean setTpdrPowerResult;
                     if (mappingObject.isPresent()) {
                         String circuitPackName = mappingObject.get().getSupportingCircuitPackName();
                         String portName = mappingObject.get().getSupportingPort();
                         Map<String, Double> txPowerRangeMap = new HashMap<>();
-                        if (openroadmVersion.getIntValue() == 1) {
-                            txPowerRangeMap = PowerMgmtVersion121.getXponderPowerRange(circuitPackName, portName,
+                        switch (openroadmVersion.getIntValue()) {
+                            case 1:
+                                txPowerRangeMap = PowerMgmtVersion121.getXponderPowerRange(circuitPackName, portName,
                                     nodeId, deviceTransactionManager);
-                        } else if (openroadmVersion.getIntValue() == 2) {
-                            txPowerRangeMap = PowerMgmtVersion221.getXponderPowerRange(circuitPackName, portName,
+                                break;
+                            case 2:
+                                txPowerRangeMap = PowerMgmtVersion221.getXponderPowerRange(circuitPackName, portName,
+                                    nodeId, deviceTransactionManager);
+                                break;
+                            case 3:
+                                txPowerRangeMap = PowerMgmtVersion710.getXponderPowerRange(circuitPackName, portName,
                                     nodeId, deviceTransactionManager);
+                                break;
+                            default:
+                                LOG.error("Unrecognized OpenRoadm version");
                         }
                         if (!txPowerRangeMap.isEmpty()) {
                             LOG.info("Transponder range exists for nodeId: {}", nodeId);
+                            OpenroadmVersion rdmOpenroadmVersion = openroadmVersion;
                             String srgId =  input.getNodes().get(i + 1).getSrcTp();
                             String nextNodeId = input.getNodes().get(i + 1).getNodeId();
+                            Optional<Nodes> inputNextOptional = OlmUtils.getNode(nextNodeId, this.db);
+                            if (inputNextOptional.isPresent()) {
+                                rdmOpenroadmVersion = inputNextOptional.get()
+                                        .getNodeInfo().getOpenroadmVersion();
+                            }
                             Map<String, Double> rxSRGPowerRangeMap = new HashMap<>();
                             Optional<Mapping> mappingObjectSRG = OlmUtils.getNode(nextNodeId, db)
                                     .flatMap(node -> node.nonnullMapping().values()
                                             .stream().filter(o -> o.key()
                                                     .equals(new MappingKey(srgId))).findFirst());
-                            if (mappingObjectSRG.isPresent()) {
 
-                                if (openroadmVersion.getIntValue() == 1) {
-                                    rxSRGPowerRangeMap = PowerMgmtVersion121.getSRGRxPowerRange(nextNodeId, srgId,
-                                            deviceTransactionManager, mappingObjectSRG.get()
-                                            .getSupportingCircuitPackName(),
-                                            mappingObjectSRG.get().getSupportingPort());
-                                } else if (openroadmVersion.getIntValue() == 2) {
-                                    rxSRGPowerRangeMap = PowerMgmtVersion221.getSRGRxPowerRange(nextNodeId, srgId,
-                                            deviceTransactionManager, mappingObjectSRG.get()
-                                            .getSupportingCircuitPackName(),
-                                            mappingObjectSRG.get().getSupportingPort());
+                            if (mappingObjectSRG.isPresent()) {
+                                switch (rdmOpenroadmVersion.getIntValue()) {
+                                    case 1:
+                                        rxSRGPowerRangeMap = PowerMgmtVersion121.getSRGRxPowerRange(nextNodeId, srgId,
+                                                deviceTransactionManager, mappingObjectSRG.get()
+                                                        .getSupportingCircuitPackName(),
+                                                mappingObjectSRG.get().getSupportingPort());
+                                        break;
+                                    case 2:
+                                        rxSRGPowerRangeMap = PowerMgmtVersion221.getSRGRxPowerRange(nextNodeId, srgId,
+                                                deviceTransactionManager, mappingObjectSRG.get()
+                                                        .getSupportingCircuitPackName(),
+                                                mappingObjectSRG.get().getSupportingPort());
+                                        break;
+                                    case 3:
+                                        rxSRGPowerRangeMap = PowerMgmtVersion710.getSRGRxPowerRange(nextNodeId, srgId,
+                                                deviceTransactionManager, mappingObjectSRG.get()
+                                                        .getSupportingCircuitPackName(),
+                                                mappingObjectSRG.get().getSupportingPort());
+                                        break;
+                                    default:
+                                        LOG.error("Unrecognized OpenRoadm version");
+                                        return false;
                                 }
                             }
                             double powerValue = 0;
@@ -153,8 +184,14 @@ public class PowerMgmtImpl implements PowerMgmt {
                                 LOG.info("SRG Power Range not found, setting the Transponder range to default");
                                 String interfaceName = String.join(GridConstant.NAME_PARAMETERS_SEPARATOR,
                                         destTpId, spectralSlotName);
-                                if (callSetTransponderPower(nodeId, interfaceName, new BigDecimal(-5),
-                                    openroadmVersion)) {
+                                if (openroadmVersion.getIntValue() == 3) {
+                                    setTpdrPowerResult = callSetTransponderPower(nodeId, interfaceName,
+                                            DEFAULT_TPDR_PWR_400G, openroadmVersion);
+                                } else {
+                                    setTpdrPowerResult = callSetTransponderPower(nodeId, interfaceName,
+                                            DEFAULT_TPDR_PWR_100G, openroadmVersion);
+                                }
+                                if (setTpdrPowerResult) {
                                     LOG.info("Transponder OCH connection: {} power updated ", interfaceName);
                                     try {
                                         Thread.sleep(OlmUtils.OLM_TIMER_1);
@@ -170,7 +207,14 @@ public class PowerMgmtImpl implements PowerMgmt {
                             LOG.info("Tranponder range not available setting to default power for nodeId: {}", nodeId);
                             String interfaceName = String.join(GridConstant.NAME_PARAMETERS_SEPARATOR,
                                     destTpId, spectralSlotName);
-                            if (callSetTransponderPower(nodeId, interfaceName, new BigDecimal(-5),openroadmVersion)) {
+                            if (openroadmVersion.getIntValue() == 3) {
+                                setTpdrPowerResult = callSetTransponderPower(nodeId, interfaceName,
+                                        DEFAULT_TPDR_PWR_400G, openroadmVersion);
+                            } else {
+                                setTpdrPowerResult = callSetTransponderPower(nodeId, interfaceName,
+                                        DEFAULT_TPDR_PWR_100G, openroadmVersion);
+                            }
+                            if (setTpdrPowerResult) {
                                 LOG.info("Transponder OCH connection: {} power updated ", interfaceName);
                                 try {
                                     Thread.sleep(OlmUtils.OLM_TIMER_1);
@@ -507,27 +551,42 @@ public class PowerMgmtImpl implements PowerMgmt {
                                             OpenroadmVersion openroadmVersion) {
         boolean powerSetupResult = false;
         try {
-            if (openroadmVersion.getIntValue() == 1) {
-                Optional<Interface> interfaceOptional;
-                interfaceOptional = openRoadmInterfaces.getInterface(nodeId, interfaceName);
-                if (interfaceOptional.isPresent()) {
+            switch (openroadmVersion.getIntValue()) {
+                case 1:
+                    Optional<Interface> interfaceOptional121;
+                    interfaceOptional121 = openRoadmInterfaces.getInterface(nodeId, interfaceName);
+                    if (!interfaceOptional121.isPresent()) {
+                        LOG.error("Interface {} on node {} is not present!", interfaceName, nodeId);
+                        return false;
+                    }
                     powerSetupResult = PowerMgmtVersion121.setTransponderPower(nodeId, interfaceName,
-                            txPower, deviceTransactionManager, interfaceOptional.get());
-                } else {
-                    LOG.error("Interface {} on node {} is not present!", interfaceName, nodeId);
-                    return false;
-                }
-            } else if (openroadmVersion.getIntValue() == 2) {
-                Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp
-                        .Interface> interfaceOptional;
-                interfaceOptional = openRoadmInterfaces.getInterface(nodeId, interfaceName);
-                if (interfaceOptional.isPresent()) {
+                                txPower, deviceTransactionManager, interfaceOptional121.get());
+                    break;
+                case 2:
+                    Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp
+                            .Interface> interfaceOptional221;
+                    interfaceOptional221 = openRoadmInterfaces.getInterface(nodeId, interfaceName);
+                    if (!interfaceOptional221.isPresent()) {
+                        LOG.error("Interface {} on node {} is not present!", interfaceName, nodeId);
+                        return false;
+                    }
                     powerSetupResult = PowerMgmtVersion221.setTransponderPower(nodeId, interfaceName,
-                            txPower, deviceTransactionManager, interfaceOptional.get());
-                } else {
-                    LOG.error("Interface {} on node {} is not present!", interfaceName, nodeId);
+                                txPower, deviceTransactionManager, interfaceOptional221.get());
+                    break;
+                case 3:
+                    Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp
+                            .Interface> interfaceOptional710;
+                    interfaceOptional710 = openRoadmInterfaces.getInterface(nodeId, interfaceName);
+                    if (!interfaceOptional710.isPresent()) {
+                        LOG.error("Interface {} on node {} is not present!", interfaceName, nodeId);
+                        return false;
+                    }
+                    powerSetupResult = PowerMgmtVersion710.setTransponderPower(nodeId, interfaceName,
+                            txPower, deviceTransactionManager, interfaceOptional710.get());
+                    break;
+                default:
+                    LOG.error("Unrecognized OpenRoadm version");
                     return false;
-                }
             }
         } catch (OpenRoadmInterfaceException ex) {
             LOG.error("Failed to get interface {} from node {}!", interfaceName, nodeId, ex);
@@ -536,12 +595,11 @@ public class PowerMgmtImpl implements PowerMgmt {
         if (powerSetupResult) {
             LOG.debug("Transponder power set up completed successfully for nodeId {} and interface {}",
                     nodeId,interfaceName);
-            return powerSetupResult;
         } else {
             LOG.debug("Transponder power setup failed for nodeId {} on interface {}",
                     nodeId, interfaceName);
-            return powerSetupResult;
         }
+        return powerSetupResult;
     }
 
     /*
diff --git a/olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtVersion710.java b/olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtVersion710.java
new file mode 100644 (file)
index 0000000..97b3c3a
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * Copyright Â© 2020 AT&T and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.transportpce.olm.power;
+
+import com.google.common.util.concurrent.FluentFuture;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.Timeouts;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
+import org.opendaylight.transportpce.common.device.DeviceTransaction;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.OpticalControlMode;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.PowerDBm;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.Ports;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.PortsKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacksKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1Builder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.container.OtsiBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+public final class PowerMgmtVersion710 {
+    private static final Logger LOG = LoggerFactory.getLogger(PowerMgmtVersion710.class);
+
+    private PowerMgmtVersion710() {
+    }
+
+    /**
+     * This method provides Transponder transmit power range.
+     *
+     * @param circuitPackName
+     *            Transponder circuitPack name
+     * @param portName
+     *            Transponder port name
+     * @param deviceId
+     *            Node Id of a device
+     * @param deviceTransactionManager
+     *            Device transaction manager to read device data
+     * @return HashMap holding Min and Max transmit power for given port
+     */
+    public static Map<String, Double> getXponderPowerRange(String circuitPackName, String portName, String deviceId,
+            DeviceTransactionManager deviceTransactionManager) {
+        InstanceIdentifier<Ports> portIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                .child(CircuitPacks.class, new CircuitPacksKey(circuitPackName))
+                .child(Ports.class, new PortsKey(portName));
+        LOG.debug("Fetching logical Connection Point value for port {} at circuit pack {}", portName, circuitPackName);
+        Optional<Ports> portObject =
+                deviceTransactionManager.getDataFromDevice(deviceId, LogicalDatastoreType.OPERATIONAL, portIID,
+                        Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+        if (!portObject.isPresent()) {
+            return new HashMap<>();
+        }
+        Ports port = portObject.get();
+        if (port.getTransponderPort() == null || port.getTransponderPort().getPortPowerCapabilityMaxTx() == null) {
+            LOG.warn("Logical Connection Point value missing for {} {}", circuitPackName, port.getPortName());
+            return new HashMap<>();
+        }
+        Map<String, Double> powerRangeMap = new HashMap<>();
+        powerRangeMap.put("MaxTx", port.getTransponderPort().getPortPowerCapabilityMaxTx().getValue().doubleValue());
+        powerRangeMap.put("MinTx", port.getTransponderPort().getPortPowerCapabilityMinTx().getValue().doubleValue());
+        return powerRangeMap;
+    }
+
+    /**
+     * This method provides Transponder transmit power range.
+     *
+     * @param nodeId
+     *            Unique identifier for the mounted netconf- node
+     * @param srgId
+     *            SRG Id connected to transponder
+     * @param deviceTransactionManager
+     *            Device transaction manager to read device data
+     * @param circuitPackName
+     *            SRG circuitpack name
+     * @param portName
+     *            SRG port name
+     * @return HashMap holding Min and Max transmit power for given port
+     */
+    public static Map<String, Double> getSRGRxPowerRange(String nodeId, String srgId,
+            DeviceTransactionManager deviceTransactionManager,
+            String circuitPackName, String portName) {
+        LOG.debug("Coming inside SRG power range");
+        LOG.debug("Mapping object exists.");
+        InstanceIdentifier<Ports> portIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                .child(CircuitPacks.class, new CircuitPacksKey(circuitPackName))
+                .child(Ports.class, new PortsKey(portName));
+        LOG.debug("Fetching logical Connection Point value for port {} at circuit pack {}{}", portName,
+                circuitPackName, portIID);
+        Optional<Ports> portObject =
+                deviceTransactionManager.getDataFromDevice(nodeId, LogicalDatastoreType.OPERATIONAL, portIID,
+                        Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+        if (!portObject.isPresent()) {
+            LOG.info("Port not found");
+            return new HashMap<>();
+        }
+        Ports port = portObject.get();
+        if (port.getRoadmPort() == null) {
+            LOG.warn("Roadm ports power value is missing for {} {}", circuitPackName, port.getPortName());
+            return new HashMap<>();
+        }
+        LOG.debug("Port found on the node ID");
+        Map<String, Double> powerRangeMap = new HashMap<>();
+        powerRangeMap.put("MinRx", port.getRoadmPort().getPortPowerCapabilityMinRx().getValue().doubleValue());
+        powerRangeMap.put("MaxRx", port.getRoadmPort().getPortPowerCapabilityMaxRx().getValue().doubleValue());
+        return powerRangeMap;
+    }
+
+    /**
+     * This method retrieves transponder OCH interface and
+     * sets power.
+     *
+     * @param nodeId
+     *            Unique identifier for the mounted netconf- node
+     * @param interfaceName
+     *            OCH interface name carrying WL
+     * @param txPower
+     *            Calculated transmit power
+     * @param deviceTransactionManager
+     *            Device Transaction Manager
+     * @param interfaceObj
+     *            Interface object
+     *
+     * @return true/false based on status of operation
+     */
+    public static boolean setTransponderPower(String nodeId, String interfaceName, BigDecimal txPower,
+            DeviceTransactionManager deviceTransactionManager,
+            Interface interfaceObj) {
+        LOG.debug("Setting target-power for transponder nodeId: {} InterfaceName: {}",
+                nodeId, interfaceName);
+        InterfaceBuilder otsiInterfaceBuilder = new InterfaceBuilder(interfaceObj);
+        OtsiBuilder otsiBuilder = new OtsiBuilder(otsiInterfaceBuilder.augmentation(Interface1.class).getOtsi());
+        otsiBuilder.setTransmitPower(new PowerDBm(txPower));
+        otsiInterfaceBuilder.addAugmentation(new Interface1Builder().setOtsi(otsiBuilder.build()).build());
+        Future<Optional<DeviceTransaction>> deviceTxFuture = deviceTransactionManager.getDeviceTransaction(nodeId);
+        DeviceTransaction deviceTx;
+        try {
+            Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
+            if (deviceTxOpt.isPresent()) {
+                deviceTx = deviceTxOpt.get();
+            } else {
+                LOG.error("Transaction for device {} was not found during transponder power setup for Node:", nodeId);
+                return false;
+            }
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Unable to get transaction for device {} during transponder power setup!", nodeId, e);
+            return false;
+        }
+        InstanceIdentifier<Interface> interfacesIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                .child(Interface.class, new InterfaceKey(interfaceName));
+        deviceTx.merge(LogicalDatastoreType.CONFIGURATION, interfacesIID, otsiInterfaceBuilder.build());
+        FluentFuture<? extends @NonNull CommitInfo> commit =
+            deviceTx.commit(Timeouts.DEVICE_WRITE_TIMEOUT, Timeouts.DEVICE_WRITE_TIMEOUT_UNIT);
+        try {
+            commit.get();
+            LOG.info("Transponder Power update is committed");
+            return true;
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Setting transponder power failed: ", e);
+        }
+        return false;
+    }
+
+    /**
+     * This method does an edit-config on roadm connection subtree for a given
+     * connection number in order to set power level for use by the optical
+     * power control.
+     *
+     * @param deviceId
+     *            Device id.
+     * @param mode
+     *            Optical control modelcan be off, power or gainLoss.
+     * @param powerValue
+     *            Power value in DBm.
+     * @param connectionNumber
+     *            Name of the cross connect.
+     * @param crossConnect
+     *            cross connect.
+     * @param deviceTransactionManager
+     *            Device Transaction Manager.
+     *
+     * @return true/false based on status of operation.
+     */
+    public static boolean setPowerLevel(String deviceId, OpticalControlMode mode, BigDecimal powerValue,
+            String connectionNumber, CrossConnect crossConnect,
+            DeviceTransactionManager deviceTransactionManager) {
+        @SuppressWarnings("unchecked") Optional<RoadmConnections> rdmConnOpt =
+            (Optional<RoadmConnections>) crossConnect.getCrossConnect(deviceId, connectionNumber);
+        if (!rdmConnOpt.isPresent()) {
+            LOG.warn("Roadm-Connection is null in set power level ({})", connectionNumber);
+            return false;
+        }
+        RoadmConnectionsBuilder rdmConnBldr = new RoadmConnectionsBuilder(rdmConnOpt.get());
+        rdmConnBldr.setOpticalControlMode(mode);
+        if (powerValue != null) {
+            rdmConnBldr.setTargetOutputPower(new PowerDBm(powerValue));
+        }
+        RoadmConnections newRdmConn = rdmConnBldr.build();
+        Future<Optional<DeviceTransaction>> deviceTxFuture = deviceTransactionManager.getDeviceTransaction(deviceId);
+        DeviceTransaction deviceTx;
+        try {
+            Optional<DeviceTransaction> deviceTxOpt = deviceTxFuture.get();
+            if (!deviceTxOpt.isPresent()) {
+                LOG.error("Transaction for device {} was not found!", deviceId);
+                return false;
+            }
+            deviceTx = deviceTxOpt.get();
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Unable to get transaction for device {}!", deviceId, e);
+            return false;
+        }
+        // post the cross connect on the device
+        InstanceIdentifier<RoadmConnections> roadmConnIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                .child(RoadmConnections.class, new RoadmConnectionsKey(connectionNumber));
+        deviceTx.put(LogicalDatastoreType.CONFIGURATION, roadmConnIID, newRdmConn);
+        FluentFuture<? extends @NonNull CommitInfo> commit =
+            deviceTx.commit(Timeouts.DEVICE_WRITE_TIMEOUT, Timeouts.DEVICE_WRITE_TIMEOUT_UNIT);
+        try {
+            commit.get();
+            LOG.info("Roadm connection power level successfully set ");
+            return true;
+        } catch (InterruptedException | ExecutionException ex) {
+            LOG.warn("Failed to post {}", newRdmConn, ex);
+        }
+        return false;
+    }
+
+}
index 4f0d931575bbaebd8e62c2b1c7edb0fbfc837963..530c04a8a35425668048f5cde643be9053eb89de 100644 (file)
@@ -126,16 +126,23 @@ public class OlmPowerServiceImpl implements OlmPowerService {
     @Override
     public GetPmOutput getPm(GetPmInput pmInput) {
         OpenroadmVersion openroadmVersion;
-        if (mappingUtils.getOpenRoadmVersion(pmInput.getNodeId())
-            .equals(StringConstants.OPENROADM_DEVICE_VERSION_1_2_1)) {
-            LOG.info("Device version is 1.2.1");
-            openroadmVersion = OpenroadmVersion._121;
-        } else {
-            openroadmVersion = OpenroadmVersion._221;
-            LOG.info("Device version is 2.2.1");
+        GetPmOutputBuilder pmOutputBuilder = new GetPmOutputBuilder();
+        switch (mappingUtils.getOpenRoadmVersion(pmInput.getNodeId())) {
+            case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
+                openroadmVersion = OpenroadmVersion._121;
+                break;
+            case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
+                openroadmVersion = OpenroadmVersion._221;
+                break;
+            case StringConstants.OPENROADM_DEVICE_VERSION_7_1_0:
+                openroadmVersion = OpenroadmVersion._710;
+                break;
+            default:
+                LOG.error("Unknown device version");
+                return pmOutputBuilder.build();
         }
         LOG.info("Now calling get pm data");
-        GetPmOutputBuilder pmOutputBuilder = OlmUtils.pmFetch(pmInput, deviceTransactionManager,
+        pmOutputBuilder = OlmUtils.pmFetch(pmInput, deviceTransactionManager,
             openroadmVersion);
         return pmOutputBuilder.build();
     }
@@ -355,13 +362,13 @@ public class OlmPowerServiceImpl implements OlmPowerService {
             .build();
         GetPmOutput otsPmOutput = getPm(getPmInput);
 
-        if (otsPmOutput == null) {
+        if (otsPmOutput == null || otsPmOutput.getMeasurements() == null) {
             LOG.info("OTS PM not found for NodeId: {} TP Id:{} PMName:{}", realNodeId, tpID, pmName);
             return null;
         }
         try {
             for (Measurements measurement : otsPmOutput.getMeasurements()) {
-                if (pmName.equals(measurement.getPmparameterName())) {
+                if (pmName.equalsIgnoreCase(measurement.getPmparameterName())) {
                     return new OtsPmHolder(pmName, Double.parseDouble(measurement.getPmparameterValue()),
                         mapping.getSupportingOts());
                 }
@@ -521,7 +528,14 @@ public class OlmPowerServiceImpl implements OlmPowerService {
             String destNodeId = link.getDestNodeId();
             String destTpId = link.getDestTpid();
             OtsPmHolder srcOtsPmHoler = getPmMeasurements(sourceNodeId, sourceTpId, "OpticalPowerOutput");
+            if (srcOtsPmHoler == null) {
+                srcOtsPmHoler = getPmMeasurements(sourceNodeId, sourceTpId, "OpticalPowerOutputOSC");
+            }
             OtsPmHolder destOtsPmHoler = getPmMeasurements(destNodeId, destTpId, "OpticalPowerInput");
+            if (destOtsPmHoler == null) {
+                destOtsPmHoler = getPmMeasurements(destNodeId, destTpId, "OpticalPowerInputOSC");
+            }
+
             if (srcOtsPmHoler.getOtsInterfaceName() == null || destOtsPmHoler.getOtsInterfaceName() == null) {
                 LOG.warn("OTS is not present for the link {}", link);
                 continue;
@@ -533,6 +547,9 @@ public class OlmPowerServiceImpl implements OlmPowerService {
             if (spanLoss.doubleValue() > 28) {
                 LOG.warn("Span Loss is out of range of OpenROADM specifications");
             }
+            if (spanLoss.intValue() <= 0) {
+                spanLoss = BigDecimal.valueOf(0);
+            }
             if (!setSpanLoss(sourceNodeId, srcOtsPmHoler.getOtsInterfaceName(), spanLoss, "TX")) {
                 LOG.info("Setting spanLoss failed for {}", sourceNodeId);
                 return null;
index 47598be64ba7cb53b0e7d3316cbf649ff44e81ab..ff1d08e8ced19d6d94f8fdd96d5679492223e802 100644 (file)
@@ -76,10 +76,19 @@ public final class OlmUtils {
         LOG.info("Getting PM Data for NodeId: {} ResourceType: {} ResourceName: {}", input.getNodeId(),
             input.getResourceType(), input.getResourceIdentifier());
         GetPmOutputBuilder pmOutputBuilder;
-        if (openRoadmVersion.getIntValue() == 1) {
-            pmOutputBuilder = OlmUtils121.pmFetch(input, deviceTransactionManager);
-        } else {
-            pmOutputBuilder = OlmUtils22.pmFetch(input, deviceTransactionManager);
+        switch (openRoadmVersion.getIntValue()) {
+            case 1:
+                pmOutputBuilder = OlmUtils121.pmFetch(input, deviceTransactionManager);
+                break;
+            case 2:
+                pmOutputBuilder = OlmUtils221.pmFetch(input, deviceTransactionManager);
+                break;
+            case 3:
+                pmOutputBuilder = OlmUtils710.pmFetch(input, deviceTransactionManager);
+                break;
+            default:
+                LOG.error("Unrecognized OpenRoadm version");
+                pmOutputBuilder = new GetPmOutputBuilder();
         }
         return pmOutputBuilder;
     }
diff --git a/olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils221.java b/olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils221.java
new file mode 100644 (file)
index 0000000..8927bad
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ * Copyright Â© 2017 AT&T and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.olm.util;
+
+import com.google.common.base.Strings;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.Timeouts;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.get.pm.output.Measurements;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.get.pm.output.MeasurementsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.pack.Ports;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.pack.PortsKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs.CircuitPacks;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs.CircuitPacksKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.Interface;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.InterfaceKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.internal.links.InternalLink;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.internal.links.InternalLinkKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.OrgOpenroadmDevice;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.Degree;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.DegreeKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.SharedRiskGroupKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.physical.links.PhysicalLink;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.physical.links.PhysicalLinkKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.shelves.Shelves;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.shelves.ShelvesKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.CurrentPmList;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.current.pm.group.CurrentPm;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.current.pm.list.CurrentPmEntry;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.current.pm.list.CurrentPmEntryKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.current.pm.val.group.Measurement;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.Direction;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.Location;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.PmNamesEnum;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.olm.get.pm.input.ResourceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+final class OlmUtils221 {
+
+    private static final Logger LOG = LoggerFactory.getLogger(OlmUtils221.class);
+
+    /**
+     * This method retrieves list of current PMs for given nodeId,
+     * resourceType, resourceName and Granularity.Currently vendorExtentions
+     * are excluded but can be added back based on requirement
+     *
+     * <p>
+     * 1. pmFetch This operation traverse through current PM list and gets PM for
+     * given NodeId and Resource name
+     *
+     * @param input
+     *            Input parameter from the olm yang model get-pm rpc
+     * @param deviceTransactionManager
+     *            Device tx manager
+     *
+     * @return Result of the request list of PM readings
+     */
+    public static GetPmOutputBuilder pmFetch(GetPmInput input, DeviceTransactionManager deviceTransactionManager) {
+        LOG.info("Getting PM Data for 2.2.1 NodeId: {} ResourceType: {} ResourceName: {}", input.getNodeId(),
+                input.getResourceType(), input.getResourceIdentifier());
+
+        GetPmOutputBuilder pmOutputBuilder = new GetPmOutputBuilder();
+
+        InstanceIdentifier<?> resourceKeyIID =
+                findClassKeyIdentifiers(input.getResourceType(), input.getResourceIdentifier());
+        CurrentPmEntryKey resourceKey = new CurrentPmEntryKey(resourceKeyIID,
+                convertResourceTypeEnum(input.getResourceType()),"");
+        InstanceIdentifier<CurrentPmList> iidCurrentPmList = InstanceIdentifier.create(CurrentPmList.class);
+
+        Optional<CurrentPmList> currentPmListOpt = deviceTransactionManager.getDataFromDevice(input.getNodeId(),
+                LogicalDatastoreType.OPERATIONAL, iidCurrentPmList, Timeouts.DEVICE_READ_TIMEOUT,
+                Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+        if (currentPmListOpt.isPresent()) {
+            CurrentPmList currentPmList = currentPmListOpt.get();
+            @NonNull
+            Map<CurrentPmEntryKey,CurrentPmEntry> currentPmEntryList = currentPmList.nonnullCurrentPmEntry();
+            LOG.info("Current PM list exists for node {} and contains {} entries.", input.getNodeId(),
+                    currentPmEntryList.size());
+            for (Map.Entry<CurrentPmEntryKey, CurrentPmEntry> entry : currentPmEntryList.entrySet()) {
+                CurrentPmEntry cpe = entry.getValue();
+                CurrentPmEntryKey cpek = new CurrentPmEntryKey(cpe.getPmResourceInstance(), cpe.getPmResourceType(),
+                        "");
+                if (resourceKey.equals(cpek)) {
+                    List<CurrentPm> currentPMList = new ArrayList<>(cpe.nonnullCurrentPm().values());
+                    Stream<CurrentPm> currentPMStream = currentPMList.stream();
+                    if (input.getPmNameType() != null) {
+                        currentPMStream = currentPMStream.filter(pm -> pm.getType().getIntValue()
+                                == PmNamesEnum.forValue(input.getPmNameType().getIntValue()).getIntValue());
+                    }
+                    if (input.getPmExtension() != null) {
+                        currentPMStream = currentPMStream.filter(pm -> pm.getExtension()
+                                .equals(input.getPmExtension()));
+                    }
+                    if (input.getLocation() != null) {
+                        currentPMStream = currentPMStream.filter(pm -> Location.forValue(pm.getLocation()
+                                .getIntValue())
+                                .equals(Location.forValue(input.getLocation().getIntValue())));
+                    }
+                    if (input.getDirection() != null) {
+                        currentPMStream = currentPMStream.filter(pm -> Direction.forValue(pm.getDirection()
+                                .getIntValue())
+                                .equals(Direction.forValue((input.getDirection().getIntValue()))));
+                    }
+                    List<CurrentPm> filteredPMs = currentPMStream.collect(Collectors.toList());
+                    List<Measurements> measurements = extractWantedMeasurements(filteredPMs,input.getGranularity());
+                    if (measurements.isEmpty()) {
+                        LOG.error(
+                                "No Matching PM data found for node: {}, resource type: {}, resource name: {}, "
+                                        + "pm type: {}, extention: {}, location: {} and direction: {}",
+                                input.getNodeId(), input.getResourceType(),
+                                getResourceIdentifierAsString(input.getResourceIdentifier()),
+                                input.getPmNameType(),input.getPmExtension(),input.getLocation(),
+                                input.getDirection());
+                    } else {
+                        pmOutputBuilder.setNodeId(input.getNodeId()).setResourceType(input.getResourceType())
+                                .setResourceIdentifier(input.getResourceIdentifier()).setGranularity(input
+                                .getGranularity())
+                                .setMeasurements(measurements);
+                        LOG.info(
+                                "PM data found successfully for node: {}, resource type: {}, resource name: {}, "
+                                        + "pm type: {}, extention: {}, location: {} and direction: {}",
+                                input.getNodeId(), input.getResourceType(),
+                                getResourceIdentifierAsString(input.getResourceIdentifier()),
+                                input.getPmNameType(),input.getPmExtension(),input.getLocation(),
+                                input.getDirection());
+                    }
+                }
+            }
+        } else {
+            LOG.error("Unable to get CurrentPmList for node {}", input.getNodeId());
+        }
+        return pmOutputBuilder;
+    }
+
+    private static String getResourceIdentifierAsString(ResourceIdentifier resourceIdentifier) {
+        if (Strings.isNullOrEmpty(resourceIdentifier.getCircuitPackName())) {
+            return resourceIdentifier.getResourceName();
+        } else {
+            return resourceIdentifier.getResourceName() + ", circuit pack name: "
+                    + resourceIdentifier.getCircuitPackName();
+        }
+    }
+
+    private static List<Measurements> extractWantedMeasurements(List<CurrentPm> currentPmList,
+            org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmGranularity wantedGranularity) {
+        List<Measurements> olmMeasurements = new ArrayList<>();
+        for (CurrentPm pm : currentPmList) {
+            for (Measurement measurements: pm.nonnullMeasurement().values()) {
+                if (measurements.getGranularity().getIntValue()
+                        == org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev171215.PmGranularity.forValue(
+                                wantedGranularity.getIntValue()).getIntValue()) {
+                    MeasurementsBuilder pmMeasureBuilder = new MeasurementsBuilder();
+                    pmMeasureBuilder.setPmparameterName(pm.getType().name());
+                    pmMeasureBuilder.setPmparameterValue(measurements.getPmParameterValue().stringValue());
+                    olmMeasurements.add(pmMeasureBuilder.build());
+                }
+            }
+        }
+        return olmMeasurements;
+    }
+
+    private static InstanceIdentifier<?> findClassKeyIdentifiers(ResourceTypeEnum wantedResourceType,
+            ResourceIdentifier wantedResourceIdentifier) {
+        switch (wantedResourceType) {
+            case Device:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class);
+            case Degree:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                        .child(Degree.class, new DegreeKey(Uint16.valueOf(wantedResourceIdentifier.getResourceName())));
+            case SharedRiskGroup:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                        .child(SharedRiskGroup.class,
+                                new SharedRiskGroupKey(Uint16.valueOf(wantedResourceIdentifier.getResourceName())));
+            case Connection:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                        .child(RoadmConnections.class, new RoadmConnectionsKey(wantedResourceIdentifier
+                                .getResourceName()));
+            case CircuitPack:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                        .child(CircuitPacks.class, new CircuitPacksKey(wantedResourceIdentifier.getResourceName()));
+            case Port:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                        .child(CircuitPacks.class, new CircuitPacksKey(wantedResourceIdentifier.getCircuitPackName()))
+                        .child(Ports.class, new PortsKey(wantedResourceIdentifier.getResourceName()));
+            case Interface:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                        .child(Interface.class, new InterfaceKey(wantedResourceIdentifier.getResourceName()));
+            case InternalLink:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                        .child(InternalLink.class, new InternalLinkKey(wantedResourceIdentifier.getResourceName()));
+            case PhysicalLink:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                        .child(PhysicalLink.class, new PhysicalLinkKey(wantedResourceIdentifier.getResourceName()));
+            case Shelf:
+                return InstanceIdentifier.create(OrgOpenroadmDevice.class)
+                        .child(Shelves.class, new ShelvesKey(wantedResourceIdentifier.getResourceName()));
+            default:
+                LOG.error("Unknown resource type {}", wantedResourceType);
+                return null;
+        }
+    }
+
+    private static org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum
+        convertResourceTypeEnum(ResourceTypeEnum wantedResourceType) {
+        switch (wantedResourceType) {
+            case Device:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Device;
+            case Degree:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Degree;
+            case SharedRiskGroup:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                        .ResourceTypeEnum.SharedRiskGroup;
+            case Connection:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                        .ResourceTypeEnum.Connection;
+            case CircuitPack:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                        .ResourceTypeEnum.CircuitPack;
+            case Port:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Port;
+            case Interface:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                        .ResourceTypeEnum.Interface;
+            case InternalLink:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                        .ResourceTypeEnum.InternalLink;
+            case PhysicalLink:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                        .ResourceTypeEnum.PhysicalLink;
+            case Shelf:
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Shelf;
+            default:
+                LOG.error("Unknown resource type {}", wantedResourceType);
+                return null;
+        }
+    }
+
+    private OlmUtils221() {
+    }
+
+}
similarity index 74%
rename from olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils22.java
rename to olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils710.java
index a6289524be1f20510f71ed6e7c233656ebae64b5..02dac7345a385297aeabffe0fca88027ddf5e9dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright Â© 2017 AT&T and others.  All rights reserved.
+ * Copyright Â© 2020 AT&T and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -22,30 +22,30 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev17
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.get.pm.output.Measurements;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.get.pm.output.MeasurementsBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.pack.Ports;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.pack.PortsKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs.CircuitPacks;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs.CircuitPacksKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.Interface;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.InterfaceKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.internal.links.InternalLink;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.internal.links.InternalLinkKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.OrgOpenroadmDevice;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.Degree;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.DegreeKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.SharedRiskGroupKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.physical.links.PhysicalLink;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.physical.links.PhysicalLinkKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.shelves.Shelves;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.shelves.ShelvesKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.CurrentPmList;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.current.pm.group.CurrentPm;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.current.pm.list.CurrentPmEntry;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.current.pm.list.CurrentPmEntryKey;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev181019.current.pm.val.group.Measurement;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.Ports;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.PortsKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacksKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.internal.links.InternalLink;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.internal.links.InternalLinkKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Degree;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.DegreeKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.RoadmConnections;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.SharedRiskGroupKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.physical.links.PhysicalLink;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.physical.links.PhysicalLinkKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.Shelves;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.ShelvesKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.CurrentPmList;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.current.pm.group.CurrentPm;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.current.pm.list.CurrentPmEntry;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.current.pm.list.CurrentPmEntryKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.current.pm.val.group.Measurement;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.Direction;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.Location;
@@ -56,9 +56,9 @@ import org.opendaylight.yangtools.yang.common.Uint16;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-final class OlmUtils22 {
+final class OlmUtils710 {
 
-    private static final Logger LOG = LoggerFactory.getLogger(OlmUtils22.class);
+    private static final Logger LOG = LoggerFactory.getLogger(OlmUtils710.class);
 
     /**
      * This method retrieves list of current PMs for given nodeId,
@@ -76,73 +76,73 @@ final class OlmUtils22 {
      *
      * @return Result of the request list of PM readings
      */
-    //LOG.info message length is >120 char and can be difficultly shortened
-    @SuppressWarnings("checkstyle:linelength")
     public static GetPmOutputBuilder pmFetch(GetPmInput input, DeviceTransactionManager deviceTransactionManager) {
-        LOG.info("Getting PM Data for 2.2.1 NodeId: {} ResourceType: {} ResourceName: {}", input.getNodeId(),
-            input.getResourceType(), input.getResourceIdentifier());
+        LOG.info("Getting PM Data for 7.1.0 NodeId: {} ResourceType: {} ResourceName: {}", input.getNodeId(),
+                input.getResourceType(), input.getResourceIdentifier());
 
         GetPmOutputBuilder pmOutputBuilder = new GetPmOutputBuilder();
 
         InstanceIdentifier<?> resourceKeyIID =
-            findClassKeyIdentifiers(input.getResourceType(), input.getResourceIdentifier());
+                findClassKeyIdentifiers(input.getResourceType(), input.getResourceIdentifier());
         CurrentPmEntryKey resourceKey = new CurrentPmEntryKey(resourceKeyIID,
-            convertResourceTypeEnum(input.getResourceType()), "");
+                convertResourceTypeEnum(input.getResourceType()), "");
 
         InstanceIdentifier<CurrentPmList> iidCurrentPmList = InstanceIdentifier.create(CurrentPmList.class);
 
         Optional<CurrentPmList> currentPmListOpt = deviceTransactionManager.getDataFromDevice(input.getNodeId(),
-            LogicalDatastoreType.OPERATIONAL, iidCurrentPmList, Timeouts.DEVICE_READ_TIMEOUT,
-            Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+                LogicalDatastoreType.OPERATIONAL, iidCurrentPmList, Timeouts.DEVICE_READ_TIMEOUT,
+                Timeouts.DEVICE_READ_TIMEOUT_UNIT);
         if (currentPmListOpt.isPresent()) {
             CurrentPmList  currentPmList = currentPmListOpt.get();
-
             @NonNull
             Map<CurrentPmEntryKey, CurrentPmEntry> currentPmEntryList = currentPmList.nonnullCurrentPmEntry();
             LOG.info("Current PM list exists for node {} and contains {} entries.", input.getNodeId(),
-                currentPmEntryList.size());
+                    currentPmEntryList.size());
             for (Map.Entry<CurrentPmEntryKey, CurrentPmEntry> entry : currentPmEntryList.entrySet()) {
                 CurrentPmEntry cpe = entry.getValue();
                 CurrentPmEntryKey cpek = new CurrentPmEntryKey(cpe.getPmResourceInstance(), cpe.getPmResourceType(),
-                    cpe.getPmResourceTypeExtension());
+                        "");
                 if (resourceKey.equals(cpek)) {
                     List<CurrentPm> currentPMList = new ArrayList<>(cpe.nonnullCurrentPm().values());
                     Stream<CurrentPm> currentPMStream = currentPMList.stream();
                     if (input.getPmNameType() != null) {
                         currentPMStream = currentPMStream.filter(pm -> pm.getType().getIntValue()
-                            == PmNamesEnum.forValue(input.getPmNameType().getIntValue()).getIntValue());
+                                == PmNamesEnum.forValue(input.getPmNameType().getIntValue()).getIntValue());
                     }
                     if (input.getPmExtension() != null) {
                         currentPMStream = currentPMStream.filter(pm -> pm.getExtension()
-                            .equals(input.getPmExtension()));
+                                .equals(input.getPmExtension()));
                     }
                     if (input.getLocation() != null) {
                         currentPMStream = currentPMStream.filter(pm -> Location.forValue(pm.getLocation().getIntValue())
-                            .equals(Location.forValue(input.getLocation().getIntValue())));
+                                .equals(Location.forValue(input.getLocation().getIntValue())));
                     }
                     if (input.getDirection() != null) {
-                        currentPMStream = currentPMStream.filter(pm -> Direction.forValue(pm.getDirection().getIntValue())
-                            .equals(Direction.forValue((input.getDirection().getIntValue()))));
+                        currentPMStream = currentPMStream.filter(pm -> Direction.forValue(pm.getDirection()
+                                .getIntValue())
+                                .equals(Direction.forValue((input.getDirection().getIntValue()))));
                     }
                     List<CurrentPm> filteredPMs = currentPMStream.collect(Collectors.toList());
                     List<Measurements> measurements = extractWantedMeasurements(filteredPMs,input.getGranularity());
                     if (measurements.isEmpty()) {
                         LOG.error(
-                            "No Matching PM data found for node: {}, resource type: {}, resource name: {}, pm type: {}, extention: {}, location: {} and direction: {}",
-                            input.getNodeId(), input.getResourceType(),
-                            getResourceIdentifierAsString(input.getResourceIdentifier()),
-                            input.getPmNameType(),input.getPmExtension(),input.getLocation(),
-                            input.getDirection());
+                                "No Matching PM data found for node: {}, resource type: {}, resource name: {}, "
+                                        + "pm type: {}, extention: {}, location: {} and direction: {}",
+                                input.getNodeId(), input.getResourceType(),
+                                getResourceIdentifierAsString(input.getResourceIdentifier()),
+                                input.getPmNameType(),input.getPmExtension(),input.getLocation(),
+                                input.getDirection());
                     } else {
                         pmOutputBuilder.setNodeId(input.getNodeId()).setResourceType(input.getResourceType())
-                            .setResourceIdentifier(input.getResourceIdentifier()).setGranularity(input.getGranularity())
-                            .setMeasurements(measurements);
+                                .setResourceIdentifier(input.getResourceIdentifier()).setGranularity(input
+                                .getGranularity()).setMeasurements(measurements);
                         LOG.info(
-                            "PM data found successfully for node: {}, resource type: {}, resource name: {}, pm type: {}, extention: {}, location: {} and direction: {}",
-                            input.getNodeId(), input.getResourceType(),
-                            getResourceIdentifierAsString(input.getResourceIdentifier()),
-                            input.getPmNameType(),input.getPmExtension(),input.getLocation(),
-                            input.getDirection());
+                                "PM data found successfully for node: {}, resource type: {}, resource name: {}, "
+                                        + "pm type: {}, extention: {}, location: {} and direction: {}",
+                                input.getNodeId(), input.getResourceType(),
+                                getResourceIdentifierAsString(input.getResourceIdentifier()),
+                                input.getPmNameType(),input.getPmExtension(),input.getLocation(),
+                                input.getDirection());
                     }
                 }
             }
@@ -218,42 +218,42 @@ final class OlmUtils22 {
         }
     }
 
-    private static org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum
+    private static org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum
         convertResourceTypeEnum(ResourceTypeEnum wantedResourceType) {
         switch (wantedResourceType) {
             case Device:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Device;
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum.Device;
             case Degree:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Degree;
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum.Degree;
             case SharedRiskGroup:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129
                     .ResourceTypeEnum.SharedRiskGroup;
             case Connection:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129
                     .ResourceTypeEnum.Connection;
             case CircuitPack:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129
                     .ResourceTypeEnum.CircuitPack;
             case Port:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Port;
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum.Port;
             case Interface:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129
                     .ResourceTypeEnum.Interface;
             case InternalLink:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129
                     .ResourceTypeEnum.InternalLink;
             case PhysicalLink:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129
                     .ResourceTypeEnum.PhysicalLink;
             case Shelf:
-                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Shelf;
+                return org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum.Shelf;
             default:
                 LOG.error("Unknown resource type {}", wantedResourceType);
                 return null;
         }
     }
 
-    private OlmUtils22() {
+    private OlmUtils710() {
     }
 
 }
index 2083190ee778e3d629874a613eb8787b3c318613..a52f944d5da09abe4dac7fd3a6336051587c4a90 100644 (file)
@@ -179,4 +179,4 @@ public class OlmPowerServiceImplSpanLossBaseTest extends AbstractTest {
         Assert.assertEquals("ROADM-A1-to-ROADM-C1", output.getSpans().get(0).getLinkId().getValue());
         Assert.assertEquals("14.6", output.getSpans().get(0).getSpanloss());
     }
-}
+}
\ No newline at end of file
index 091181e1c003368c0197bf26c59594ef08345bab..4f106606d1d541c64cf56cd8028cae20fc2c3d7f 100644 (file)
@@ -175,7 +175,6 @@ public final class OlmPowerServiceRpcImplUtil {
 
     public static CalculateSpanlossBaseInput getCalculateSpanlossBaseInputAll() {
         CalculateSpanlossBaseInput input = new CalculateSpanlossBaseInputBuilder()
-                .setLinkId(new LinkId("ROADM-A1-to-ROADM-C1"))
                 .setSrcType(CalculateSpanlossBaseInput.SrcType.All)
                 .build();
         return input;
index 2c4f7ba7ad6af01a743aa4c8130c899d37f35f4c..bc9bf5cb9a9d19eee5eb76aaf8401fb41677e917 100644 (file)
@@ -133,43 +133,49 @@ public final class OlmTransactionUtils {
         Map<AmplifiedLinkKey,AmplifiedLink>
                 amplifiedLinkValues = new HashMap<>();
         org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link.attributes.AmplifiedLink al =
-            new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link.attributes
-            .AmplifiedLinkBuilder()
-                .setSectionElement(new SectionElementBuilder().setSectionElement(
-                            new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link.attributes
-                            .amplified.link.section.element.section.element.SpanBuilder().setSpan(
-                                    new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link
-                                    .attributes.amplified.link.section.element.section.element.span.SpanBuilder()
-                                        .setAdministrativeState(AdminStates.InService)
-                                        .setAutoSpanloss(true)
-                                        .setEngineeredSpanloss(new RatioDB(BigDecimal.ONE))
-                                        .setLinkConcatenation(linkConcentationValues)
-                                        .setSpanlossBase(new RatioDB(BigDecimal.ONE))
-                                        .setSpanlossCurrent(new RatioDB(BigDecimal.ONE))
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link.attributes
+                        .AmplifiedLinkBuilder()
+                        .setSectionElement(new SectionElementBuilder().setSectionElement(
+                                new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified
+                                        .link.attributes
+                                        .amplified.link.section.element.section.element.SpanBuilder()
+                                        .setSpan(new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529
+                                                .amplified.link.attributes.amplified.link.section.element
+                                                .section.element
+                                                .span.SpanBuilder()
+                                                .setAdministrativeState(AdminStates.InService)
+                                                .setAutoSpanloss(true)
+                                                .setEngineeredSpanloss(new RatioDB(BigDecimal.ONE))
+                                                .setLinkConcatenation(linkConcentationValues)
+                                                .setSpanlossBase(new RatioDB(BigDecimal.ONE))
+                                                .setSpanlossCurrent(new RatioDB(BigDecimal.ONE))
+                                                .build())
                                         .build())
                                 .build())
-                        .build())
-                .setSectionEltNumber(Uint16.valueOf(1))
-                .build();
+                        .setSectionEltNumber(Uint16.valueOf(1))
+                        .build();
         org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link.attributes.AmplifiedLink al2 =
-            new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link.attributes
-            .AmplifiedLinkBuilder()
-                .setSectionElement(new SectionElementBuilder().setSectionElement(
-                            new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link.attributes
-                            .amplified.link.section.element.section.element.SpanBuilder().setSpan(
-                                    new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link
-                                    .attributes.amplified.link.section.element.section.element.span.SpanBuilder()
-                                        .setAdministrativeState(AdminStates.InService)
-                                        .setAutoSpanloss(true)
-                                        .setEngineeredSpanloss(new RatioDB(BigDecimal.ONE))
-                                        .setLinkConcatenation(linkConcentationValues)
-                                        .setSpanlossBase(new RatioDB(BigDecimal.ONE))
-                                        .setSpanlossCurrent(new RatioDB(BigDecimal.ONE))
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified.link.attributes
+                        .AmplifiedLinkBuilder()
+                        .setSectionElement(new SectionElementBuilder().setSectionElement(
+                                new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529.amplified
+                                        .link.attributes
+                                        .amplified.link.section.element.section.element.SpanBuilder()
+                                        .setSpan(new org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev200529
+                                                .amplified.link.attributes.amplified.link.section.element
+                                                .section.element
+                                                .span.SpanBuilder()
+                                                .setAdministrativeState(AdminStates.InService)
+                                                .setAutoSpanloss(true)
+                                                .setEngineeredSpanloss(new RatioDB(BigDecimal.ONE))
+                                                .setLinkConcatenation(linkConcentationValues)
+                                                .setSpanlossBase(new RatioDB(BigDecimal.ONE))
+                                                .setSpanlossCurrent(new RatioDB(BigDecimal.ONE))
+                                                .build())
                                         .build())
                                 .build())
-                        .build())
-                .setSectionEltNumber(Uint16.valueOf(1))
-                .build();
+                        .setSectionEltNumber(Uint16.valueOf(1))
+                        .build();
         amplifiedLinkValues.put(al.key(),al);
         amplifiedLinkValues.put(al2.key(),al2);
         Map<Class<? extends Augmentation<Link>>, Augmentation<Link>> map = Collections.emptyMap();
@@ -181,8 +187,8 @@ public final class OlmTransactionUtils {
                         .build())
                 .build();
         org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1 aug12 =
-            new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder()
-                .setLinkType(OpenroadmLinkType.ROADMTOROADM).build();
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder()
+                        .setLinkType(OpenroadmLinkType.ROADMTOROADM).build();
         Augmentation<Link> aug21 = new Link1Builder()
                 .setAmplified(true)
                 .setOMSAttributes(new OMSAttributesBuilder()
@@ -190,18 +196,19 @@ public final class OlmTransactionUtils {
                         .setSpan(new SpanBuilder().build()).build())
                 .build();
         org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1 aug22 =
-            new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder()
-                .setLinkType(OpenroadmLinkType.ROADMTOROADM).build();
+                new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder()
+                        .setLinkType(OpenroadmLinkType.ROADMTOROADM).build();
         // create the roadm-to-roadm link to be measured
         Link roadm2roadmLink = new LinkBuilder().setLinkId(new LinkId("ROADM-A1-to-ROADM-C1"))
-            .setSource(new SourceBuilder().setSourceNode(ietfNodeA.getNodeId()).setSourceTp("DEG2-TTP-TXRX").build())
-            .setDestination(
-                new DestinationBuilder().setDestNode(ietfNodeC.getNodeId()).setDestTp("DEG1-TTP-TXRX").build())
-            .addAugmentation(aug11)
-            .addAugmentation(aug12)
-            .addAugmentation(aug21)
-            .addAugmentation(aug22)
-            .build();
+                .setSource(new SourceBuilder().setSourceNode(ietfNodeA.getNodeId()).setSourceTp("DEG2-TTP-TXRX")
+                        .build())
+                .setDestination(
+                        new DestinationBuilder().setDestNode(ietfNodeC.getNodeId()).setDestTp("DEG1-TTP-TXRX").build())
+                .addAugmentation(aug11)
+                .addAugmentation(aug12)
+                .addAugmentation(aug21)
+                .addAugmentation(aug22)
+                .build();
         // create the ietf network
         Network1 openroadmAugmToIetfNetwork = new Network1Builder()
                 .setLink(Map.of(roadm2roadmLink.key(),roadm2roadmLink)).build();
@@ -227,23 +234,26 @@ public final class OlmTransactionUtils {
     public static Optional<CurrentPmList> getCurrentPmListA() {
         Measurement measurementA = new MeasurementBuilder()
                 .withKey(new MeasurementKey(PmGranularity._15min))
-                .setGranularity(org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev171215.PmGranularity._15min)
+                .setGranularity(org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev171215
+                        .PmGranularity._15min)
                 .setPmParameterValue(new PmDataType(new BigDecimal("-3.5")))
                 .setValidity(Validity.Complete)
                 .build();
         CurrentPm cpA = new CurrentPmBuilder()
                 .withKey(new CurrentPmKey(Direction.Bidirectional,
                         "", Location.NotApplicable, PmNamesEnum.OpticalPowerOutput))
-            .setType(org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev171215.PmNamesEnum.OpticalPowerOutput)
-            .setMeasurement(Map.of(measurementA.key(),measurementA))
-            .build();
+                .setType(org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev171215.PmNamesEnum
+                        .OpticalPowerOutput)
+                .setMeasurement(Map.of(measurementA.key(),measurementA))
+                .build();
         InstanceIdentifier<Interface> interfaceIIDA = InstanceIdentifier.create(OrgOpenroadmDevice.class)
                 .child(Interface.class, new InterfaceKey("OTS-DEG2-TTP-TXRX"));
         CurrentPmEntry currentPmEntryA = new CurrentPmEntryBuilder()
                 .setCurrentPm(Map.of(cpA.key(),cpA))
                 .setPmResourceInstance(interfaceIIDA)
                 .setPmResourceType(
-                    org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Interface)
+                        org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum
+                                .Interface)
                 .setPmResourceTypeExtension("")
                 .setRetrievalTime(new DateAndTime("2018-06-07T13:22:58+00:00"))
                 .build();
@@ -260,20 +270,22 @@ public final class OlmTransactionUtils {
         CurrentPm cpC = new CurrentPmBuilder()
                 .withKey(new CurrentPmKey(Direction.Bidirectional,
                         "", Location.NotApplicable, PmNamesEnum.OpticalPowerInput))
-            .setType(org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev171215.PmNamesEnum.OpticalPowerInput)
-            .setMeasurement(Map.of(measurementC.key(),measurementC))
-            .build();
+                .setType(org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev171215.PmNamesEnum
+                        .OpticalPowerInput)
+                .setMeasurement(Map.of(measurementC.key(),measurementC))
+                .build();
         InstanceIdentifier<Interface> interfaceIIDC = InstanceIdentifier.create(OrgOpenroadmDevice.class)
                 .child(Interface.class, new InterfaceKey("OTS-DEG1-TTP-TXRX"));
         CurrentPmEntry currentPmEntryC = new CurrentPmEntryBuilder()
                 .setCurrentPm(Map.of(cpC.key(),cpC))
                 .setPmResourceInstance(interfaceIIDC)
                 .setPmResourceType(
-                    org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceTypeEnum.Interface)
+                        org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019
+                                .ResourceTypeEnum.Interface)
                 .setPmResourceTypeExtension("")
                 .setRetrievalTime(new DateAndTime("2018-06-07T13:22:58+00:00"))
                 .build();
         return Optional.of(new CurrentPmListBuilder()
                 .setCurrentPmEntry(Map.of(currentPmEntryC.key(),currentPmEntryC)).build());
     }
-}
+}
\ No newline at end of file
index be1057d31904edce0014decf0d7b1e95ae81a288..c8f96d64b6ef3cd42175cb32f7d6b9c6abcacf23 100644 (file)
@@ -117,13 +117,14 @@ public class OpenRoadmInterface221 {
         }
 
         List<String> interfacesCreated = new ArrayList<>();
-
+        String mcInterfaceCreated = "";
         if (logicalConnPoint.contains("DEG")) {
-            String mcInterfaceCreated = createMCInterface(nodeId, logicalConnPoint, spectrumInformation);
+            mcInterfaceCreated = createMCInterface(nodeId, logicalConnPoint, spectrumInformation);
             interfacesCreated.add(mcInterfaceCreated);
         }
-        String mcInterfaceCreated = createNMCInterface(nodeId, logicalConnPoint, spectrumInformation);
-        interfacesCreated.add(mcInterfaceCreated);
+        String nmcInterfaceCreated = createNMCInterface(nodeId, logicalConnPoint, spectrumInformation,
+                mcInterfaceCreated);
+        interfacesCreated.add(nmcInterfaceCreated);
         return interfacesCreated;
     }
 
@@ -162,7 +163,7 @@ public class OpenRoadmInterface221 {
     }
 
     public String createNMCInterface(String nodeId, String logicalConnPoint,
-        SpectrumInformation spectrumInformation)
+        SpectrumInformation spectrumInformation, String mcName)
         throws OpenRoadmInterfaceException {
         LOG.info("This is the central frequency {}", spectrumInformation.getCenterFrequency());
         LOG.info("This is the nmc width {}", spectrumInformation.getWidth());
@@ -177,7 +178,7 @@ public class OpenRoadmInterface221 {
         InterfaceBuilder nmcInterfaceBldr = createGenericInterfaceBuilder(portMap,
             NetworkMediaChannelConnectionTerminationPoint.class, nmcName);
         if (logicalConnPoint.contains("DEG")) {
-            nmcInterfaceBldr.setSupportingInterface(nmcName);
+            nmcInterfaceBldr.setSupportingInterface(mcName);
         }
 
         NmcCtpBuilder nmcCtpIfBuilder = new NmcCtpBuilder()