import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
-import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev240923.OtnLinkType;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.or.network.augmentation.rev240923.DataModelEnum;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.or.network.augmentation.rev240923.LinkClassEnum;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev240315.OpenconfigNodeVersion;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev240315.OpenroadmNodeVersion;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev240315.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev240315.network.Nodes;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev240315.network.nodes.NodeInfo;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
LOG.warn("Could not generate port mapping for {} skipping network model creation", nodeId);
return;
}
- NodeInfo nodeInfo = portMapping.getNode(nodeId).getNodeInfo();
+ Nodes mappingNode = portMapping.getNode(nodeId);
+ NodeInfo nodeInfo = mappingNode.getNodeInfo();
// node creation in clli-network
- Node clliNode = ClliNetwork.createNode(nodeId, nodeInfo);
- DataObjectIdentifier<Node> iiClliNode = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.CLLI_NETWORK_ID)))
- .child(Node.class, clliNode.key())
- .build();
- LOG.info("creating node in {}", NetworkUtils.CLLI_NETWORK_ID);
- networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiClliNode, clliNode);
-
+ addNodeInClliNetwork(nodeId, nodeInfo);
// node creation in openroadm-network
- Node openroadmNetworkNode = OpenRoadmNetwork.createNode(nodeId, nodeInfo);
- DataObjectIdentifier<Node> iiopenroadmNetworkNode = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID)))
- .child(Node.class, openroadmNetworkNode.key())
- .build();
- LOG.info("creating node in {}", NetworkUtils.UNDERLAY_NETWORK_ID);
- networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiopenroadmNetworkNode,
- openroadmNetworkNode);
-
+ addNodeInOpenroadmNetwork(nodeId, nodeInfo);
// nodes/links creation in openroadm-topology
- TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(portMapping.getNode(nodeId),
- firstMount);
- if (topologyShard != null) {
- this.topologyShardMountedDevice.put(nodeId, topologyShard);
- for (Node openRoadmTopologyNode : topologyShard.getNodes()) {
- LOG.info("creating node {} in {}", openRoadmTopologyNode.getNodeId().getValue(),
- NetworkUtils.OVERLAY_NETWORK_ID);
- DataObjectIdentifier<Node> iiOpenRoadmTopologyNode = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
- .child(Node.class, openRoadmTopologyNode.key())
- .build();
- networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyNode,
- openRoadmTopologyNode);
- }
- for (Link openRoadmTopologyLink : topologyShard.getLinks()) {
- LOG.info("creating link {} in {}", openRoadmTopologyLink.getLinkId().getValue(),
- NetworkUtils.OVERLAY_NETWORK_ID);
- DataObjectIdentifier<Link> iiOpenRoadmTopologyLink = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
- .augmentation(Network1.class)
- .child(Link.class, openRoadmTopologyLink.key())
- .build();
- networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyLink,
- openRoadmTopologyLink);
- }
- } else {
- LOG.error("Unable to create openroadm-topology shard for node {}!", nodeId);
- }
+ addNodeInOpenroadmTopology(mappingNode, firstMount);
// nodes/links creation in otn-topology
- if (nodeInfo.getNodeType().getIntValue() == 2 && (nodeInfo.getOpenroadmVersion().getIntValue() != 1)) {
- createOpenRoadmOtnNode(nodeId);
+ if (NodeTypes.Xpdr.equals(nodeInfo.getNodeType())
+ && !OpenroadmNodeVersion._121.equals(nodeInfo.getOpenroadmVersion())) {
+ addNodeInOtnTopology(nodeId);
}
networkTransactionService.commit().get();
// neighbour links through LLDP
if (!ocPortMapping.createMappingData(nodeId, openConfigVersion, ipAddress)) {
LOG.error("could not generate portmapping {}", nodeId);
}
+ Nodes mappingNode = portMapping.getNode(nodeId);
+ NodeInfo nodeInfo = portMapping.getNode(nodeId).getNodeInfo();
+ // node creation in clli-network
+ addNodeInClliNetwork(nodeId, nodeInfo);
+ // node creation in openroadm-network
+ addNodeInOpenroadmNetwork(nodeId, nodeInfo);
+ // nodes/links creation in openroadm-topology
+ addNodeInOpenroadmTopology(mappingNode, true);
+ // nodes/links creation in otn-topology
+ if (NodeTypes.Xpdr.equals(nodeInfo.getNodeType())) {
+ addNodeInOtnTopology(nodeId);
+ }
+
+ try {
+ networkTransactionService.commit().get();
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Error adding openconfig node in openroadm network layers");
+ }
}
@Override
*/
}
- /*
- @see org.opendaylight.transportpce.networkmodel.service.NetworkModelService# deleteOpenROADMnode(java.lang.String)
+ /**
+ * This Method is used to delete OpenROADM node from openroadm network layers and portmapping datastores.
+ * @param nodeId
+ * unique node ID of OpenConfig node.
+ *
+ * @return result of node deletion from network and portmapping datastore
*/
-
@Override
public boolean deleteOpenRoadmnode(String nodeId) {
+ if (!this.portMapping.isNodeExist(nodeId)) {
+ return false;
+ }
+ OpenroadmNodeVersion deviceVersion = this.portMapping.getNode(nodeId).getNodeInfo().getOpenroadmVersion();
+ LOG.info("deleteOpenROADMnode: {} version {}", nodeId, deviceVersion.getName());
+ removeNodeFromOpenroadmNetwork(nodeId);
+ removeNodeFromOpenroadmTopology(nodeId);
+ NodeTypes nodeType = this.portMapping.getNode(nodeId).getNodeInfo().getNodeType();
+ if (NodeTypes.Xpdr.equals(nodeType) && !OpenroadmNodeVersion._121.equals(deviceVersion)) {
+ removeNodeFromOtnTopology(nodeId);
+ }
try {
- if (!this.portMapping.isNodeExist(nodeId)) {
- return false;
- }
- NodeKey nodeIdKey = new NodeKey(new NodeId(nodeId));
-
- LOG.info("deleting node in {}", NetworkUtils.UNDERLAY_NETWORK_ID);
- DataObjectIdentifier<Node> iiopenroadmNetworkNode = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID)))
- .child(Node.class, nodeIdKey)
- .build();
- this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiopenroadmNetworkNode);
-
- TopologyShard topologyShard = this.topologyShardMountedDevice.get(nodeId);
- if (topologyShard != null) {
- for (Node openRoadmTopologyNode : topologyShard.getNodes()) {
- LOG.info("deleting node {} in {}", openRoadmTopologyNode.getNodeId().getValue(),
- NetworkUtils.OVERLAY_NETWORK_ID);
- DataObjectIdentifier<Node> iiOpenRoadmTopologyNode = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
- .child(Node.class, openRoadmTopologyNode.key())
- .build();
- this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyNode);
- }
- for (Link openRoadmTopologyLink : topologyShard.getLinks()) {
- LOG.info("deleting link {} in {}", openRoadmTopologyLink.getLinkId().getValue(),
- NetworkUtils.OVERLAY_NETWORK_ID);
- DataObjectIdentifier<Link> iiOpenRoadmTopologyLink = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
- .augmentation(Network1.class)
- .child(Link.class, openRoadmTopologyLink.key())
- .build();
- this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyLink);
- }
- } else {
- LOG.warn("TopologyShard for node '{}' is not present", nodeId);
- }
- @Nullable
- OpenroadmNodeVersion deviceVersion = this.portMapping.getNode(nodeId).getNodeInfo().getOpenroadmVersion();
- @Nullable
- NodeTypes nodeType = this.portMapping.getNode(nodeId).getNodeInfo().getNodeType();
- if (nodeType.getIntValue() == 2 && deviceVersion.getIntValue() != 1) {
- TopologyShard otnTopologyShard = this.otnTopologyShardMountedDevice.get(nodeId);
- if (otnTopologyShard != null) {
- LOG.info("suppression de otnTopologyShard = {}", otnTopologyShard.toString());
- for (Node otnTopologyNode : otnTopologyShard.getNodes()) {
- LOG.info("deleting node {} in {}", otnTopologyNode.getNodeId().getValue(),
- NetworkUtils.OTN_NETWORK_ID);
- DataObjectIdentifier<Node> iiotnTopologyNode = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
- .child(Node.class, otnTopologyNode.key())
- .build();
- this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiotnTopologyNode);
- }
- for (Link otnTopologyLink : otnTopologyShard.getLinks()) {
- LOG.info("deleting link {} in {}", otnTopologyLink.getLinkId().getValue(),
- NetworkUtils.OTN_NETWORK_ID);
- DataObjectIdentifier<Link> iiotnTopologyLink = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
- .augmentation(Network1.class)
- .child(Link.class, otnTopologyLink.key())
- .build();
- this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiotnTopologyLink);
- }
- }
- }
-
- LOG.info("deleteOpenROADMnode: {} version {}", nodeId, deviceVersion.getName());
- this.portMapping.deletePortMappingNode(nodeId);
-
this.networkTransactionService.commit().get(1, TimeUnit.SECONDS);
- LOG.info("all nodes and links deleted ! ");
+ LOG.info("all nodes and links deleted in topologies! ");
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.error("Error when trying to delete node : {}", nodeId, e);
return false;
}
+ this.portMapping.deletePortMappingNode(nodeId);
return true;
}
/**
- * This Method is used to delete openconfig node in portmapping.
+ * This Method is used to delete openconfig node from openroadm network layers and portmapping datastores.
* @param nodeId
* unique node ID of OpenConfig node.
*
- * @return result of node deletion from portmapping
+ * @return result of node deletion from network and portmapping datastore
*/
@Override
public boolean deleteOpenConfignode(String nodeId) {
if (!this.portMapping.isNodeExist(nodeId)) {
return false;
}
- OpenconfigNodeVersion deviceVersion = this.portMapping.getNode(nodeId).getNodeInfo().getOpenconfigVersion();
- LOG.info("deleteOpenConfignode: {} version {}", nodeId, deviceVersion.getName());
+ NodeInfo nodeInfo = this.portMapping.getNode(nodeId).getNodeInfo();
+ LOG.info("deleteOpenConfignode: {} version {}", nodeId, nodeInfo.getOpenconfigVersion().getName());
+
+ removeNodeFromOpenroadmNetwork(nodeId);
+ removeNodeFromOpenroadmTopology(nodeId);
+ if (NodeTypes.Xpdr.equals(nodeInfo.getNodeType())) {
+ removeNodeFromOtnTopology(nodeId);
+ }
+ try {
+ this.networkTransactionService.commit().get(1, TimeUnit.SECONDS);
+ LOG.info("all nodes and links deleted in topologies! ");
+
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.error("Error when trying to delete node : {}", nodeId, e);
+ return false;
+ }
this.portMapping.deletePortMappingNode(nodeId);
return true;
}
}
}
+ private void addNodeInClliNetwork(String nodeId, NodeInfo nodeInfo) {
+ Node clliNode = ClliNetwork.createNode(nodeId, nodeInfo);
+ DataObjectIdentifier<Node> iiClliNode = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.CLLI_NETWORK_ID)))
+ .child(Node.class, clliNode.key())
+ .build();
+ LOG.info("creating node in {}", NetworkUtils.CLLI_NETWORK_ID);
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiClliNode, clliNode);
+
+ }
+
+ private void addNodeInOpenroadmNetwork(String nodeId, NodeInfo nodeInfo) {
+ Node openroadmNetworkNode = OpenRoadmNetwork.createNode(nodeId, nodeInfo);
+ DataObjectIdentifier<Node> iiopenroadmNetworkNode = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID)))
+ .child(Node.class, openroadmNetworkNode.key())
+ .build();
+ LOG.info("creating node in {}", NetworkUtils.UNDERLAY_NETWORK_ID);
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiopenroadmNetworkNode,
+ openroadmNetworkNode);
+ }
+
+ private void addNodeInOpenroadmTopology(Nodes mappingNode, boolean firstMount) {
+ // nodes/links creation in openroadm-topology
+ TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode, firstMount);
+ if (topologyShard != null) {
+ this.topologyShardMountedDevice.put(mappingNode.getNodeId(), topologyShard);
+ for (Node openRoadmTopologyNode : topologyShard.getNodes()) {
+ LOG.info("creating node {} in {}", openRoadmTopologyNode.getNodeId().getValue(),
+ NetworkUtils.OVERLAY_NETWORK_ID);
+ DataObjectIdentifier<Node> iiOpenRoadmTopologyNode = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
+ .child(Node.class, openRoadmTopologyNode.key())
+ .build();
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyNode,
+ openRoadmTopologyNode);
+ }
+ for (Link openRoadmTopologyLink : topologyShard.getLinks()) {
+ LOG.info("creating link {} in {}", openRoadmTopologyLink.getLinkId().getValue(),
+ NetworkUtils.OVERLAY_NETWORK_ID);
+ DataObjectIdentifier<Link> iiOpenRoadmTopologyLink = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
+ .augmentation(Network1.class)
+ .child(Link.class, openRoadmTopologyLink.key())
+ .build();
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyLink,
+ openRoadmTopologyLink);
+ }
+ } else {
+ LOG.error("Unable to create openroadm-topology shard for node {}!", mappingNode.getNodeId());
+ }
+ }
+
+ private void addNodeInOtnTopology(String nodeId) {
+ TopologyShard otnTopologyShard = OpenRoadmOtnTopology.createTopologyShard(portMapping.getNode(nodeId));
+ if (otnTopologyShard != null) {
+ this.otnTopologyShardMountedDevice.put(nodeId, otnTopologyShard);
+ for (Node otnTopologyNode : otnTopologyShard.getNodes()) {
+ LOG.info("creating otn node {} in {}", otnTopologyNode.getNodeId().getValue(),
+ NetworkUtils.OTN_NETWORK_ID);
+ DataObjectIdentifier<Node> iiOtnTopologyNode = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
+ .child(Node.class, otnTopologyNode.key())
+ .build();
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOtnTopologyNode, otnTopologyNode);
+ }
+ for (Link otnTopologyLink : otnTopologyShard.getLinks()) {
+ LOG.info("creating otn link {} in {}", otnTopologyLink.getLinkId().getValue(),
+ NetworkUtils.OVERLAY_NETWORK_ID);
+ DataObjectIdentifier<Link> iiOtnTopologyLink = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
+ .augmentation(Network1.class)
+ .child(Link.class, otnTopologyLink.key())
+ .build();
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOtnTopologyLink, otnTopologyLink);
+ }
+ } else {
+ LOG.error("Unable to create OTN topology shard for node {}!", nodeId);
+ }
+ }
+
+ private void removeNodeFromOpenroadmNetwork(String nodeId) {
+ LOG.info("deleting node {} in {}", nodeId, NetworkUtils.UNDERLAY_NETWORK_ID);
+ DataObjectIdentifier<Node> iiopenroadmNetworkNode = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID)))
+ .child(Node.class, new NodeKey(new NodeId(nodeId)))
+ .build();
+ this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiopenroadmNetworkNode);
+ }
+
+ private void removeNodeFromOpenroadmTopology(String nodeId) {
+ TopologyShard topologyShard = this.topologyShardMountedDevice.get(nodeId);
+ if (topologyShard != null) {
+ for (Node openRoadmTopologyNode : topologyShard.getNodes()) {
+ LOG.info("deleting node {} in {}", openRoadmTopologyNode.getNodeId().getValue(),
+ NetworkUtils.OVERLAY_NETWORK_ID);
+ DataObjectIdentifier<Node> iiOpenRoadmTopologyNode = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
+ .child(Node.class, openRoadmTopologyNode.key())
+ .build();
+ this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyNode);
+ }
+ for (Link openRoadmTopologyLink : topologyShard.getLinks()) {
+ LOG.info("deleting link {} in {}", openRoadmTopologyLink.getLinkId().getValue(),
+ NetworkUtils.OVERLAY_NETWORK_ID);
+ DataObjectIdentifier<Link> iiOpenRoadmTopologyLink = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
+ .augmentation(Network1.class)
+ .child(Link.class, openRoadmTopologyLink.key())
+ .build();
+ this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyLink);
+ }
+ } else {
+ LOG.warn("TopologyShard for node '{}' is not present", nodeId);
+ }
+ }
+
+ private void removeNodeFromOtnTopology(String nodeId) {
+ TopologyShard otnTopologyShard = this.otnTopologyShardMountedDevice.get(nodeId);
+ if (otnTopologyShard != null) {
+ LOG.info("suppression de otnTopologyShard = {}", otnTopologyShard.toString());
+ for (Node otnTopologyNode : otnTopologyShard.getNodes()) {
+ LOG.info("deleting node {} in {}", otnTopologyNode.getNodeId().getValue(),
+ NetworkUtils.OTN_NETWORK_ID);
+ DataObjectIdentifier<Node> iiotnTopologyNode = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
+ .child(Node.class, otnTopologyNode.key())
+ .build();
+ this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiotnTopologyNode);
+ }
+ for (Link otnTopologyLink : otnTopologyShard.getLinks()) {
+ LOG.info("deleting link {} in {}", otnTopologyLink.getLinkId().getValue(),
+ NetworkUtils.OTN_NETWORK_ID);
+ DataObjectIdentifier<Link> iiotnTopologyLink = DataObjectIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
+ .augmentation(Network1.class)
+ .child(Link.class, otnTopologyLink.key())
+ .build();
+ this.networkTransactionService.delete(LogicalDatastoreType.CONFIGURATION, iiotnTopologyLink);
+ }
+ }
+ }
+
private List<Link> getOtnLinks(List<LinkId> linkIds) {
List<Link> links = new ArrayList<>();
for (LinkId linkId : linkIds) {
return links;
}
- private void createOpenRoadmOtnNode(String nodeId) {
- TopologyShard otnTopologyShard = OpenRoadmOtnTopology.createTopologyShard(portMapping.getNode(nodeId));
- if (otnTopologyShard != null) {
- this.otnTopologyShardMountedDevice.put(nodeId, otnTopologyShard);
- for (Node otnTopologyNode : otnTopologyShard.getNodes()) {
- LOG.info("creating otn node {} in {}", otnTopologyNode.getNodeId().getValue(),
- NetworkUtils.OTN_NETWORK_ID);
- DataObjectIdentifier<Node> iiOtnTopologyNode = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
- .child(Node.class, otnTopologyNode.key())
- .build();
- networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOtnTopologyNode, otnTopologyNode);
- }
- for (Link otnTopologyLink : otnTopologyShard.getLinks()) {
- LOG.info("creating otn link {} in {}", otnTopologyLink.getLinkId().getValue(),
- NetworkUtils.OVERLAY_NETWORK_ID);
- DataObjectIdentifier<Link> iiOtnTopologyLink = DataObjectIdentifier.builder(Networks.class)
- .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
- .augmentation(Network1.class)
- .child(Link.class, otnTopologyLink.key())
- .build();
- networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOtnTopologyLink, otnTopologyLink);
- }
- } else {
- LOG.error("Unable to create OTN topology shard for node {}!", nodeId);
- }
- }
-
private NodeBuilder createTapiNodeBuilder(String supportingLayer, String nodeId) {
SupportingNodeBuilder supNBd = new SupportingNodeBuilder()
.setNetworkRef(new NetworkId(supportingLayer))
--- /dev/null
+#!/usr/bin/env python
+
+##############################################################################
+# Copyright (c) 2019 Orange, Inc. and others. All rights reserved.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+import unittest
+import time
+import requests
+# pylint: disable=wrong-import-order
+import sys
+sys.path.append('transportpce_tests/common/')
+# pylint: disable=wrong-import-position
+# pylint: disable=import-error
+import test_utils # nopep8
+import test_utils_oc # nopep8
+
+
+class TransportPCEtesting(unittest.TestCase):
+
+ processes = None
+ NODE_VERSION = 'oc'
+
+ @classmethod
+ def setUpClass(cls):
+ cls.processes = test_utils.start_tpce()
+ cls.processes = test_utils.start_sims([('oc-mpdr', cls.NODE_VERSION)])
+
+ @classmethod
+ def tearDownClass(cls):
+ # pylint: disable=not-an-iterable
+ for process in cls.processes:
+ test_utils.shutdown_process(process)
+ print("all processes killed")
+
+ def setUp(self):
+ time.sleep(2)
+
+ def test_01_meta_data_insertion(self):
+ response = test_utils_oc.metadata_input()
+ self.assertEqual(response.status_code, requests.codes.created,
+ test_utils.CODE_SHOULD_BE_201)
+
+ def test_02_catlog_input_insertion(self):
+ response = test_utils_oc.catlog_input()
+ self.assertEqual(response.status_code, requests.codes.ok,
+ test_utils.CODE_SHOULD_BE_200)
+
+ def test_03_connect_mpdr(self):
+ response = test_utils.mount_device("XPDR-OC",
+ ('oc-mpdr', self.NODE_VERSION))
+ self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
+ time.sleep(3)
+
+ response = test_utils.check_device_connection("XPDR-OC")
+ self.assertEqual(response['status_code'], requests.codes.ok)
+ self.assertEqual(response['connection-status'], 'connected')
+
+ def test_04_getClliNetwork(self):
+ response = test_utils.get_ietf_network_request('clli-network', 'config')
+ self.assertEqual(response['status_code'], requests.codes.ok)
+ self.assertEqual(response['network'][0]['node'][0]['node-id'], '1')
+ self.assertEqual(response['network'][0]['node'][0]['org-openroadm-clli-network:clli'], '1')
+
+ def test_05_getOpenRoadmNetwork(self):
+ response = test_utils.get_ietf_network_request('openroadm-network', 'config')
+ self.assertEqual(response['status_code'], requests.codes.ok)
+ self.assertEqual(response['network'][0]['node'][0]['node-id'], 'XPDR-OC')
+ self.assertEqual(response['network'][0]['node'][0]['supporting-node'][0]['network-ref'], 'clli-network')
+ self.assertEqual(response['network'][0]['node'][0]['supporting-node'][0]['node-ref'], '1')
+ self.assertEqual(response['network'][0]['node'][0]['org-openroadm-common-network:node-type'], 'XPONDER')
+ self.assertEqual(response['network'][0]['node'][0]['org-openroadm-network:model'], 'Chassis component')
+ self.assertEqual(response['network'][0]['node'][0]['org-openroadm-network:vendor'], 'vendor1')
+ self.assertEqual(response['network'][0]['node'][0]['org-openroadm-network:ip'], '127.0.0.1')
+
+ def test_06_getLinks_OpenroadmTopology(self):
+ response = test_utils.get_ietf_network_request('openroadm-topology', 'config')
+ self.assertEqual(response['status_code'], requests.codes.ok)
+ self.assertNotIn('ietf-network-topology:link', response['network'][0])
+
+ def test_07_getNodes_OpenRoadmTopology(self):
+ # pylint: disable=redundant-unittest-assert
+ response = test_utils.get_ietf_network_request('openroadm-topology', 'config')
+ self.assertEqual(response['status_code'], requests.codes.ok)
+ self.assertIn('node', response['network'][0])
+ self.assertEqual(len(response['network'][0]['node']), 1)
+ listNode = ['XPDR-OC-XPDR1']
+ for node in response['network'][0]['node']:
+ self.assertIn({'network-ref': 'openroadm-network', 'node-ref': 'XPDR-OC'}, node['supporting-node'])
+ self.assertIn({'network-ref': 'clli-network', 'node-ref': '1'}, node['supporting-node'])
+ nodeType = node['org-openroadm-common-network:node-type']
+ nodeId = node['node-id']
+ if nodeId not in listNode:
+ self.assertFalse(True)
+ continue
+ self.assertEqual(nodeType, 'XPONDER')
+ client = 0
+ network = 0
+ for tp in node['ietf-network-topology:termination-point']:
+ tpType = tp['org-openroadm-common-network:tp-type']
+ if tpType == 'XPONDER-CLIENT':
+ client += 1
+ elif tpType == 'XPONDER-NETWORK':
+ network += 1
+ self.assertTrue(client == 0)
+ self.assertTrue(network == 1)
+ listNode.remove(nodeId)
+ self.assertEqual(len(listNode), 0)
+
+ def test_08_getLinks_OtnTopology(self):
+ response = test_utils.get_ietf_network_request('otn-topology', 'config')
+ self.assertEqual(response['status_code'], requests.codes.ok)
+ self.assertNotIn('ietf-network-topology:link', response['network'][0])
+
+ def test_07_getNodes_OtnTopology(self):
+ # pylint: disable=redundant-unittest-assert
+ response = test_utils.get_ietf_network_request('otn-topology', 'config')
+ self.assertEqual(response['status_code'], requests.codes.ok)
+ self.assertEqual(len(response['network'][0]['node']), 1)
+ listNode = ['XPDR-OC-XPDR1']
+ CHECK_LIST = {
+ 'XPDR-OC-XPDR1': {
+ 'node-type': 'MUXPDR',
+ 'xpdr-number': 1,
+ 'network_nb': 1,
+ 'nbl_nb': 4,
+ 'tp-checklist': ['XPDR1-NETWORK1', 'XPDR1-CLIENT1'],
+ 'tp-unchecklist': ['XPDR1-CLIENT2']
+ }
+ }
+ for node in response['network'][0]['node']:
+ nodeId = node['node-id']
+ self.assertEqual(node['org-openroadm-common-network:node-type'], CHECK_LIST[nodeId]['node-type'])
+ self.assertIn({'network-ref': 'openroadm-network', 'node-ref': 'XPDR-OC'},
+ node['supporting-node'])
+ self.assertIn({'network-ref': 'openroadm-topology', 'node-ref': nodeId},
+ node['supporting-node'])
+ self.assertIn({'network-ref': 'clli-network', 'node-ref': '1'},
+ node['supporting-node'])
+ self.assertEqual(node['org-openroadm-otn-network-topology:xpdr-attributes']['xpdr-number'],
+ CHECK_LIST[nodeId]['xpdr-number'])
+ client = 0
+ network = 0
+ for tp in node['ietf-network-topology:termination-point']:
+ tpType = tp['org-openroadm-common-network:tp-type']
+ tpId = tp['tp-id']
+ if tpType == 'XPONDER-CLIENT':
+ client += 1
+ elif tpType == 'XPONDER-NETWORK':
+ network += 1
+ self.assertEqual((tp['org-openroadm-otn-network-topology:tp-supported-interfaces']
+ ['supported-interface-capability'][0]['if-cap-type']),
+ 'org-openroadm-port-types:if-OTUCn-ODUCn')
+ self.assertEqual((tp['supporting-termination-point'][0]['network-ref']), 'openroadm-topology')
+ self.assertEqual((tp['supporting-termination-point'][0]['node-ref']), nodeId)
+ self.assertEqual((tp['supporting-termination-point'][0]['tp-ref']), tpId)
+ self.assertTrue(client == 4)
+ self.assertTrue(network == CHECK_LIST[nodeId]['network_nb'])
+ self.assertEqual(
+ len(node['org-openroadm-otn-network-topology:switching-pools']
+ ['odu-switching-pools'][0]['non-blocking-list']),
+ CHECK_LIST[nodeId]['nbl_nb'])
+ # pylint: disable=line-too-long
+ for nbl in node['org-openroadm-otn-network-topology:switching-pools']['odu-switching-pools'][0]['non-blocking-list']:
+ if nbl['nbl-number'] == 1:
+ self.assertEqual(nbl['available-interconnect-bandwidth'], 10)
+ self.assertEqual(nbl['interconnect-bandwidth-unit'], 1000000000)
+ for tp in CHECK_LIST[nodeId]['tp-checklist']:
+ self.assertIn(tp, nbl['tp-list'])
+ for tp in CHECK_LIST[nodeId]['tp-unchecklist']:
+ self.assertNotIn(tp, nbl['tp-list'])
+ listNode.remove(nodeId)
+ self.assertEqual(len(listNode), 0)
+
+ def test_08_disconnect_mpdr(self):
+ response = test_utils.unmount_device("XPDR-OC")
+ self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content))
+
+ def test_09_getClliNetwork(self):
+ response = test_utils.get_ietf_network_request('clli-network', 'config')
+ self.assertEqual(response['status_code'], requests.codes.ok)
+ self.assertEqual(len(response['network'][0]['node']), 1)
+ self.assertEqual(response['network'][0]['node'][0]['org-openroadm-clli-network:clli'], '1')
+
+ def test_10_getOpenRoadmNetwork(self):
+ response = test_utils.get_ietf_network_request('openroadm-network', 'config')
+ self.assertEqual(response['status_code'], requests.codes.ok)
+ self.assertNotIn('node', response['network'][0])
+
+ def test_11_getNodes_OpenRoadmTopology(self):
+ response = test_utils.get_ietf_network_request('openroadm-topology', 'config')
+ self.assertNotIn('node', response['network'][0])
+
+ def test_12_getNodes_OtnTopology(self):
+ response = test_utils.get_ietf_network_request('otn-topology', 'config')
+ self.assertNotIn('node', response['network'][0])
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)