Add SpectrumFillingRule check in postAlgoValidator 64/110164/10
authororenais <olivier.renais@orange.com>
Tue, 6 Feb 2024 18:29:39 +0000 (19:29 +0100)
committerOlivier Renais <olivier.renais@orange.com>
Thu, 29 Feb 2024 15:24:30 +0000 (15:24 +0000)
JIRA: TRNSPRTPCE-783
Change-Id: I4c98c6ddfcff4e71c2f8c00774b8e6d80801ca07
Signed-off-by: orenais <olivier.renais@orange.com>
pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java
pce/src/main/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraints.java [new file with mode: 0644]
pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java
pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java
pce/src/test/java/org/opendaylight/transportpce/pce/PceSendingPceRPCsTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraintsTest.java [new file with mode: 0644]
pce/src/test/java/org/opendaylight/transportpce/pce/graph/PceGraphTest.java
pce/src/test/resources/spectrum-filling-rule1.json [new file with mode: 0644]
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java

index f89cff96c2fb16b8e2c1808285d23831091119e0..08b46d744edc30a86cd5ff183a7b0ea1cb0421c2 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.transportpce.pce;
 import org.opendaylight.transportpce.common.ResponseCodes;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.transportpce.pce.constraints.OperatorConstraints;
 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
 import org.opendaylight.transportpce.pce.constraints.PceConstraintsCalc;
 import org.opendaylight.transportpce.pce.gnpy.GnpyException;
@@ -121,10 +122,11 @@ public class PceSendingPceRPCs {
             LOG.error("In pathComputationWithConstraints, nwAnalizer: result = {}", rc);
             return;
         }
+        OperatorConstraints opConstraints = new OperatorConstraints(networkTransaction);
         LOG.info("PceGraph ...");
         PceGraph graph = new PceGraph(nwAnalizer.getaendPceNode(), nwAnalizer.getzendPceNode(),
                 nwAnalizer.getAllPceNodes(), nwAnalizer.getAllPceLinks(), hardConstraints,
-                rc, serviceType, networkTransaction, mode);
+                rc, serviceType, networkTransaction, mode, opConstraints.getBitMapConstraint(input.getCustomerName()));
         graph.calcPath();
         rc = graph.getReturnStructure();
         if (!rc.getStatus()) {
diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraints.java b/pce/src/main/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraints.java
new file mode 100644 (file)
index 0000000..3c11596
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2024 Orange, Inc. 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.pce.constraints;
+
+import java.util.BitSet;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.fixedflex.GridUtils;
+import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev230526.FrequencyTHz;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters.SpectrumFilling;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters.spectrum.filling.SpectrumFillingRules;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters.spectrum.filling.SpectrumFillingRulesKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ControllerBehaviourSettings;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*
+ * Class to handle Operator Constraints associated with Specific Engineering rules
+ * as they are defined in the controller-behaviour-settings container of the service
+ * Data-Store.
+ *
+ */
+
+public class OperatorConstraints {
+
+    /* Logging. */
+    private static final Logger LOG = LoggerFactory.getLogger(OperatorConstraints.class);
+    private NetworkTransactionService networkTransaction;
+
+    public OperatorConstraints(NetworkTransactionService networkTransaction) {
+
+        this.networkTransaction = networkTransaction;
+
+    }
+
+    public BitSet getBitMapConstraint(String customerName) {
+        BitSet referenceBitSet = new BitSet(GridConstant.EFFECTIVE_BITS);
+        referenceBitSet.set(0, GridConstant.EFFECTIVE_BITS, true);
+        InstanceIdentifier<SpectrumFilling> sfIID =
+            InstanceIdentifier
+                .builder(ControllerBehaviourSettings.class)
+                .child(SpectrumFilling.class)
+                .build();
+
+        try {
+            if (networkTransaction.read(LogicalDatastoreType.CONFIGURATION, sfIID).get().isPresent()) {
+                SpectrumFilling spectrumConstraint = networkTransaction
+                    .read(LogicalDatastoreType.CONFIGURATION, sfIID).get().orElseThrow();
+                if (spectrumConstraint.getSpectrumFillingRules().isEmpty()) {
+                    return referenceBitSet;
+                }
+                for (Map.Entry<SpectrumFillingRulesKey, SpectrumFillingRules> rule:
+                        spectrumConstraint.getSpectrumFillingRules().entrySet()) {
+                    FrequencyTHz startFreq = rule.getValue().getSpectrumRangeOfAppliance().getStartEdgeFrequency();
+                    FrequencyTHz stopFreq = rule.getValue().getSpectrumRangeOfAppliance().getStopEdgeFrequency();
+                    if (customerName != null
+                            && rule.getValue().getSpectrumRangeOfAppliance().getNonAuthorizedCustomer() != null
+                            && rule.getValue().getSpectrumRangeOfAppliance().getNonAuthorizedCustomer()
+                                .contains(customerName)) {
+                        //Customer shall not be put in this spectrum portion
+                        referenceBitSet.set(
+                            GridUtils.getIndexFromFrequency(startFreq.getValue()),
+                            GridUtils.getIndexFromFrequency(stopFreq.getValue()), false);
+                        LOG.info("Specific Spectrum filling Rules have been defined for customer {}, exluding it from "
+                            + "the spectrum range {} - {} ", customerName, startFreq.toString(), stopFreq.toString());
+                    } else if (customerName != null
+                            && rule.getValue().getSpectrumRangeOfAppliance().getDedicatedCustomer() != null
+                            && rule.getValue().getSpectrumRangeOfAppliance()
+                                .getDedicatedCustomer().contains(customerName)) {
+                        // Spectrum portion is dedicated to customers including this one
+                        referenceBitSet.set(
+                            GridUtils.getIndexFromFrequency(startFreq.getValue()),
+                            GridUtils.getIndexFromFrequency(stopFreq.getValue()), true);
+                        LOG.info("Specific Spectrum filling Rules have been defined for customer {}, to dedicate "
+                            + "spectrum range {} - {} to it ", customerName, startFreq.toString(), stopFreq.toString());
+                    } else if (rule.getValue().getSpectrumRangeOfAppliance().getDedicatedCustomer() != null
+                            && !rule.getValue().getSpectrumRangeOfAppliance().getDedicatedCustomer().isEmpty()) {
+                        // Spectrum portion is dedicated to some customers that do not include this one
+                        referenceBitSet.set(
+                            GridUtils.getIndexFromFrequency(startFreq.getValue()),
+                            GridUtils.getIndexFromFrequency(stopFreq.getValue()), false);
+                        LOG.info("Specific Spectrum filling Rules have been defined for other customers, preventing"
+                            + " the customer to use spectrum range {}--{}", startFreq.toString(), stopFreq.toString());
+                    }
+                }
+                return referenceBitSet;
+            }
+        } catch (InterruptedException | ExecutionException e1) {
+            LOG.error("Exception caught handling Spectrum filling Rules {} ", e1.getCause().toString());
+        }
+        LOG.info("Did not succeed finding any Specific Spectrum filling Rules defined in Configuration Datastore");
+        return referenceBitSet;
+    }
+}
index b5d77ac89a51f75c7faaa23e9a7812abfb8f2208..994d3256fcbdce825275437c91d2357e60b176f2 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.transportpce.pce.graph;
 
 import java.util.ArrayList;
+import java.util.BitSet;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -54,6 +55,7 @@ public class PceGraph {
     private Double margin = null;
     PceConstraints pceHardConstraints;
     private PceConstraintMode pceConstraintMode;
+    private BitSet spectrumConstraint;
 
     // results
     private PceResult pceResult = null;
@@ -68,7 +70,7 @@ public class PceGraph {
 
     public PceGraph(PceNode aendNode, PceNode zendNode, Map<NodeId, PceNode> allPceNodes,
             Map<LinkId, PceLink> allPceLinks, PceConstraints pceHardConstraints,PceResult pceResult, String serviceType,
-            NetworkTransactionService networkTransactionService, PceConstraintMode mode) {
+            NetworkTransactionService networkTransactionService, PceConstraintMode mode, BitSet spectrumConstraint) {
         super();
         this.apceNode = aendNode;
         this.zpceNode = zendNode;
@@ -79,6 +81,7 @@ public class PceGraph {
         this.serviceType = serviceType;
         this.networkTransactionService = networkTransactionService;
         this.pceConstraintMode = mode;
+        this.spectrumConstraint = spectrumConstraint;
 
         LOG.info("In GraphCalculator: A and Z = {} / {} ", aendNode, zendNode);
         LOG.debug("In GraphCalculator: allPceNodes size {}, nodes {} ", allPceNodes.size(), allPceNodes);
@@ -102,7 +105,7 @@ public class PceGraph {
         for (Entry<Integer, GraphPath<String, PceGraphEdge>> entry : allWPaths.entrySet()) {
             GraphPath<String, PceGraphEdge> path = entry.getValue();
             LOG.info("validating path n° {} - {}", entry.getKey(), path.getVertexList());
-            PostAlgoPathValidator papv = new PostAlgoPathValidator(networkTransactionService);
+            PostAlgoPathValidator papv = new PostAlgoPathValidator(networkTransactionService, spectrumConstraint);
             pceResult = papv.checkPath(
                     path, allPceNodes, allPceLinks, pceResult, pceHardConstraints, serviceType, pceConstraintMode);
             this.margin = papv.getTpceCalculatedMargin();
index 56186777dce03378ff5167ec5273091a8de82ed0..53353aeae0415acfb29aa9867e4f4d2de734be67 100644 (file)
@@ -61,9 +61,11 @@ public class PostAlgoPathValidator {
 
     private Double tpceCalculatedMargin = 0.0;
     private final NetworkTransactionService networkTransactionService;
+    private final BitSet spectrumConstraint;
 
-    public PostAlgoPathValidator(NetworkTransactionService networkTransactionService) {
+    public PostAlgoPathValidator(NetworkTransactionService networkTransactionService, BitSet spectrumConstraint) {
         this.networkTransactionService = networkTransactionService;
+        this.spectrumConstraint = spectrumConstraint;
     }
 
     @SuppressWarnings("fallthrough")
@@ -1048,6 +1050,10 @@ public class PostAlgoPathValidator {
                 pceNode.getNodeId(), pceNodeVersion, sltWdthGran, ctralFreqGran);
             isFlexGrid = false;
         }
+        if (spectrumConstraint != null) {
+            result.and(spectrumConstraint);
+        }
+
         LOG.debug("Bitset result {}", result);
         return computeBestSpectrumAssignment(result, spectralWidthSlotNumber, isFlexGrid);
     }
index 3ade493bb58e3774a66aa8a663f4e163df04671f..bcc21d6f370f1c48f835bc26acc199c05c1ae80c 100644 (file)
@@ -7,13 +7,13 @@
  */
 package org.opendaylight.transportpce.pce;
 
-
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.lenient;
 import static org.mockito.Mockito.when;
 
+import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -27,7 +27,6 @@ import org.opendaylight.transportpce.pce.gnpy.JerseyServer;
 import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumer;
 import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumerImpl;
 import org.opendaylight.transportpce.pce.utils.PceTestData;
-import org.opendaylight.transportpce.pce.utils.PceTestUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.MappingBuilder;
@@ -38,6 +37,7 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmappi
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
 
+
 @ExtendWith(MockitoExtension.class)
 public class PceSendingPceRPCsTest extends AbstractTest {
 
@@ -54,10 +54,9 @@ public class PceSendingPceRPCsTest extends AbstractTest {
 
 
     @BeforeEach
-    void setUp() {
+    void setUp() throws InterruptedException, ExecutionException {
         this.dataBroker = getNewDataBroker();
         networkTransaction = new NetworkTransactionImpl(this.dataBroker);
-        PceTestUtils.writeNetworkInDataStore(this.dataBroker);
         gnpyConsumer = new GnpyConsumerImpl(
             "http://localhost:9998", "mylogin", "mypassword", getDataStoreContextUtil().getBindingDOMCodecServices());
         pceSendingPceRPCs = new PceSendingPceRPCs(
@@ -94,6 +93,7 @@ public class PceSendingPceRPCsTest extends AbstractTest {
         assertNull(pceSendingPceRPCs.getMessage());
     }
 
+
     @Test
     void responseCodeTest() {
         assertNull(pceSendingPceRPCs.getResponseCode());
diff --git a/pce/src/test/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraintsTest.java b/pce/src/test/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraintsTest.java
new file mode 100644 (file)
index 0000000..4fbab35
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2024 Orange Labs, Inc. 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.pce.constraints;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.util.BitSet;
+import java.util.concurrent.ExecutionException;
+import org.eclipse.jdt.annotation.NonNull;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
+import org.opendaylight.transportpce.pce.graph.PceGraphTest;
+import org.opendaylight.transportpce.pce.utils.PceTestUtils;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.transportpce.test.converter.DataObjectConverter;
+import org.opendaylight.transportpce.test.converter.JSONDataObjectConverter;
+//import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters
+//.SpectrumFilling;
+//import org.opendaylight.yang.gen.v1.http.org.openroadm.controller.customization.rev230526.controller.parameters
+//.spectrum.filling.SpectrumFillingRules;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ControllerBehaviourSettings;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+@ExtendWith(MockitoExtension.class)
+public class OperatorConstraintsTest extends AbstractTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(PceGraphTest.class);
+    private NetworkTransactionImpl networkTransaction;
+    private static final String SPEC_FILLING_FILE = "src/test/resources/spectrum-filling-rule1.json";
+//    private static SpectrumFillingRules sfRule;
+    private static ControllerBehaviourSettings cbSettings;
+    private OperatorConstraints opConstraints;
+    @Mock
+    private BindingDOMCodecServices bindingDOMCodecServices;
+    private DataBroker dataBroker;
+
+    @BeforeEach
+    void setUp() throws InterruptedException, ExecutionException {
+        this.dataBroker = getNewDataBroker();
+        networkTransaction = new NetworkTransactionImpl(this.dataBroker);
+        opConstraints = new OperatorConstraints(networkTransaction);
+        PceTestUtils.writeNetworkInDataStore(this.dataBroker);
+        DataObjectConverter dataObjectConverter = JSONDataObjectConverter
+            .createWithDataStoreUtil(getDataStoreContextUtil());
+        // The Spectrum filling rules associated with CustomerProfileLamda1 is populated from a file in the Data Store
+        try (Reader reader = new FileReader(SPEC_FILLING_FILE, StandardCharsets.UTF_8)) {
+            NormalizedNode normalizedNode = dataObjectConverter.transformIntoNormalizedNode(reader).orElseThrow();
+            cbSettings = (ControllerBehaviourSettings) getDataStoreContextUtil()
+                .getBindingDOMCodecServices()
+                .fromNormalizedNode(
+                    YangInstanceIdentifier.of(ControllerBehaviourSettings.QNAME), normalizedNode)
+                .getValue();
+            InstanceIdentifier<ControllerBehaviourSettings> sfIID =
+                InstanceIdentifier
+                    .builder(ControllerBehaviourSettings.class)
+//                    .child(SpectrumFilling.class)
+//                    .child(SpectrumFillingRules.class)
+                    .build();
+            @NonNull
+            WriteTransaction newWriteOnlyTransaction = dataBroker.newWriteOnlyTransaction();
+            newWriteOnlyTransaction.put(LogicalDatastoreType.CONFIGURATION, sfIID, cbSettings);
+            newWriteOnlyTransaction.commit().get();
+        } catch (IOException e) {
+            LOG.error("Cannot load Spectrum-Filling-Rules in Service DS ", e);
+            fail("Cannot load Spectrum-Filling-Rules");
+        }
+    }
+
+
+    @Test
+    void checkSpecttrumFilling() {
+        BitSet referenceBitSet = new BitSet(GridConstant.EFFECTIVE_BITS);
+        referenceBitSet.set(0, GridConstant.EFFECTIVE_BITS, false);
+        referenceBitSet.set(0, 8, true);
+        assertEquals(referenceBitSet, opConstraints.getBitMapConstraint("CustomerProfileLamda1"));
+        referenceBitSet.set(8, GridConstant.EFFECTIVE_BITS, true);
+        referenceBitSet.set(0, 8, false);
+        assertEquals(referenceBitSet, opConstraints.getBitMapConstraint("otherCustomer"));
+    }
+
+}
index cbf5ba570e8fcaf20034a45b49eaafc39d8f0db0..d85efa20c81a25fc668a1960331c71a0b90382f7 100644 (file)
@@ -249,7 +249,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(3.0919881995992924));
     }
@@ -262,7 +262,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_OTUC2, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_OTUC2, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(1.1559963686478447));
     }
@@ -275,7 +275,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_OTUC3, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_OTUC3, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(0.3351048800367167));
     }
@@ -288,7 +288,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), false);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(0.0));
     }
@@ -301,7 +301,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_400GE, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(1.4432381874659086));
     }
@@ -314,7 +314,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(1.4432381874659086));
     }
@@ -327,7 +327,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_OTUC4, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(0.0));
     }
@@ -340,7 +340,7 @@ public class PceGraphTest extends AbstractTest {
         pceCalc.retrievePceNetwork();
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose, null);
         assertEquals(pceGraph.calcPath(), true);
         assertEquals(Optional.ofNullable(pceGraph.getmargin()), Optional.ofNullable(3.0919881995992924));
     }
@@ -354,7 +354,7 @@ public class PceGraphTest extends AbstractTest {
         pceHardConstraints.setPceMetrics(PceMetric.PropagationDelay);
         pceGraph = new PceGraph(pceCalc.getaendPceNode(), pceCalc.getzendPceNode(),
             pceCalc.getAllPceNodes(), pceCalc.getAllPceLinks(), pceHardConstraints,
-            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose);
+            rc, StringConstants.SERVICE_TYPE_100GE_T, netTransServ, PceConstraintMode.Loose, null);
         pceGraph.setConstrains(pceHardConstraints);
 
         assertEquals(pceGraph.calcPath(), true);
@@ -417,7 +417,7 @@ public class PceGraphTest extends AbstractTest {
             new NodeId("optical"), pceOtnNode,
             new NodeId("optical2"), pceOtnNode2);
         return new PceGraph(pceOtnNode, pceOtnNode2, allPceNodes, allPceLinks, pceHardConstraints,
-                new PceResult(), type, null, PceConstraintMode.Loose);
+                new PceResult(), type, null, PceConstraintMode.Loose, null);
     }
 
     private void saveOpenRoadmNetwork(Network network, String networkId)
diff --git a/pce/src/test/resources/spectrum-filling-rule1.json b/pce/src/test/resources/spectrum-filling-rule1.json
new file mode 100644 (file)
index 0000000..dfb0c83
--- /dev/null
@@ -0,0 +1,38 @@
+{
+    "controller-behaviour-settings": {
+        "spectrum-filling": {
+          "spectrum-filling-rules": [
+            {
+              "rule-id": 1,
+              "priority": 1,
+              "RMSA-policy": "maximize-capacity",
+              "spectrum-range-of-appliance": {
+                "dedicated-signal-bandwidth-multiple": 50,
+                "spectrum-portion-id": 0,
+                "start-edge-frequency": 191.325,
+                "stop-edge-frequency": 191.375,
+                "dedicated-customer": [
+                  "CustomerProfileLamda1"
+                ],
+                "non-authorized-customer": [
+                  "All-other"
+                ]
+              }
+            },
+            {
+              "rule-id": 2,
+              "priority": 1,
+              "RMSA-policy": "maximize-capacity",
+              "spectrum-range-of-appliance": {
+                "spectrum-portion-id": 1,
+                "start-edge-frequency": 191.375,
+                "stop-edge-frequency": 196.125,
+                "non-authorized-customer": [
+                  "CustomerProfileLamda1"
+                ]
+              }
+            }
+          ]
+        }
+    }
+}
index 2ea5077a6be795d34f43843a66cf6865dd94abde..7eb2e29c1ba6ab7b6474fdfec907a77194340f04 100644 (file)
@@ -78,7 +78,8 @@ public class PCEServiceWrapper {
             return performPCE(serviceCreateInput.getHardConstraints(), serviceCreateInput.getSoftConstraints(),
                     serviceCreateInput.getServiceName(), serviceCreateInput.getSdncRequestHeader(),
                     serviceCreateInput.getServiceAEnd(), serviceCreateInput.getServiceZEnd(),
-                    ServiceNotificationTypes.ServiceCreateResult, reserveResource);
+                    ServiceNotificationTypes.ServiceCreateResult, reserveResource,
+                    serviceCreateInput.getCustomer());
         } else {
             return returnPCEFailed();
         }
@@ -91,7 +92,8 @@ public class PCEServiceWrapper {
             return performPCE(tempServiceCreateInput.getHardConstraints(), tempServiceCreateInput.getSoftConstraints(),
                     tempServiceCreateInput.getCommonId(), tempServiceCreateInput.getSdncRequestHeader(),
                     tempServiceCreateInput.getServiceAEnd(), tempServiceCreateInput.getServiceZEnd(),
-                    ServiceNotificationTypes.ServiceCreateResult, reserveResource);
+                    ServiceNotificationTypes.ServiceCreateResult, reserveResource,
+                    tempServiceCreateInput.getCustomer());
         } else {
             return returnPCEFailed();
         }
@@ -106,7 +108,8 @@ public class PCEServiceWrapper {
                     serviceFeasibilityCheckInput.getSoftConstraints(), serviceFeasibilityCheckInput.getCommonId(),
                     serviceFeasibilityCheckInput.getSdncRequestHeader(), serviceFeasibilityCheckInput.getServiceAEnd(),
                     serviceFeasibilityCheckInput.getServiceZEnd(),
-                    ServiceNotificationTypes.ServiceCreateResult, reserveResource);
+                    ServiceNotificationTypes.ServiceCreateResult, reserveResource,
+                    serviceFeasibilityCheckInput.getCustomer());
         } else {
             return returnPCEFailed();
         }
@@ -114,7 +117,8 @@ public class PCEServiceWrapper {
 
     private PathComputationRequestOutput performPCE(HardConstraints hardConstraints, SoftConstraints softConstraints,
             String serviceName, SdncRequestHeader sdncRequestHeader, ServiceEndpoint serviceAEnd,
-            ServiceEndpoint serviceZEnd, ServiceNotificationTypes notifType, boolean reserveResource) {
+            ServiceEndpoint serviceZEnd, ServiceNotificationTypes notifType, boolean reserveResource,
+            String customerName) {
         LOG.info("Calling path computation.");
         notification = new ServiceRpcResultShBuilder().setNotificationType(notifType).setServiceName(serviceName)
                 .setStatus(RpcStatusEx.Pending)
@@ -127,7 +131,7 @@ public class PCEServiceWrapper {
         FutureCallback<PathComputationRequestOutput> pceCallback =
                 new PathComputationRequestOutputCallback(notifType, serviceName);
         PathComputationRequestInput pathComputationRequestInput = createPceRequestInput(serviceName, sdncRequestHeader,
-                hardConstraints, softConstraints, reserveResource, serviceAEnd, serviceZEnd);
+                hardConstraints, softConstraints, reserveResource, serviceAEnd, serviceZEnd, customerName);
         ListenableFuture<PathComputationRequestOutput> pce = this.pathComputationService
                 .pathComputationRequest(pathComputationRequestInput);
         Futures.addCallback(pce, pceCallback, executor);
@@ -173,7 +177,7 @@ public class PCEServiceWrapper {
     private PathComputationRequestInput createPceRequestInput(String serviceName,
             SdncRequestHeader serviceHandler, HardConstraints hardConstraints,
             SoftConstraints softConstraints, Boolean reserveResource, ServiceEndpoint serviceAEnd,
-            ServiceEndpoint serviceZEnd) {
+            ServiceEndpoint serviceZEnd, String customerName) {
         LOG.info("Mapping ServiceCreateInput or ServiceFeasibilityCheckInput or serviceReconfigureInput to PCE"
                 + "requests");
         ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder();
@@ -187,6 +191,7 @@ public class PCEServiceWrapper {
             .setHardConstraints(hardConstraints)
             .setSoftConstraints(softConstraints)
             .setPceRoutingMetric(PceMetric.TEMetric)
+            .setCustomerName(customerName)
             .setServiceAEnd(ModelMappingUtils.createServiceAEnd(serviceAEnd))
             .setServiceZEnd(ModelMappingUtils.createServiceZEnd(serviceZEnd))
             .build();