sed 's/8101/ODL_SHELL_PORT/' ../etc/org.apache.karaf.shell.cfg > org.apache.karaf.shell._template.cfg
sed -e 's/1099/ODL_RMI_REGISTRY_PORT/' -e 's/44444/ODL_RMI_SERVER_PORT/' ../etc/org.apache.karaf.management.cfg > org.apache.karaf.management._template.cfg
+sed 's/^#persistent=true/persistent=false/' ../system/org/opendaylight/controller/sal-clustering-config/*/sal-clustering-config-*-datastore.cfg > ../etc/org.opendaylight.controller.cluster.datastore.cfg
+
sed -i'_' -e '1 a\
\
. \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\
</dependency>
<dependency>
<groupId>org.opendaylight.transportpce.models</groupId>
- <artifactId>tapi-2.1.1</artifactId>
+ <artifactId>tapi-2.4.0</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.transportpce</groupId>
Network network = createNetwork(networkId);
InstanceIdentifier.Builder<Network> nwIID = InstanceIdentifier.builder(Networks.class).child(Network.class,
new NetworkKey(new NetworkId(networkId)));
- networkTransactionService.put(LogicalDatastoreType.CONFIGURATION, nwIID.build(), network);
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, nwIID.build(), network);
this.networkTransactionService.commit().get(1, TimeUnit.SECONDS);
LOG.info("{} network layer created successfully.", networkId);
} catch (ExecutionException | TimeoutException | InterruptedException e) {
LOG.info("Spanloss TX is {}", spanLossTx);
// TODO: The span-loss limits should be obtained from optical specifications
- if (spanLossTx == null || spanLossTx.intValue() <= 0 || spanLossTx.intValue() > 27) {
- LOG.error("Power Value is null: spanLossTx null or out of openROADM range ]0,27] {}",
+ if (spanLossTx == null || spanLossTx.intValue() < 0 || spanLossTx.intValue() > 27) {
+ LOG.error("Power Value is null: spanLossTx null or out of openROADM range [0,27] {}",
spanLossTx);
return false;
}
--- /dev/null
+/*
+ * Copyright (c) 2024 Smartoptics 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.networkanalyzer.port;
+
+import java.util.Map;
+import java.util.Set;
+
+public class ClientPreference implements Preference {
+
+ Map<String, Set<String>> nodePortPreference;
+
+ public ClientPreference(Map<String, Set<String>> nodePortPreference) {
+ this.nodePortPreference = nodePortPreference;
+ }
+
+ @Override
+ public boolean isPreferredPort(String node, String portName) {
+
+ //If there is no preferred port registered for the node, it means
+ //the client has no preference regarding the node.
+ //Therefore, we'll treat the node as it was preferred to
+ //prevent it from NOT being used.
+ return !nodePortPreference.containsKey(node) || nodePortPreference.get(node).contains(portName);
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2024 Smartoptics 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.networkanalyzer.port;
+
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
+
+public interface Factory {
+
+ /**
+ * Extracting preferred ports from pathComputationRequestInput.
+ *
+ * <p>
+ * This is the recommended method of determining if a node/port combination
+ * is preferred by the client.
+ *
+ * <p>
+ * Pseudocode example:
+ * <pre>
+ * Factory.portPreference(PCRI).preferredPort("ROADM-B-SRG1", "SRG1-PP1-TXRX");
+ * </pre>
+ *
+ * @return Client port preference
+ */
+ Preference portPreference(PathComputationRequestInput pathComputationRequestInput);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2024 Smartoptics 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.networkanalyzer.port;
+
+/**
+ * This class represents a state where the client has no port preference.
+ * In essence, all ports on all nodes will therefore be treated as 'preferred'
+ * when queried.
+ *
+ * <p>
+ * Usage of this class is of sorts the 'backwards compatible' approach. Meaning,
+ * intended to offer a path for the application to behave as it did
+ * prior to implementing client port preference.
+ */
+public class NoPreference implements Preference {
+ @Override
+ public boolean isPreferredPort(String node, String portName) {
+ return true;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2024 Smartoptics 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.networkanalyzer.port;
+
+public interface Preference {
+
+ /**
+ * Return true if the portName is among the ports preferred by the client.
+ */
+ boolean isPreferredPort(String node, String portName);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2024 Smartoptics 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.networkanalyzer.port;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEnd;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.Port;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.endpoint.sp.RxDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.endpoint.sp.TxDirection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PreferenceFactory implements Factory {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PreferenceFactory.class);
+
+ private final String portNamePattern = "(?i)SRG\\d+-PP\\d+-(TXRX|TX|RX)";
+
+ @Override
+ public Preference portPreference(PathComputationRequestInput pathComputationRequestInput) {
+
+ Map<String, Set<String>> map = nodePortMap(pathComputationRequestInput);
+
+ if (map.isEmpty()) {
+ LOG.debug("No port preference found in path computation request.");
+ return new NoPreference();
+ }
+
+ LOG.debug("Port preference in path computation request: {}." , map);
+ return new ClientPreference(map);
+ }
+
+ /**
+ * Create a key value mapper from PCRI where key is the node and the value is
+ * a unique list of port names.
+ *
+ * @return Client port preference map
+ */
+ Map<String, Set<String>> nodePortMap(PathComputationRequestInput pathComputationRequestInput) {
+
+ Map<String, Set<String>> mapper = new HashMap<>();
+
+ ServiceAEnd serviceAEnd = pathComputationRequestInput.getServiceAEnd();
+ if (serviceAEnd != null) {
+
+ RxDirection rxAzDirection = serviceAEnd.getRxDirection();
+ if (rxAzDirection != null) {
+
+ Port rxAZport = rxAzDirection.getPort();
+ if (rxAZport != null) {
+ add(rxAZport.getPortDeviceName(), rxAZport.getPortName(), mapper);
+ }
+ }
+
+ TxDirection txAzDirection = serviceAEnd.getTxDirection();
+ if (txAzDirection != null) {
+
+ Port txAZport = txAzDirection.getPort();
+ if (txAZport != null) {
+ add(txAZport.getPortDeviceName(), txAZport.getPortName(), mapper);
+ }
+ }
+ }
+
+ ServiceZEnd serviceZEnd = pathComputationRequestInput.getServiceZEnd();
+ if (serviceZEnd != null) {
+
+ RxDirection rxZaDirection = serviceZEnd.getRxDirection();
+ if (rxZaDirection != null) {
+
+ Port rxZAport = rxZaDirection.getPort();
+ if (rxZAport != null) {
+ add(rxZAport.getPortDeviceName(), rxZAport.getPortName(), mapper);
+ }
+ }
+
+ TxDirection txZaDirection = serviceZEnd.getTxDirection();
+ if (txZaDirection != null) {
+
+ Port txZAport = txZaDirection.getPort();
+ if (txZAport != null) {
+ add(txZAport.getPortDeviceName(), txZAport.getPortName(), mapper);
+ }
+ }
+ }
+
+ return mapper;
+ }
+
+ /**
+ * Add node/port name to key value map. Mutable method, modifies the argument nodePortMap.
+ */
+ boolean add(String node, String port, Map<String, Set<String>> nodePortMap) {
+
+ if (node == null || port == null) {
+ return false;
+ }
+
+ String nodeTrimmed = node.trim();
+ String portTrimmed = port.trim();
+
+ if (nodeTrimmed.isEmpty() || portTrimmed.isEmpty()) {
+ return false;
+ }
+
+ if (!portTrimmed.matches(portNamePattern)) {
+ LOG.warn("Preferred port name '{}' on node {} doesn't match pattern '{}'",
+ portTrimmed,
+ nodeTrimmed,
+ portNamePattern
+ );
+ }
+
+ if (nodePortMap.containsKey(nodeTrimmed)) {
+ boolean added = nodePortMap.get(nodeTrimmed).add(portTrimmed);
+ if (added) {
+ LOG.debug("Preferred port '{}' for node '{}' registered.", portTrimmed, nodeTrimmed);
+ } else {
+ LOG.debug("Failed registering port '{}' for node '{}'.", portTrimmed, nodeTrimmed);
+ }
+ return added;
+ }
+
+ nodePortMap.put(nodeTrimmed, new HashSet<>(Arrays.asList(portTrimmed)));
+
+ return true;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.networkanalyzer.port;
+
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class ClientPreferenceTest {
+
+ @Test
+ void preferredPort_returnTrue() {
+
+ Map<String, Set<String>> nodePortPreference = new HashMap<>();
+ nodePortPreference.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+
+ Preference clientPreference = new ClientPreference(nodePortPreference);
+
+ Assertions.assertTrue(clientPreference.isPreferredPort("ROADM-B-SRG1", "SRG1-PP1-TXRX"));
+ }
+
+ /**
+ * The client prefer to use SRG1-PP1-TXRX on ROADM-B-SRG1.
+ * Therefore, preferredPort returns false on SRG1-PP2-TXRX.
+ */
+ @Test
+ void nonPreferredPort_returnFalse() {
+
+ Map<String, Set<String>> nodePortPreference = new HashMap<>();
+ nodePortPreference.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+
+ Preference clientPreference = new ClientPreference(nodePortPreference);
+
+ Assertions.assertFalse(clientPreference.isPreferredPort("ROADM-B-SRG1", "SRG1-PP2-TXRX"));
+ }
+
+ /**
+ * In this scenario ROADM-A-SRG1 is missing from the client preferred list.
+ * We treat this as the client has no opinion on what port
+ * to use on ROADM-A-SRG1. Meaning, as far as the client goes, all
+ * ports on ROADM-A-SRG1 are fine.
+ */
+ @Test
+ void nodeMissingInPreferredList_returnTrue() {
+
+ Map<String, Set<String>> nodePortPreference = new HashMap<>();
+ nodePortPreference.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+
+ Preference clientPreference = new ClientPreference(nodePortPreference);
+
+ Assertions.assertTrue(clientPreference.isPreferredPort("ROADM-A-SRG1", "SRG1-PP2-TXRX"));
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2024 Smartoptics 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.networkanalyzer.port;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev230925.path.computation.request.input.ServiceZEnd;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.PortBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.endpoint.sp.RxDirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.endpoint.sp.TxDirection;
+
+class PreferenceFactoryTest {
+
+ @Test
+ void emptyPathComputationRequest_returnEmptyHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathComputationRequestServiceAEndRxDirectionWithoutDeviceAndPort_returnEmptyHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+ RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+ Mockito.when(rxDirection.getPort()).thenReturn(new PortBuilder().build());
+ Mockito.when(serviceAEnd.getRxDirection()).thenReturn(rxDirection);
+ Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathComputationRequestServiceAEndRxDirectionWithoutPort_returnEmptyHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+ RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+ Mockito.when(rxDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .build()
+ );
+ Mockito.when(serviceAEnd.getRxDirection()).thenReturn(rxDirection);
+ Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathComputationRequestServiceAEndRxDirectionTxRx_returnHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+ RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+ Mockito.when(rxDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .setPortName("SRG1-PP1-TXRX")
+ .build()
+ );
+ Mockito.when(serviceAEnd.getRxDirection()).thenReturn(rxDirection);
+ Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathComputationRequestServiceAEndRxDirectionTx_returnHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+ RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+ Mockito.when(rxDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .setPortName("SRG1-PP1-TX")
+ .build()
+ );
+ Mockito.when(serviceAEnd.getRxDirection()).thenReturn(rxDirection);
+ Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TX"));
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathComputationRequestServiceAEndRxDirectionRx_returnHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceAEnd serviceAEnd = Mockito.mock(ServiceAEnd.class);
+ TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+ Mockito.when(txDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .setPortName("SRG1-PP1-RX")
+ .build()
+ );
+ Mockito.when(serviceAEnd.getTxDirection()).thenReturn(txDirection);
+ Mockito.when(pathComputationRequestInput.getServiceAEnd()).thenReturn(serviceAEnd);
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-RX"));
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathComputationRequestServiceZEndRx_returnHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+ RxDirection rxDirection = Mockito.mock(RxDirection.class);
+
+ Mockito.when(rxDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .setPortName("SRG1-PP1-TXRX")
+ .build()
+ );
+ Mockito.when(serviceZEnd.getRxDirection()).thenReturn(rxDirection);
+ Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathComputationRequestServiceZEndTxDirectionTxRx_returnHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+ TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+ Mockito.when(txDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .setPortName("SRG1-PP1-TXRX")
+ .build()
+ );
+ Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+ Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathComputationRequestServiceZEndTxDirectionTx_returnHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+ TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+ Mockito.when(txDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .setPortName("SRG1-PP1-TX")
+ .build()
+ );
+ Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+ Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TX"));
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathComputationRequestServiceZEndTxDirectionRx_returnHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+ TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+ Mockito.when(txDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .setPortName("SRG1-PP1-RX")
+ .build()
+ );
+ Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+ Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ expected.put("ROADM-B-SRG1", Set.of("SRG1-PP1-RX"));
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathEmptyComputationRequestServiceZEndTx_returnHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+ TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+ Mockito.when(txDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .setPortName(" ")
+ .build()
+ );
+ Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+ Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+ Map<String, Set<String>> expected = new HashMap<>();
+
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void pathUnexpectedPortName_returnHashmap() {
+
+ PathComputationRequestInput pathComputationRequestInput = Mockito.mock(PathComputationRequestInput.class);
+ ServiceZEnd serviceZEnd = Mockito.mock(ServiceZEnd.class);
+ TxDirection txDirection = Mockito.mock(TxDirection.class);
+
+ Mockito.when(txDirection.getPort()).thenReturn(
+ new PortBuilder()
+ .setPortDeviceName("ROADM-B-SRG1")
+ .setPortName("FUBAR")
+ .build()
+ );
+ Mockito.when(serviceZEnd.getTxDirection()).thenReturn(txDirection);
+ Mockito.when(pathComputationRequestInput.getServiceZEnd()).thenReturn(serviceZEnd);
+
+ Map<String, Set<String>> expected = new HashMap<>();
+ expected.put("ROADM-B-SRG1", Set.of("FUBAR"));
+
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+ Assertions.assertEquals(expected, portPreferenceFactory.nodePortMap(pathComputationRequestInput));
+
+ }
+
+ @Test
+ void addingMultiplePort() {
+
+ PreferenceFactory portPreferenceFactory = new PreferenceFactory();
+ Map<String, Set<String>> mapper = new HashMap<>();
+
+ //New ports
+ Assertions.assertTrue(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP1-TXRX", mapper));
+ Assertions.assertTrue(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP2-TXRX", mapper));
+ Assertions.assertTrue(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP3-RX", mapper));
+ Assertions.assertTrue(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP3-TX", mapper));
+
+ //This port already exists, should return false.
+ Assertions.assertFalse(portPreferenceFactory.add("ROADM-B-SRG1", "SRG1-PP2-TXRX", mapper));
+
+ Assertions.assertEquals(
+ Set.of("SRG1-PP1-TXRX", "SRG1-PP2-TXRX", "SRG1-PP3-RX", "SRG1-PP3-TX"),
+ mapper.get("ROADM-B-SRG1")
+ );
+ }
+}
\ No newline at end of file
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOmsInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOmsOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackInput;
*/
ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction);
+ /**
+ * This method set's wavelength path based on following steps.
+ *
+ * <p>
+ * For each node:
+ * 1. Create Och interface on source termination point.
+ * 2. Create Och interface on destination termination point.
+ * 3. Create cross connect between source and destination tps created in step 1
+ * and 2.
+ *
+ * Naming convention used for OCH interfaces name : tp-wavenumber Naming
+ * convention used for cross connect name : src-dest-wavenumber
+ * </p>
+ *
+ * @param input
+ * Input parameter from the service-path yang model
+ * @param direction
+ * Service Path direction
+ * @param transactionHistory
+ * Object tracking created interface(s) and connection(s).
+ *
+ * @return Result list of all nodes if request successful otherwise specific
+ * reason of failure.
+ */
+ ServicePathOutput setupServicePath(
+ ServicePathInput input,
+ ServicePathDirection direction,
+ History transactionHistory);
+
/**
* This method removes wavelength path based on following steps.
*
*/
RendererRollbackOutput rendererRollback(RendererRollbackInput input);
+ /**
+ * Rollback created interfaces and cross connects specified by transaction history.
+ *
+ * @param transactionHistory The transaction history in need of rollback.
+ * @return Success flag and nodes which failed to rollback
+ */
+ RendererRollbackOutput rendererRollback(History transactionHistory);
+
/**
* This method creates the basis of ots and oms interfaces on a specific ROADM degree.
*
import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServiceListTopology;
import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Connection;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.DeviceInterface;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.DeleteService;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.DeleteSubscriber;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.FailedRollbackResult;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Result;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Subscriber;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.NonStickHistoryMemory;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.ServiceNodelist;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistKey;
this.openRoadmInterfaceFactory = new OpenRoadmInterfaceFactory(mappingUtils, portMapping, openRoadmInterfaces);
}
+ @Override
+ public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
+ return setupServicePath(input, direction, new NonStickHistoryMemory());
+ }
+
@SuppressWarnings("rawtypes")
// FIXME check if the ForkJoinTask raw type can be avoided
// Raw types use are discouraged since they lack type safety.
// Resulting Problems are observed at run time and not at compile time
@Override
- public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
+ public ServicePathOutput setupServicePath(
+ ServicePathInput input,
+ ServicePathDirection direction,
+ History transactionHistory
+ ) {
LOG.info("setup service path for input {} and direction {}", input, direction);
List<Nodes> nodes = new ArrayList<>();
if (input.getNodes() != null) {
crossConnectFlag++;
String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
nodeId, destTp, spectrumInformation);
+ transactionHistory.add(new DeviceInterface(nodeId, supportingOchInterface));
+
// Split the string based on # pass the last element as the supported Interface
// This is needed for 7.1 device models with B100G, we have OTSI, OTSI-group combined as OCH
String[] listOfSuppOchInf = supportingOchInterface.split("#");
List<String> createdOchInf = Arrays.asList(listOfSuppOchInf);
+ transactionHistory.addInterfaces(nodeId, listOfSuppOchInf);
+
createdOchInterfaces.addAll(createdOchInf);
LOG.info("DEST all otsi interfaces {}", createdOchInterfaces);
// Taking the last element
.createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface, apiInfoA,
apiInfoZ);
createdOtuInterfaces.add(supportingOtuInterface);
+ transactionHistory.add(new DeviceInterface(nodeId, supportingOtuInterface));
+
LOG.info("all dest otu interfaces {}", createdOtuInterfaces);
if (srcTp == null) {
otnLinkTps.add(new LinkTpBuilder().setNodeId(nodeId).setTpId(destTp).build());
// If src and dest tp contains the network token, then it is regenerator
LOG.info("Create the ODUCn for regen on the dest-tp");
// Here we first create ODUCn interface for the Regen
- createdOduInterfaces.add(this.openRoadmInterfaceFactory
- .createOpenRoadmOducn(nodeId, destTp));
+ String openRoadmOducn = this.openRoadmInterfaceFactory
+ .createOpenRoadmOducn(nodeId, destTp);
+ createdOduInterfaces.add(openRoadmOducn);
+ transactionHistory.addInterfaces(nodeId, openRoadmOducn);
+
LOG.info("all dest odu interfaces {}", createdOduInterfaces);
} else {
// This is needed for 7.1 device models for 400GE, since we have ODUC4 and ODUflex
// are combined
- createdOduInterfaces = Set.of(this.openRoadmInterfaceFactory
- .createOpenRoadmOdu4HOInterface(
- nodeId, destTp, false, apiInfoA, apiInfoZ, PT_07).split("#"));
+ String[] oduInterfaces = this.openRoadmInterfaceFactory
+ .createOpenRoadmOdu4HOInterface(
+ nodeId, destTp, false, apiInfoA, apiInfoZ, PT_07).split("#");
+ createdOduInterfaces.addAll(Arrays.asList(oduInterfaces));
+ transactionHistory.addInterfaces(nodeId, oduInterfaces);
+
}
}
if ((srcTp != null) && srcTp.contains(StringConstants.CLIENT_TOKEN)) {
LOG.info("Adding supporting EThernet interface for node {}, src tp {}", nodeId, srcTp);
crossConnectFlag++;
// create OpenRoadm Xponder Client Interfaces
- createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
- nodeId, srcTp));
+ String openRoadmEthInterface = this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
+ nodeId, srcTp);
+ createdEthInterfaces.add(openRoadmEthInterface);
+ transactionHistory.add(new DeviceInterface(nodeId, openRoadmEthInterface));
+
}
if ((srcTp != null) && srcTp.contains(StringConstants.NETWORK_TOKEN)) {
LOG.info("Adding supporting OCH interface for node {}, src tp {}, spectrumInformation {}",
// create OpenRoadm Xponder Line Interfaces
String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
nodeId, srcTp, spectrumInformation);
+ transactionHistory.add(new DeviceInterface(nodeId, supportingOchInterface));
+
// createdOchInterfaces.add(supportingOchInterface);
// Split the string based on # pass the last element as the supported Interface
// This is needed for 7.1 device models with B100G, we have OTSI, OTSI-group combined as OCH
String[] listOfSuppOchInf = supportingOchInterface.split("#");
+ transactionHistory.addInterfaces(nodeId, listOfSuppOchInf);
+
List<String> tmpCreatedOchInterfaces = Arrays.asList(listOfSuppOchInf);
createdOchInterfaces.addAll(tmpCreatedOchInterfaces);
// Taking the last element
String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface(
nodeId, srcTp, supportingOchInterface, apiInfoA, apiInfoZ);
createdOtuInterfaces.add(supportingOtuInterface);
+ transactionHistory.add(new DeviceInterface(nodeId, supportingOtuInterface));
+
if (destTp == null) {
otnLinkTps.add(new LinkTpBuilder().setNodeId(nodeId).setTpId(srcTp).build());
} else if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
// If the src and dest tp have network-token, then it is a regen
LOG.info("Create the regen-interfaces on the src-tp");
// Here we first create ODUCn interface for the Regen
- createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOducn(nodeId,
- srcTp));
+ String openRoadmOducn = this.openRoadmInterfaceFactory.createOpenRoadmOducn(nodeId,
+ srcTp);
+ createdOduInterfaces.add(openRoadmOducn);
+ transactionHistory.add(new DeviceInterface(nodeId, openRoadmOducn));
+
LOG.info("all src odu interfaces {}", createdOduInterfaces);
} else {
- createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4HOInterface(
- nodeId, srcTp, false, apiInfoA, apiInfoZ, PT_07));
+ String openRoadmOdu4HOInterface = this.openRoadmInterfaceFactory
+ .createOpenRoadmOdu4HOInterface(nodeId, srcTp, false, apiInfoA, apiInfoZ, PT_07);
+ createdOduInterfaces.add(openRoadmOdu4HOInterface);
+ transactionHistory.add(new DeviceInterface(nodeId, openRoadmOdu4HOInterface));
}
}
if ((destTp != null) && destTp.contains(StringConstants.CLIENT_TOKEN)) {
LOG.info("Adding supporting EThernet interface for node {}, dest tp {}", nodeId, destTp);
crossConnectFlag++;
// create OpenRoadm Xponder Client Interfaces
- createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
- nodeId, destTp));
+ String openRoadmEthInterface = this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(
+ nodeId, destTp);
+ createdEthInterfaces.add(openRoadmEthInterface);
+ transactionHistory.add(new DeviceInterface(nodeId, openRoadmEthInterface));
}
if ((srcTp != null) && (srcTp.contains(StringConstants.TTP_TOKEN)
|| srcTp.contains(StringConstants.PP_TOKEN))) {
LOG.info("Adding supporting OCH interface for node {}, src tp {}, spectrumInformation {}",
nodeId, srcTp, spectrumInformation);
- createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(
- nodeId, srcTp, spectrumInformation));
+ List<String> openRoadmOchInterfaces = this.openRoadmInterfaceFactory
+ .createOpenRoadmOchInterfaces(nodeId, srcTp, spectrumInformation);
+ createdOchInterfaces.addAll(openRoadmOchInterfaces);
+ transactionHistory.addInterfaces(nodeId, openRoadmOchInterfaces);
}
if ((destTp != null) && (destTp.contains(StringConstants.TTP_TOKEN)
|| destTp.contains(StringConstants.PP_TOKEN))) {
LOG.info("Adding supporting OCH interface for node {}, dest tp {}, spectrumInformation {}",
nodeId, destTp, spectrumInformation);
- createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(
- nodeId, destTp, spectrumInformation));
+ List<String> openRoadmOchInterfaces = this.openRoadmInterfaceFactory
+ .createOpenRoadmOchInterfaces(nodeId, destTp, spectrumInformation);
+ createdOchInterfaces.addAll(openRoadmOchInterfaces);
+ transactionHistory.addInterfaces(nodeId, openRoadmOchInterfaces);
}
if (crossConnectFlag < 1) {
LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp,
this.crossConnect.postCrossConnect(nodeId, srcTp, destTp, spectrumInformation);
if (connectionNameOpt.isPresent()) {
nodesProvisioned.add(nodeId);
- createdConnections.add(connectionNameOpt.orElseThrow());
+ String connectionName = connectionNameOpt.orElseThrow();
+ createdConnections.add(connectionName);
+ transactionHistory.add(new Connection(nodeId, connectionName, false));
} else {
processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
results);
.build();
}
+ @Override
+ public RendererRollbackOutput rendererRollback(History transactionHistory) {
+ LOG.info("Rolling back...");
+
+ Result rollbackResult = new FailedRollbackResult();
+ Subscriber deleteSubscriber = new DeleteSubscriber(rollbackResult);
+
+ transactionHistory.rollback(
+ new DeleteService(
+ crossConnect,
+ openRoadmInterfaces,
+ deleteSubscriber
+ )
+ );
+
+ LOG.info("Rollback done!");
+
+ return rollbackResult.renderRollbackOutput();
+ }
+
private boolean alarmSuppressionNodeRegistration(ServicePathInput input) {
Map<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
.nodelist.nodelist.NodesKey,
import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
import org.opendaylight.transportpce.renderer.provisiondevice.tasks.DeviceRenderingRollbackTask;
import org.opendaylight.transportpce.renderer.provisiondevice.tasks.DeviceRenderingTask;
+import org.opendaylight.transportpce.renderer.provisiondevice.tasks.NetworkDeviceRenderingRollbackTask;
import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OlmPowerSetupRollbackTask;
import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OlmPowerSetupTask;
import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OtnDeviceRenderingTask;
import org.opendaylight.transportpce.renderer.provisiondevice.tasks.RollbackProcessor;
+import org.opendaylight.transportpce.renderer.provisiondevice.tasks.RollbackResultMessage;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.TransactionHistory;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.Action;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.OtnLinkType;
servicePathDataAtoZ.getServicePathInput().getServiceName(),
RpcStatusEx.Pending,
RENDERING_DEVICES_A_Z_MSG);
+
+ History transactionHistory = new TransactionHistory();
ListenableFuture<DeviceRenderingResult> atozrenderingFuture =
this.executor.submit(
- new DeviceRenderingTask(this.deviceRenderer, servicePathDataAtoZ, ServicePathDirection.A_TO_Z));
+ new DeviceRenderingTask(this.deviceRenderer, servicePathDataAtoZ, ServicePathDirection.A_TO_Z,
+ transactionHistory));
LOG.info(RENDERING_DEVICES_Z_A_MSG);
sendNotifications(
RENDERING_DEVICES_Z_A_MSG);
ListenableFuture<DeviceRenderingResult> ztoarenderingFuture =
this.executor.submit(
- new DeviceRenderingTask(this.deviceRenderer, servicePathDataZtoA, ServicePathDirection.Z_TO_A));
+ new DeviceRenderingTask(this.deviceRenderer, servicePathDataZtoA, ServicePathDirection.Z_TO_A,
+ transactionHistory));
ListenableFuture<List<DeviceRenderingResult>> renderingCombinedFuture =
Futures.allAsList(atozrenderingFuture, ztoarenderingFuture);
}
rollbackProcessor.addTask(
- new DeviceRenderingRollbackTask(
- "AtoZDeviceTask",
- ! renderingResults.get(0).isSuccess(),
- renderingResults.get(0).getRenderedNodeInterfaces(),
- this.deviceRenderer));
- rollbackProcessor.addTask(
- new DeviceRenderingRollbackTask("ZtoADeviceTask",
- ! renderingResults.get(1).isSuccess(),
- renderingResults.get(1).getRenderedNodeInterfaces(),
- this.deviceRenderer));
+ new NetworkDeviceRenderingRollbackTask(
+ "RollbackTransactionHistoryTask",
+ transactionHistory,
+ ! (renderingResults.get(0).isSuccess() && renderingResults.get(1).isSuccess()),
+ deviceRenderer,
+ new RollbackResultMessage()
+ )
+ );
+
return renderingResults;
}
import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRenderingResult;
import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutput;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.optical.renderer.nodes.Nodes;
import org.slf4j.Logger;
private final DeviceRendererService deviceRenderer;
private final ServicePathInputData servicePathInputData;
private final ServicePathDirection direction;
+ private final History transactionHistory;
public DeviceRenderingTask(DeviceRendererService deviceRenderer, ServicePathInputData servicePathInputData,
- ServicePathDirection direction) {
+ ServicePathDirection direction, History transactionHistory) {
this.deviceRenderer = deviceRenderer;
this.servicePathInputData = servicePathInputData;
this.direction = direction;
+ this.transactionHistory = transactionHistory;
}
@Override
case Create:
operation = "setup";
output = this.deviceRenderer.setupServicePath(this.servicePathInputData.getServicePathInput(),
- this.direction);
+ this.direction, transactionHistory);
olmList = this.servicePathInputData.getNodeLists().getOlmNodeList();
break;
case Delete:
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.tasks;
+
+import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutput;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class NetworkDeviceRenderingRollbackTask extends RollbackTask {
+
+ private final History transactionHistory;
+
+ private final boolean isRollbackNecessary;
+
+ private final DeviceRendererService deviceRendererService;
+
+ private final ResultMessage message;
+
+ private static final Logger LOG = LoggerFactory.getLogger(NetworkDeviceRenderingRollbackTask.class);
+
+ public NetworkDeviceRenderingRollbackTask(String id, History transactionHistory,
+ boolean isRollbackNecessary,
+ DeviceRendererService deviceRendererService, ResultMessage message) {
+ super(id);
+ this.transactionHistory = transactionHistory;
+ this.isRollbackNecessary = isRollbackNecessary;
+ this.deviceRendererService = deviceRendererService;
+ this.message = message;
+ }
+
+ @Override
+ public boolean isRollbackNecessary() {
+ return isRollbackNecessary;
+ }
+
+ @Override
+ public Void call() throws Exception {
+
+ RendererRollbackOutput rollbackOutput = deviceRendererService.rendererRollback(transactionHistory);
+
+ if (! rollbackOutput.getSuccess()) {
+ LOG.warn("Device rendering rollback of {} was not successful! Failed rollback on {}.", this.getId(),
+ message.createErrorMessage(rollbackOutput.nonnullFailedToRollback().values()));
+ } else {
+ LOG.info("Device rollback of {} successful.", this.getId());
+ }
+
+ return null;
+ }
+}
.setNodes(this.powerSetupInput.getNodes())
.setServiceName(this.powerSetupInput.getServiceName())
.setWaveNumber(this.powerSetupInput.getWaveNumber())
+ .setLowerSpectralSlotNumber(this.powerSetupInput.getLowerSpectralSlotNumber())
+ .setHigherSpectralSlotNumber(this.powerSetupInput.getHigherSpectralSlotNumber())
.build();
Future<RpcResult<ServicePowerTurndownOutput>> powerTurndownResultFuture =
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.tasks;
+
+import java.util.Collection;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollback;
+
+public interface ResultMessage {
+
+ /**
+ * Build an error message for a failed rollback.
+ */
+ String createErrorMessage(Collection<FailedToRollback> failedRollbacks);
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.tasks;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollback;
+
+public class RollbackResultMessage implements ResultMessage {
+
+ @Override
+ public String createErrorMessage(Collection<FailedToRollback> failedRollbacks) {
+ List<String> failedRollbackNodes = new ArrayList<>();
+
+ failedRollbacks.forEach(failedRollback -> {
+ var intf = failedRollback.getInterface();
+
+ failedRollbackNodes.add(
+ failedRollback.getNodeId()
+ + ": "
+ + intf == null ? "" : String.join(", ", intf)
+ );
+ });
+
+ return String.join(System.lineSeparator(), failedRollbackNodes);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction;
+
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Connection transaction.
+ *
+ * <p>
+ * i.e. a class tracking a connection.
+ */
+public class Connection implements Transaction {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Connection.class);
+ private final String deviceId;
+ private final String connectionNumber;
+ private final boolean isOtn;
+
+ public Connection(String deviceId, String connectionNumber, boolean isOtn) {
+ this.deviceId = deviceId;
+ this.connectionNumber = connectionNumber;
+ this.isOtn = isOtn;
+ }
+
+ @Override
+ public boolean rollback(Delete delete) {
+ List<String> supportingInterfaces = delete.deleteCrossConnect(deviceId, connectionNumber, isOtn);
+
+ if (supportingInterfaces == null || supportingInterfaces.size() == 0) {
+ return false;
+ }
+
+ LOG.info("Supporting interfaces {} affected by rollback on {} {}",
+ String.join(", ", supportingInterfaces), deviceId, connectionNumber);
+
+ return true;
+
+ }
+
+ @Override
+ public String description() {
+ return String.format("Connection %s connection number %s isOtn %s", deviceId,
+ connectionNumber, isOtn);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (!(object instanceof Connection)) {
+ return false;
+ }
+ Connection that = (Connection) object;
+ return isOtn == that.isOtn && Objects.equals(deviceId, that.deviceId)
+ && Objects.equals(connectionNumber, that.connectionNumber);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(deviceId, connectionNumber, isOtn);
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction;
+
+import java.util.Objects;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+public class DeviceInterface implements Transaction {
+
+ private final String nodeId;
+
+ private final String interfaceId;
+
+ public DeviceInterface(String nodeId, String interfaceId) {
+ this.nodeId = nodeId;
+ this.interfaceId = interfaceId;
+ }
+
+ @Override
+ public boolean rollback(Delete delete) {
+ return delete.deleteInterface(nodeId, interfaceId);
+ }
+
+ @Override
+ public String description() {
+ return String.format("Node: %s interface id: %s", nodeId, interfaceId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nodeId, interfaceId);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (!(object instanceof DeviceInterface)) {
+ return false;
+ }
+ DeviceInterface that = (DeviceInterface) object;
+ return Objects.equals(nodeId, that.nodeId) && Objects.equals(interfaceId,
+ that.interfaceId);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction;
+
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+/**
+ * Any class wishing to keep track of transactions
+ * may implement this interface.
+ */
+public interface Transaction {
+
+ /**
+ * Rollback this transaction.
+ */
+ boolean rollback(Delete delete);
+
+ String description();
+
+ int hashCode();
+
+ boolean equals(Object object);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.delete;
+
+import java.util.List;
+
+/**
+ * A class capable of deleting service connections/interfaces
+ * may implement this interface.
+ */
+public interface Delete {
+
+ /**
+ * Delete cross connection.
+ * Typically, deleted before interfaces.
+ */
+ List<String> deleteCrossConnect(String deviceId, String connectionNumber, boolean isOtn);
+
+ /**
+ * Delete an interface.
+ * Typically, deleted after the cross connection.
+ */
+ boolean deleteInterface(String nodeId, String interfaceId);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.delete;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
+import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DeleteService implements Delete {
+
+ private final CrossConnect crossConnect;
+ private final OpenRoadmInterfaces openRoadmInterfaces;
+
+ private final Subscriber subscriber;
+
+ private static final Logger LOG = LoggerFactory.getLogger(DeleteService.class);
+
+ public DeleteService(
+ CrossConnect crossConnect,
+ OpenRoadmInterfaces openRoadmInterfaces,
+ Subscriber subscriber) {
+ this.crossConnect = crossConnect;
+ this.openRoadmInterfaces = openRoadmInterfaces;
+ this.subscriber = subscriber;
+ }
+
+ @Override
+ public @NonNull List<String> deleteCrossConnect(String deviceId, String connectionNumber,
+ boolean isOtn) {
+ List<String> result = crossConnect.deleteCrossConnect(deviceId, connectionNumber, isOtn);
+
+ if (result == null) {
+ subscriber.result(false, deviceId, connectionNumber);
+ return new ArrayList<>();
+ }
+
+ subscriber.result(true, deviceId, connectionNumber);
+
+ return result;
+ }
+
+ @Override
+ public boolean deleteInterface(String nodeId, String interfaceId) {
+ try {
+ openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
+
+ subscriber.result(true, nodeId, interfaceId);
+ return true;
+ } catch (OpenRoadmInterfaceException e) {
+ LOG.error("Failed rolling back {} {}", nodeId, interfaceId);
+ subscriber.result(false, nodeId, interfaceId);
+ return false;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.delete;
+
+public class DeleteSubscriber implements Subscriber {
+
+ private final Result result;
+
+ public DeleteSubscriber(Result result) {
+ this.result = result;
+ }
+
+ @Override
+ public void result(Boolean success, String nodeId, String interfaceId) {
+
+ result.add(success, nodeId, interfaceId);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.delete;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollback;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollbackBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.renderer.rollback.output.FailedToRollbackKey;
+
+public class FailedRollbackResult implements Result {
+
+ private final Map<String, Set<String>> failedRollback = Collections.synchronizedMap(
+ new HashMap<>());
+
+ @Override
+ public boolean add(boolean success, String nodeId, String interfaceId) {
+
+ if (success) {
+ return false;
+ }
+
+ if (!failedRollback.containsKey(nodeId)) {
+ failedRollback.put(nodeId, new LinkedHashSet<>());
+ }
+
+ return failedRollback.get(nodeId).add(interfaceId);
+ }
+
+ @Override
+ public RendererRollbackOutput renderRollbackOutput() {
+
+ Map<FailedToRollbackKey, FailedToRollback> failedToRollbackList = new HashMap<>();
+
+ for (Entry<String, Set<String>> entry : failedRollback.entrySet()) {
+
+ FailedToRollback failedToRollack = new FailedToRollbackBuilder()
+ .withKey(new FailedToRollbackKey(entry.getKey()))
+ .setNodeId(entry.getKey())
+ .setInterface(entry.getValue())
+ .build();
+
+ failedToRollbackList.put(failedToRollack.key(), failedToRollack);
+
+ }
+
+ return new RendererRollbackOutputBuilder()
+ .setSuccess(failedRollback.isEmpty())
+ .setFailedToRollback(failedToRollbackList)
+ .build();
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.delete;
+
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutput;
+
+public interface Result {
+
+ boolean add(boolean success, String nodeId, String interfaceId);
+
+ RendererRollbackOutput renderRollbackOutput();
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.delete;
+
+public interface Subscriber {
+
+ void result(Boolean success, String nodeId, String interfaceId);
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.history;
+
+import java.util.List;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Transaction;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+public interface History {
+
+ /**
+ * Add transaction.
+ *
+ * <p>
+ * Only accepts the transaction if this History
+ * object doesn't already contain the object.
+ *
+ * @return true if the transaction was added.
+ */
+ boolean add(Transaction transaction);
+
+ /**
+ * A list of transactions.
+ *
+ * <p>
+ * Will only accept unique transactions.
+ * @return true if all transactions was added. false if one or more transactions was rejected.
+ */
+ boolean add(List<Transaction> transactions);
+
+ /**
+ * Add an array of interface transactions.
+ *
+ * <p>
+ * Duplicate interface ids, null or empty strings
+ * are silently ignored.
+ * @return may return false
+ */
+ boolean addInterfaces(String nodeId, String interfaceId);
+
+ /**
+ * Add an array of interface transactions.
+ *
+ * <p>
+ * Duplicate interface ids, null or empty strings
+ * are silently ignored.
+ * @return may return false
+ */
+ boolean addInterfaces(String nodeId, String[] interfaceIds);
+
+ /**
+ * Add a list of interface transactions.
+ *
+ * <p>
+ * Duplicate interface ids, null or empty strings
+ * are silently ignored.
+ */
+ boolean addInterfaces(String nodeId, List<String> interfaceIds);
+
+ /**
+ * Rollback all transactions.
+ *
+ * <p>
+ * Typically, the transactions are rolled back in reverse
+ * order, but the implementing class may choose a different
+ * logic.
+ */
+ boolean rollback(Delete delete);
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.history;
+
+import java.util.List;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Transaction;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Goldfish implementation of the History interface.
+ *
+ * <p>
+ * This implementation simply doesn't track anything.
+ * Most useful for backwards compatibility reasons.
+ */
+public class NonStickHistoryMemory implements History {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NonStickHistoryMemory.class);
+
+ @Override
+ public boolean add(Transaction transaction) {
+ LOG.warn("Transaction history disabled. Ignoring '{}'.", transaction.description());
+ return false;
+ }
+
+ @Override
+ public boolean add(List<Transaction> transactions) {
+ LOG.warn("Transaction history disabled. No rollback executed.");
+ return false;
+ }
+
+ @Override
+ public boolean addInterfaces(String nodeId, String interfaceId) {
+ LOG.warn("Transaction history disabled.");
+ return false;
+ }
+
+ @Override
+ public boolean addInterfaces(String nodeId, String[] interfaceIds) {
+ LOG.warn("Transaction history disabled.");
+ return false;
+ }
+
+ @Override
+ public boolean addInterfaces(String nodeId, List<String> interfaceIds) {
+ LOG.warn("Transaction history disabled.");
+ return false;
+ }
+
+ @Override
+ public boolean rollback(Delete delete) {
+ LOG.warn("Transaction history disabled. No rollback executed.");
+ return false;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.history;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.DeviceInterface;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Transaction;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A class keeping track of transaction history.
+ *
+ * <p>
+ * A transaction can be something like an interface or a roadm connection, that may need to be
+ * rolled back in the future.
+ */
+public class TransactionHistory implements History {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TransactionHistory.class);
+ Set<Transaction> transactionHistory = Collections.synchronizedSet(new LinkedHashSet<>());
+
+ @Override
+ public boolean add(Transaction transaction) {
+
+ boolean result = transactionHistory.add(transaction);
+
+ if (result) {
+ LOG.info("Adding {}", transaction.description());
+ } else {
+ LOG.warn("Transaction {} not added.", transaction.description());
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean add(List<Transaction> transactions) {
+ Set<Boolean> results = new HashSet<>(transactions.size());
+
+ for (Transaction transaction : transactions) {
+ results.add(add(transaction));
+ }
+
+ return results.stream().allMatch(i -> (i.equals(Boolean.TRUE)));
+ }
+
+ @Override
+ public boolean addInterfaces(String nodeId, String interfaceId) {
+ return addInterfaces(nodeId, Collections.singletonList(interfaceId));
+ }
+
+ @Override
+ public boolean addInterfaces(String nodeId, String[] interfaceIds) {
+
+ return addInterfaces(nodeId, Arrays.asList(interfaceIds));
+
+ }
+
+ @Override
+ public boolean addInterfaces(String nodeId, List<String> interfaceIds) {
+
+ Set<Boolean> results = new HashSet<>();
+ Set<String> unique = new LinkedHashSet<>();
+
+ for (String interfaceId : interfaceIds) {
+ if (interfaceId != null && !interfaceId.trim().isEmpty()) {
+ unique.add(interfaceId.trim());
+ }
+ }
+
+ for (String interfaceId : unique) {
+ results.add(this.add(new DeviceInterface(nodeId, interfaceId)));
+ }
+
+ return results.stream().allMatch(i -> (i.equals(Boolean.TRUE)));
+
+ }
+
+ @Override
+ public boolean rollback(Delete delete) {
+
+ LOG.info("History contains {} items. Rolling them back in reverse order.",
+ transactionHistory.size());
+
+ List<Transaction> reverse = new ArrayList<>(transactionHistory);
+
+ Collections.reverse(reverse);
+
+ boolean success = true;
+
+ for (Transaction transaction : reverse) {
+ LOG.info("Rolling back {}", transaction.description());
+ if (!transaction.rollback(delete)) {
+ success = false;
+ }
+ }
+
+ return success;
+
+ }
+}
\ No newline at end of file
.buildServiceImplementationRequestInputTerminationPointResource(StringConstants.TTP_TOKEN);
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
ServiceImplementationRequestOutput result =
this.rendererServiceOperations.serviceImplementation(input, false).get();
assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
.buildServiceImplementationRequestInputTerminationPointResource(StringConstants.TTP_TOKEN);
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
doReturn(RpcResultBuilder.failed().buildFuture()).when(this.olmService).servicePowerSetup(any());
ServiceImplementationRequestOutput result =
this.rendererServiceOperations.serviceImplementation(input, false).get();
.buildServiceImplementationRequestInputTerminationPointResource(StringConstants.PP_TOKEN);
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
false).get();
assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
.buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN);
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
false).get();
assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
.buildServiceImplementationRequestInputTerminationPointResource(StringConstants.CLIENT_TOKEN);
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
false).get();
assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("failed")
.setSuccess(false);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
for (String tpToken : interfaceTokens) {
ServiceImplementationRequestInput input = ServiceDataUtils
when(this.olmService.getPm(eq(getPmInputA))).thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN);
ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
when(this.olmService.getPm(any())).thenReturn(RpcResultBuilder.success(getPmOutput1).buildFuture());
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
false).get();
assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
when(this.olmService.getPm(any())).thenReturn(RpcResultBuilder.success(getPmOutput).buildFuture());
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
false).get();
assertEquals(ResponseCodes.RESPONSE_OK, result.getConfigurationResponseCommon().getResponseCode());
doReturn(RpcResultBuilder.success(getPmOutput).buildFuture()).when(this.olmService).getPm(any());
ServicePathOutputBuilder mockOutputBuilder = new ServicePathOutputBuilder().setResult("success")
.setSuccess(true);
- doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any());
+ doReturn(mockOutputBuilder.build()).when(this.deviceRenderer).setupServicePath(any(), any(), any());
ServiceImplementationRequestInput input = ServiceDataUtils
.buildServiceImplementationRequestInputTerminationPointResource(StringConstants.NETWORK_TOKEN);
ServiceImplementationRequestOutput result = this.rendererServiceOperations.serviceImplementation(input,
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+class ConnectionTest {
+
+ @Test
+ void rollback() {
+ Delete delete = Mockito.mock(Delete.class);
+ Mockito.when(delete.deleteCrossConnect("ROADM-A", "DEG1", false))
+ .thenReturn(List.of("Interface1"));
+
+ Connection n1 = new Connection("ROADM-A", "DEG1", false);
+
+ Assert.assertTrue(n1.rollback(delete));
+
+ Mockito.verify(delete, Mockito.times(1))
+ .deleteCrossConnect("ROADM-A", "DEG1", false);
+ }
+
+ @Test
+ void testTwoObjectsWithSameInformationIsEqual() {
+ Connection n1 = new Connection("ROADM-A", "DEG1", false);
+ Connection n2 = new Connection("ROADM-A", "DEG1", false);
+
+ Assert.assertTrue(n1.equals(n2));
+ }
+
+ @Test
+ void testTwoObjectsWithDifferentInformationIsNotEqual() {
+ Connection n1 = new Connection("ROADM-A", "DEG1", true);
+ Connection n2 = new Connection("ROADM-A", "DEG1", false);
+
+ Assert.assertFalse(n1.equals(n2));
+ }
+
+ @Test
+ void testTwoDifferentRoadmNodesAreNotEqual() {
+ Connection n1 = new Connection("ROADM-A", "DEG1", false);
+ Connection n2 = new Connection("ROADM-B", "DEG1", false);
+
+ Assert.assertFalse(n1.equals(n2));
+ }
+
+
+ @Test
+ void deleteReturnNull() {
+ Delete delete = Mockito.mock(Delete.class);
+ Mockito.when(delete.deleteCrossConnect("ROADM-A", "DEG1", false))
+ .thenReturn(null);
+
+ Connection n1 = new Connection("ROADM-A", "DEG1", false);
+
+ Assert.assertFalse(n1.rollback(delete));
+
+ Mockito.verify(delete, Mockito.times(1))
+ .deleteCrossConnect("ROADM-A", "DEG1", false);
+ }
+
+ @Test
+ void deleteReturnEmptyList() {
+ Delete delete = Mockito.mock(Delete.class);
+ Mockito.when(delete.deleteCrossConnect("ROADM-A", "DEG1", false))
+ .thenReturn(new ArrayList<>());
+
+ Connection n1 = new Connection("ROADM-A", "DEG1", false);
+
+ Assert.assertFalse(n1.rollback(delete));
+
+ Mockito.verify(delete, Mockito.times(1))
+ .deleteCrossConnect("ROADM-A", "DEG1", false);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction;
+
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+class DeviceInterfaceTest {
+
+ @Test
+ void rollback() {
+ Delete delete = Mockito.mock(Delete.class);
+ Mockito.when(delete.deleteInterface("ROADM-A", "DEG1")).thenReturn(true);
+
+ DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
+ Assert.assertTrue(n1.rollback(delete));
+
+ Mockito.verify(delete, Mockito.times(1)).deleteInterface("ROADM-A", "DEG1");
+ }
+
+ @Test
+ void testTwoInterfacesAreEqual() {
+ DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
+ DeviceInterface n2 = new DeviceInterface("ROADM-A", "DEG1");
+
+ Assert.assertTrue(n1.equals(n2));
+ }
+
+ @Test
+ void testTwoInterfacesAreNotEqual() {
+ DeviceInterface n1 = new DeviceInterface("ROADM-A", "DEG1");
+ DeviceInterface n2 = new DeviceInterface("ROADM-B", "DEG1");
+
+ Assert.assertFalse(n1.equals(n2));
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2024 Smartoptics 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.renderer.provisiondevice.transaction.history;
+
+import java.util.List;
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.mockito.InOrder;
+import org.mockito.Mockito;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.DeviceInterface;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.Transaction;
+import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
+
+class TransactionHistoryTest {
+
+ @Test
+ void add() {
+ Transaction transaction = Mockito.mock(Transaction.class);
+ History history = new TransactionHistory();
+
+ Assert.assertTrue(history.add(transaction));
+ }
+
+ @Test
+ void testDuplicateTransactionIsIgnored() {
+
+ Transaction t1 = new DeviceInterface("ROADM-A", "DEG1");
+ Transaction t2 = new DeviceInterface("ROADM-A", "DEG1");
+
+ History history = new TransactionHistory();
+
+ history.add(t1);
+ Assert.assertFalse(history.add(t2));
+ }
+
+ @Test
+ void testAddCollectionOfUniqueTransactions() {
+ Transaction t1 = new DeviceInterface("ROADM-A", "DEG1");
+ Transaction t2 = new DeviceInterface("ROADM-A", "DEG2");
+
+ List<Transaction> transactions = List.of(t1, t2);
+
+ History history = new TransactionHistory();
+
+ Assert.assertTrue(history.add(transactions));
+ }
+
+ @Test
+ void testAddCollectionOfDuplicateTransactions() {
+ Transaction t1 = new DeviceInterface("ROADM-A", "DEG1");
+ Transaction t2 = new DeviceInterface("ROADM-A", "DEG1");
+
+ List<Transaction> transactions = List.of(t1, t2);
+
+ History history = new TransactionHistory();
+
+ Assert.assertFalse(history.add(transactions));
+ }
+
+ @Test
+ void testAddUniqueStringOfInterfaceIds() {
+ String nodeId = "ROADM-A";
+ String[] interfaces = new String[]{"DEG1", "DEG2"};
+
+ History history = new TransactionHistory();
+
+ Assert.assertTrue(history.addInterfaces(nodeId, interfaces));
+ }
+
+ @Test
+ void testAddDuplicateStringOfInterfaceIds() {
+ String nodeId = "ROADM-A";
+ String[] interfaces = new String[]{"DEG1", "DEG1"};
+
+ History history = new TransactionHistory();
+
+ Assert.assertTrue(history.addInterfaces(nodeId, interfaces));
+
+ }
+
+ @Test
+ void testAddDuplicateListOfInterfaceIds() {
+ String nodeId = "ROADM-A";
+ List<String> interfaces = List.of("DEG1", "DEG1");
+
+ History history = new TransactionHistory();
+
+ Assert.assertTrue(history.addInterfaces(nodeId, interfaces));
+
+ }
+
+ @Test
+ void rollbackOneInterface() {
+
+ String nodeId = "ROADM-A";
+ List<String> interfaces = List.of("DEG1", "DEG1");
+
+ History history = new TransactionHistory();
+ history.addInterfaces(nodeId, interfaces);
+
+ Delete delete = Mockito.mock(Delete.class);
+ Mockito.when(delete.deleteInterface("ROADM-A", "DEG1")).thenReturn(true);
+
+ Assert.assertTrue(history.rollback(delete));
+
+ //Although the same interface was added twice, we only rollback once.
+ Mockito.verify(delete, Mockito.times(1))
+ .deleteInterface("ROADM-A", "DEG1");
+ }
+
+ @Test
+ void rollbackTwoInterfacesInReverseOrderTheyWereAdded() {
+
+ String nodeId = "ROADM-A";
+
+ //Note DEG1 is added before DEG2
+ List<String> interfaces = List.of("DEG1", "DEG2");
+
+ History history = new TransactionHistory();
+ history.addInterfaces(nodeId, interfaces);
+
+ Delete delete = Mockito.mock(Delete.class);
+ Mockito.when(delete.deleteInterface("ROADM-A", "DEG1")).thenReturn(true);
+ Mockito.when(delete.deleteInterface("ROADM-A", "DEG2")).thenReturn(true);
+
+ Assert.assertTrue(history.rollback(delete));
+
+ //The rollback occurs in the reverse order.
+ // i.e. DEG2 before DEG1.
+ InOrder inOrder = Mockito.inOrder(delete);
+ inOrder.verify(delete, Mockito.times(1))
+ .deleteInterface("ROADM-A", "DEG2");
+ inOrder.verify(delete, Mockito.times(1))
+ .deleteInterface("ROADM-A", "DEG1");
+
+ }
+}
\ No newline at end of file
} else {
deleteServiceOperationResult = this.serviceDataStoreOperations.deleteService(serviceName);
}
- if (deleteServiceOperationResult.isSuccess()) {
+ if (!deleteServiceOperationResult.isSuccess()) {
LOG.warn("{}Service was not removed from datastore!", serviceType);
}
}
try {
LOG.info("initializing service registry");
WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction();
- transaction.put(
+ transaction.merge(
LogicalDatastoreType.OPERATIONAL,
InstanceIdentifier.create(ServiceList.class),
new ServiceListBuilder().build());
try {
LOG.info("initializing temp service registry");
WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction();
- transaction.put(
+ transaction.merge(
LogicalDatastoreType.OPERATIONAL,
InstanceIdentifier.create(TempServiceList.class),
new TempServiceListBuilder().build());
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ServiceType;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointKey;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnection;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionKey;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology;
public final class ConnectivityUtils {
- private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
- .getBytes(StandardCharsets.UTF_8)).toString());
+ private final Uuid tapiTopoUuid = new Uuid(
+ UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)).toString());
private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class);
private final ServiceDataStoreOperations serviceDataStoreOperations;
private final TapiContext tapiContext;
private Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap;
+ // this variable is for complete connection objects
private final Map<
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionKey,
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection>
- connectionFullMap; // this variable is for complete connection objects
+ connectionFullMap;
private final NetworkTransactionService networkTransactionService;
private Connection topConnRdmRdm;
private Connection topConnXpdrXpdrPhtn;
.setServiceName("service test")
.setServiceAEnd(serviceAEnd)
.setServiceZEnd(serviceZEnd)
- .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
- .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
- "appname")
- .build())
+ .setSdncRequestHeader(
+ new SdncRequestHeaderBuilder()
+ .setRequestId("request-1")
+ .setRpcAction(RpcActions.ServiceCreate)
+ .setNotificationUrl("notification url")
+ .setRequestSystemId("appname")
+ .build())
.build();
}
- public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
- String txPortName, String rxPortDeviceName, String rxPortName) {
+ public static ServiceAEnd buildServiceAEnd(
+ String nodeid, String clli, String txPortDeviceName,
+ String txPortName, String rxPortDeviceName, String rxPortName) {
return new ServiceAEndBuilder()
.setClli(clli)
.setNodeId(new NodeIdType(nodeid))
.setOpticType(OpticTypes.Gray)
.setServiceFormat(ServiceFormat.Ethernet)
.setServiceRate(Uint32.valueOf(100))
- .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder()
- .setPort(new PortBuilder()
- .setPortDeviceName(txPortDeviceName)
- .setPortName(txPortName)
- .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
- .setPortShelf("00")
- .setPortType(TapiStringConstants.PORT_TYPE)
- .build())
- .setLgx(new LgxBuilder()
- .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
- .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
- .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
- .setLgxPortShelf("00")
- .build())
- .build()))
- .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder()
- .setPort(new PortBuilder()
- .setPortDeviceName(rxPortDeviceName)
- .setPortName(rxPortName)
- .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
- .setPortShelf("00")
- .setPortType(TapiStringConstants.PORT_TYPE)
- .build())
- .setLgx(new LgxBuilder()
- .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
- .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
- .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
- .setLgxPortShelf("00")
- .build())
- .build()))
+ .setTxDirection(Map.of(
+ new TxDirectionKey(Uint8.ZERO),
+ new TxDirectionBuilder()
+ .setPort(new PortBuilder()
+ .setPortDeviceName(txPortDeviceName)
+ .setPortName(txPortName)
+ .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
+ .setPortShelf("00")
+ .setPortType(TapiStringConstants.PORT_TYPE)
+ .build())
+ .setLgx(new LgxBuilder()
+ .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
+ .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
+ .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
+ .setLgxPortShelf("00")
+ .build())
+ .build()))
+ .setRxDirection(Map.of(
+ new RxDirectionKey(Uint8.ZERO),
+ new RxDirectionBuilder()
+ .setPort(new PortBuilder()
+ .setPortDeviceName(rxPortDeviceName)
+ .setPortName(rxPortName)
+ .setPortRack(TapiStringConstants.PORT_RACK_VALUE)
+ .setPortShelf("00")
+ .setPortType(TapiStringConstants.PORT_TYPE)
+ .build())
+ .setLgx(new LgxBuilder()
+ .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME)
+ .setLgxPortName(TapiStringConstants.LGX_PORT_NAME)
+ .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE)
+ .setLgxPortShelf("00")
+ .build())
+ .build()))
.build();
}
- public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
- String txPortName, String rxPortDeviceName, String rxPortName) {
+ public static ServiceZEnd buildServiceZEnd(
+ String nodeid, String clli, String txPortDeviceName,
+ String txPortName, String rxPortDeviceName, String rxPortName) {
return new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid))
.setOpticType(OpticTypes.Gray)
.setServiceFormat(ServiceFormat.Ethernet)
LOG.info("Service = {}", service);
Optional<ServicePaths> optServicePaths =
this.serviceDataStoreOperations.getServicePath(service.getServiceName());
- if (!optServicePaths.isPresent()) {
+ if (optServicePaths.isEmpty()) {
LOG.error("No service path found for service {}", service.getServiceName());
return null;
}
- ServicePaths servicePaths = optServicePaths.orElseThrow();
- PathDescription pathDescription = servicePaths.getPathDescription();
+ PathDescription pathDescription = optServicePaths.orElseThrow().getPathDescription();
LOG.info("Path description of service = {}", pathDescription);
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd serviceAEnd
- = service.getServiceAEnd();
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd serviceAEnd =
+ service.getServiceAEnd();
// Endpoint creation
EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription);
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd serviceZEnd
- = service.getServiceZEnd();
- EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription);
- Map<EndPointKey, EndPoint> endPointMap = new HashMap<>();
- endPointMap.put(endPoint1.key(), endPoint1);
- endPointMap.put(endPoint2.key(), endPoint2);
+ EndPoint endPoint2 = mapServiceZEndPoint(service.getServiceZEnd(), pathDescription);
+ Map<EndPointKey, EndPoint> endPointMap = new HashMap<>(Map.of(
+ endPoint1.key(), endPoint1,
+ endPoint2.key(), endPoint2));
LOG.info("EndPoints of connectivity services = {}", endPointMap);
// Services Names
- Name name = new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName())
- .build();
+ Name name =
+ new NameBuilder().setValueName("Connectivity Service Name").setValue(service.getServiceName()).build();
// Connection creation
Map<ConnectionKey, Connection> connMap =
createConnectionsFromService(pathDescription, mapServiceLayerToAend(serviceAEnd));
- LOG.debug("connectionMap for service {} = {} ", name.toString(), connMap.toString());
+ LOG.debug("connectionMap for service {} = {} ", name, connMap);
ConnectivityConstraint conConstr =
new ConnectivityConstraintBuilder().setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY).build();
// TODO: full connectivity service?? With constraints and the rest of fields...
.setAdministrativeState(AdministrativeState.UNLOCKED)
.setOperationalState(OperationalState.ENABLED)
.setLifecycleState(LifecycleState.INSTALLED)
- .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(StandardCharsets.UTF_8))
- .toString()))
+ .setUuid(new Uuid(
+ UUID.nameUUIDFromBytes(service.getServiceName().getBytes(StandardCharsets.UTF_8)).toString()))
.setLayerProtocolName(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2))
.setConnectivityConstraint(conConstr)
.setDirection(ForwardingDirection.BIDIRECTIONAL)
.build();
}
- public Map<ConnectionKey, Connection> createConnectionsFromService(PathDescription pathDescription,
- LayerProtocolName lpn) {
+ public Map<ConnectionKey, Connection> createConnectionsFromService(
+ PathDescription pathDescription, LayerProtocolName lpn) {
Map<ConnectionKey, Connection> connectionServMap = new HashMap<>();
// build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs
// and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs
List<String> rdmNodelist = new ArrayList<>();
List<String> xpdrNodelist = new ArrayList<>();
for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream()
- .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) {
+ .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) {
resourceType = elem.getResource().getResource().implementedInterface().getSimpleName();
switch (resourceType) {
case TapiStringConstants.TP:
// - XC Connection between OTSiMC CEPs mapped from OTSiMC NEPs (within a roadm)
// - Top Connection MC betwwen MC CEPs of different roadms
// - Top Connection OTSiMC betwwen OTSiMC CEPs of extreme roadms
- connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
- edgeRoadm1, edgeRoadm2));
+ connectionServMap.putAll(
+ createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2));
if (!pathDescription.getAToZDirection().getAToZ().values().stream().findFirst().orElseThrow().getId()
- .contains("ROADM")) {
+ .contains("ROADM")) {
// - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr
// - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi
connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
// Check if OC, OTU and ODU are created
if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) {
LOG.info("WDM ETH service");
- connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist,
- edgeRoadm1, edgeRoadm2));
+ connectionServMap.putAll(
+ createRoadmCepsAndConnections(
+ rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2));
connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist));
this.topConnRdmRdm = null;
xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist);
LOG.info("Associated client ports = {}", xpdrClientTplist);
- connectionServMap.putAll(createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist,
- connectionServMap));
+ connectionServMap.putAll(
+ createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist, connectionServMap));
this.topConnXpdrXpdrPhtn = null;
}
break;
// TODO: We create both ODU and DSR because there is no ODU service creation for the switch
// - XC Connection OTSi between iODU and eODU of xpdr
// - Top connection in the ODU layer, between xpdr eODU ports (?)
- connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
- xpdrNodelist));
+ connectionServMap.putAll(
+ createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, xpdrNodelist));
this.topConnXpdrXpdrPhtn = null;
}
if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) {
// TODO: OTN service but mux has 3 steps at rendering. Verify that things exist
- connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist,
- xpdrNodelist));
+ connectionServMap.putAll(
+ createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, xpdrNodelist));
this.topConnXpdrXpdrOdu = null;
}
break;
default:
LOG.error("Service type format not supported");
}
- LOG.debug("CONNSERVERMAP = {}", connectionServMap.toString());
+ LOG.debug("CONNSERVERMAP = {}", connectionServMap);
return connectionServMap;
}
.child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid))
.build();
try {
- Optional<OwnedNodeEdgePoint> optionalOnep = this.networkTransactionService.read(
- LogicalDatastoreType.OPERATIONAL, onepIID).get();
+ Optional<OwnedNodeEdgePoint> optionalOnep =
+ this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, onepIID).get();
if (optionalOnep.isPresent()) {
LOG.error("ONEP is already present in datastore");
return;
}
// merge in datastore
- this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID,
- onep);
+ this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onep);
this.networkTransactionService.commit().get();
- LOG.info("NEP {} added successfully.", onep.getName().toString());
+ LOG.info("NEP {} added successfully.", onep.getName());
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Couldnt put NEP {} in topology, error = ", onep.getName().toString(), e);
+ LOG.error("Couldnt put NEP {} in topology, error = ", onep.getName(), e);
}
}
public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
// TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
- Map<org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPointKey,
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint>
- endPointMap = input.getEndPoint();
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .create.connectivity.service.input.EndPointKey,
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .create.connectivity.service.input.EndPoint> endPointMap = input.getEndPoint();
ConnectionType connType = null;
ServiceFormat serviceFormat = null;
- String nodeAid = String.join("+", endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
+ String nodeAid = String.join("+",
+ endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
TapiStringConstants.XPDR);
- String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
+ String nodeZid = String.join("+",
+ endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
TapiStringConstants.XPDR);
LOG.info("NodeAid = {}", nodeAid);
LOG.info("NodeZid = {}", nodeZid);
Uint64 capacity = Uint64.valueOf(Math.abs(
input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue().intValue()));
// map endpoints into service end points. Map the type of service from TAPI to OR
- ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().orElseThrow(),
+ ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(
+ endPointMap.values().stream().findFirst().orElseThrow(),
serviceFormat, nodeAid, capacity, input.getLayerProtocolName());
- ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst()
- .orElseThrow(), serviceFormat, nodeZid, capacity, input.getLayerProtocolName());
+ ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(
+ endPointMap.values().stream().skip(1).findFirst().orElseThrow(),
+ serviceFormat, nodeZid, capacity, input.getLayerProtocolName());
if (serviceAEnd == null || serviceZEnd == null) {
LOG.error("Couldnt map endpoints to service end");
return null;
}
private LayerProtocolName mapServiceLayerToAend(
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd
- serviceAEnd) {
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+ .service.ServiceAEnd serviceAEnd) {
ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
switch (serviceFormat) {
case OC:
case ODU:
return LayerProtocolName.ODU;
case Ethernet:
- if (getOpenroadmType(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
- .getPortDeviceName()).equals(OpenroadmNodeType.TPDR)) {
+ if (getOpenroadmType(
+ serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow()
+ .getPort().getPortDeviceName())
+ .equals(OpenroadmNodeType.TPDR)) {
return LayerProtocolName.ETH;
}
return LayerProtocolName.DSR;
}
return null;
}
+ //TODO factorize these two similar methods
private OpenroadmNodeType getOpenroadmType(String nodeName) {
LOG.info("Node name = {}", nodeName);
- Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",nodeName, TapiStringConstants.XPDR))
- .getBytes(StandardCharsets.UTF_8)).toString());
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node tapiNode
- = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
- if (tapiNode != null) {
- return OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type"))
- .getValue());
- }
- return null;
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node tapiNode =
+ this.tapiContext.getTapiNode(
+ this.tapiTopoUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+",nodeName, TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
+ .toString()));
+ return tapiNode == null
+ ? null
+ : OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type")).getValue());
}
- private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(List<String> xpdrClientTplist,
- List<String> xpdrNodelist,
- Map<ConnectionKey, Connection> lowerConn) {
+ private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(
+ List<String> xpdrClientTplist, List<String> xpdrNodelist, Map<ConnectionKey, Connection> lowerConn) {
// TODO: do we need to create cross connection between iODU and eODU??
// add the lower connections of the previous steps for this kind of service
Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
xcMap.put(conn.key(), conn);
}
- Map<ConnectionKey, Connection> connServMap = new HashMap<>();
- Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
- ConnectionEndPoint> cepMapDsr = new HashMap<>();
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapDsr = new HashMap<>();
// Create 1 cep per Xpdr in the CLIENT
// 1 top connection DSR between the CLIENT xpdrs
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
- .orElseThrow();
- ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR,
- LayerProtocolName.DSR);
- putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR,
- TapiStringConstants.XPDR, netCep1);
-
+ String spcXpdrClient =
+ xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
+ ConnectionEndPoint netCep1 =
+ createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, LayerProtocolName.DSR);
+ putXpdrCepInTopologyContext(
+ xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, netCep1);
cepMapDsr.put(netCep1.key(), netCep1);
}
- String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().orElseThrow();
- String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
-
// DSR top connection between edge xpdr CLIENT DSR
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
- LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connectionDsr =
+ createTopConnection(
+ //spcXpdr1,
+ xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
+ .findFirst().orElseThrow(),
+ //spcXpdr2,
+ xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
+ .findFirst().orElseThrow(),
+ cepMapDsr, TapiStringConstants.DSR, LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
-
// DSR top connection that will be added to the service object
Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
- connServMap.put(conn1.key(), conn1);
-
- return connServMap;
+ return new HashMap<>(Map.of(conn1.key(), conn1));
}
- private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(List<String> xpdrClientTplist,
- List<String> xpdrNetworkTplist,
- List<String> xpdrNodelist) {
+ private Map<ConnectionKey,Connection> createXpdrCepsAndConnectionsDsr(
+ List<String> xpdrClientTplist, List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
Map<ConnectionKey, Connection> connServMap = new HashMap<>();
- Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
- ConnectionEndPoint> cepMapDsr = new HashMap<>();
- Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
- ConnectionEndPoint> cepMapOdu = new HashMap<>();
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapDsr = new HashMap<>();
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMapOdu = new HashMap<>();
// TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
// be added to the lower connection of a top connection
Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
// 1 top connection between eODU and a top connection DSR between the CLIENT xpdrs
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
- .orElseThrow();
- ConnectionEndPoint clientCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR,
- TapiStringConstants.XPDR, LayerProtocolName.DSR);
- putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR,
- clientCep1);
-
- ConnectionEndPoint clientCep2 = createCepXpdr(spcXpdrClient, TapiStringConstants.E_ODU,
- TapiStringConstants.XPDR, LayerProtocolName.ODU);
- putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR,
- clientCep2);
-
- String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
- ConnectionEndPoint netCep3 = getAssociatediODUCep(spcXpdrNetwork);
-
+ String spcXpdrClient =
+ xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
+ ConnectionEndPoint clientCep1 =
+ createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, LayerProtocolName.DSR);
+ putXpdrCepInTopologyContext(
+ xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, clientCep1);
+ ConnectionEndPoint clientCep2 = createCepXpdr(
+ spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR, LayerProtocolName.ODU);
+ putXpdrCepInTopologyContext(
+ xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR, clientCep2);
cepMapDsr.put(clientCep1.key(), clientCep1);
cepMapOdu.put(clientCep2.key(), clientCep2);
+
+ String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist);
// Create x connection between I_ODU and E_ODU within xpdr
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- connection = createXCBetweenCeps(clientCep2, netCep3, spcXpdrClient, spcXpdrNetwork,
- TapiStringConstants.ODU, LayerProtocolName.ODU);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connection =
+ createXCBetweenCeps(
+ clientCep2, getAssociatediODUCep(spcXpdrNetwork),
+ spcXpdrClient, spcXpdrNetwork, TapiStringConstants.ODU, LayerProtocolName.ODU);
this.connectionFullMap.put(connection.key(), connection);
// Create X connection that will be added to the service object
}
// DSR top connection between edge xpdr CLIENT DSR
- String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().orElseThrow();
- String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
-
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
- LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu);
+ String spcXpdr1 =
+ xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
+ .findFirst().orElseThrow();
+ String spcXpdr2 =
+ xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
+ .findFirst().orElseThrow();
+
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connectionOdu =
+ createTopConnection(
+ spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU,
+ LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu);
this.connectionFullMap.put(connectionOdu.key(), connectionOdu);
// ODU top connection that will be added to the service object
LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build();
xcMap.put(lowerConn.key(), lowerConn);
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
- LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connectionDsr =
+ createTopConnection(
+ spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
+ LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
-
// DSR top connection that will be added to the service object
Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
connServMap.put(conn1.key(), conn1);
-
return connServMap;
}
- private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(List<String> xpdrNetworkTplist,
- List<String> xpdrNodelist) {
+ private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsOdu(
+ List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
Map<ConnectionKey, Connection> connServMap = new HashMap<>();
- Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
- ConnectionEndPoint> cepMap = new HashMap<>();
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
// TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
// be added to the lower connection of a top connection
- Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
-
// Create 1 cep per Xpdr in the I_ODU and a top
// connection iODU between the xpdrs
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
- .orElseThrow();
- ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU,
- TapiStringConstants.XPDR, LayerProtocolName.ODU);
- putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR,
- netCep1);
-
+ String spcXpdrNetwork =
+ xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
+ ConnectionEndPoint netCep1 =
+ createCepXpdr(
+ spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, LayerProtocolName.ODU);
+ putXpdrCepInTopologyContext(
+ xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, netCep1);
cepMap.put(netCep1.key(), netCep1);
}
-
// ODU top connection between edge xpdr i_ODU
- String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().orElseThrow();
- String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU,
- LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrPhtn);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connection =
+ createTopConnection(
+ //spcXpdr1,
+ xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
+ .findFirst().orElseThrow(),
+ //spcXpdr2,
+ xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
+ .findFirst().orElseThrow(),
+ cepMap, TapiStringConstants.I_ODU,
+ LayerProtocolName.ODU, new HashMap<>(), this.topConnXpdrXpdrPhtn);
this.connectionFullMap.put(connection.key(), connection);
-
// ODU top connection that will be added to the service object
Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
connServMap.put(conn.key(), conn);
this.topConnXpdrXpdrOdu = conn;
-
return connServMap;
}
- private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(List<String> xpdrNetworkTplist,
- List<String> xpdrNodelist) {
-
+ private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsPht(
+ List<String> xpdrNetworkTplist, List<String> xpdrNodelist) {
// TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will
// be added to the lower connection of a top connection
Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
// create ceps and x connections within xpdr
for (String xpdr:xpdrNodelist) {
LOG.info("Creating ceps and xc for xpdr {}", xpdr);
- String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
- .orElseThrow();
+ String spcXpdrNetwork =
+ xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().orElseThrow();
// There should be 1 network tp per xpdr
// Just create 2 different CEPs (1 OTS + 1 OTSI_MC)
- ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
- TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
- putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
- TapiStringConstants.XPDR, netCep1);
- ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.OTSI_MC,
- TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
- putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR,
- netCep2);
+ ConnectionEndPoint netCep1 = createCepXpdr(
+ spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS,
+ TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
+ putXpdrCepInTopologyContext(
+ xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.XPDR, netCep1);
+ ConnectionEndPoint netCep2 = createCepXpdr(
+ spcXpdrNetwork, TapiStringConstants.OTSI_MC,
+ TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
+ putXpdrCepInTopologyContext(
+ xpdr, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR, netCep2);
// ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI,
// TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA);
// putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI,
// netCep3);
-
cepMap.put(netCep1.key(), netCep1);
cepMap.put(netCep2.key(), netCep2);
// cepMap.put(netCep3.key(), netCep3);
}
-
// OTSi top connection between edge OTSI_MC Xpdr
- Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
- String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(0))).findFirst().orElseThrow();
- String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist
- .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.OTSI_MC,
- LayerProtocolName.PHOTONICMEDIA, xcMap, this.topConnRdmRdm);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connection =
+ createTopConnection(
+ //spcXpdr1,
+ xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(0)))
+ .findFirst().orElseThrow(),
+ //spcXpdr2,
+ xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist.get(xpdrNodelist.size() - 1)))
+ .findFirst().orElseThrow(),
+ cepMap, TapiStringConstants.OTSI_MC,
+ LayerProtocolName.PHOTONICMEDIA, new HashMap<>(), this.topConnRdmRdm);
this.connectionFullMap.put(connection.key(), connection);
-
- // OTSi top connection that will be added to the service object
- Map<ConnectionKey, Connection> connServMap = new HashMap<>();
+ // OTSi top connection that will be added to the service object
Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
- connServMap.put(conn.key(), conn);
this.topConnXpdrXpdrPhtn = conn;
-
- return connServMap;
+ return new HashMap<>(Map.of(conn.key(), conn));
}
- private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(List<String> rdmAddDropTplist,
- List<String> rdmDegTplist,
- List<String> rdmNodelist,
- String edgeRoadm1, String edgeRoadm2) {
+ private Map<ConnectionKey, Connection> createRoadmCepsAndConnections(
+ List<String> rdmAddDropTplist, List<String> rdmDegTplist, List<String> rdmNodelist,
+ String edgeRoadm1, String edgeRoadm2) {
// TODO: will need to check if things exist already or not
- Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
- ConnectionEndPoint> cepMap = new HashMap<>();
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap = new HashMap<>();
// create ceps and x connections within roadm
Map<LowerConnectionKey, LowerConnection> xcLowerMap = new HashMap<>();
for (String roadm : rdmNodelist) {
LOG.info("Creating ceps and xc for roadm {}", roadm);
if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) {
LOG.info("EDGE ROADM, cross connections needed between SRG and DEG");
- String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst()
- .orElseThrow();
+ String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm))
+ .findFirst().orElseThrow();
LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD);
// There should be only 1 AD and 1 DEG per roadm
// TODO photonic media model should be updated to have the corresponding CEPs. I will just create
LOG.info("Going to create cross connections for ROADM {}", roadm);
// Create X connections between MC and OTSi_MC for full map
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection1
- = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connection1 =
+ createXCBetweenCeps(
+ adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC,
LayerProtocolName.PHOTONICMEDIA);
- LOG.info("Cross connection 1 created = {}", connection1.toString());
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2
- = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
- LayerProtocolName.PHOTONICMEDIA);
- LOG.info("Cross connection 2 created = {}", connection2.toString());
+ LOG.info("Cross connection 1 created = {}", connection1);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connection2 =
+ createXCBetweenCeps(
+ adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC,
+ LayerProtocolName.PHOTONICMEDIA);
+ LOG.info("Cross connection 2 created = {}", connection2);
this.connectionFullMap.put(connection1.key(), connection1);
this.connectionFullMap.put(connection2.key(), connection2);
cepMap.put(deg1Cep2.key(), deg1Cep2);
cepMap.put(deg1Cep3.key(), deg1Cep3);
- String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst()
- .orElseThrow();
+ String spcRdmDEG2 =
+ rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst().orElseThrow();
LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2);
ConnectionEndPoint deg2Cep0 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS);
LOG.info("Going to create cross connections for ROADM {}", roadm);
// Create X connections between MC and OTSi_MC for full map
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection1
- = createXCBetweenCeps(deg1Cep2, deg2Cep2, spcRdmDEG1, spcRdmDEG2,
- TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA);
- LOG.info("Cross connection 1 created = {}", connection1.toString());
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2
- = createXCBetweenCeps(deg1Cep3, deg2Cep3, spcRdmDEG1, spcRdmDEG2,
- TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connection1 =
+ createXCBetweenCeps(
+ deg1Cep2, deg2Cep2, spcRdmDEG1, spcRdmDEG2,
+ TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA);
+ LOG.info("Cross connection 1 created = {}", connection1);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connection2 =
+ createXCBetweenCeps(
+ deg1Cep3, deg2Cep3, spcRdmDEG1, spcRdmDEG2,
+ TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA);
LOG.info("Cross connection 2 created = {}", connection2.toString());
this.connectionFullMap.put(connection1.key(), connection1);
this.connectionFullMap.put(connection2.key(), connection2);
// Create X connections that will be added to the service object
LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
- LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
-
xcLowerMap.put(conn1.key(), conn1);
+ LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build();
xcLowerMap.put(conn2.key(), conn2);
}
}
String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().orElseThrow();
// MC top connection between edge roadms
LOG.info("Going to created top connection between MC");
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
- LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connection =
+ createTopConnection(
+ spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC,
+ LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null);
this.connectionFullMap.put(connection.key(), connection);
- LOG.info("Top connection created = {}", connection.toString());
+ LOG.info("Top connection created = {}", connection);
- Map<ConnectionKey, Connection> connServMap = new HashMap<>();
- // OTSiMC top connections that will be added to the service object
- Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
- connServMap.put(conn.key(), conn);
LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
- Map<LowerConnectionKey, LowerConnection> topLowerMap = new HashMap<>();
- topLowerMap.put(conn1.key(), conn1);
-
// OTSiMC top connection between edge roadms
LOG.info("Going to created top connection between OTSiMC");
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- connection1 = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
- LayerProtocolName.PHOTONICMEDIA, topLowerMap, null);
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection connection1 =
+ createTopConnection(
+ spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC,
+ LayerProtocolName.PHOTONICMEDIA,
+ //topLowerMap,
+ new HashMap<>(Map.of(conn1.key(), conn1)),
+ null);
this.connectionFullMap.put(connection1.key(), connection1);
- LOG.info("Top connection created = {}", connection1.toString());
+ LOG.info("Top connection created = {}", connection1);
// OTSiMC top connections that will be added to the service object
+ Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build();
Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build();
- connServMap.put(conn2.key(), conn2);
this.topConnRdmRdm = conn2;
- return connServMap;
+ return new HashMap<>(Map.of(conn.key(), conn, conn2.key(), conn2));
}
- private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- createTopConnection(String tp1, String tp2,
- Map<org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
- ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol,
- Map<LowerConnectionKey, LowerConnection> xcMap, Connection additionalLowerConn) {
+ private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection createTopConnection(
+ String tp1,
+ String tp2,
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .cep.list.ConnectionEndPointKey, ConnectionEndPoint> cepMap,
+ String qual, LayerProtocolName topPortocol,
+ Map<LowerConnectionKey, LowerConnection> xcMap,
+ Connection additionalLowerConn) {
// find cep for each AD MC of roadm 1 and 2
- LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual));
+ String topConnName = String.join("+", "TOP", tp1, tp2, qual);
+ LOG.info("Top connection name = {}", topConnName);
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep1 =
- cepMap.get(new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey(
- new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0],
- qual, tp1.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
- .toString())));
+ cepMap.get(
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .cep.list.ConnectionEndPointKey(new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "CEP", tp1.split("\\+")[0], qual, tp1.split("\\+")[1]))
+ .getBytes(StandardCharsets.UTF_8)).toString())));
LOG.info("ADCEP1 = {}", adCep1);
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cep1 =
- new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connection.ConnectionEndPoint cep1 =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(adCep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
.setNodeUuid(adCep1.getParentNodeEdgePoint().getNodeUuid())
.setTopologyUuid(adCep1.getParentNodeEdgePoint().getTopologyUuid())
.setConnectionEndPointUuid(adCep1.getUuid())
.build();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep2 =
- cepMap.get(new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey(
- new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0],
- qual, tp2.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
- .toString())));
+ cepMap.get(
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .cep.list.ConnectionEndPointKey(
+ new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "CEP", tp2.split("\\+")[0], qual, tp2.split("\\+")[1]))
+ .getBytes(StandardCharsets.UTF_8)).toString())));
LOG.info("ADCEP2 = {}", adCep2);
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cep2 =
- new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connection.ConnectionEndPoint cep2 =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connection.ConnectionEndPointBuilder()
.setNodeEdgePointUuid(adCep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
.setNodeUuid(adCep2.getParentNodeEdgePoint().getNodeUuid())
.setTopologyUuid(adCep2.getParentNodeEdgePoint().getTopologyUuid())
.setConnectionEndPointUuid(adCep1.getUuid())
.build();
- Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>();
- ceps.put(cep1.key(), cep1);
- ceps.put(cep2.key(), cep2);
Name connName = new NameBuilder()
.setValueName("Connection name")
- .setValue(String.join("+", "TOP", tp1, tp2, qual))
+ .setValue(topConnName)
.build();
// TODO: lower connection, supported link.......
if (additionalLowerConn != null) {
xcMap.putIfAbsent(new LowerConnectionKey(additionalLowerConn.getConnectionUuid()),
new LowerConnectionBuilder().setConnectionUuid(additionalLowerConn.getConnectionUuid()).build());
}
- return new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder()
- .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual))
- .getBytes(StandardCharsets.UTF_8)).toString()))
+ return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.ConnectionBuilder()
+ .setUuid(new Uuid(UUID.nameUUIDFromBytes(topConnName.getBytes(StandardCharsets.UTF_8)).toString()))
.setName(Map.of(connName.key(), connName))
- .setConnectionEndPoint(ceps)
+ .setConnectionEndPoint(new HashMap<>(Map.of(cep1.key(), cep1, cep2.key(), cep2)))
.setOperationalState(OperationalState.ENABLED)
.setLayerProtocolName(topPortocol)
.setLifecycleState(LifecycleState.INSTALLED)
.build();
}
- private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
- createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual,
- LayerProtocolName xcProtocol) {
+ private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection createXCBetweenCeps(
+ ConnectionEndPoint cep1, ConnectionEndPoint cep2,
+ String tp1, String tp2, String qual, LayerProtocolName xcProtocol) {
+ String crossConnName = String.join("+", "XC", tp1, tp2, qual);
LOG.info("Creation cross connection between: {} and {}", tp1, tp2);
- LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual));
- LOG.debug("Parent NEP of CEP1 = {}", cep1.getParentNodeEdgePoint().toString());
- LOG.debug("Parent NEP CEP2 = {}", cep2.getParentNodeEdgePoint().toString());
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ1 =
- new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
- .setNodeEdgePointUuid(cep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
- .setNodeUuid(cep1.getParentNodeEdgePoint().getNodeUuid())
- .setTopologyUuid(cep1.getParentNodeEdgePoint().getTopologyUuid())
- .setConnectionEndPointUuid(cep1.getUuid())
- .build();
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ2 =
- new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder()
- .setNodeEdgePointUuid(cep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
- .setNodeUuid(cep2.getParentNodeEdgePoint().getNodeUuid())
- .setTopologyUuid(cep2.getParentNodeEdgePoint().getTopologyUuid())
- .setConnectionEndPointUuid(cep2.getUuid())
- .build();
- Map<ConnectionEndPointKey, org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>();
- ceps.put(cepServ1.key(), cepServ1);
- ceps.put(cepServ2.key(), cepServ2);
+ LOG.info("Cross connection name = {}", crossConnName);
+ LOG.debug("Parent NEP of CEP1 = {}", cep1.getParentNodeEdgePoint());
+ LOG.debug("Parent NEP CEP2 = {}", cep2.getParentNodeEdgePoint());
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connection.ConnectionEndPoint cepServ1 =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connection.ConnectionEndPointBuilder()
+ .setNodeEdgePointUuid(cep1.getParentNodeEdgePoint().getNodeEdgePointUuid())
+ .setNodeUuid(cep1.getParentNodeEdgePoint().getNodeUuid())
+ .setTopologyUuid(cep1.getParentNodeEdgePoint().getTopologyUuid())
+ .setConnectionEndPointUuid(cep1.getUuid())
+ .build();
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connection.ConnectionEndPoint cepServ2 =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connection.ConnectionEndPointBuilder()
+ .setNodeEdgePointUuid(cep2.getParentNodeEdgePoint().getNodeEdgePointUuid())
+ .setNodeUuid(cep2.getParentNodeEdgePoint().getNodeUuid())
+ .setTopologyUuid(cep2.getParentNodeEdgePoint().getTopologyUuid())
+ .setConnectionEndPointUuid(cep2.getUuid())
+ .build();
Name connName = new NameBuilder()
.setValueName("Connection name")
- .setValue(String.join("+", "XC", tp1, tp2, qual))
+ .setValue(crossConnName)
.build();
// TODO: lower connection, supported link.......
- return new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder()
- .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual))
- .getBytes(StandardCharsets.UTF_8)).toString()))
+ return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.ConnectionBuilder()
+ .setUuid(new Uuid(UUID.nameUUIDFromBytes(crossConnName.getBytes(StandardCharsets.UTF_8)).toString()))
.setName(Map.of(connName.key(), connName))
- .setConnectionEndPoint(ceps)
+ .setConnectionEndPoint(new HashMap<>(Map.of(cepServ1.key(), cepServ1, cepServ2.key(), cepServ2)))
.setOperationalState(OperationalState.ENABLED)
.setLayerProtocolName(xcProtocol)
.setLifecycleState(LifecycleState.INSTALLED)
}
private ConnectionEndPoint createCepRoadm(String id, String qualifier) {
- LOG.info("NEP = {}", String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
+ String nepId = String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]);
+ String nodeNepId = String.join("+",id.split("\\+")[0], TapiStringConstants.PHTNC_MEDIA);
+ LOG.info("NEP = {}", nepId);
Name cepName = new NameBuilder()
.setValueName("ConnectionEndPoint name")
- .setValue(String.join("+", id.split("\\+")[0], qualifier,
- id.split("\\+")[1]))
+ .setValue(nepId)
.build();
ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
- .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
- qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
+ .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
+ nepId.getBytes(StandardCharsets.UTF_8))
+ .toString()))
+ .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
+ nodeNepId.getBytes(StandardCharsets.UTF_8))
.toString()))
- .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
- TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8))
+ .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(
+ TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8))
.toString()))
- .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
- .getBytes(StandardCharsets.UTF_8)).toString()))
.build();
String clientQualifier = "";
switch (qualifier) {
TapiStringConstants.OTSI_MC, onepOTSiMC);
break;
default:
- LOG.debug("not currently handling client NEP for OTSiMC CEP {}",
- String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
+ LOG.debug("not currently handling client NEP for OTSiMC CEP {}", nepId);
break;
}
ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
- .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
- clientQualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
+ .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", id.split("\\+")[0], clientQualifier, id.split("\\+")[1]))
+ .getBytes(StandardCharsets.UTF_8))
.toString()))
- .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
- TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8))
+ .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
+ nodeNepId.getBytes(StandardCharsets.UTF_8))
+ .toString()))
+ .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(
+ TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8))
.toString()))
- .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
- .getBytes(StandardCharsets.UTF_8)).toString()))
.build();
// TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
// TODO: add parent ONEP??
ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
- .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
- qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
+ .setUuid(new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "CEP", id.split("\\+")[0], qualifier, id.split("\\+")[1]))
+ .getBytes(StandardCharsets.UTF_8))
.toString()))
.setParentNodeEdgePoint(pnep)
.setName(Map.of(cepName.key(), cepName))
.setOperationalState(OperationalState.ENABLED)
.setLifecycleState(LifecycleState.INSTALLED)
.setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA);
- if (!(TapiStringConstants.OTSI_MC.equals(qualifier))) {
- cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep));
- }
- return cepBldr.build();
+ return TapiStringConstants.OTSI_MC.equals(qualifier)
+ ? cepBldr.build()
+ : cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)).build();
}
- private ConnectionEndPoint createCepXpdr(String id, String qualifier, String nodeLayer,
- LayerProtocolName cepProtocol) {
+ private ConnectionEndPoint createCepXpdr(
+ String id, String qualifier, String nodeLayer, LayerProtocolName cepProtocol) {
+ String nepId = String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]);
+ String nepNodeId = String.join("+",id.split("\\+")[0], TapiStringConstants.XPDR);
Name cepName = new NameBuilder()
.setValueName("ConnectionEndPoint name")
- .setValue(String.join("+", id.split("\\+")[0], qualifier,
- id.split("\\+")[1]))
+ .setValue(nepId)
.build();
ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder()
- .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
- qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
- .toString()))
- .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
- TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
- .toString()))
- .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
- .getBytes(StandardCharsets.UTF_8)).toString()))
+ .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
+ nepId.getBytes(StandardCharsets.UTF_8)).toString()))
+ .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
+ nepNodeId.getBytes(StandardCharsets.UTF_8)).toString()))
+ .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(
+ TapiStringConstants.T0_FULL_MULTILAYER
+ .getBytes(StandardCharsets.UTF_8)).toString()))
.build();
String clientQualifier = "";
String clientNodeLayer = TapiStringConstants.PHTNC_MEDIA;
clientNodeLayer = TapiStringConstants.DSR;
break;
default :
- LOG.debug("no client CEP for DSR NEP {}",
- String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1]));
+ LOG.debug("no client CEP for DSR NEP {}", nepId);
break;
}
ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder()
- .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0],
- clientQualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
- .toString()))
- .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0],
- TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8))
- .toString()))
- .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
- .getBytes(StandardCharsets.UTF_8)).toString()))
+ .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", id.split("\\+")[0], clientQualifier, id.split("\\+")[1]))
+ .getBytes(StandardCharsets.UTF_8)).toString()))
+ .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes(
+ nepNodeId.getBytes(StandardCharsets.UTF_8)).toString()))
+ .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(
+ TapiStringConstants.T0_FULL_MULTILAYER
+ .getBytes(StandardCharsets.UTF_8)).toString()))
.build();
// TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...)
// TODO: add parent ONEP??
ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder()
- .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0],
- qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8))
- .toString()))
+ .setUuid(new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "CEP", id.split("\\+")[0], qualifier, id.split("\\+")[1]))
+ .getBytes(StandardCharsets.UTF_8)).toString()))
.setParentNodeEdgePoint(pnep)
.setName(Map.of(cepName.key(), cepName))
.setConnectionPortRole(PortRole.SYMMETRIC)
.setOperationalState(OperationalState.ENABLED)
.setLifecycleState(LifecycleState.INSTALLED)
.setLayerProtocolName(cepProtocol);
- if (!(TapiStringConstants.DSR.equals(qualifier))) {
- cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep));
- }
- return cepBldr.build();
+ return TapiStringConstants.DSR.equals(qualifier)
+ ? cepBldr.build()
+ : cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)).build();
}
private EndPoint mapServiceZEndPoint(
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd
- serviceZEnd, PathDescription pathDescription) {
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+ .service.ServiceZEnd serviceZEnd, PathDescription pathDescription) {
EndPointBuilder endPointBuilder = new EndPointBuilder();
// 1. Service Format: ODU, OTU, ETH
ServiceFormat serviceFormat = serviceZEnd.getServiceFormat();
default:
LOG.error("Service Format not supported");
}
+ var portZEnd = serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
.setValueName("OpenROADM info")
- .setValue(String.join("-", serviceZEnd.getClli(),
- serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
- .getPortDeviceName(),
- serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
+ .setValue(String.join("-", serviceZEnd.getClli(), portZEnd.getPortDeviceName(), portZEnd.getPortName()))
.build();
return endPointBuilder
.setServiceInterfacePoint(new ServiceInterfacePointBuilder()
.setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceZEnd.getServiceRate().doubleValue())))
.setUnit(CAPACITYUNITGBPS.VALUE)
.build())
-// .setBandwidthProfile(new BandwidthProfileBuilder().build())
+// .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile
.build())
.setProtectionRole(ProtectionRole.WORK)
.setRole(PortRole.SYMMETRIC)
- .setLocalId(serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow()
- .getPort().getPortDeviceName())
+ .setLocalId(portZEnd.getPortDeviceName())
.build();
}
default:
LOG.error("Service Format not supported");
}
+ var portAEnd = serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name =
new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder()
.setValueName("OpenROADM info")
- .setValue(String.join("-", serviceAEnd.getClli(),
- serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
- .getPortDeviceName(),
- serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName()))
+ .setValue(String.join("-", serviceAEnd.getClli(), portAEnd.getPortDeviceName(), portAEnd.getPortName()))
.build();
return endPointBuilder
.setServiceInterfacePoint(new ServiceInterfacePointBuilder()
}
private Uuid getSipIdFromZend(Map<ZToAKey, ZToA> mapztoa, String serviceNodeId, ServiceFormat serviceFormat) {
- Uuid zendUuid = null;
if (serviceNodeId.contains("ROADM")) {
// Service from ROADM to ROADM
// AddDrop-AddDrop ports --> MC layer SIPs
- ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
- .orElseThrow();
+ ZToA firstElement =
+ mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().orElseThrow();
TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
- Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
- tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
- .toString());
+ Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()))
+ .getBytes(StandardCharsets.UTF_8)).toString());
LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
for (ServiceInterfacePoint sip:this.sipMap.values()) {
- if (!sip.getUuid().equals(sipUuid)) {
- LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
- continue;
+ if (sip.getUuid().equals(sipUuid)) {
+ return sip.getUuid();
}
- zendUuid = sip.getUuid();
- break;
- }
- } else {
- // Service from XPDR to XPDR
- ZToA firstElement;
- TerminationPoint tp;
- Uuid sipUuid;
- switch (serviceFormat) {
- case ODU:
- firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
- .orElseThrow();
- tp = (TerminationPoint) firstElement.getResource().getResource();
- // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
- sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
- TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
- LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU,
- tp.getTpId()));
- break;
- case OTU:
- firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst()
- .orElseThrow();
- tp = (TerminationPoint) firstElement.getResource().getResource();
- // Network-Network ports --> iOTSi layer SIPs
- sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
- TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
- LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI,
- tp.getTpId()));
- break;
- case Ethernet:
- LOG.info("Elements ZA = {}", mapztoa.values().toString());
- firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst()
- .orElseThrow();
- tp = (TerminationPoint) firstElement.getResource().getResource();
- // Client-client ports --> DSR layer SIPs
- sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
- TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
- LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR,
- tp.getTpId()));
- break;
- default:
- sipUuid = null;
- LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
+ LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
}
- for (ServiceInterfacePoint sip:this.sipMap.values()) {
- if (!sip.getUuid().equals(sipUuid)) {
- LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
- continue;
- }
- zendUuid = sip.getUuid();
+ return null;
+ }
+ // Service from XPDR to XPDR
+ ZToA firstElement;
+ TerminationPoint tp;
+ Uuid sipUuid;
+ switch (serviceFormat) {
+ case ODU:
+ firstElement =
+ mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().orElseThrow();
+ tp = (TerminationPoint) firstElement.getResource().getResource();
+ // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU
+ sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()))
+ .getBytes(StandardCharsets.UTF_8)).toString());
+ LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()));
+ break;
+ case OTU:
+ firstElement =
+ mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().orElseThrow();
+ tp = (TerminationPoint) firstElement.getResource().getResource();
+ // Network-Network ports --> iOTSi layer SIPs
+ sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()))
+ .getBytes(StandardCharsets.UTF_8)).toString());
+ LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()));
+ break;
+ case Ethernet:
+ LOG.info("Elements ZA = {}", mapztoa.values());
+ firstElement =
+ mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().orElseThrow();
+ tp = (TerminationPoint) firstElement.getResource().getResource();
+ // Client-client ports --> DSR layer SIPs
+ sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()))
+ .getBytes(StandardCharsets.UTF_8)).toString());
+ LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()));
break;
+ default:
+ sipUuid = null;
+ LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
+ }
+ for (ServiceInterfacePoint sip:this.sipMap.values()) {
+ if (sip.getUuid().equals(sipUuid)) {
+ return sip.getUuid();
}
+ LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
}
- return zendUuid;
+ return null;
}
private Uuid getSipIdFromAend(Map<AToZKey, AToZ> mapatoz, String serviceNodeId, ServiceFormat serviceFormat) {
- Uuid aendUuid = null;
LOG.info("ServiceNode = {} and ServiceFormat = {}", serviceNodeId, serviceFormat.getName());
LOG.info("Map a to z = {}", mapatoz);
if (serviceNodeId.contains("ROADM")) {
// Service from ROADM to ROADM
// AddDrop-AddDrop ports --> MC layer SIPs
- AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
- .orElseThrow();
+ AToZ firstElement =
+ mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().orElseThrow();
LOG.info("First element of service path = {}", firstElement.getResource().getResource());
TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource();
- Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP",
- tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8))
- .toString());
- LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC,
- tp.getTpId()));
+ Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()))
+ .getBytes(StandardCharsets.UTF_8)).toString());
+ LOG.info("ROADM SIP name = {}",
+ String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId()));
for (ServiceInterfacePoint sip:this.sipMap.values()) {
- if (!sip.getUuid().equals(sipUuid)) {
- LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
- continue;
+ if (sip.getUuid().equals(sipUuid)) {
+ return sip.getUuid();
}
- aendUuid = sip.getUuid();
- break;
- }
- } else {
- // Service from XPDR to XPDR
- AToZ firstElement;
- TerminationPoint tp;
- Uuid sipUuid;
- switch (serviceFormat) {
- case ODU:
- firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
- .orElseThrow();
- tp = (TerminationPoint) firstElement.getResource().getResource();
- // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
- sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
- TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
- LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
- TapiStringConstants.I_ODU, tp.getTpId()));
- break;
- case OTU:
- firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst()
- .orElseThrow();
- tp = (TerminationPoint) firstElement.getResource().getResource();
- // Network-Network ports --> iOTSi layer SIPs
- sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
- TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
- LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
- TapiStringConstants.I_OTSI, tp.getTpId()));
- break;
- case Ethernet:
- LOG.info("Elements AZ = {}", mapatoz.values().toString());
- firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst()
- .orElseThrow();
- tp = (TerminationPoint) firstElement.getResource().getResource();
- // Client-client ports --> DSR layer SIPs
- sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(),
- TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString());
- LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(),
- TapiStringConstants.DSR, tp.getTpId()));
- break;
- default:
- sipUuid = null;
- LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
+ LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
}
- for (ServiceInterfacePoint sip:this.sipMap.values()) {
- if (!sip.getUuid().equals(sipUuid)) {
- LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
- continue;
- }
- aendUuid = sip.getUuid();
+ return null;
+ }
+ // Service from XPDR to XPDR
+ AToZ firstElement;
+ TerminationPoint tp;
+ Uuid sipUuid;
+ switch (serviceFormat) {
+ case ODU:
+ firstElement =
+ mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().orElseThrow();
+ tp = (TerminationPoint) firstElement.getResource().getResource();
+ // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU
+ sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()))
+ .getBytes(StandardCharsets.UTF_8)).toString());
+ LOG.info("ODU XPDR SIP name = {}",
+ String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU, tp.getTpId()));
+ break;
+ case OTU:
+ firstElement =
+ mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().orElseThrow();
+ tp = (TerminationPoint) firstElement.getResource().getResource();
+ // Network-Network ports --> iOTSi layer SIPs
+ sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()))
+ .getBytes(StandardCharsets.UTF_8)).toString());
+ LOG.info("OTU XPDR SIP name = {}",
+ String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI, tp.getTpId()));
break;
+ case Ethernet:
+ LOG.info("Elements AZ = {}", mapatoz.values());
+ firstElement =
+ mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().orElseThrow();
+ tp = (TerminationPoint) firstElement.getResource().getResource();
+ // Client-client ports --> DSR layer SIPs
+ sipUuid = new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", "SIP", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()))
+ .getBytes(StandardCharsets.UTF_8)).toString());
+ LOG.info("DSR XPDR SIP name = {}",
+ String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR, tp.getTpId()));
+ break;
+ default:
+ sipUuid = null;
+ LOG.warn("Service format {} not supported (?)", serviceFormat.getName());
+ }
+ for (ServiceInterfacePoint sip:this.sipMap.values()) {
+ if (sip.getUuid().equals(sipUuid)) {
+ return sip.getUuid();
}
+ LOG.debug("SIP {} does not match sipname {}", sip.getUuid().getValue(), sipUuid.getValue());
}
- return aendUuid;
+ return null;
}
private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) {
- LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1]));
- LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA));
+ String nepId = String.join("+", node, qual, spcRdmAD.split("\\+")[1]);
+ String nodeNepId = String.join("+", node, TapiStringConstants.PHTNC_MEDIA);
+ LOG.info("NEP id before Merge = {}", nepId);
+ LOG.info("Node of NEP id before Merge = {}", nodeNepId);
// Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
- Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
- .getBytes(StandardCharsets.UTF_8)).toString());
- Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA)
- .getBytes(StandardCharsets.UTF_8)).toString());
- Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1])
- .getBytes(StandardCharsets.UTF_8)).toString());
- this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
+ this.tapiContext.updateTopologyWithCep(
+ //topoUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8)).toString()),
+ //nodeUuid,
+ new Uuid(UUID.nameUUIDFromBytes(nodeNepId.getBytes(StandardCharsets.UTF_8)).toString()),
+ //nepUuid,
+ new Uuid(UUID.nameUUIDFromBytes(nepId.getBytes(StandardCharsets.UTF_8)).toString()),
+ cep);
}
- private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer,
- ConnectionEndPoint cep) {
+ private void putXpdrCepInTopologyContext(
+ String node, String spcXpdrNet, String qual, String nodeLayer, ConnectionEndPoint cep) {
// Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
- Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
- .getBytes(StandardCharsets.UTF_8)).toString());
- Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer)
- .getBytes(StandardCharsets.UTF_8)).toString());
- Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1])
- .getBytes(StandardCharsets.UTF_8)).toString());
- this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep);
+ this.tapiContext.updateTopologyWithCep(
+ //topoUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ TapiStringConstants.T0_FULL_MULTILAYER.getBytes(StandardCharsets.UTF_8))
+ .toString()),
+ //nodeUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ String.join("+", node, nodeLayer).getBytes(StandardCharsets.UTF_8))
+ .toString()),
+ //nepUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ String.join("+", node, qual, spcXpdrNet.split("\\+")[1]).getBytes(StandardCharsets.UTF_8))
+ .toString()),
+ cep);
}
private void putRdmNepInTopologyContext(String orNodeId, String orTpId, String qual, OwnedNodeEdgePoint onep) {
- LOG.info("NEP id before Merge = {}", String.join("+", orNodeId, qual, orTpId));
- LOG.info("Node of NEP id before Merge = {}", String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA));
+ String nepId = String.join("+", orNodeId, qual, orTpId);
+ String nepNodeId = String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA);
+ LOG.info("NEP id before Merge = {}", nepId);
+ LOG.info("Node of NEP id before Merge = {}", nepNodeId);
// Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep
- Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
- .getBytes(Charset.forName("UTF-8"))).toString());
- Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)
- .getBytes(Charset.forName("UTF-8"))).toString());
- Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, qual, orTpId)
- .getBytes(Charset.forName("UTF-8"))).toString());
- updateTopologyWithNep(topoUuid, nodeUuid, nepUuid, onep);
+ updateTopologyWithNep(
+ //topoUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8")))
+ .toString()),
+ //nodeUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ nepNodeId.getBytes(Charset.forName("UTF-8")))
+ .toString()),
+ //nepUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ nepId.getBytes(Charset.forName("UTF-8")))
+ .toString()),
+ onep);
}
private String getIdBasedOnModelVersion(String nodeid) {
- return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0],
- nodeid.split("-")[1]) : nodeid.split("-")[0];
+ return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*")
+ ? String.join("-", nodeid.split("-")[0], nodeid.split("-")[1])
+ : nodeid.split("-")[0];
}
private ServiceZEnd tapiEndPointToServiceZPoint(
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint,
- ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .create.connectivity.service.input.EndPoint endPoint,
+ ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) {
// TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
// Not the rest which is needed in the txPortDeviceName.
// It could be obtained from the SIP which has the NEP and includes all the OR name.
// connection is between 2 CLIENT ports. Otherwise it will not work...
OwnedNodeEdgePoint nep = null;
for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
- if (onep.getMappedServiceInterfacePoint() == null) {
- continue;
- }
- if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
+ if (onep.getMappedServiceInterfacePoint() != null
+ && onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
nep = onep;
break;
}
return null;
}
String nodeName = "";
- for (Map.Entry<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
+ for (Map.Entry<
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
endPoint.getName().entrySet()) {
if (!("Node Type").equals(entry.getValue().getValueName())) {
nodeName = entry.getValue().getValue();
if (serviceFormat.equals(ServiceFormat.OTU)) {
serviceZEndBuilder.setOtuServiceRate(OTU4.VALUE);
}
- if (!serviceLayer.equals(LayerProtocolName.ETH)) {
- serviceZEndBuilder
- .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
+ return serviceLayer.equals(LayerProtocolName.ETH)
+ ? serviceZEndBuilder.build()
+ : serviceZEndBuilder
+ .setEthernetAttributes(new EthernetAttributesBuilder()
+ .setSubrateEthSla(new SubrateEthSlaBuilder()
.setCommittedBurstSize(Uint16.valueOf(64))
.setCommittedInfoRate(Uint32.valueOf(100000))
.build())
- .build());
- }
- return serviceZEndBuilder.build();
+ .build())
+ .build();
}
private ServiceAEnd tapiEndPointToServiceAPoint(
- org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint,
- ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .create.connectivity.service.input.EndPoint endPoint,
+ ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) {
// TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1.
// Not the rest which is needed in the txPortDeviceName.
// It could be obtained from the SIP which has the NEP and includes all the OR name.
// connection is between 2 CLIENT ports. Otherwise it will not work...
OwnedNodeEdgePoint nep = null;
for (OwnedNodeEdgePoint onep : node.getOwnedNodeEdgePoint().values()) {
- if (onep.getMappedServiceInterfacePoint() == null) {
- continue;
- }
- if (onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
+ if (onep.getMappedServiceInterfacePoint() != null
+ && onep.getMappedServiceInterfacePoint().containsKey(new MappedServiceInterfacePointKey(sipUuid))) {
nep = onep;
break;
}
return null;
}
String nodeName = "";
- for (Map.Entry<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
+ for (Map.Entry<
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameKey,
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name> entry:
- endPoint.getName().entrySet()) {
+ endPoint.getName().entrySet()) {
if (!("Node Type").equals(entry.getValue().getValueName())) {
nodeName = entry.getValue().getValue();
}
.setServiceFormat(serviceFormat)
.setServiceRate(Uint32.valueOf(capacity))
.setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(
- new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.subrate.eth
- .sla.SubrateEthSlaBuilder()
+ new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526
+ .subrate.eth.sla.SubrateEthSlaBuilder()
.setCommittedBurstSize(Uint16.valueOf(64))
.setCommittedInfoRate(Uint32.valueOf(100000))
.build())
} else if (serviceFormat.equals(ServiceFormat.OTU)) {
serviceAEndBuilder.setOtuServiceRate(OTU4.VALUE);
}
- if (!serviceLayer.equals(LayerProtocolName.ETH)) {
- serviceAEndBuilder
- .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder()
+ return serviceLayer.equals(LayerProtocolName.ETH)
+ ? serviceAEndBuilder.build()
+ : serviceAEndBuilder
+ .setEthernetAttributes(new EthernetAttributesBuilder()
+ .setSubrateEthSla(new SubrateEthSlaBuilder()
.setCommittedBurstSize(Uint16.valueOf(64))
.setCommittedInfoRate(Uint32.valueOf(100000))
.build())
- .build());
- }
- return serviceAEndBuilder.build();
+ .build())
+ .build();
}
- private ConnectionType getConnectionTypePhtnc(Collection<org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) {
- if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
- .anyMatch(name -> name.getValue().contains("ROADM")))) {
+ private ConnectionType getConnectionTypePhtnc(
+ Collection<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .create.connectivity.service.input.EndPoint> endPoints) {
+ return endPoints.stream()
+ .anyMatch(ep -> ep.getName().values().stream().anyMatch(name -> name.getValue().contains("ROADM")))
// EndPoints are ROADMs
- return ConnectionType.RoadmLine;
- }
- // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
- return ConnectionType.Infrastructure;
+ ? ConnectionType.RoadmLine
+ // EndPoints are not ROADMs -> XPDR, MUXPDR, SWTICHPDR
+ : ConnectionType.Infrastructure;
}
- private ServiceFormat getServiceFormatPhtnc(Collection<org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) {
- if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream()
- .anyMatch(name -> name.getValue().contains("ROADM")))) {
+ private ServiceFormat getServiceFormatPhtnc(
+ Collection<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .create.connectivity.service.input.EndPoint> endPoints) {
+ return endPoints.stream()
+ .anyMatch(ep -> ep.getName().values().stream().anyMatch(name -> name.getValue().contains("ROADM")))
// EndPoints are ROADMs
- return ServiceFormat.OC;
- }
- // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
- return ServiceFormat.OTU;
+ ? ServiceFormat.OC
+ // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR
+ : ServiceFormat.OTU;
}
private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) {
- Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
- TapiStringConstants.XPDR).getBytes(StandardCharsets.UTF_8))).toString());
- Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0],
- TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]).getBytes(StandardCharsets.UTF_8)))
- .toString());
- Uuid cepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP",
- spcXpdrNetwork.split("\\+")[0], TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]))
- .getBytes(StandardCharsets.UTF_8)).toString());
- return this.tapiContext.getTapiCEP(this.tapiTopoUuid, nodeUuid, nepUuid, cepUuid);
+ return this.tapiContext.getTapiCEP(
+ this.tapiTopoUuid,
+ //nodeUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+",
+ spcXpdrNetwork.split("\\+")[0],
+ TapiStringConstants.XPDR)
+ .getBytes(StandardCharsets.UTF_8))).toString()),
+ //nepUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+",
+ spcXpdrNetwork.split("\\+")[0],
+ TapiStringConstants.I_ODU,
+ spcXpdrNetwork.split("\\+")[1])
+ .getBytes(StandardCharsets.UTF_8))).toString()),
+ //cepUuid,
+ new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+",
+ "CEP",
+ spcXpdrNetwork.split("\\+")[0],
+ TapiStringConstants.I_ODU,
+ spcXpdrNetwork.split("\\+")[1]))
+ .getBytes(StandardCharsets.UTF_8)).toString()));
}
private String getAssociatedNetworkPort(String spcXpdrClient, List<String> xpdrNetworkTplist) {
private List<String> getAssociatedClientsPort(List<String> xpdrNetworkTplist) {
List<String> clientPortList = new ArrayList<>();
for (String networkPort:xpdrNetworkTplist) {
- String nodeId = String.join("-", networkPort.split("\\+")[0].split("-")[0],
+ String nodeId = String.join("-",
+ networkPort.split("\\+")[0].split("-")[0],
networkPort.split("\\+")[0].split("-")[1]);
String tpId = networkPort.split("\\+")[1];
InstanceIdentifier<Mapping> mapIID = InstanceIdentifier.builder(Network.class)
.child(Nodes.class, new NodesKey(nodeId))
.child(Mapping.class, new MappingKey(tpId)).build();
try {
- Optional<Mapping> optMapping = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
- mapIID).get();
- if (!optMapping.isPresent()) {
+ Optional<Mapping> optMapping =
+ this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, mapIID).get();
+ if (optMapping.isEmpty()) {
LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId);
}
Mapping mapping = optMapping.orElseThrow();
LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping);
- String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]),
+ String key = String.join("+",
+ String.join("-", nodeId, tpId.split("\\-")[0]),
mapping.getConnectionMapLcp());
LOG.info("Key to be added to list = {}", key);
if (!clientPortList.contains(key)) {
private OpenroadmNodeType getOpenRoadmNodeType(List<String> xpdrNodelist) {
List<OpenroadmNodeType> openroadmNodeTypeList = new ArrayList<>();
for (String xpdrNode:xpdrNodelist) {
- Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",xpdrNode, TapiStringConstants.XPDR))
- .getBytes(StandardCharsets.UTF_8)).toString());
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeIID = InstanceIdentifier.builder(
- Context.class).augmentation(org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.topology.rev221121.Context1.class).child(TopologyContext.class)
- .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
- .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
- new NodeKey(nodeUuid)).build();
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+ .topology.Node> nodeIID =
+ InstanceIdentifier.builder(Context.class)
+ .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class)
+ .child(TopologyContext.class)
+ .child(Topology.class, new TopologyKey(this.tapiTopoUuid))
+ .child(
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
+ new NodeKey(
+ //nodeUUID
+ new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+",xpdrNode, TapiStringConstants.XPDR))
+ .getBytes(StandardCharsets.UTF_8)).toString())))
+ .build();
try {
- Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> optNode
- = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
+ Optional<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> optNode =
+ this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get();
if (optNode.isEmpty()) {
return null;
}
- OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(
- new NameKey("Node Type")).getValue());
+ OpenroadmNodeType openroadmNodeType =
+ OpenroadmNodeType.forName(optNode.orElseThrow().getName().get(new NameKey("Node Type")).getValue());
if (!openroadmNodeTypeList.contains(openroadmNodeType)) {
openroadmNodeTypeList.add(openroadmNodeType);
}
}
}
// TODO for now check that there is only one type, otherwise error
- if (openroadmNodeTypeList.size() != 1) {
- LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
- return null;
+ if (openroadmNodeTypeList.size() == 1) {
+ return openroadmNodeTypeList.get(0);
}
- return openroadmNodeTypeList.get(0);
+ LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList);
+ return null;
}
- private OwnedNodeEdgePoint createRoadmNep(String orNodeId, String tpId,
- boolean withSip, OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) {
-
+ private OwnedNodeEdgePoint createRoadmNep(
+ String orNodeId, String tpId, boolean withSip,
+ OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) {
//TODO : complete implementation with SIP
- Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, nepPhotonicSublayer,
- tpId)).getBytes(StandardCharsets.UTF_8)).toString());
Name nepName = new NameBuilder()
.setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
.setValue(String.join("+", orNodeId, nepPhotonicSublayer, tpId))
.build();
- List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
- if (TapiStringConstants.MC.equals(nepPhotonicSublayer)) {
- sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
- .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIERMC.VALUE)
- .setNumberOfCepInstances(Uint64.valueOf(1))
- .build());
- } else {
- sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
- .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTSiMC.VALUE)
- .setNumberOfCepInstances(Uint64.valueOf(1))
- .build());
- }
- OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
- .setUuid(nepUuid)
+ return new OwnedNodeEdgePointBuilder()
+ .setUuid(
+ new Uuid(UUID.nameUUIDFromBytes(
+ (String.join("+", orNodeId, nepPhotonicSublayer,tpId)).getBytes(StandardCharsets.UTF_8))
+ .toString()))
.setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
.setName(Map.of(nepName.key(), nepName))
- .setSupportedCepLayerProtocolQualifierInstances(sclpqiList)
+ .setSupportedCepLayerProtocolQualifierInstances(
+ new ArrayList<>(List.of(
+ new SupportedCepLayerProtocolQualifierInstancesBuilder()
+ .setLayerProtocolQualifier(
+ TapiStringConstants.MC.equals(nepPhotonicSublayer)
+ ? PHOTONICLAYERQUALIFIERMC.VALUE
+ : PHOTONICLAYERQUALIFIEROTSiMC.VALUE)
+ .setNumberOfCepInstances(Uint64.valueOf(1))
+ .build())))
.setDirection(Direction.BIDIRECTIONAL)
.setLinkPortRole(PortRole.SYMMETRIC)
.setAdministrativeState(adminState).setOperationalState(operState)
.setLifecycleState(LifecycleState.INSTALLED)
.build();
-
- return onep;
}
-
}
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.node.termination.point.PpAttributes;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.node.termination.point.XpdrNetworkAttributes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPools;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.PhotonicMediaNodeEdgePointSpec;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.PhotonicMediaNodeEdgePointSpecBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.photonic.media.node.edge.point.spec.SpectrumCapabilityPacBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrum;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrumBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrumKey;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrum;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrumBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrumKey;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrum;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrumBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrumKey;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPac;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.AvailablePayloadStructure;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.AvailablePayloadStructureBuilder;
public void convertNode(Node ietfNode, List<String> networkPorts) {
this.ietfNodeId = ietfNode.getNodeId().getValue();
- if (ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
- == null) {
+ var ietfAug =
+ ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class);
+ if (ietfAug == null) {
return;
}
- this.ietfNodeType = ietfNode.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class).getNodeType();
- this.ietfNodeAdminState = ietfNode.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
- .getAdministrativeState();
- this.ietfNodeOperState = ietfNode.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
- .getOperationalState();
- this.oorNetworkPortList = ietfNode.augmentation(
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
- .getTerminationPoint().values().stream()
+ this.ietfNodeType = ietfAug.getNodeType();
+ this.ietfNodeAdminState = ietfAug.getAdministrativeState();
+ this.ietfNodeOperState = ietfAug.getOperationalState();
+ var ietfAugTopo =
+ ietfNode.augmentation(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class);
+ this.oorNetworkPortList = ietfAugTopo.getTerminationPoint().values().stream()
.filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
- == OpenroadmTpType.XPONDERNETWORK.getIntValue()
+ == OpenroadmTpType.XPONDERNETWORK.getIntValue()
&& networkPorts.contains(tp.getTpId().getValue()))
.sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
.collect(Collectors.toList());
- if (!OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
- this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
- .values().stream().findFirst().orElseThrow();
- this.oorClientPortList = ietfNode.augmentation(
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
- .getTerminationPoint().values().stream()
- .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
- == OpenroadmTpType.XPONDERCLIENT.getIntValue())
- .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
- .collect(Collectors.toList());
- } else {
+ if (OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
this.oorOduSwitchingPool = createOduSwitchingPoolForTp100G();
List<TpId> tpList = this.oorOduSwitchingPool.getNonBlockingList().values().stream()
.flatMap(nbl -> nbl.getTpList().stream())
.collect(Collectors.toList());
- this.oorClientPortList = ietfNode.augmentation(
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
- .getTerminationPoint().values().stream()
+ this.oorClientPortList = ietfAugTopo.getTerminationPoint().values().stream()
.filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
- == OpenroadmTpType.XPONDERCLIENT.getIntValue() && tpList.contains(tp.getTpId()))
+ == OpenroadmTpType.XPONDERCLIENT.getIntValue()
+ && tpList.contains(tp.getTpId()))
.sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
.collect(Collectors.toList());
this.oorClientPortList.forEach(tp -> LOG.info("tp = {}", tp.getTpId()));
+ } else {
+ this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
+ .values().stream().findFirst().orElseThrow();
+ this.oorClientPortList = ietfAugTopo.getTerminationPoint().values().stream()
+ .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
+ == OpenroadmTpType.XPONDERCLIENT.getIntValue())
+ .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
+ .collect(Collectors.toList());
}
// node creation [DSR/ODU] ([DSR/ODU] and OTSI merged in R 2.4.X)
LOG.info("creation of a DSR/ODU node for {}", this.ietfNodeId);
- Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
- TapiStringConstants.XPDR)).getBytes(Charset.forName("UTF-8"))).toString());
- this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.XPDR), nodeUuid);
- Name nameDsr = new NameBuilder().setValueName("dsr/odu node name")
- .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.XPDR)).build();
- Name namePhot = new NameBuilder().setValueName("otsi node name")
- .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.XPDR)).build();
- Name nameNodeType = new NameBuilder().setValueName("Node Type")
- .setValue(this.ietfNodeType.getName()).build();
- Set<LayerProtocolName> dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU,
- LayerProtocolName.DIGITALOTN,LayerProtocolName.PHOTONICMEDIA);
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology
- .Node dsrNode = createTapiNode(Map.of(nameDsr.key(), nameDsr, namePhot.key(), namePhot,nameNodeType.key(),
- nameNodeType), dsrLayerProtocols);
- LOG.debug("XPDR Node {} should have {} NEPs and SIPs", this.ietfNodeId,
- this.oorClientPortList.size() + this.oorNetworkPortList.size());
- LOG.info("XPDR Node {} has {} NEPs and {} SIPs", this.ietfNodeId,
- dsrNode.getOwnedNodeEdgePoint().values().size(), dsrNode.getOwnedNodeEdgePoint().values().stream()
+ String nodeIdXpdr = String.join("+", this.ietfNodeId, TapiStringConstants.XPDR);
+ this.uuidMap.put(nodeIdXpdr,
+ //nodeUuid
+ new Uuid(UUID.nameUUIDFromBytes(nodeIdXpdr.getBytes(Charset.forName("UTF-8"))).toString()));
+ Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(nodeIdXpdr).build();
+ Name namePhot = new NameBuilder().setValueName("otsi node name").setValue(nodeIdXpdr).build();
+ Name nameNodeType = new NameBuilder().setValueName("Node Type").setValue(this.ietfNodeType.getName()).build();
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+ .topology.Node dsrNode =
+ createTapiNode(
+ Map.of(nameDsr.key(), nameDsr, namePhot.key(), namePhot,nameNodeType.key(), nameNodeType),
+ //dsrLayerProtocols
+ Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU,
+ LayerProtocolName.DIGITALOTN, LayerProtocolName.PHOTONICMEDIA));
+ LOG.debug("XPDR Node {} should have {} NEPs and SIPs",
+ this.ietfNodeId, this.oorClientPortList.size() + this.oorNetworkPortList.size());
+ LOG.info("XPDR Node {} has {} NEPs and {} SIPs",
+ this.ietfNodeId,
+ dsrNode.getOwnedNodeEdgePoint().values().size(),
+ dsrNode.getOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
tapiNodes.put(dsrNode.key(), dsrNode);
}
- public Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String topoType, Uuid nodeUuid,
- String orNodeId, Collection<OwnedNodeEdgePoint> onepl) {
+ public Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(
+ String topoType, Uuid nodeUuid, String orNodeId, Collection<OwnedNodeEdgePoint> onepl) {
Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
- nepMap = new HashMap<>();
+ nepMap = new HashMap<>();
for (OwnedNodeEdgePoint onep : onepl) {
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
- nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group
- .NodeEdgePointBuilder()
+ var nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+ .node.rule.group.NodeEdgePointBuilder()
.setTopologyUuid(tapiTopoUuid)
.setNodeUuid(nodeUuid)
.setNodeEdgePointUuid(onep.key().getUuid())
.build();
nepMap.put(nep.key(), nep);
}
- String rdmName =
- topoType.equals("Abstracted")
- ? "rdm infra node rule group"
- : orNodeId + " node rule group";
- Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
- Set<RuleType> ruleTypes = new HashSet<>();
- ruleTypes.add(RuleType.FORWARDING);
- Map<RuleKey, Rule> ruleList = new HashMap<>();
Rule rule = new RuleBuilder()
.setLocalId("forward")
.setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
- .setRuleType(ruleTypes)
+ .setRuleType(new HashSet<>(Set.of(RuleType.FORWARDING)))
.build();
- ruleList.put(rule.key(), rule);
NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
- .setUuid(new Uuid(UUID.nameUUIDFromBytes((rdmName)
+ .setUuid(new Uuid(UUID.nameUUIDFromBytes((
+ topoType.equals("Abstracted") ? "rdm infra node rule group" : orNodeId + " node rule group")
.getBytes(Charset.forName("UTF-8"))).toString()))
- .setRule(ruleList)
+ .setRule(new HashMap<>(Map.of(rule.key(), rule)))
.setNodeEdgePoint(nepMap)
.build();
- nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
- return nodeRuleGroupMap;
+ return new HashMap<>(Map.of(nodeRuleGroup.key(), nodeRuleGroup));
}
- public Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(int nb,
- LayerProtocolName layerProtocol, String tpId, String nodeid,
+ public Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(
+ int nb, LayerProtocolName layerProtocol, String tpId, String nodeid,
Collection<SupportedInterfaceCapability> supportedInterfaceCapability,
OperationalState operState, AdministrativeState adminState) {
// add them to SIP context
String sipName =
nb == 1
? String.join("+", "SIP", nodeid, tpId)
- : String.join("+", "SIP", nodeid, tpId,"Nber", String.valueOf(i));
+ : String.join("+", "SIP", nodeid, tpId, "Nber", String.valueOf(i));
LOG.info("SIP = {}", sipName);
Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(sipName.getBytes(Charset.forName("UTF-8"))).toString());
MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
- .setServiceInterfacePointUuid(sipUuid).build();
- ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tpId, nodeid, supportedInterfaceCapability,
- operState, adminState);
+ .setServiceInterfacePointUuid(sipUuid)
+ .build();
+ ServiceInterfacePoint sip =
+ createSIP(sipUuid, layerProtocol, tpId, nodeid, supportedInterfaceCapability, operState, adminState);
this.tapiSips.put(sip.key(), sip);
msipl.put(msip.key(), msip);
LOG.debug("SIP created {}", sip.getUuid());
return msipl;
}
- public List<AvailablePayloadStructure> createAvailablePayloadStructureForPhtncMedia(Boolean otsiProvisioned,
- Collection<SupportedInterfaceCapability> sicList, List<OperationalModeKey> supportedOpModes) {
+ public List<AvailablePayloadStructure> createAvailablePayloadStructureForPhtncMedia(
+ Boolean otsiProvisioned,
+ Collection<SupportedInterfaceCapability> sicList,
+ List<OperationalModeKey> supportedOpModes) {
if (supportedOpModes == null || supportedOpModes.isEmpty()) {
return null;
}
nepRate = loopRate;
}
}
- CapacityBuilder capBd = new CapacityBuilder()
- .setUnit(CAPACITYUNITGBPS.VALUE);
List<AvailablePayloadStructure> aps = new ArrayList<>();
- Integer cepInstanceNber = 1;
- if (otsiProvisioned) {
- cepInstanceNber = 0;
- }
+ Integer cepInstanceNber = otsiProvisioned ? 0 : 1;
for (SupportedInterfaceCapability sic : sicList) {
- String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
- switch (ifCapType) {
+ switch (sic.getIfCapType().toString().split("\\{")[0]) {
case "IfOCHOTU4ODU4":
case "IfOCHOTU4ODU4Regen":
case "IfOCHOTU4ODU4Uniregen":
aps.add(new AvailablePayloadStructureBuilder()
.setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, ODUTYPEODU4.VALUE))
.setNumberOfCepInstances(Uint64.valueOf(cepInstanceNber))
- .setCapacity(capBd.setValue(Decimal64.valueOf(100.0 * cepInstanceNber, RoundingMode.DOWN))
- .build())
+ .setCapacity(
+ new CapacityBuilder()
+ .setUnit(CAPACITYUNITGBPS.VALUE)
+ .setValue(Decimal64.valueOf(100.0 * cepInstanceNber, RoundingMode.DOWN))
+ .build())
.build());
break;
case "IfOCHOTUCnODUCn":
ODUTYPEODUCN.VALUE, ODUTYPEODU4.VALUE))
.setNumberOfCepInstances(Uint64.valueOf(nepRate * cepInstanceNber))
.setCapacity(
- capBd.setValue(Decimal64.valueOf(nepRate * 100.0 * cepInstanceNber, RoundingMode.DOWN))
- .build())
+ new CapacityBuilder()
+ .setUnit(CAPACITYUNITGBPS.VALUE)
+ .setValue(Decimal64.valueOf(nepRate * 100.0 * cepInstanceNber, RoundingMode.DOWN))
+ .build())
.build());
break;
default:
nepRate = loopRate;
}
}
- CapacityBuilder capBd = new CapacityBuilder()
- .setUnit(CAPACITYUNITGBPS.VALUE);
List<SupportedPayloadStructure> sps = new ArrayList<>();
for (SupportedInterfaceCapability sic : sicList) {
String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
sps.add(new SupportedPayloadStructureBuilder()
.setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, ODUTYPEODU4.VALUE))
.setNumberOfCepInstances(Uint64.valueOf(1))
- .setCapacity(capBd.setValue(Decimal64.valueOf(100.0, RoundingMode.DOWN)).build())
+ .setCapacity(
+ new CapacityBuilder()
+ .setUnit(CAPACITYUNITGBPS.VALUE)
+ .setValue(Decimal64.valueOf(100.0, RoundingMode.DOWN))
+ .build())
.build());
break;
case "IfOCHOTUCnODUCn":
case "IfOCHOTUCnODUCnRegen":
case "IfOCHOTUCnODUCnUniregen":
sps.add(new SupportedPayloadStructureBuilder()
- .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, OTUTYPEOTUCN.VALUE,
+ .setMultiplexingSequence(Set.of(
+ PHOTONICLAYERQUALIFIEROTSi.VALUE, OTUTYPEOTUCN.VALUE,
ODUTYPEODUCN.VALUE, ODUTYPEODU4.VALUE))
.setNumberOfCepInstances(Uint64.valueOf(nepRate))
- .setCapacity(capBd.setValue(Decimal64.valueOf(nepRate * 100.0, RoundingMode.DOWN)).build())
+ .setCapacity(
+ new CapacityBuilder()
+ .setUnit(CAPACITYUNITGBPS.VALUE)
+ .setValue(Decimal64.valueOf(nepRate * 100.0, RoundingMode.DOWN))
+ .build())
.build());
break;
default:
justification = "Voluntarily No break in switchcase where comment is inserted in following method")
public List<SupportedCepLayerProtocolQualifierInstances> createSupportedCepLayerProtocolQualifier(
Collection<SupportedInterfaceCapability> sicList, LayerProtocolName lpn) {
- List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
if (sicList == null) {
- sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
- .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
- .setNumberOfCepInstances(Uint64.valueOf(1))
- .build());
- return sclpqiList;
+ return new ArrayList<>(List.of(
+ new SupportedCepLayerProtocolQualifierInstancesBuilder()
+ .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
+ .setNumberOfCepInstances(Uint64.valueOf(1))
+ .build()));
}
LOG.debug("SIC list = {}", sicList);
+ List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
for (SupportedInterfaceCapability sic : sicList) {
String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
switch (lpn.getName()) {
}
public Map<Double, Double> getXpdrUsedWavelength(TerminationPoint tp) {
- if (tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
- .TerminationPoint1.class) == null
- || tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm
- .network.topology.rev230526.TerminationPoint1.class).getXpdrNetworkAttributes()
- == null) {
+ var tpAug = tp.augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
+ if (tpAug == null || tpAug.getXpdrNetworkAttributes() == null) {
return null;
}
- XpdrNetworkAttributes xnatt = tp.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class)
- .getXpdrNetworkAttributes();
- Map<Double,Double> freqWidthMap = new HashMap<>();
- if (xnatt.getWavelength() != null && xnatt.getWavelength().getFrequency() != null
- && xnatt.getWavelength().getWidth() != null) {
- freqWidthMap.put(xnatt.getWavelength().getFrequency().getValue().doubleValue(),
- xnatt.getWavelength().getWidth().getValue().doubleValue());
- return freqWidthMap;
- }
- return null;
+ var xnattWvlgth = tpAug.getXpdrNetworkAttributes().getWavelength();
+ return xnattWvlgth == null || xnattWvlgth.getFrequency() == null || xnattWvlgth.getWidth() == null
+ ? null
+ : new HashMap<>(Map.of(
+ xnattWvlgth.getFrequency().getValue().doubleValue(),
+ xnattWvlgth.getWidth().getValue().doubleValue()));
}
public Map<Double, Double> getPPUsedWavelength(TerminationPoint tp) {
PpAttributes ppAtt = tp.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class)
+ org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class)
.getPpAttributes();
- if (ppAtt == null) {
- return null;
- }
- Map<Double,Double> freqWidthMap = new HashMap<>();
- if (ppAtt.getUsedWavelength() != null && ppAtt.getUsedWavelength().entrySet().iterator().next() != null) {
- freqWidthMap.put(ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency().getValue()
- .doubleValue(), ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency()
- .getValue().doubleValue());
- return freqWidthMap;
- }
- return null;
+ return ppAtt == null || ppAtt.getUsedWavelength() == null
+ || ppAtt.getUsedWavelength().entrySet().iterator().next() == null
+ ? null
+ : new HashMap<>(Map.of(
+ ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency().getValue().doubleValue(),
+ ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency().getValue().doubleValue()));
}
- public OwnedNodeEdgePointBuilder addPayloadStructureAndPhotSpecToOnep(String nodeId,
- Map<Double, Double> freqWidthMap, List<OperationalModeKey> operModeList,
+ public OwnedNodeEdgePointBuilder addPayloadStructureAndPhotSpecToOnep(
+ String nodeId, Map<Double, Double> freqWidthMap, List<OperationalModeKey> operModeList,
Collection<SupportedInterfaceCapability> sicColl, OwnedNodeEdgePointBuilder onepBldr, String keyword) {
- if (String.join("+", nodeId, TapiStringConstants.OTSI_MC).equals(keyword)
- || String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)) {
- //Creating OTS & OTSI_MC NEP specific attributes
- onepBldr.setSupportedPayloadStructure(createSupportedPayloadStructureForPhtncMedia(
- sicColl,operModeList));
- SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
- OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
- if (freqWidthMap == null || freqWidthMap.isEmpty()) {
- ospecBd
- .setUpperFrequency(Uint64.valueOf(0))
- .setLowerFrequency(Uint64.valueOf(0));
- onepBldr.setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(
- false, sicColl,operModeList));
- double naz = 0.01;
- AvailableSpectrum aspec = new AvailableSpectrumBuilder()
- .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + naz)))
- .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
- + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz)))
- .build();
- Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
- aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(),
- aspec.getUpperFrequency()), aspec);
- spectrumPac.setAvailableSpectrum(aspecMap);
- } else {
- onepBldr.setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(
- true, sicColl,operModeList));
- ospecBd
- .setUpperFrequency(Uint64.valueOf(Math.round(
- freqWidthMap.keySet().iterator().next().doubleValue() * 1E09
- + (freqWidthMap.entrySet().iterator().next().getValue().doubleValue() * 1E06) / 2)))
- .setLowerFrequency(Uint64.valueOf(Math.round(
- freqWidthMap.keySet().iterator().next().doubleValue() * 1E09
- - (freqWidthMap.entrySet().iterator().next().getValue().doubleValue() * 1E06) / 2)));
- }
- OccupiedSpectrum ospec = ospecBd.build();
- Map<OccupiedSpectrumKey, OccupiedSpectrum> ospecMap = new HashMap<>();
- ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(),
- ospec.getUpperFrequency()), ospec);
- spectrumPac.setOccupiedSpectrum(ospecMap);
- double nazz = 0.01;
- SupportableSpectrum sspec = new SupportableSpectrumBuilder()
- .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + nazz)))
- .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
- + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + nazz)))
- .build();
- Map<SupportableSpectrumKey, SupportableSpectrum> sspecMap = new HashMap<>();
- sspecMap.put(new SupportableSpectrumKey(sspec.getLowerFrequency(),
- sspec.getUpperFrequency()), sspec);
- spectrumPac.setSupportableSpectrum(sspecMap);
- PhotonicMediaNodeEdgePointSpec pnepSpec = new PhotonicMediaNodeEdgePointSpecBuilder()
- .setSpectrumCapabilityPac(spectrumPac.build())
- .build();
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.OwnedNodeEdgePoint1 onep1 =
- new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
- .OwnedNodeEdgePoint1Builder()
- .setPhotonicMediaNodeEdgePointSpec(pnepSpec)
- .build();
- onepBldr.addAugmentation(onep1);
+ if (!String.join("+", nodeId, TapiStringConstants.OTSI_MC).equals(keyword)
+ && !String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)) {
+ return onepBldr;
+ }
+ //Creating OTS & OTSI_MC NEP specific attributes
+ double naz = 0.01;
+ Uint64 supLoFreq = Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + naz));
+ Uint64 supUpFreq = Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
+ + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz));
+ boolean boolParam;
+ Uint64 upFreq;
+ Uint64 loFreq;
+ SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
+ if (freqWidthMap == null || freqWidthMap.isEmpty()) {
+ upFreq = Uint64.valueOf(0);
+ loFreq = Uint64.valueOf(0);
+ boolParam = false;
+ AvailableSpectrum aspec =
+ new AvailableSpectrumBuilder().setUpperFrequency(supUpFreq).setLowerFrequency(supLoFreq).build();
+ spectrumPac.setAvailableSpectrum(new HashMap<>(Map.of(
+ new AvailableSpectrumKey(aspec.getLowerFrequency(), aspec.getUpperFrequency()), aspec)));
+ } else {
+ upFreq = Uint64.valueOf(Math.round(
+ freqWidthMap.keySet().iterator().next().doubleValue() * 1E09
+ + (freqWidthMap.entrySet().iterator().next().getValue().doubleValue() * 1E06) / 2));
+ loFreq = Uint64.valueOf(Math.round(
+ freqWidthMap.keySet().iterator().next().doubleValue() * 1E09
+ - (freqWidthMap.entrySet().iterator().next().getValue().doubleValue() * 1E06) / 2));
+ boolParam = true;
}
- return onepBldr;
+ return onepBldr
+ .setSupportedPayloadStructure(createSupportedPayloadStructureForPhtncMedia(sicColl, operModeList))
+ .setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(boolParam, sicColl,operModeList))
+ .addAugmentation(
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
+ .OwnedNodeEdgePoint1Builder()
+ .setPhotonicMediaNodeEdgePointSpec(
+ new PhotonicMediaNodeEdgePointSpecBuilder()
+ .setSpectrumCapabilityPac(
+ spectrumPac
+ .setOccupiedSpectrum(new HashMap<>(Map.of(
+ new OccupiedSpectrumKey(loFreq, upFreq),
+ new OccupiedSpectrumBuilder()
+ .setUpperFrequency(upFreq)
+ .setLowerFrequency(loFreq)
+ .build())))
+ .setSupportableSpectrum(new HashMap<>(Map.of(
+ new SupportableSpectrumKey(supLoFreq, supUpFreq),
+ new SupportableSpectrumBuilder()
+ .setUpperFrequency(supUpFreq)
+ .setLowerFrequency(supLoFreq)
+ .build())))
+ .build())
+ .build())
+ .build());
}
private OduSwitchingPools createOduSwitchingPoolForTp100G() {
Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
int count = 1;
for (TerminationPoint tp : this.oorNetworkPortList) {
- TpId tpid1 = tp.getTpId();
- TpId tpid2 = tp.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1.class)
- .getAssociatedConnectionMapTp().iterator().next();
- Set<TpId> tpList = new HashSet<>();
- tpList.add(tpid1);
- tpList.add(tpid2);
NonBlockingList nbl = new NonBlockingListBuilder()
.setNblNumber(Uint16.valueOf(count))
- .setTpList(tpList)
+ .setTpList(new HashSet<>(Set.of(
+ tp.getTpId(),
+ tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526
+ .TerminationPoint1.class)
+ .getAssociatedConnectionMapTp().iterator().next())))
.build();
nblMap.put(nbl.key(), nbl);
count++;
.build();
}
- private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node
- createTapiNode(Map<NameKey, Name> nodeNames, Set<LayerProtocolName> layerProtocols) {
+ private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node createTapiNode(
+ Map<NameKey, Name> nodeNames, Set<LayerProtocolName> layerProtocols) {
Uuid nodeUuid = null;
Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
- Map<RuleKey, Rule> ruleList = new HashMap<>();
- Set<RuleType> ruleTypes = new HashSet<>();
- ruleTypes.add(RuleType.FORWARDING);
- Rule rule = new RuleBuilder()
- .setLocalId("forward")
- .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
- .setRuleType(ruleTypes)
- .build();
- ruleList.put(rule.key(), rule);
if (layerProtocols.contains(LayerProtocolName.DSR)
|| layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
- nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, ruleList);
+ Rule rule = new RuleBuilder()
+ .setLocalId("forward")
+ .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
+ .setRuleType(new HashSet<>(Set.of(RuleType.FORWARDING)))
+ .build();
+ nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, new HashMap<>(Map.of(rule.key(), rule)));
} else {
- LOG.error("Undefined LayerProtocolName for {} node {}", nodeNames.get(nodeNames.keySet().iterator().next())
- .getValueName(), nodeNames.get(nodeNames.keySet().iterator().next()).getValue());
+ LOG.error("Undefined LayerProtocolName for {} node {}",
+ nodeNames.get(nodeNames.keySet().iterator().next()).getValueName(),
+ nodeNames.get(nodeNames.keySet().iterator().next()).getValue());
}
// Empty random creation of mandatory fields for avoiding errors....
CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
.setRiskCharacteristicName("risk characteristic")
.setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
.build();
- RiskParameterPac riskParamPac = new RiskParameterPacBuilder()
- .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
- .build();
return new NodeBuilder()
.setUuid(nodeUuid)
.setName(nodeNames)
.setNodeRuleGroup(nodeRuleGroupList)
.setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
.setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
- .setRiskParameterPac(riskParamPac)
+ .setRiskParameterPac(
+ new RiskParameterPacBuilder()
+ .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
+ .build())
.setErrorCharacteristic("error")
.setLossCharacteristic("loss")
.setRepeatDeliveryCharacteristic("repeat delivery")
.build();
}
- private Uuid getNodeUuid4Dsr(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
- Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList, Map<RuleKey, Rule> ruleList) {
- Uuid nodeUuid;
- nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, TapiStringConstants.XPDR));
+ private Uuid getNodeUuid4Dsr(
+ Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
+ Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList,
+ Map<RuleKey, Rule> ruleList) {
// client NEP DSR creation on DSR/ODU node
for (int i = 0; i < oorClientPortList.size(); i++) {
- Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
- (String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
- oorClientPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
- LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
- oorClientPortList.get(i).getTpId().getValue()), nepUuid);
- this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
- oorClientPortList.get(i).getTpId().getValue()), nepUuid);
- NameBuilder nameBldr = new NameBuilder().setValue(
- String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
- oorClientPortList.get(i).getTpId().getValue()));
- Name name;
- if (OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
- name = nameBldr.setValueName("100G-tpdr").build();
- } else {
- name = nameBldr.setValueName("NodeEdgePoint_C").build();
- }
-
- OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(name.key(), name),
- LayerProtocolName.DSR, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId,
- TapiStringConstants.DSR));
+ String nodeIdDsr = String.join("+",
+ this.ietfNodeId, TapiStringConstants.DSR, oorClientPortList.get(i).getTpId().getValue());
+ Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(nodeIdDsr.getBytes(Charset.forName("UTF-8"))).toString());
+ LOG.info("NEP = {} has Uuid {} ", nodeIdDsr, nepUuid);
+ this.uuidMap.put(nodeIdDsr, nepUuid);
+ Name name = new NameBuilder()
+ .setValue(nodeIdDsr)
+ .setValueName(OpenroadmNodeType.TPDR.equals(this.ietfNodeType) ? "100G-tpdr" : "NodeEdgePoint_C")
+ .build();
+ OwnedNodeEdgePoint onep = createNep(
+ oorClientPortList.get(i),
+ Map.of(name.key(), name),
+ LayerProtocolName.DSR, LayerProtocolName.DSR, true,
+ String.join("+", this.ietfNodeId, TapiStringConstants.DSR));
onepl.put(onep.key(), onep);
}
// CLIENT NEP E_ODU creation on DSR/ODU node
for (int i = 0; i < oorClientPortList.size(); i++) {
- Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
- (String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
- oorClientPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
- LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
- oorClientPortList.get(i).getTpId().getValue()), nepUuid1);
- this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
- oorClientPortList.get(i).getTpId().getValue()), nepUuid1);
+ String nodeIdEodu = String.join("+",
+ this.ietfNodeId, TapiStringConstants.E_ODU, oorClientPortList.get(i).getTpId().getValue());
+ Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(nodeIdEodu.getBytes(Charset.forName("UTF-8"))).toString());
+ LOG.info("NEP = {} has Uuid {} ", nodeIdEodu, nepUuid1);
+ this.uuidMap.put(nodeIdEodu, nepUuid1);
Name onedName = new NameBuilder()
.setValueName("eNodeEdgePoint_N")
- .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
- oorClientPortList.get(i).getTpId().getValue()))
+ .setValue(nodeIdEodu)
.build();
-
- OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(onedName.key(), onedName),
- LayerProtocolName.ODU, LayerProtocolName.DSR, false, String.join("+", this.ietfNodeId,
- TapiStringConstants.E_ODU));
+ OwnedNodeEdgePoint onep = createNep(
+ oorClientPortList.get(i),
+ Map.of(onedName.key(), onedName),
+ LayerProtocolName.ODU, LayerProtocolName.DSR, false,
+ String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU));
onepl.put(onep.key(), onep);
}
// NETWORK NEPs I_ODU creation on DSR/ODU node
for (int i = 0; i < oorNetworkPortList.size(); i++) {
- Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
- (String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
- oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
- LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
- oorNetworkPortList.get(i).getTpId().getValue()), nepUuid1);
- this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
- oorNetworkPortList.get(i).getTpId().getValue()), nepUuid1);
+ String nodeIdIodu = String.join("+",
+ this.ietfNodeId, TapiStringConstants.I_ODU, oorNetworkPortList.get(i).getTpId().getValue());
+ Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(nodeIdIodu.getBytes(Charset.forName("UTF-8"))).toString());
+ LOG.info("NEP = {} has Uuid {} ", nodeIdIodu, nepUuid1);
+ this.uuidMap.put(nodeIdIodu, nepUuid1);
Name onedName = new NameBuilder()
.setValueName("iNodeEdgePoint_N")
- .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
- oorNetworkPortList.get(i).getTpId().getValue()))
+ .setValue(nodeIdIodu)
.build();
-
- OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
- LayerProtocolName.ODU, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId,
- TapiStringConstants.I_ODU));
+ OwnedNodeEdgePoint onep = createNep(
+ oorNetworkPortList.get(i),
+ Map.of(onedName.key(), onedName),
+ LayerProtocolName.ODU, LayerProtocolName.DSR, true,
+ String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU));
onepl.put(onep.key(), onep);
}
// NETWORK NEP OTS network on DSR/ODU node
for (int i = 0; i < oorNetworkPortList.size(); i++) {
- Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
- (String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
- oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
- .toString());
- LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
- oorNetworkPortList.get(i).getTpId().getValue()), nepUuid2);
- this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
- oorNetworkPortList.get(i).getTpId().getValue()), nepUuid2);
+ String nodeIdPmOts = String.join("+",
+ this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS, oorNetworkPortList.get(i).getTpId().getValue());
+ Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(nodeIdPmOts.getBytes(Charset.forName("UTF-8"))).toString());
+ LOG.info("NEP = {} has Uuid {} ", nodeIdPmOts, nepUuid2);
+ this.uuidMap.put(nodeIdPmOts, nepUuid2);
Name onedName = new NameBuilder()
.setValueName("eNodeEdgePoint")
- .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS,
- oorNetworkPortList.get(i).getTpId().getValue()))
+ .setValue(nodeIdPmOts)
.build();
-
- OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
+ OwnedNodeEdgePoint onep = createNep(
+ oorNetworkPortList.get(i),
+ Map.of(onedName.key(), onedName),
LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS));
onepl.put(onep.key(), onep);
}
for (int i = 0; i < oorNetworkPortList.size(); i++) {
- Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
- (String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
- oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
- .toString());
- LOG.info("NEP = {} has Uuid {} ", String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
- oorNetworkPortList.get(i).getTpId().getValue()), nepUuid3);
- this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
- oorNetworkPortList.get(i).getTpId().getValue()), nepUuid3);
+ String nodeIdOtMc = String.join("+",
+ this.ietfNodeId, TapiStringConstants.OTSI_MC, oorNetworkPortList.get(i).getTpId().getValue());
+ Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(nodeIdOtMc.getBytes(Charset.forName("UTF-8"))).toString());
+ LOG.info("NEP = {} has Uuid {} ", nodeIdOtMc, nepUuid3);
+ this.uuidMap.put(nodeIdOtMc, nepUuid3);
Name onedName = new NameBuilder()
.setValueName("PhotMedNodeEdgePoint")
- .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
- oorNetworkPortList.get(i).getTpId().getValue()))
+ .setValue(nodeIdOtMc)
.build();
-
- OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
+ OwnedNodeEdgePoint onep = createNep(
+ oorNetworkPortList.get(i),
+ Map.of(onedName.key(), onedName),
LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC));
onepl.put(onep.key(), onep);
// create NodeRuleGroup
int count = 1;
LOG.debug("ODU switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
+ String ietfXpdr = String.join("+", this.ietfNodeId, TapiStringConstants.XPDR);
for (NonBlockingList nbl : this.oorOduSwitchingPool.nonnullNonBlockingList().values()) {
Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
- nepList = new HashMap<>();
+ nepList = new HashMap<>();
Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
- oduNepList = new HashMap<>();
+ oduNepList = new HashMap<>();
LOG.debug("UUidMap={}", this.uuidMap.keySet());
LOG.debug("TP list = {}", nbl.getTpList());
for (TpId tp : nbl.getTpList()) {
LOG.debug("TP={}", tp.getValue());
- LOG.debug("UuidKey={}", String.join("+", this.ietfNodeId,
- TapiStringConstants.E_ODU, tp.getValue()));
- if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
- tp.getValue())) || this.uuidMap.containsKey(String.join(
- "+", this.ietfNodeId, TapiStringConstants.I_ODU, tp.getValue()))) {
- String qual = tp.getValue().contains("CLIENT") ? TapiStringConstants.DSR
- : TapiStringConstants.I_ODU;
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
- nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
- .node.rule.group.NodeEdgePointBuilder()
- .setTopologyUuid(tapiTopoUuid)
- .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
- TapiStringConstants.XPDR)))
- .setNodeEdgePointUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
- qual, tp.getValue())))
- .build();
+ String ietfEoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU, tp.getValue());
+ LOG.debug("UuidKey={}", ietfEoduTp);
+ String ietfIoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU, tp.getValue());
+ if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, TapiStringConstants.DSR, tp.getValue()))
+ || this.uuidMap.containsKey(ietfIoduTp)) {
+ String qual = tp.getValue().contains("CLIENT")
+ ? TapiStringConstants.DSR : TapiStringConstants.I_ODU;
+ var nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+ .node.rule.group.NodeEdgePointBuilder()
+ .setTopologyUuid(tapiTopoUuid)
+ .setNodeUuid(this.uuidMap.get(ietfXpdr))
+ .setNodeEdgePointUuid(this.uuidMap.get(
+ String.join("+", this.ietfNodeId, qual, tp.getValue())))
+ .build();
nepList.put(nep.key(), nep);
}
- if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId,
- TapiStringConstants.E_ODU, tp.getValue()))) {
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
- nep1 = new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointBuilder()
- .setTopologyUuid(tapiTopoUuid)
- .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
- TapiStringConstants.XPDR)))
- .setNodeEdgePointUuid(this.uuidMap.get(String.join(
- "+", this.ietfNodeId, TapiStringConstants.E_ODU, tp.getValue())))
- .build();
+ if (this.uuidMap.containsKey(ietfEoduTp)) {
+ var nep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+ .node.rule.group.NodeEdgePointBuilder()
+ .setTopologyUuid(tapiTopoUuid)
+ .setNodeUuid(this.uuidMap.get(ietfXpdr))
+ .setNodeEdgePointUuid(this.uuidMap.get(ietfEoduTp))
+ .build();
oduNepList.put(nep1.key(), nep1);
}
- if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId,
- TapiStringConstants.I_ODU, tp.getValue()))) {
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
- nep2 = new org.opendaylight.yang.gen.v1.urn
- .onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointBuilder()
- .setTopologyUuid(tapiTopoUuid)
- .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
- TapiStringConstants.XPDR)))
- .setNodeEdgePointUuid(this.uuidMap.get(String.join(
- "+", this.ietfNodeId, TapiStringConstants.I_ODU, tp.getValue())))
- .build();
+ if (this.uuidMap.containsKey(ietfIoduTp)) {
+ // TODO already checked with DSR above -> potential factorization ?
+ var nep2 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+ .node.rule.group.NodeEdgePointBuilder()
+ .setTopologyUuid(tapiTopoUuid)
+ .setNodeUuid(this.uuidMap.get(ietfXpdr))
+ .setNodeEdgePointUuid(this.uuidMap.get(ietfIoduTp))
+ .build();
oduNepList.put(nep2.key(), nep2);
}
}
- LOG.debug("NEPLIST (DSR/I_ODU) of [dsr node rule group] is {}", nepList.toString());
- LOG.debug("NEPLIST (E_ODU/I_ODU) of [odu node rule group] is {}", nepList.toString());
+ LOG.debug("NEPLIST (DSR/I_ODU) of [dsr node rule group] is {}", nepList);
+ LOG.debug("NEPLIST (E_ODU/I_ODU) of [odu node rule group] is {}", nepList);
// Empty random creation of mandatory fields for avoiding errors....
CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
.setCostAlgorithm("Restricted Shortest Path - RSP")
nodeRuleGroupList.put(nodeRuleGroup2.key(), nodeRuleGroup2);
count++;
}
- return nodeUuid;
+ return this.uuidMap.get(ietfXpdr);
}
private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, Map<NameKey, Name> nepNames,
LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip, String keyword) {
- String key = String.join("+", keyword, oorTp.getTpId().getValue());
- AdministrativeState adminState = (oorTp.augmentation(TerminationPoint1.class).getAdministrativeState() != null)
- ? transformAsToTapiAdminState(oorTp.augmentation(TerminationPoint1.class).getAdministrativeState()
- .getName())
- : null;
- OperationalState operState = (oorTp.augmentation(TerminationPoint1.class).getOperationalState() != null)
- ? transformOsToTapiOperationalState(oorTp.augmentation(TerminationPoint1.class).getOperationalState()
- .getName())
- : null;
- org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.TerminationPoint1 tp1 =
- oorTp.augmentation(org.opendaylight.yang.gen.v1.http
- .org.openroadm.otn.network.topology.rev230526.TerminationPoint1.class);
+ var tp1 = oorTp.augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.TerminationPoint1.class);
if (tp1.getTpSupportedInterfaces() == null) {
LOG.warn("Tp supported interface doesnt exist on TP {}", oorTp.getTpId().getValue());
return null;
}
- Collection<SupportedInterfaceCapability> sicColl = tp1.getTpSupportedInterfaces()
- .getSupportedInterfaceCapability().values();
+ AdministrativeState adminState =
+ oorTp.augmentation(TerminationPoint1.class).getAdministrativeState() == null
+ ? null
+ : transformAsToTapiAdminState(
+ oorTp.augmentation(TerminationPoint1.class).getAdministrativeState().getName());
+ OperationalState operState =
+ oorTp.augmentation(TerminationPoint1.class).getOperationalState() == null
+ ? null
+ : transformOsToTapiOperationalState(
+ oorTp.augmentation(TerminationPoint1.class).getOperationalState().getName());
+ Collection<SupportedInterfaceCapability> sicColl =
+ tp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values();
OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
- .setUuid(this.uuidMap.get(key))
+ .setUuid(this.uuidMap.get(String.join("+", keyword, oorTp.getTpId().getValue())))
.setLayerProtocolName(nepProtocol)
- .setName(nepNames);
- onepBldr.setSupportedCepLayerProtocolQualifierInstances(createSupportedCepLayerProtocolQualifier(sicColl,
- nepProtocol))
+ .setName(nepNames)
+ .setSupportedCepLayerProtocolQualifierInstances(
+ createSupportedCepLayerProtocolQualifier(sicColl, nepProtocol))
.setDirection(Direction.BIDIRECTIONAL)
.setLinkPortRole(PortRole.SYMMETRIC)
.setAdministrativeState(adminState)
onepBldr.setMappedServiceInterfacePoint(
createMSIP(1, nepProtocol, oorTp.getTpId().getValue(), keyword, sicColl, operState, adminState));
}
- List<OperationalModeKey> opModeList = new ArrayList<>();
if (oorTp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
- if (oorTp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
- .TerminationPoint1.class) == null
- || oorTp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm
- .network.topology.rev230526.TerminationPoint1.class).getXpdrNetworkAttributes()
- == null) {
+ List<OperationalModeKey> opModeList = new ArrayList<>();
+ var tp11 = oorTp.augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
+ if (tp11 == null || tp11.getXpdrNetworkAttributes() == null) {
for (SupportedInterfaceCapability sic : sicColl) {
String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
if (("IfOCHOTUCnODUCn").equals(ifCapType) || ("IfOCHOTUCnODUCnUniregen").equals(ifCapType)
|| ("IfOCHOTUCnODUCnRegen").equals(ifCapType)) {
opModeList.add(new OperationalModeKey("400G"));
- LOG.warn(TopologyUtils.NOOPMODEDECLARED + "400G rate available", oorTp.getTpId().toString());
+ LOG.warn(TopologyUtils.NOOPMODEDECLARED + "400G rate available", oorTp.getTpId());
break;
}
}
opModeList.add(new OperationalModeKey("100G"));
- LOG.warn(TopologyUtils.NOOPMODEDECLARED + "100G rate available", oorTp.getTpId().toString());
+ LOG.warn(TopologyUtils.NOOPMODEDECLARED + "100G rate available", oorTp.getTpId());
} else {
- opModeList = oorTp.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class)
- .getXpdrNetworkAttributes().getSupportedOperationalModes().getOperationalMode().keySet().stream()
- .toList();
+ opModeList = tp11.getXpdrNetworkAttributes().getSupportedOperationalModes().getOperationalMode()
+ .keySet().stream().toList();
}
- Map<Double, Double> freqWidthMap = getXpdrUsedWavelength(oorTp);
- onepBldr = addPayloadStructureAndPhotSpecToOnep(this.ietfNodeId, freqWidthMap, opModeList, sicColl,
- onepBldr, keyword);
+ onepBldr = addPayloadStructureAndPhotSpecToOnep(
+ this.ietfNodeId, getXpdrUsedWavelength(oorTp), opModeList, sicColl, onepBldr, keyword);
}
return onepBldr.build();
}
.setValueName("SIP name")
.setValue(String.join("+", nodeid, tpId))
.build();
-
return new ServiceInterfacePointBuilder()
.setUuid(sipUuid)
.setName(Map.of(sipName.key(), sipName))
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "SF_SWITCH_FALLTHROUGH",
justification = "Voluntarily No break in switchcase where comment is inserted in following method")
private List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
- .service._interface.point.SupportedCepLayerProtocolQualifierInstances>
- createSipSupportedLayerProtocolQualifier(
- Collection<SupportedInterfaceCapability> supportedInterfaceCapability,
- LayerProtocolName lpn) {
- List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
- .service._interface.point.SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
+ .service._interface.point.SupportedCepLayerProtocolQualifierInstances>
+ createSipSupportedLayerProtocolQualifier(
+ Collection<SupportedInterfaceCapability> supportedInterfaceCapability, LayerProtocolName lpn) {
if (supportedInterfaceCapability == null) {
- sclpqiList.add(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
- .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
+ return new ArrayList<>(List.of(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
+ .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
.setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
.setNumberOfCepInstances(Uint64.valueOf(1))
- .build());
- return sclpqiList;
+ .build()));
}
+ List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
+ .service._interface.point.SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
for (SupportedInterfaceCapability sic : supportedInterfaceCapability) {
String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
switch (lpn.getName()) {
}
public AdministrativeState transformAsToTapiAdminState(String adminState) {
- if (adminState == null) {
- return null;
- }
- return adminState.equals(AdminStates.InService.getName())
- || adminState.equals(AdministrativeState.UNLOCKED.getName()) ? AdministrativeState.UNLOCKED
- : AdministrativeState.LOCKED;
+ return adminState == null
+ ? null
+ : adminState.equals(AdminStates.InService.getName())
+ || adminState.equals(AdministrativeState.UNLOCKED.getName())
+ ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
}
public OperationalState transformOsToTapiOperationalState(String operState) {
- if (operState == null) {
- return null;
- }
- return operState.equals("inService") || operState.equals(OperationalState.ENABLED.getName())
- ? OperationalState.ENABLED : OperationalState.DISABLED;
+ return operState == null
+ ? null
+ : operState.equals("inService") || operState.equals(OperationalState.ENABLED.getName())
+ ? OperationalState.ENABLED : OperationalState.DISABLED;
}
public Map<ServiceInterfacePointKey, ServiceInterfacePoint> getTapiSips() {
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPac;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristic;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristicBuilder;
this.tapiLink = tapiLink;
}
- public void convertRdmToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
- .ietf.network.topology.rev180226.networks.network.Link> rdmTordmLinkList) {
+ public void convertRdmToRdmLinks(
+ List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link> rdmTordmLinkList) {
List<String> linksToNotConvert = new ArrayList<>();
LOG.info("creation of {} roadm to roadm links", rdmTordmLinkList.size() / 2);
- for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
- .Link link : rdmTordmLinkList) {
+ for (var link : rdmTordmLinkList) {
if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
- .ietf.network.topology.rev180226.networks.network.Link oppositeLink = rdmTordmLinkList.stream()
+ var oppositeLink = rdmTordmLinkList.stream()
.filter(l -> l.getLinkId().equals(link.augmentation(Link1.class).getOppositeLink()))
.findAny().orElse(null);
-
AdminStates oppLnkAdmState = null;
State oppLnkOpState = null;
if (oppositeLink != null) {
oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
}
- String adminState =
- link.augmentation(Link1.class).getAdministrativeState() == null
- || oppLnkAdmState == null
- ? null
- : this.tapiLink.setTapiAdminState(
- link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName();
- String operState =
- link.augmentation(Link1.class).getOperationalState() == null
- || oppLnkOpState == null
- ? null
- : this.tapiLink.setTapiOperationalState(
- link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName();
- Link tapLink = this.tapiLink.createTapiLink(String.join("-",
+ Link tapLink = this.tapiLink.createTapiLink(
+ String.join("-",
link.getSource().getSourceNode().getValue().split("-")[0],
link.getSource().getSourceNode().getValue().split("-")[1]),
- link.getSource().getSourceTp().getValue(), String.join("-",
+ link.getSource().getSourceTp().getValue(),
+ String.join("-",
link.getDestination().getDestNode().getValue().split("-")[0],
link.getDestination().getDestNode().getValue().split("-")[1]),
link.getDestination().getDestTp().getValue(), TapiStringConstants.OMS_RDM_RDM_LINK,
TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.PHTNC_MEDIA,
- TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS, adminState, operState,
+ TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS,
+ //adminState,
+ link.augmentation(Link1.class).getAdministrativeState() == null || oppLnkAdmState == null
+ ? null
+ : this.tapiLink.setTapiAdminState(
+ link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName(),
+ //operState,
+ link.augmentation(Link1.class).getOperationalState() == null || oppLnkOpState == null
+ ? null
+ : this.tapiLink.setTapiOperationalState(
+ link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName(),
Set.of(LayerProtocolName.PHOTONICMEDIA), Set.of(LayerProtocolName.PHOTONICMEDIA.getName()),
this.tapiTopoUuid);
- linksToNotConvert.add(link
- .augmentation(Link1.class)
- .getOppositeLink().getValue());
+ linksToNotConvert.add(link.augmentation(Link1.class).getOppositeLink().getValue());
tapiLinks.put(tapLink.key(), tapLink);
}
}
public void convertRoadmNode(Node roadm, Network openroadmTopo) {
this.ietfNodeId = roadm.getNodeId().getValue();
this.ietfNodeType = roadm.augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class).getNodeType();
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
+ .getNodeType();
Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist = new HashMap<>();
// 1. Get degree and srg nodes to map TPs into NEPs
if (openroadmTopo.getNode() == null) {
int numSips = 0;
List<Node> nodeList = new ArrayList<Node>(openroadmTopo.getNode().values());
for (Node node:nodeList) {
- if (node.getSupportingNode().values().stream().noneMatch(sp -> sp.getNodeRef().getValue()
- .equals(this.ietfNodeId))) {
- LOG.debug("Abstracted node {} is not part of {}",
- node.getNodeId().getValue(), this.ietfNodeId);
+ if (node.getSupportingNode().values().stream()
+ .noneMatch(sp -> sp.getNodeRef().getValue().equals(this.ietfNodeId))) {
+ LOG.debug("Abstracted node {} is not part of {}", node.getNodeId().getValue(), this.ietfNodeId);
continue;
}
if (node.augmentation(Node1.class) == null
- && node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
- .ietf.network.topology.rev180226.Node1.class) == null) {
+ && node.augmentation(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .Node1.class) == null) {
LOG.warn("Abstracted node {} doesnt have type of node or is not disaggregated",
node.getNodeId().getValue());
continue;
}
- OpenroadmNodeType nodeType = node.augmentation(org.opendaylight.yang.gen.v1.http
- .org.openroadm.common.network.rev230526.Node1.class).getNodeType();
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 node1 =
- node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
- .ietf.network.topology.rev180226.Node1.class);
+ OpenroadmNodeType nodeType = node.augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
+ .getNodeType();
+ var node1 = node.augmentation(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class);
LOG.info("TPs of node: {}", node1.getTerminationPoint().values());
switch (nodeType.getIntValue()) {
case 11:
// Get only external TPs of the degree
List<TerminationPoint> degPortList = node1.getTerminationPoint().values().stream()
.filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
- == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
+ == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
|| tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
- == OpenroadmTpType.DEGREERXTTP.getIntValue()
+ == OpenroadmTpType.DEGREERXTTP.getIntValue()
|| tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
- == OpenroadmTpType.DEGREETXTTP.getIntValue())
+ == OpenroadmTpType.DEGREETXTTP.getIntValue())
.collect(Collectors.toList());
// Convert TP List in NEPs and put it in onepl
LOG.info("Degree port List: {}", degPortList);
// Get only external TPs of the srg
List<TerminationPoint> srgPortList = node1.getTerminationPoint().values().stream()
.filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
- == OpenroadmTpType.SRGTXRXPP.getIntValue()
+ == OpenroadmTpType.SRGTXRXPP.getIntValue()
|| tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
- == OpenroadmTpType.SRGRXPP.getIntValue()
+ == OpenroadmTpType.SRGRXPP.getIntValue()
|| tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
- == OpenroadmTpType.SRGTXPP.getIntValue())
+ == OpenroadmTpType.SRGTXPP.getIntValue())
.collect(Collectors.toList());
// Convert TP List in NEPs and put it in onepl
LOG.info("Srg port List: {}", srgPortList);
}
// create tapi Node
// UUID
- Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", roadm.getNodeId().getValue(),
- TapiStringConstants.PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
- LOG.info("Creation of PHOTONIC node for {}, of Uuid {}", roadm.getNodeId().getValue(), nodeUuid.toString());
+ String nodeIdPhMed = String.join("+", roadm.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA);
+ Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeIdPhMed.getBytes(Charset.forName("UTF-8"))).toString());
+ LOG.info("Creation of PHOTONIC node for {}, of Uuid {}", roadm.getNodeId().getValue(), nodeUuid);
// Names
- Name nodeNames = new NameBuilder().setValueName("roadm node name")
- .setValue(String.join("+", roadm.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA)).build();
- Name nameNodeType = new NameBuilder().setValueName("Node Type")
- .setValue(this.ietfNodeType.getName()).build();
+ Name nodeNames = new NameBuilder().setValueName("roadm node name").setValue(nodeIdPhMed).build();
+ Name nameNodeType = new NameBuilder().setValueName("Node Type").setValue(this.ietfNodeType.getName()).build();
// Protocol Layer
Set<LayerProtocolName> layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
// Build tapi node
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology
- .Node roadmNode = createRoadmTapiNode(nodeUuid,
- Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType), layerProtocols, oneplist);
+ var roadmNode = createRoadmTapiNode(
+ nodeUuid, Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType), layerProtocols, oneplist);
// TODO add states corresponding to device config
LOG.info("ROADM node {} should have {} NEPs and {} SIPs", roadm.getNodeId().getValue(), numNeps, numSips);
- LOG.info("ROADM node {} has {} NEPs and {} SIPs", roadm.getNodeId().getValue(),
+ LOG.info("ROADM node {} has {} NEPs and {} SIPs",
+ roadm.getNodeId().getValue(),
roadmNode.nonnullOwnedNodeEdgePoint().values().size(),
roadmNode.nonnullOwnedNodeEdgePoint().values().stream()
.filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
-
tapiNodes.put(roadmNode.key(), roadmNode);
}
- private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node
- createRoadmTapiNode(Uuid nodeUuid, Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
- Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
+ private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node createRoadmTapiNode(
+ Uuid nodeUuid, Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
+ Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
// Empty random creation of mandatory fields for avoiding errors....
CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
.setCostAlgorithm("Restricted Shortest Path - RSP")
.setRiskCharacteristicName("risk characteristic")
.setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
.build();
- RiskParameterPac riskParamPac = new RiskParameterPacBuilder()
- .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
- .build();
return new NodeBuilder()
.setUuid(nodeUuid)
.setName(nameMap)
.createNodeRuleGroupForRdmNode("Full",nodeUuid, this.ietfNodeId, oneplist.values()))
.setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
.setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
- .setRiskParameterPac(riskParamPac)
+ .setRiskParameterPac(
+ new RiskParameterPacBuilder()
+ .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
+ .build())
.setErrorCharacteristic("error")
.setLossCharacteristic("loss")
.setRepeatDeliveryCharacteristic("repeat delivery")
.build();
}
- private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(List<TerminationPoint> tpList,
- boolean withSip, String nepPhotonicSublayer) {
+ private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(
+ List<TerminationPoint> tpList, boolean withSip, String nepPhotonicSublayer) {
// create neps for MC and OTSiMC and Photonic Media
Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
for (TerminationPoint tp:tpList) {
- // Admin and oper state common for all tps
- AdminStates admin = tp.augmentation(TerminationPoint1.class).getAdministrativeState();
- State oper = tp.augmentation(TerminationPoint1.class).getOperationalState();
// PHOTONIC MEDIA nep
- LOG.info("PHOTO NEP = {}", String.join("+", this.ietfNodeId, nepPhotonicSublayer,
- tp.getTpId().getValue()));
+ String nodeIdNepTp = String.join("+", this.ietfNodeId, nepPhotonicSublayer, tp.getTpId().getValue());
+ LOG.info("PHOTO NEP = {}", nodeIdNepTp);
Name nepName = new NameBuilder()
.setValueName(nepPhotonicSublayer + "NodeEdgePoint")
- .setValue(String.join("+", this.ietfNodeId, nepPhotonicSublayer,
- tp.getTpId().getValue()))
+ .setValue(nodeIdNepTp)
.build();
-
- List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
- sclpqiList.add(
- new SupportedCepLayerProtocolQualifierInstancesBuilder()
- .setLayerProtocolQualifier(
- TapiStringConstants.PHTNC_MEDIA_OMS.equals(nepPhotonicSublayer)
- ? PHOTONICLAYERQUALIFIEROMS.VALUE
- : PHOTONICLAYERQUALIFIEROTS.VALUE)
- .setNumberOfCepInstances(Uint64.valueOf(1))
- .build());
OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
- .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
- nepPhotonicSublayer, tp.getTpId().getValue()))
- .getBytes(Charset.forName("UTF-8"))).toString()))
+ .setUuid(new Uuid(UUID.nameUUIDFromBytes(nodeIdNepTp.getBytes(Charset.forName("UTF-8"))).toString()))
.setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
.setName(Map.of(nepName.key(), nepName))
- .setSupportedCepLayerProtocolQualifierInstances(sclpqiList)
+ .setSupportedCepLayerProtocolQualifierInstances(
+ new ArrayList<>(List.of(
+ new SupportedCepLayerProtocolQualifierInstancesBuilder()
+ .setLayerProtocolQualifier(
+ TapiStringConstants.PHTNC_MEDIA_OMS.equals(nepPhotonicSublayer)
+ ? PHOTONICLAYERQUALIFIEROMS.VALUE
+ : PHOTONICLAYERQUALIFIEROTS.VALUE)
+ .setNumberOfCepInstances(Uint64.valueOf(1))
+ .build())))
.setDirection(Direction.BIDIRECTIONAL)
.setLinkPortRole(PortRole.SYMMETRIC)
- .setAdministrativeState(this.tapiLink.setTapiAdminState(admin.getName()))
- .setOperationalState(this.tapiLink.setTapiOperationalState(oper.getName()))
+ .setAdministrativeState(this.tapiLink.setTapiAdminState(
+ // Admin state common for all tps
+ tp.augmentation(TerminationPoint1.class).getAdministrativeState().getName()))
+ .setOperationalState(this.tapiLink.setTapiOperationalState(
+ // Oper state common for all tps
+ tp.augmentation(TerminationPoint1.class).getOperationalState().getName()))
.setLifecycleState(LifecycleState.INSTALLED)
.build();
onepMap.put(onep.key(), onep);
return onepMap;
}
- public void convertXpdrToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
- .ietf.network.topology.rev180226.networks.network.Link> xpdrRdmLinkList) {
+ public void convertXpdrToRdmLinks(
+ List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link> xpdrRdmLinkList) {
List<String> linksToNotConvert = new ArrayList<>();
LOG.info("creation of {} xpdr to roadm links", xpdrRdmLinkList.size() / 2);
// LOG.info("Link list = {}", xpdrRdmLinkList.toString());
- for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
- .ietf.network.topology.rev180226.networks.network.Link link:xpdrRdmLinkList) {
+ for (var link:xpdrRdmLinkList) {
if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
- .ietf.network.topology.rev180226.networks.network.Link oppositeLink = xpdrRdmLinkList.stream()
+ var oppositeLink = xpdrRdmLinkList.stream()
.filter(l -> l.getLinkId().equals(link.augmentation(Link1.class).getOppositeLink())).findAny()
.orElse(null);
-
AdminStates oppLnkAdmState = null;
State oppLnkOpState = null;
if (oppositeLink != null) {
oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
}
- String adminState =
- link.augmentation(Link1.class).getAdministrativeState() == null
- || oppLnkAdmState == null
- ? null
- : this.tapiLink.setTapiAdminState(
- link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName();
- String operState =
- link.augmentation(Link1.class).getOperationalState() == null
- || oppLnkOpState == null
- ? null
- : this.tapiLink.setTapiOperationalState(
- link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName();
-
- String sourceNode = (link.getSource().getSourceNode().getValue().contains("ROADM"))
- ? getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue())
- : link.getSource().getSourceNode().getValue();
- String sourceTp = link.getSource().getSourceTp().getValue();
- String sourceNodeQual = sourceNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA
- : TapiStringConstants.XPDR;
- String destNode = (link.getDestination().getDestNode().getValue().contains("ROADM"))
- ? getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue())
- : link.getDestination().getDestNode().getValue();
- String destTp = link.getDestination().getDestTp().getValue();
- String destNodeQual = destNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA
- : TapiStringConstants.XPDR;
- Link tapLink = this.tapiLink.createTapiLink(sourceNode, sourceTp, destNode, destTp,
- TapiStringConstants.OMS_XPDR_RDM_LINK, sourceNodeQual, destNodeQual,
- TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS, adminState,
- operState, Set.of(LayerProtocolName.PHOTONICMEDIA),
- Set.of(LayerProtocolName.PHOTONICMEDIA.getName()), this.tapiTopoUuid);
+ String sourceNode =
+ link.getSource().getSourceNode().getValue().contains("ROADM")
+ ? getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue())
+ : link.getSource().getSourceNode().getValue();
+ String destNode =
+ link.getDestination().getDestNode().getValue().contains("ROADM")
+ ? getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue())
+ : link.getDestination().getDestNode().getValue();
+ Link tapLink = this.tapiLink.createTapiLink(
+ sourceNode, link.getSource().getSourceTp().getValue(),
+ destNode, link.getDestination().getDestTp().getValue(),
+ TapiStringConstants.OMS_XPDR_RDM_LINK,
+ sourceNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA : TapiStringConstants.XPDR,
+ destNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA : TapiStringConstants.XPDR,
+ TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS,
+ //adminState,
+ link.augmentation(Link1.class).getAdministrativeState() == null || oppLnkAdmState == null
+ ? null
+ : this.tapiLink.setTapiAdminState(
+ link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName(),
+ //operState,
+ link.augmentation(Link1.class).getOperationalState() == null || oppLnkOpState == null
+ ? null
+ : this.tapiLink.setTapiOperationalState(
+ link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName(),
+ Set.of(LayerProtocolName.PHOTONICMEDIA), Set.of(LayerProtocolName.PHOTONICMEDIA.getName()),
+ this.tapiTopoUuid);
linksToNotConvert.add(link.augmentation(Link1.class).getOppositeLink().getValue());
this.tapiLinks.put(tapLink.key(), tapLink);
}
}
}
-
public void setTapiNodes(Map<NodeKey,
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeMap) {
this.tapiNodes.putAll(nodeMap);
private Integer nrgContainsClientAndNetwork(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid) {
// 1 NRG should at least contain the NEP of interest in the NEP List
- Boolean foundClient = false;
- Boolean foundNetwork = false;
Integer indexNrg = 0;
for (NodeRuleGroup nrg : nrgList) {
+ Boolean foundClient = false;
+ Boolean foundNetwork = false;
for (NodeEdgePoint nep : nrg.nonnullNodeEdgePoint().values()) {
- if (nep.getNodeEdgePointUuid().equals(clientNepUuid)) {
- foundClient = true;
- } else if (nep.getNodeEdgePointUuid().equals(networkNepUuid)) {
- foundNetwork = true;
- }
+ foundClient = foundClient || nep.getNodeEdgePointUuid().equals(clientNepUuid);
+ foundNetwork = foundNetwork || nep.getNodeEdgePointUuid().equals(networkNepUuid);
}
if (foundClient && foundNetwork) {
- break;
- } else {
- foundClient = false;
- foundNetwork = false;
+ return indexNrg;
}
indexNrg++;
}
- if (foundClient && foundNetwork) {
- return indexNrg;
- }
return null;
}
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
@BeforeAll
static void setUp() throws InterruptedException, ExecutionException {
- TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
- TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
- TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
- TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
- TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
+ TopologyDataUtils.writeTopologyFromFileToDatastore(
+ getDataStoreContextUtil(),
+ TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE,
+ InstanceIdentifiers.OVERLAY_NETWORK_II);
+ TopologyDataUtils.writeTopologyFromFileToDatastore(
+ getDataStoreContextUtil(),
+ TapiTopologyDataUtils.OTN_TOPOLOGY_FILE,
+ InstanceIdentifiers.OTN_NETWORK_II);
+ TopologyDataUtils.writePortmappingFromFileToDatastore(
+ getDataStoreContextUtil(),
TapiTopologyDataUtils.PORTMAPPING_FILE);
-
- KeyedInstanceIdentifier<Node, NodeKey> muxAIID = InstanceIdentifier.create(Networks.class)
- .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
- .class, new NetworkKey(new NetworkId("otn-topology")))
- .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1")));
FluentFuture<Optional<Node>> muxAFuture = dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, muxAIID);
- KeyedInstanceIdentifier<Node, NodeKey> muxCIID = InstanceIdentifier.create(Networks.class)
- .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
- .class, new NetworkKey(new NetworkId("otn-topology")))
- .child(Node.class, new NodeKey(new NodeId("SPDR-SC1-XPDR1")));
- FluentFuture<Optional<Node>> muxCFuture = dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, muxCIID);
- KeyedInstanceIdentifier<Node, NodeKey> switchIID = InstanceIdentifier.create(Networks.class)
- .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
- .class, new NetworkKey(new NetworkId("otn-topology")))
- .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2")));
- FluentFuture<Optional<Node>> switchFuture = dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, switchIID);
-
+ .read(LogicalDatastoreType.CONFIGURATION,
+ //muxAIID
+ InstanceIdentifier.create(Networks.class)
+ .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
+ .networks.Network.class,
+ new NetworkKey(new NetworkId("otn-topology")))
+ .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1"))));
+ FluentFuture<Optional<Node>> muxCFuture =
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
+ //muxCIID
+ InstanceIdentifier.create(Networks.class)
+ .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
+ .networks.Network.class,
+ new NetworkKey(new NetworkId("otn-topology")))
+ .child(Node.class, new NodeKey(new NodeId("SPDR-SC1-XPDR1"))));
+ FluentFuture<Optional<Node>> switchFuture =
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
+ //switchIID
+ InstanceIdentifier.create(Networks.class)
+ .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
+ .networks.Network.class,
+ new NetworkKey(new NetworkId("otn-topology")))
+ .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2"))));
otnMuxA = muxAFuture.get().orElseThrow();
otnMuxC = muxCFuture.get().orElseThrow();
otnSwitch = switchFuture.get().orElseThrow();
-
- KeyedInstanceIdentifier<Node, NodeKey> tpdrIID = InstanceIdentifier.create(Networks.class)
- .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
- .class, new NetworkKey(new NetworkId("otn-topology")))
- .child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1")));
- FluentFuture<Optional<Node>> tpdrFuture = dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tpdrIID);
+ FluentFuture<Optional<Node>> tpdrFuture =
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
+ //tpdrIID
+ InstanceIdentifier.create(Networks.class)
+ .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
+ .networks.Network.class,
+ new NetworkKey(new NetworkId("otn-topology")))
+ .child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1"))));
tpdr100G = tpdrFuture.get().orElseThrow();
-
- InstanceIdentifier<Network1> linksIID = InstanceIdentifier.create(Networks.class)
- .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
- .class, new NetworkKey(new NetworkId("otn-topology")))
- .augmentation(Network1.class);
FluentFuture<Optional<Network1>> linksFuture = dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, linksIID);
+ .read(LogicalDatastoreType.CONFIGURATION,
+ //linksIID
+ InstanceIdentifier.create(Networks.class)
+ .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
+ .networks.Network.class,
+ new NetworkKey(new NetworkId("otn-topology")))
+ .augmentation(Network1.class));
otnLinks = linksFuture.get().orElseThrow().getLink();
-
- topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
- Charset.forName("UTF-8"))).toString());
+ topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER
+ .getBytes(Charset.forName("UTF-8"))).toString());
networkTransactionService = new NetworkTransactionImpl(getDataBroker());
tapiLink = new TapiLinkImpl(networkTransactionService);
LOG.info("TEST SETUP READY");
ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
tapiFactory.convertNode(tpdr, networkPortList);
- Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
- .getTapiNodes().get(new
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
+ Uuid dsrNodeUuid = new Uuid(
+ UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
+ var dsrNode = tapiFactory.getTapiNodes()
+ .get(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+ .topology.NodeKey(dsrNodeUuid));
Uuid networkNepUuid = new Uuid(
UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
.toString());
@Test
void convertNodeWhenBadStates1() {
- Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.OutOfService,
- State.OutOfService);
+ Node tpdr =
+ changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.OutOfService, State.OutOfService);
List<String> networkPortList = new ArrayList<>();
for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
tapiFactory.convertNode(tpdr, networkPortList);
- Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
- .getTapiNodes().get(new
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
+ Uuid dsrNodeUuid = new Uuid(
+ UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
+ var dsrNode = tapiFactory.getTapiNodes()
+ .get(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+ .topology.NodeKey(dsrNodeUuid));
Uuid networkNepUuid = new Uuid(
UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
.toString());
@Test
void convertNodeWhenBadStates2() {
- Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.Maintenance,
- State.Degraded);
+ Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.Maintenance, State.Degraded);
List<String> networkPortList = new ArrayList<>();
for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
tapiFactory.convertNode(tpdr, networkPortList);
- Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
- .getTapiNodes().get(new
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
+ Uuid dsrNodeUuid = new Uuid(
+ UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
+ var dsrNode = tapiFactory.getTapiNodes()
+ .get(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+ .topology.NodeKey(dsrNodeUuid));
Uuid networkNepUuid = new Uuid(
UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
.toString());
@Test
void convertOtnLinkWhenNoState() {
- HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
- .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
- link = changeOtnLinkState(otnLinks.get(new LinkKey(
+ HashMap<LinkKey,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link link =
+ changeOtnLinkState(otnLinks.get(new LinkKey(
new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))), null, null);
otnLinksAlt.replace(link.key(), link);
@Test
void convertOtnLinkWhenNoStateOnOppositeLink() {
- HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
- .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
- link = changeOtnLinkState(otnLinks.get(new LinkKey(
+ HashMap<LinkKey,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link link =
+ changeOtnLinkState(otnLinks.get(new LinkKey(
new LinkId("ODTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1"))), null, null);
otnLinksAlt.replace(link.key(), link);
@Test
void convertOtnLinkWhenBadState1() {
- HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
- .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
- link = changeOtnLinkState(otnLinks.get(new LinkKey(
+ HashMap<LinkKey,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link link =
+ changeOtnLinkState(otnLinks.get(new LinkKey(
new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))),
AdminStates.OutOfService, State.OutOfService);
otnLinksAlt.replace(link.key(), link);
tapiFactory.convertNode(otnMuxC, networkPortListC);
tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
tapiAbsFactory.convertLinks(otnLinksAlt);
-
List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
.sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
.collect(Collectors.toList());
- LOG.info("TapiLinks are as follow : {}", tapiLinks.toString());
+ LOG.info("TapiLinks are as follow : {}", tapiLinks);
assertEquals(AdministrativeState.LOCKED, tapiLinks.get(1).getAdministrativeState(),
"Administrative state should be LOCKED");
assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
@Test
void convertOtnLinkWhenBadState2() {
- HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
- .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
- link = changeOtnLinkState(otnLinks.get(new LinkKey(
+ HashMap<LinkKey,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link link =
+ changeOtnLinkState(otnLinks.get(new LinkKey(
new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))),
AdminStates.Maintenance, State.Degraded);
otnLinksAlt.replace(link.key(), link);
tapiFactory.convertNode(otnMuxC, networkPortListC);
tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
tapiAbsFactory.convertLinks(otnLinksAlt);
-
List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
.sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
.collect(Collectors.toList());
@Test
void convertOtnLinkWhenBadStateOnOppositeLink() {
- HashMap<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
- .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link
- link = changeOtnLinkState(otnLinks.get(new LinkKey(
+ HashMap<LinkKey,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link link =
+ changeOtnLinkState(otnLinks.get(new LinkKey(
new LinkId("ODTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1"))),
AdminStates.OutOfService, State.OutOfService);
otnLinksAlt.replace(link.key(), link);
}
}
tapiFactory.convertNode(tpdr100G, networkPortList);
- List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
- = tapiFactory.getTapiNodes().values().stream()
- .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
- .collect(Collectors.toList());
+ List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
+ tapiFactory.getTapiNodes().values().stream()
+ .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
+ .collect(Collectors.toList());
assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 (no more transitional links)");
- Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
+ Uuid dsrNodeUuid = new Uuid(
+ UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
checkDsrNode(tapiNodes.get(getNodeRank("SPDR-SA1", tapiNodes)), dsrNodeUuid, "tpdr", "XPDR-A1-XPDR1+XPONDER");
}
}
}
tapiFactory.convertNode(otnMuxA, networkPortList);
- List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
- = tapiFactory.getTapiNodes().values().stream()
- .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
- .collect(Collectors.toList());
+ List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
+ tapiFactory.getTapiNodes().values().stream()
+ .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
+ .collect(Collectors.toList());
assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR & ODU merged");
assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0, no more transitional links");
- Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
+ Uuid dsrNodeUuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
checkDsrNode(tapiNodes.get(getNodeRank("SPDR-SA1", tapiNodes)), dsrNodeUuid, "mux", "SPDR-SA1-XPDR1+XPONDER");
}
}
}
tapiFactory.convertNode(otnSwitch, networkPortList);
- List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
- = tapiFactory.getTapiNodes().values().stream()
- .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
- .collect(Collectors.toList());
+ List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
+ tapiFactory.getTapiNodes().values().stream()
+ .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
+ .collect(Collectors.toList());
assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR/ODU merged)");
assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
- Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
+ Uuid dsrNodeUuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
checkDsrNode(tapiNodes.get(getNodeRank("SPDR-SA1", tapiNodes)), dsrNodeUuid, "switch",
"SPDR-SA1-XPDR2+XPONDER");
}
tapiAbsFactory.convertLinks(otnLinks);
assertEquals(2, tapiAbsFactory.getTapiLinks().size(), "Link list size should be 2 : no transitional link");
- Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
- Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
- Uuid node3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
- Uuid node4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
- Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1"
- .getBytes(Charset.forName("UTF-8"))).toString());
- Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
- .getBytes(Charset.forName("UTF-8"))).toString());
- Uuid tp3Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1"
- .getBytes(Charset.forName("UTF-8"))).toString());
- Uuid tp4Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
- .getBytes(Charset.forName("UTF-8"))).toString());
- Uuid link1Uuid =
- new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
- .getBytes(Charset.forName("UTF-8"))).toString());
- Uuid link2Uuid =
- new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
- .getBytes(Charset.forName("UTF-8"))).toString());
-
+ Uuid node1Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
+ Uuid node2Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
+ Uuid node3Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
+ Uuid node4Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
+ Uuid tp1Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
+ Uuid tp2Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
+ Uuid tp3Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8")))
+ .toString());
+ Uuid tp4Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8")))
+ .toString());
+ Uuid link1Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
+ .getBytes(Charset.forName("UTF-8")))
+ .toString());
+ Uuid link2Uuid = new Uuid(
+ UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
+ .getBytes(Charset.forName("UTF-8")))
+ .toString());
List<Link> links = tapiAbsFactory.getTapiLinks().values().stream()
.sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
.collect(Collectors.toList());
- LOG.info("Node3 {}, Node4 = {},", node3Uuid.toString(), node4Uuid.toString());
+ LOG.info("Node3 {}, Node4 = {},", node3Uuid, node4Uuid);
checkOtnLink(links.get(1), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link1Uuid,
"SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1");
checkOtnLink(links.get(0), node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link2Uuid,
"SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1");
- LOG.info("The link we check has name {}", links.get(0).getName().toString());
+ LOG.info("The link we check has name {}", links.get(0).getName());
}
@Test
assertEquals(1, tapiAbsFactory.getTapiNodes().size(), "Node list size should be 1");
assertEquals(0, tapiAbsFactory.getTapiLinks().size(), "Link list size should be empty");
- List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
- = tapiAbsFactory.getTapiNodes().values().stream().collect(Collectors.toList());
- Uuid photNodeUuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
- .toString());
+ List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
+ tapiAbsFactory.getTapiNodes().values().stream().collect(Collectors.toList());
+ Uuid photNodeUuid = new Uuid(
+ UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8"))).toString());
checkOtsiNode(tapiNodes.get(0), photNodeUuid, "infra", "ROADM-infra");
}
Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey,
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeMap =
- tapiFactory.getTapiNodes();
+ tapiFactory.getTapiNodes();
nodeMap.putAll(tapiAbsFactory.getTapiNodes());
- List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
- = nodeMap.values().stream()
- .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
- .collect(Collectors.toList());
-
- Uuid otsiNodeUuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
- .toString());
- checkOtsiNode(tapiNodes.get(getNodeRank("ROADM", tapiNodes)), otsiNodeUuid, "infra", "ROADM-infra");
-
+ List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
+ nodeMap.values().stream()
+ .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
+ .collect(Collectors.toList());
+ checkOtsiNode(
+ tapiNodes.get(getNodeRank("ROADM", tapiNodes)),
+ //otsiNodeUuid,
+ new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8"))).toString()),
+ "infra", "ROADM-infra");
List<Link> links = tapiAbsFactory.getTapiLinks().values().stream()
.sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
.collect(Collectors.toList());
- Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
- .toString());
- Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8")))
- .toString());
- Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
- .getBytes(Charset.forName("UTF-8"))).toString());
- Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("roadm node+nep+1")
- .getBytes(Charset.forName("UTF-8"))).toString());
- String str1 = "SPDR-SA1-XPDR1+XPONDER--SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1 and ROADM-infra-"
- + "-NodeEdgePoint_1";
- Uuid linkUuid =
- new Uuid(UUID.nameUUIDFromBytes(str1.getBytes(Charset.forName("UTF-8"))).toString());
- LOG.info("LinksCheck 0 = {} ", links.get(0).getName().toString());
- checkOmsLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid, str1);
+ String str1 =
+ "SPDR-SA1-XPDR1+XPONDER--SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1 and ROADM-infra--NodeEdgePoint_1";
+ LOG.info("LinksCheck 0 = {} ", links.get(0).getName());
+ checkOmsLink(links.get(0),
+ //node1Uuid,
+ new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString()),
+ //node2Uuid,
+ new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8"))).toString()),
+ //tp1Uuid,
+ new Uuid(
+ UUID.nameUUIDFromBytes(
+ "SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8")))
+ .toString()),
+ //tp2Uuid,
+ new Uuid(UUID.nameUUIDFromBytes(("roadm node+nep+1").getBytes(Charset.forName("UTF-8"))).toString()),
+ //linkUuid,
+ new Uuid(UUID.nameUUIDFromBytes(str1.getBytes(Charset.forName("UTF-8"))).toString()),
+ str1);
}
- private void checkDsrNode(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
- Uuid nodeUuid, String dsrNodeType, String nodeId) {
+ private void checkDsrNode(
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
+ Uuid nodeUuid, String dsrNodeType, String nodeId) {
assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
assertEquals(nodeId, node.getName().get(new NameKey("dsr/odu node name")).getValue(), "incorrect node name");
assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
}
private void checkOtsiNode(
- org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
- Uuid nodeUuid, String otsiNodeType, String nodeId) {
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
+ Uuid nodeUuid, String otsiNodeType, String nodeId) {
assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
assertEquals(nodeId, node.getName().get(new NameKey("otsi node name")).getValue(), "incorrect node name");
assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
}
}
- private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
- String nodeId, String extension) {
+ private void checkNepClient10G(
+ OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
- List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
- Name name = nameList.get(0);
- assertEquals(String.join("+", nodeId, extension, portName), name.getValue(),
+ Name name = new ArrayList<>(nep.nonnullName().values()).get(0);
+ assertEquals(
+ String.join("+", nodeId, extension, portName),
+ name.getValue(),
"value of client nep should be '" + portName + "'");
assertEquals(nepName, name.getValueName(),
"value-name of client nep for '" + portName + "' should be '" + nepName + "'");
List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
- List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
- .getSupportedCepLayerProtocolQualifierInstances();
- for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
+ for (SupportedCepLayerProtocolQualifierInstances entry : nep.getSupportedCepLayerProtocolQualifierInstances()) {
lpql.add(entry.getLayerProtocolQualifier());
}
assertEquals(3, lpql.size(), "Client nep should support 3 kind of cep");
checkSIP(nep, portName, nodeId, extension);
}
- private void checkNepNetworkODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
- String nodeId, String extension) {
+ private void checkNepNetworkODU4(
+ OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
Name name = nameList.get(0);
assertEquals(nepName, name.getValueName(),
"value-name of network nep for '" + portName + "' should be '" + nepName + "'");
List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
- List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
- .getSupportedCepLayerProtocolQualifierInstances();
- for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
+ for (SupportedCepLayerProtocolQualifierInstances entry :nep.getSupportedCepLayerProtocolQualifierInstances()) {
lpql.add(entry.getLayerProtocolQualifier());
}
assertEquals(1, lpql.size(), "Network nep should support 1 kind of cep");
checkSIP(nep, portName, nodeId, extension);
}
- private void checkNodeRuleGroupForTpdrDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
- Uuid nodeUuid) {
+ private void checkNodeRuleGroupForTpdrDSR(
+ List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
assertEquals(4, nrgList.size(), "transponder DSR should contain 4 node rule group (2*DSR/I_ODU+2*E_ODU/I_ODU)");
for (NodeRuleGroup nodeRuleGroup : nrgList) {
assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
"the rule type should be 'FORWARDING'");
}
- private void checkNodeRuleGroupForMuxDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
- Uuid nodeUuid) {
+ private void checkNodeRuleGroupForMuxDSR(
+ List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
assertEquals(8, nrgList.size(), "muxponder DSR should contain 8 node rule group (4*DSR/I_ODU + 4*E_ODU/I_ODU)");
for (NodeRuleGroup nodeRuleGroup : nrgList) {
assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
"the rule type should be 'FORWARDING'");
}
- private void checkNodeRuleGroupForSwitchDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
- Uuid nodeUuid) {
+ private void checkNodeRuleGroupForSwitchDSR(
+ List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
assertEquals(2, nrgList.size(), "Switch-DSR should contain 2 node rule groups (DSR/I_ODU + E_ODU/I_ODU)");
assertEquals(8, nrgList.get(0).getNodeEdgePoint().size(), "Switch-DSR node-rule-group should contain 8 NEP");
List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
"the rule type should be 'FORWARDING'");
}
- private void checkNodeRuleGroupForTpdrOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
- Uuid nodeUuid) {
+ private void checkNodeRuleGroupForTpdrOTSi(
+ List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
assertEquals(2, nrgList.size(), "Tpdr-OTSi should contain two node rule groups");
List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
assertEquals(2, nodeEdgePointList.size(), "Tpdr-OTSi node-rule-group should contain 2 NEP");
"the rule type should be 'FORWARDING'");
}
- private void checkNodeRuleGroupForMuxOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
- Uuid nodeUuid) {
+ private void checkNodeRuleGroupForMuxOTSi(
+ List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
assertEquals(1, nrgList.size(), "Mux-OTSi should contain a single node rule group");
List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
assertEquals(2, nodeEdgePointList.size(), "Mux-OTSi node-rule-group should contain 2 NEP");
"the rule type should be 'FORWARDING'");
}
- private void checkNodeRuleGroupForSwitchOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
- Uuid nodeUuid) {
+ private void checkNodeRuleGroupForSwitchOTSi(
+ List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
assertEquals(4, nrgList.size(), "Switch-OTSi should contain 4 node rule group");
for (NodeRuleGroup nodeRuleGroup : nrgList) {
assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
"the rule type should be 'FORWARDING'");
}
- private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
- String nodeId, String extension) {
+ private void checkNepClient100GSwitch(
+ OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
assertEquals(nepName, nameList.get(0).getValueName(),
"value-name of client nep for '" + portName + "' should be '" + nepName + "'");
List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
- List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
- .getSupportedCepLayerProtocolQualifierInstances();
- for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
+ for (SupportedCepLayerProtocolQualifierInstances entry : nep.getSupportedCepLayerProtocolQualifierInstances()) {
lpql.add(entry.getLayerProtocolQualifier());
}
assertEquals(2, lpql.size(), "Client nep should support 2 kind of cep");
checkSIP(nep, portName, nodeId, extension);
}
- private void checkNepClient100GTpdr(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
- String nodeId, String extension) {
+ private void checkNepClient100GTpdr(
+ OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
assertEquals(nepName, nameList.get(0).getValueName(),
"value-name of client nep for '" + portName + "' should be 100G-tpdr'");
List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
- List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
- .getSupportedCepLayerProtocolQualifierInstances();
- for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
+ for (SupportedCepLayerProtocolQualifierInstances entry : nep.getSupportedCepLayerProtocolQualifierInstances()) {
lpql.add(entry.getLayerProtocolQualifier());
}
assertEquals(1, lpql.size(), "Client nep should support 1 kind of cep");
checkSIP(nep, portName, nodeId, extension);
}
- private void checkNepOtsiNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
- String nodeId, String extension) {
+ private void checkNepOtsiNode(
+ OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
"value of OTSi nep should be '" + portName + "'");
assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
- List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
- .getSupportedCepLayerProtocolQualifierInstances();
- for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
+ for (SupportedCepLayerProtocolQualifierInstances entry : nep.getSupportedCepLayerProtocolQualifierInstances()) {
lpql.add(entry.getLayerProtocolQualifier());
}
assertEquals(2, lpql.size(), "OTSi nep should support 2 kind of cep");
}
private void checkSIP(OwnedNodeEdgePoint nep, String portName, String nodeId, String extension) {
- Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeId, extension, portName))
- .getBytes(Charset.forName("UTF-8"))).toString());
+ Uuid sipUuid = new Uuid(
+ UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeId, extension, portName))
+ .getBytes(Charset.forName("UTF-8")))
+ .toString());
assertEquals(
sipUuid,
nep.getMappedServiceInterfacePoint().get(new MappedServiceInterfacePointKey(sipUuid))
assertEquals(portName, nameList.get(0).getValue(), "value of OTSi nep should be '" + portName + "'");
assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
- List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
- .getSupportedCepLayerProtocolQualifierInstances();
- for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
+ for (SupportedCepLayerProtocolQualifierInstances entry : nep.getSupportedCepLayerProtocolQualifierInstances()) {
lpql.add(entry.getLayerProtocolQualifier());
}
assertEquals(1, lpql.size(), "OTSi nep of RDM infra node should support only 1 kind of cep");
assertEquals(PortRole.SYMMETRIC, nep.getLinkPortRole(), "link-port-role of client nep should be SYMMETRIC");
}
- private void checkOtnLink(Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid,
- String linkName) {
+ private void checkOtnLink(
+ Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
assertEquals(linkName, link.getName().get(new NameKey("otn link name")).getValue(), "bad name for the link");
assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
assertEquals(CAPACITYUNITGBPS.VALUE, link.getAvailableCapacity().getTotalSize().getUnit(),
}
assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
- .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
- LOG.info("OUTPUT: Node1UUID = {}, Node2UU2D = {},", node1Uuid.toString(), node2Uuid.toString());
- LOG.info("NEPLIST = {}", nodeEdgePointList.toString());
+ .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
+ LOG.info("OUTPUT: Node1UUID = {}, Node2UU2D = {},", node1Uuid, node2Uuid);
+ LOG.info("NEPLIST = {}", nodeEdgePointList);
assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
"topology uuid should be the same for the two termination point of the link");
assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
"administrative state should be UNLOCKED");
}
- private void checkOmsLink(Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid,
- String linkName) {
+ private void checkOmsLink(
+ Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
assertEquals(linkName, link.getName().get(new NameKey("OTS link name")).getValue(), "bad name for the link");
assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
assertEquals(
"oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
- .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
+ .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
assertEquals(2, nodeEdgePointList.size(), "oms link should be between 2 neps");
assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
"topology uuid should be the same for the two termination point of the link");
}
private Node changeTerminationPointState(Node initialNode, String tpid, AdminStates admin, State oper) {
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder tpdr1Bldr
- = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder(
- initialNode.augmentation(Node1.class));
+ var tpdr1Bldr = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .Node1Builder(initialNode.augmentation(Node1.class));
Map<TerminationPointKey, TerminationPoint> tps = new HashMap<>(tpdr1Bldr.getTerminationPoint());
- TerminationPointBuilder tpBldr = new TerminationPointBuilder(
- tps.get(new TerminationPointKey(new TpId(tpid))));
- TerminationPoint1Builder tp1Bldr = new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class));
- tp1Bldr.setAdministrativeState(admin)
- .setOperationalState(oper);
+ TerminationPointBuilder tpBldr = new TerminationPointBuilder(tps.get(new TerminationPointKey(new TpId(tpid))));
+ TerminationPoint1Builder tp1Bldr =
+ new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class))
+ .setAdministrativeState(admin)
+ .setOperationalState(oper);
tpBldr.addAugmentation(tp1Bldr.build());
tps.replace(tpBldr.key(), tpBldr.build());
- tpdr1Bldr.setTerminationPoint(tps);
- return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.build()).build();
+ return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.setTerminationPoint(tps).build()).build();
}
- private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
- .Link changeOtnLinkState(
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
- .Link initiallink, AdminStates admin, State oper) {
-
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
- .LinkBuilder linkBldr = new
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
- .LinkBuilder(initiallink);
- Link1Builder link1Bldr = new Link1Builder(linkBldr.augmentation(Link1.class));
- link1Bldr.setAdministrativeState(admin)
- .setOperationalState(oper);
- linkBldr.addAugmentation(link1Bldr.build());
- return linkBldr.build();
+ private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link changeOtnLinkState(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.Link initiallink,
+ AdminStates admin,
+ State oper) {
+ var linkBldr = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+ .networks.network.LinkBuilder(initiallink);
+ return linkBldr
+ .addAugmentation(
+ new Link1Builder(linkBldr.augmentation(Link1.class))
+ .setAdministrativeState(admin)
+ .setOperationalState(oper)
+ .build())
+ .build();
}
- private int getNodeRank(String searchedChar,
- List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeList) {
+ private int getNodeRank(
+ String searchedChar,
+ List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeList) {
int foundAtRank = 0;
int rank = 0;
- for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node: nodeList) {
+ for (var node: nodeList) {
for (Map.Entry<NameKey, Name> entry: node.getName().entrySet()) {
if (entry.getValue().getValue().contains(searchedChar)) {
foundAtRank = rank;
LOG.info("searched Char {} found at rank {}", searchedChar, foundAtRank);
return foundAtRank;
}
-}
\ No newline at end of file
+}