From 70bdf049cd030b154968d56a42bca8d26447ffc6 Mon Sep 17 00:00:00 2001 From: orenais Date: Tue, 6 Feb 2024 19:29:39 +0100 Subject: [PATCH] Add SpectrumFillingRule check in postAlgoValidator JIRA: TRNSPRTPCE-783 Change-Id: I4c98c6ddfcff4e71c2f8c00774b8e6d80801ca07 Signed-off-by: orenais --- .../transportpce/pce/PceSendingPceRPCs.java | 4 +- .../pce/constraints/OperatorConstraints.java | 103 +++++++++++++++++ .../transportpce/pce/graph/PceGraph.java | 7 +- .../pce/graph/PostAlgoPathValidator.java | 8 +- .../pce/PceSendingPceRPCsTest.java | 8 +- .../constraints/OperatorConstraintsTest.java | 105 ++++++++++++++++++ .../transportpce/pce/graph/PceGraphTest.java | 20 ++-- .../resources/spectrum-filling-rule1.json | 38 +++++++ .../service/PCEServiceWrapper.java | 17 ++- 9 files changed, 286 insertions(+), 24 deletions(-) create mode 100644 pce/src/main/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraints.java create mode 100644 pce/src/test/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraintsTest.java create mode 100644 pce/src/test/resources/spectrum-filling-rule1.json diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java b/pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java index f89cff96c..08b46d744 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java @@ -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 index 000000000..3c1159648 --- /dev/null +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraints.java @@ -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 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 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; + } +} diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java index b5d77ac89..994d3256f 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java @@ -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 allPceNodes, Map 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> entry : allWPaths.entrySet()) { GraphPath 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(); diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java index 56186777d..53353aeae 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java @@ -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); } diff --git a/pce/src/test/java/org/opendaylight/transportpce/pce/PceSendingPceRPCsTest.java b/pce/src/test/java/org/opendaylight/transportpce/pce/PceSendingPceRPCsTest.java index 3ade493bb..bcc21d6f3 100644 --- a/pce/src/test/java/org/opendaylight/transportpce/pce/PceSendingPceRPCsTest.java +++ b/pce/src/test/java/org/opendaylight/transportpce/pce/PceSendingPceRPCsTest.java @@ -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 index 000000000..4fbab35e0 --- /dev/null +++ b/pce/src/test/java/org/opendaylight/transportpce/pce/constraints/OperatorConstraintsTest.java @@ -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 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")); + } + +} diff --git a/pce/src/test/java/org/opendaylight/transportpce/pce/graph/PceGraphTest.java b/pce/src/test/java/org/opendaylight/transportpce/pce/graph/PceGraphTest.java index cbf5ba570..d85efa20c 100644 --- a/pce/src/test/java/org/opendaylight/transportpce/pce/graph/PceGraphTest.java +++ b/pce/src/test/java/org/opendaylight/transportpce/pce/graph/PceGraphTest.java @@ -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 index 000000000..dfb0c83cc --- /dev/null +++ b/pce/src/test/resources/spectrum-filling-rule1.json @@ -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" + ] + } + } + ] + } + } +} diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java index 2ea5077a6..7eb2e29c1 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/PCEServiceWrapper.java @@ -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 pceCallback = new PathComputationRequestOutputCallback(notifType, serviceName); PathComputationRequestInput pathComputationRequestInput = createPceRequestInput(serviceName, sdncRequestHeader, - hardConstraints, softConstraints, reserveResource, serviceAEnd, serviceZEnd); + hardConstraints, softConstraints, reserveResource, serviceAEnd, serviceZEnd, customerName); ListenableFuture 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(); -- 2.36.6