Merge "Device Renderer to support transponder for B100G"
authorGuillaume Lambert <guillaume.lambert@orange.com>
Thu, 25 Mar 2021 12:46:40 +0000 (12:46 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 25 Mar 2021 12:46:40 +0000 (12:46 +0000)
140 files changed:
api/src/main/yang/nbi-notifications@2020-11-30.yang [new file with mode: 0644]
api/src/main/yang/transportpce-portmapping@2021-03-10.yang [moved from api/src/main/yang/transportpce-portmapping@2020-10-12.yang with 95% similarity]
common/src/main/java/org/opendaylight/transportpce/common/mapping/MappingUtils.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/MappingUtilsImpl.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMapping.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingImpl.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java
common/src/test/java/org/opendaylight/transportpce/common/crossconnect/CrossConnectImpl221Test.java
common/src/test/java/org/opendaylight/transportpce/common/mapping/MappingUtilsImplTest.java
common/src/test/java/org/opendaylight/transportpce/common/mapping/PortMappingImplTest.java
common/src/test/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121Test.java
debug_tools/install_perl_dependencies.sh [new file with mode: 0755]
debug_tools/netconf_TCP_SSH_hijackingproxy.pl
debug_tools/netconf_terminal.pl
dmaap-client/pom.xml [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/JsonConfigurator.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/LgxSerializer.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PortSerializer.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceModule.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceSerializer.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/RxDirectionSerializer.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceAEndSerializer.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceZEndSerializer.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/TxDirectionSerializer.java [new file with mode: 0644]
dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/model/CreatedEvent.java [new file with mode: 0644]
dmaap-client/src/main/resources/OSGI-INF/blueprint/dmaap-blueprint.xml [new file with mode: 0644]
dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProviderTest.java [new file with mode: 0644]
dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImplTest.java [new file with mode: 0644]
dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApiStub.java [new file with mode: 0644]
features/odl-transportpce-dmaap-client/pom.xml [new file with mode: 0644]
features/odl-transportpce-dmaap-client/src/main/feature/feature.xml [new file with mode: 0644]
features/odl-transportpce-dmaap-client/src/main/resources/org.opendaylight.transportpce.dmaap.cfg [new file with mode: 0644]
features/odl-transportpce-nbinotifications/pom.xml [new file with mode: 0644]
features/odl-transportpce-nbinotifications/src/main/feature/feature.xml [new file with mode: 0644]
features/odl-transportpce-nbinotifications/src/main/resources/org.opendaylight.transportpce.nbinotifications.cfg [new file with mode: 0644]
features/pom.xml
karaf/pom.xml
lighty/pom.xml
lighty/src/main/java/io/lighty/controllers/tpce/Main.java
lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java
lighty/src/main/java/io/lighty/controllers/tpce/utils/TPCEUtils.java
lighty/src/test/java/io/lighty/controllers/tpce/MaintTest.java
nbinotifications/pom.xml [new file with mode: 0644]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/consumer/Subscriber.java [new file with mode: 0644]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java [new file with mode: 0644]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java [new file with mode: 0644]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java [new file with mode: 0644]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/producer/Publisher.java [new file with mode: 0644]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/ConfigConstants.java [new file with mode: 0644]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java [new file with mode: 0644]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java [new file with mode: 0644]
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/NbiNotificationsUtils.java [new file with mode: 0644]
nbinotifications/src/main/resources/OSGI-INF/blueprint/nobinotifications-blueprint.xml [new file with mode: 0644]
nbinotifications/src/main/resources/publisher.properties [new file with mode: 0644]
nbinotifications/src/main/resources/subscriber.properties [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java [new file with mode: 0644]
nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java [new file with mode: 0644]
nbinotifications/src/test/resources/event.json [new file with mode: 0644]
nbinotifications/src/test/resources/expected_event.json [new file with mode: 0644]
nbinotifications/src/test/resources/publisher.properties [new file with mode: 0644]
nbinotifications/src/test/resources/subscriber.properties [new file with mode: 0644]
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/R2RLinkDiscovery.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/dto/OtnTopoNode.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/service/NetworkModelServiceImpl.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/ClliNetwork.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopology.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopology.java
networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/ClliNetworkTest.java
networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetworkTest.java
networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopologyTest.java
networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopologyTest.java
networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/test/NetworkmodelTestUtil.java
olm/src/main/java/org/opendaylight/transportpce/olm/power/PowerMgmtImpl.java
olm/src/main/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImpl.java
olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java
olm/src/test/java/org/opendaylight/transportpce/olm/power/PowerMgmtPowerMockTest.java
olm/src/test/java/org/opendaylight/transportpce/olm/util/OlmTransactionUtils.java
olm/src/test/java/org/opendaylight/transportpce/olm/util/TransactionUtils.java
pce/src/main/java/org/opendaylight/transportpce/pce/PcePathDescription.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceSendingPceRPCs.java
pce/src/main/java/org/opendaylight/transportpce/pce/graph/PceGraph.java
pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceCalculation.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNode.java
pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java
pce/src/main/resources/OSGI-INF/blueprint/pce-blueprint.xml
pce/src/test/java/org/opendaylight/transportpce/pce/PcePathDescriptionTests.java
pce/src/test/java/org/opendaylight/transportpce/pce/PceSendingPceRPCsTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/constraints/PceConstraintsTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/graph/PceGraphEdgeTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/graph/PceGraphTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceProviderTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/impl/PceServiceRPCImplTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/PceCalculationTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLinkTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOpticalNodeTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImplTest.java
pce/src/test/java/org/opendaylight/transportpce/pce/utils/TransactionUtils.java
pom.xml
renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface221.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterfaceFactory.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmOtnInterface221.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java
renderer/src/test/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadMInterface221Test.java
renderer/src/test/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImplCreateOtsOmsTest.java
renderer/src/test/java/org/opendaylight/transportpce/renderer/utils/MountPointUtils.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java
servicehandler/src/main/resources/OSGI-INF/blueprint/servicehandler-blueprint.xml
servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImplTest.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiTopologyImpl.java
test-common/src/main/java/org/opendaylight/transportpce/test/utils/TopologyDataUtils.java
tests/installMavenCentOS.sh
tests/install_honeynode.sh
tests/inventory/install_inventory.sh
tests/inventory/start_inventory.sh
tests/nbinotifications/docker-compose.yml [new file with mode: 0644]
tests/transportpce_tests/1.2.1/test_portmapping.py
tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py
tests/transportpce_tests/2.2.1/test_nbinotifications.py [new file with mode: 0644]
tests/transportpce_tests/2.2.1/test_otn_renderer.py
tests/transportpce_tests/2.2.1/test_portmapping.py
tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py
tests/transportpce_tests/common/test_utils.py
tox.ini

diff --git a/api/src/main/yang/nbi-notifications@2020-11-30.yang b/api/src/main/yang/nbi-notifications@2020-11-30.yang
new file mode 100644 (file)
index 0000000..aa068cd
--- /dev/null
@@ -0,0 +1,120 @@
+module nbi-notifications {
+  yang-version 1;
+  namespace "nbi-notifications";
+  prefix nbinotifications;
+
+  import org-openroadm-service {
+    prefix oor-service;
+    revision-date 2019-05-31;
+  }
+  import org-openroadm-common-service-types {
+    prefix org-openroadm-common-service-types;
+    revision-date 2019-05-31;
+  }
+  import org-openroadm-common-state-types {
+    prefix org-openroadm-common-state-types;
+    revision-date 2018-11-30;
+  }
+
+  organization
+    "transportPCE";
+  contact
+    "transportPCE committers - ODL";
+  description
+    "YANG definitions for using REST API in NBI notifications module. Copyright
+     (c) 2020 ORANGE and others. All rights reserved.";
+
+  revision 2020-11-30 {
+    description
+      "Initial revision of NBI notifications";
+  }
+
+  grouping notification-service {
+    leaf message {
+      type string;
+      mandatory true;
+      description
+        "Message for the specified service";
+    }
+    leaf service-name {
+      type string;
+      mandatory true;
+      description
+        "Identifier for the service to be created in the ROADM network, e.g., CLFI, CLCI, etc.
+        This is reported against the service, but may not get reflected in the service in the network.";
+    }
+    leaf common-id {
+      type string;
+      description
+        "To be used by the ROADM controller to identify the routing constraints
+        received from planning application (PED).";
+    }
+    leaf connection-type {
+      type org-openroadm-common-service-types:connection-type;
+      mandatory true;
+    }
+    container service-a-end {
+      uses org-openroadm-common-service-types:service-endpoint;
+    }
+    container service-z-end {
+      uses org-openroadm-common-service-types:service-endpoint;
+    }
+    leaf response-failed {
+      type string;
+      description
+        "Response of the error if the service request encountered an anomaly";
+    }
+    leaf operational-state {
+      type org-openroadm-common-state-types:state;
+      config false;
+      description
+        "Operational State: Actual state of service";
+    }
+  }
+
+  container notification-service {
+    description
+      "Model used to send a notification from a service request";
+    uses notification-service;
+  }
+
+  rpc get-notifications-service {
+    description "Get the notifications service send by ServiceHandler by filtering through connection type";
+    input {
+      leaf connection-type {
+        type org-openroadm-common-service-types:connection-type;
+        mandatory true;
+        description
+          "Type connection of the service ";
+      }
+      leaf id-consumer {
+        type string;
+        mandatory true;
+        description
+          "Unique ID for the consumer";
+      }
+      leaf group-id {
+        type string;
+        mandatory true;
+        description
+          "ID Group for the consumer";
+      }
+    }
+    output {
+      list notification-service {
+        uses notification-service;
+      }
+    }
+  }
+
+  notification publish-notification-service {
+    description "Publish the notifications service for topic";
+    leaf topic {
+      type string;
+      mandatory true;
+      description
+        "Topic where to send the notification service";
+     }
+     uses notification-service;
+  }
+}
similarity index 95%
rename from api/src/main/yang/transportpce-portmapping@2020-10-12.yang
rename to api/src/main/yang/transportpce-portmapping@2021-03-10.yang
index 99cad2572a54fb0a90829bba85d9952c9fecaf9a..a782de581aa81073920b0499dca3526ee6cf7458 100644 (file)
@@ -34,9 +34,13 @@ module transportpce-portmapping {
      AT&T and others. All rights reserved. authors: Dhruv Bhardwaj
      ( db929a@att.com ) Shweta Vachhani ( sv111y@att.com )";
 
+  revision 2021-03-10 {
+      description
+      "Upgrading imported models to 7.1.0";
+  }
   revision 2020-10-12 {
-    description
-    "Upgrading imported models to 7.1.0";
+      description
+      "Upgrading imported models to 7.1.0";
   }
   revision 2020-08-27 {
     description
@@ -164,6 +168,16 @@ module transportpce-portmapping {
             "Useful to identify from portmapping client from network ports
              of XPDR";
         }
+        leaf port-admin-state {
+          type string;
+          description
+            "admin-state of port";
+        }
+        leaf port-oper-state {
+            type string;
+            description
+              "operational-state of port";
+        }
         leaf supporting-ethernet {
           type string;
           description
index b617cec39d883c59f2a1dc074e051ba9a7840ec0..802295bdde9c6b3bfa014fd236669fcb976b7b49 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.transportpce.common.mapping;
 
 import java.util.List;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilities;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilities;
 
 public interface MappingUtils {
 
index 8da678ef7b59358f4ac5ddb05a3bca145b8d03c4..1e000d50bafc6335da8e5ddaa7814b3fe521bc03 100644 (file)
@@ -15,11 +15,11 @@ import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.ReadTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.StringConstants;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilities;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilities;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 3a61657beec10629bd8ee8a13562b5e31d944a43..a9965de051c8e274496eea63ff9a92e01f35b115 100644 (file)
@@ -8,9 +8,9 @@
 
 package org.opendaylight.transportpce.common.mapping;
 
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilities;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilities;
 
 public interface PortMapping {
 
index 0a2d1eea4db9317dbbeb394f6305bad965d33753..0275dcf62c807d2f16cf0422dc1aa83bbf18b4dc 100644 (file)
@@ -19,15 +19,15 @@ import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.ReadTransaction;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilities;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilitiesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilities;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilitiesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index aeb50d8ab9b00e9a9c238a9c1b65ae007000fdd5..c3e5a744a5c17632e9e5b341f6b58e4946868a85 100644 (file)
@@ -32,20 +32,20 @@ import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.NetworkBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegree;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegreeBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegreeKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.NetworkBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegree;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegreeBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegreeKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.Direction;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.CircuitPack;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.Port;
@@ -583,7 +583,12 @@ public class PortMappingVersion121 {
                 .setSupportingCircuitPackName(circuitPackName)
                 .setSupportingPort(port.getPortName())
                 .setPortDirection(port.getPortDirection().getName());
-
+        if (port.getAdministrativeState() != null) {
+            mpBldr.setPortAdminState(port.getAdministrativeState().name());
+        }
+        if (port.getOperationalState() != null) {
+            mpBldr.setPortOperState(port.getOperationalState().name());
+        }
         if (!logicalConnectionPoint.contains(StringConstants.TTP_TOKEN) || (port.getInterfaces() == null)) {
             return mpBldr.build();
         }
@@ -639,7 +644,12 @@ public class PortMappingVersion121 {
         if (partnerLcp != null) {
             mpBldr.setPartnerLcp(partnerLcp);
         }
-
+        if (port.getAdministrativeState() != null) {
+            mpBldr.setPortAdminState(port.getAdministrativeState().name());
+        }
+        if (port.getOperationalState() != null) {
+            mpBldr.setPortOperState(port.getOperationalState().name());
+        }
         return mpBldr.build();
     }
 
index cf144749fb56e60eed5a5fc0855946c66e7d480e..6bff30368cdce312ebf56f06f9a7056f2b0e84ef 100644 (file)
@@ -31,29 +31,29 @@ import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.NetworkBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegree;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegreeBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegreeKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilities;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilitiesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilitiesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.SwitchingPoolLcp;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.SwitchingPoolLcpBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.SwitchingPoolLcpKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.switching.pool.lcp.NonBlockingList;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.switching.pool.lcp.NonBlockingListBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.switching.pool.lcp.NonBlockingListKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.NetworkBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegree;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegreeBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegreeKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilities;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilitiesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilitiesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.SwitchingPoolLcp;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.SwitchingPoolLcpBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.SwitchingPoolLcpKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.switching.pool.lcp.NonBlockingList;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.switching.pool.lcp.NonBlockingListBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.switching.pool.lcp.NonBlockingListKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.FrequencyGHz;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.Direction;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.PortQual;
@@ -774,6 +774,12 @@ public class PortMappingVersion221 {
                 .setSupportingCircuitPackName(circuitPackName)
                 .setSupportingPort(port.getPortName())
                 .setPortDirection(port.getPortDirection().getName());
+        if (port.getAdministrativeState() != null) {
+            mpBldr.setPortAdminState(port.getAdministrativeState().name());
+        }
+        if (port.getOperationalState() != null) {
+            mpBldr.setPortOperState(port.getOperationalState().name());
+        }
 
         if ((port.getInterfaces() == null)
             || (!logicalConnectionPoint.contains(StringConstants.TTP_TOKEN)
@@ -852,6 +858,12 @@ public class PortMappingVersion221 {
             }
             mpBldr.setSupportedInterfaceCapability(supportedIntf);
         }
+        if (port.getAdministrativeState() != null) {
+            mpBldr.setPortAdminState(port.getAdministrativeState().name());
+        }
+        if (port.getOperationalState() != null) {
+            mpBldr.setPortOperState(port.getOperationalState().name());
+        }
         return mpBldr.build();
     }
 
index 164ba730c6d5ab5e4b4c78aae29897245cd72fe2..3f14866360cfde5f93f77854aab179b049e90045 100644 (file)
@@ -31,29 +31,29 @@ import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.NetworkBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegree;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegreeBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegreeKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilities;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilitiesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilitiesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.SwitchingPoolLcp;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.SwitchingPoolLcpBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.SwitchingPoolLcpKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.switching.pool.lcp.NonBlockingList;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.switching.pool.lcp.NonBlockingListBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.switching.pool.lcp.NonBlockingListKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.NetworkBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegree;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegreeBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegreeKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilities;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilitiesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilitiesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.SwitchingPoolLcp;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.SwitchingPoolLcpBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.SwitchingPoolLcpKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.switching.pool.lcp.NonBlockingList;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.switching.pool.lcp.NonBlockingListBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.switching.pool.lcp.NonBlockingListKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.alarm.pm.types.rev191129.Direction;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.FrequencyGHz;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.CircuitPack;
@@ -830,6 +830,12 @@ public class PortMappingVersion710 {
                 .setSupportingCircuitPackName(circuitPackName)
                 .setSupportingPort(port.getPortName())
                 .setPortDirection(port.getPortDirection().getName());
+        if (port.getAdministrativeState() != null) {
+            mpBldr.setPortAdminState(port.getAdministrativeState().name());
+        }
+        if (port.getOperationalState() != null) {
+            mpBldr.setPortOperState(port.getOperationalState().name());
+        }
 
         if ((port.getInterfaces() == null)
             || (!logicalConnectionPoint.contains(StringConstants.TTP_TOKEN)
@@ -905,6 +911,12 @@ public class PortMappingVersion710 {
             }
             mpBldr.setSupportedInterfaceCapability(supportedIntf);
         }
+        if (port.getAdministrativeState() != null) {
+            mpBldr.setPortAdminState(port.getAdministrativeState().name());
+        }
+        if (port.getOperationalState() != null) {
+            mpBldr.setPortOperState(port.getOperationalState().name());
+        }
         return mpBldr.build();
     }
 
index 4b29e06e782e5f0bde5f566a3abfa733f00cee53..8d124e7e656e9944db331a919a82fae1be8683df 100644 (file)
@@ -29,8 +29,8 @@ import org.opendaylight.transportpce.common.device.DeviceTransaction;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
 import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.OpticalControlMode;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.ConnectionPorts;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.ConnectionPortsBuilder;
index 9a4b4323a161079f1e64f4a9d85c644c9ddb2301..ca54647d58ea6f7415f4afc618ae0aceda864f6e 100644 (file)
@@ -27,7 +27,7 @@ import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.transportpce.test.converter.DataObjectConverter;
 import org.opendaylight.transportpce.test.converter.JSONDataObjectConverter;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
index fa5c68e6f9ac3cdab977f1c1681d7ae3db0f96a7..6022fc8c8d9ae613978e12faa60b44dfd6df4176 100644 (file)
@@ -26,15 +26,15 @@ import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.test.DataStoreContext;
 import org.opendaylight.transportpce.test.DataStoreContextImpl;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class PortMappingImplTest {
index 5113e603948955db6c617bbb75fa313d69f10412..b5a8e8a079f5058640fe486c889a70efbe21228c 100644 (file)
@@ -37,10 +37,10 @@ import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfa
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
 import org.opendaylight.transportpce.test.DataStoreContext;
 import org.opendaylight.transportpce.test.DataStoreContextImpl;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.NetworkBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.NetworkBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.Direction;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.NodeTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.Port;
diff --git a/debug_tools/install_perl_dependencies.sh b/debug_tools/install_perl_dependencies.sh
new file mode 100755 (executable)
index 0000000..d2ef82d
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+set +x
+
+#check if apt exists
+if sudo apt-get install libnet-openssh-perl libio-pty-perl;then
+   echo "installed."
+   exit
+fi
+#check if yum exists
+if sudo yum install perl-Net-OpenSSH perl-IO-Tty;then
+    echo "yum-get is installed."
+    sudo yum install perl-Net-OpenSSH perl-IO-Tty
+    exit
+fi
+#check if cpanm exists
+if [ -x "$(command -v cpanm)" ];then
+    echo "cpanm is installed."
+    cpanm IO::Pty
+    cpanm Net::OpenSSH
+    exit
+else
+    echo "cannot install dependencies: apt-get and yum and perlbrew/cpanm are not available." >&2
+    exit 1
+fi
index 05ba2de83bebcf841f4f1acde1edb307d3ddc48c..e1d35fc4de6ccb88a6318fe935390e77012cb59d 100755 (executable)
@@ -7,7 +7,7 @@
 # and is available at http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
 #
-# debian dependecies: apt-get install libnet-openssh-perl libio-pty-perl
+# debian dependencies: apt-get install libnet-openssh-perl libio-pty-perl
 #
 
 use strict;
@@ -40,7 +40,7 @@ are then proxified between both ends.
 By default, exchanges are altered according to the rules specified inside this script and easily 
 modifiable. This behaviour can be disabled with the '-s' option.
 For more convenience, the server hello handshake can also alternatively be replaced by the content
-of an external file rather instead of writing specific rules.
+of an external file instead of writing specific rules.
 
 OPTIONS :
 
index c5d0e80379799ba16268d0d4deb37f646b3c31bb..789fe187e183bf3fea16b65e27260e280a17e043 100755 (executable)
@@ -7,7 +7,7 @@
 # and is available at http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
 #
-# debian dependecies: apt-get install libnet-openssh-perl libio-pty-perl
+# debian dependencies: apt-get install libnet-openssh-perl libio-pty-perl
 #
 
 use strict;
diff --git a/dmaap-client/pom.xml b/dmaap-client/pom.xml
new file mode 100644 (file)
index 0000000..0560fbc
--- /dev/null
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright © 2021 Orange 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 -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.mdsal</groupId>
+        <artifactId>binding-parent</artifactId>
+        <version>7.0.5</version>
+        <relativePath />
+    </parent>
+    <groupId>org.opendaylight.transportpce</groupId>
+    <artifactId>transportpce-dmaap-client</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+    <description>client to send message to Dmaap message router</description>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>transportpce-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-binding-api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.ext</groupId>
+            <artifactId>jersey-proxy-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.inject</groupId>
+            <artifactId>jersey-hk2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.media</groupId>
+            <artifactId>jersey-media-json-jackson</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.datatype</groupId>
+            <artifactId>jackson-datatype-jsr310</artifactId>
+        </dependency>
+        <!-- Testing dependencies -->
+        <dependency>
+            <groupId>org.glassfish.jersey.test-framework</groupId>
+            <artifactId>jersey-test-framework-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
+            <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProvider.java
new file mode 100644 (file)
index 0000000..adc4d06
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.impl;
+
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.transportpce.dmaap.client.listener.NbiNotificationsListenerImpl;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NbiNotificationsListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DmaapClientProvider {
+    private static final Logger LOG = LoggerFactory.getLogger(DmaapClientProvider.class);
+    private ListenerRegistration<NbiNotificationsListener> listenerRegistration;
+    private NotificationService notificationService;
+    private final String baseUrl;
+    private final String username;
+    private final String password;
+
+    public DmaapClientProvider(NotificationService notificationService, String baseUrl,
+            String username, String password) {
+        this.notificationService = notificationService;
+        this.baseUrl = baseUrl;
+        this.username = username;
+        this.password = password;
+    }
+
+    /**
+     * Method called when the blueprint container is created.
+     */
+    public void init() {
+        LOG.info("DmaapClientProvider Session Initiated");
+        listenerRegistration = notificationService.registerNotificationListener(
+                new NbiNotificationsListenerImpl(baseUrl, username, password));
+    }
+
+    /**
+     * Method called when the blueprint container is destroyed.
+     */
+    public void close() {
+        listenerRegistration.close();
+        LOG.info("DmaapClientProvider Closed");
+    }
+
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java
new file mode 100644 (file)
index 0000000..ed84dae
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.listener;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.glassfish.jersey.client.proxy.WebResourceFactory;
+import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.logging.LoggingFeature;
+import org.opendaylight.transportpce.dmaap.client.resource.EventsApi;
+import org.opendaylight.transportpce.dmaap.client.resource.config.JsonConfigurator;
+import org.opendaylight.transportpce.dmaap.client.resource.model.CreatedEvent;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NbiNotificationsListener;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NbiNotificationsListenerImpl implements NbiNotificationsListener {
+    private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsListenerImpl.class);
+    private String topic = "unauthenticated.TPCE";
+    private EventsApi api;
+
+    public NbiNotificationsListenerImpl(String baseUrl, String username, String password) {
+        LOG.info("Dmaap server {} for user {}", baseUrl, username);
+        Client client = ClientBuilder.newClient();
+        if (username != null && username.isBlank() && password != null && !password.isBlank()) {
+            HttpAuthenticationFeature authFeature = HttpAuthenticationFeature.basic(username, password);
+            client.register(authFeature);
+            topic = "authenticated.TPCE";
+        }
+        client.register(new LoggingFeature(java.util.logging.Logger.getLogger(this.getClass().getName())))
+        .register(JacksonFeature.class).register(JsonConfigurator.class);
+        api = WebResourceFactory.newResource(EventsApi.class, client.target(baseUrl));
+
+    }
+
+    @Override
+    public void onPublishNotificationService(PublishNotificationService notification) {
+        try {
+            CreatedEvent response = api.sendEvent(topic, notification);
+            LOG.info("Response received {}", response);
+        } catch (WebApplicationException e) {
+            LOG.warn("Cannot send event {}", notification, e);
+        }
+
+    }
+
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApi.java
new file mode 100644 (file)
index 0000000..e9d936c
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.opendaylight.transportpce.dmaap.client.resource.model.CreatedEvent;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+
+@Path("/events")
+public interface EventsApi {
+
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Path("/{topic}")
+    CreatedEvent sendEvent(@PathParam("topic") String topic, PublishNotificationService event);
+
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/JsonConfigurator.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/JsonConfigurator.java
new file mode 100644 (file)
index 0000000..62676c0
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import javax.ws.rs.ext.ContextResolver;
+
+public class JsonConfigurator implements ContextResolver<ObjectMapper> {
+
+    private final ObjectMapper mapper;
+
+    public JsonConfigurator() {
+        mapper = new ObjectMapper();
+        mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+        mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
+        mapper.enable(SerializationFeature.INDENT_OUTPUT);
+        mapper.registerModule(new JavaTimeModule());
+        mapper.registerModule(new PublishNotificationServiceModule());
+    }
+
+    @Override
+    public ObjectMapper getContext(Class<?> type) {
+        return mapper;
+    }
+
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/LgxSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/LgxSerializer.java
new file mode 100644 (file)
index 0000000..8f847a9
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.config;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.Lgx;
+
+// This class is a temporary workaround while waiting jackson
+// support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852
+public class LgxSerializer extends StdSerializer<Lgx> {
+    private static final long serialVersionUID = 1L;
+
+    public LgxSerializer() {
+        super(Lgx.class);
+    }
+
+    @Override
+    public void serialize(Lgx value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+        if (value != null) {
+            gen.writeStartObject();
+            gen.writeStringField("lgx-port-rack", value.getLgxPortRack());
+            gen.writeStringField("lgx-port-shelf", value.getLgxPortShelf());
+            gen.writeStringField("lgx-device-name", value.getLgxDeviceName());
+            gen.writeStringField("lgx-port-name", value.getLgxPortName());
+            gen.writeEndObject();
+        }
+    }
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PortSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PortSerializer.java
new file mode 100644 (file)
index 0000000..bdce081
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.config;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.Port;
+
+// This class is a temporary workaround while waiting jackson
+// support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852
+public class PortSerializer extends StdSerializer<Port> {
+    private static final long serialVersionUID = 1L;
+
+    public PortSerializer() {
+        super(Port.class);
+    }
+
+    @Override
+    public void serialize(Port value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+        if (value != null) {
+            gen.writeStartObject();
+            gen.writeStringField("port-rack", value.getPortRack());
+            gen.writeStringField("port-shelf", value.getPortShelf());
+            gen.writeStringField("port-device-name", value.getPortDeviceName());
+            gen.writeStringField("port-name", value.getPortName());
+            gen.writeStringField("port-type", value.getPortType());
+            gen.writeEndObject();
+        }
+    }
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceModule.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceModule.java
new file mode 100644 (file)
index 0000000..6b61557
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.config;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.datatype.jsr310.PackageVersion;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirection;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirection;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.Lgx;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.Port;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceZEnd;
+
+//This class is a temporary workaround while waiting jackson
+//support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852
+public class PublishNotificationServiceModule extends SimpleModule {
+
+    private static final long serialVersionUID = 1L;
+
+    public PublishNotificationServiceModule() {
+        super(PackageVersion.VERSION);
+        addSerializer(PublishNotificationService.class, new PublishNotificationServiceSerializer());
+        addSerializer(Lgx.class, new LgxSerializer());
+        addSerializer(Port.class, new PortSerializer());
+        addSerializer(RxDirection.class, new RxDirectionSerializer());
+        addSerializer(TxDirection.class, new TxDirectionSerializer());
+        addSerializer(ServiceAEnd.class, new ServiceAEndSerializer());
+        addSerializer(ServiceZEnd.class, new ServiceZEndSerializer());
+    }
+
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/PublishNotificationServiceSerializer.java
new file mode 100644 (file)
index 0000000..0ed9b7b
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.config;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+
+// This class is a temporary workaround while waiting jackson
+// support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852
+public class PublishNotificationServiceSerializer extends StdSerializer<PublishNotificationService> {
+    private static final long serialVersionUID = 1L;
+
+    public PublishNotificationServiceSerializer() {
+        super(PublishNotificationService.class);
+    }
+
+    @Override
+    public void serialize(PublishNotificationService value, JsonGenerator gen, SerializerProvider provider)
+            throws IOException {
+        if (value != null) {
+            gen.writeStartObject();
+            gen.writeStringField("common-id", value.getCommonId());
+            gen.writeStringField("message", value.getMessage());
+            gen.writeStringField("response-failed", value.getResponseFailed());
+            gen.writeStringField("service-name", value.getServiceName());
+            gen.writeStringField("topic", value.getTopic());
+            if (value.getOperationalState() != null) {
+                gen.writeStringField("operational-state", value.getOperationalState().getName());
+            }
+            gen.writeObjectField("service-a-end", value.getServiceAEnd());
+            gen.writeObjectField("service-z-end", value.getServiceZEnd());
+            gen.writeEndObject();
+        }
+    }
+
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/RxDirectionSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/RxDirectionSerializer.java
new file mode 100644 (file)
index 0000000..376b6be
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.config;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirection;
+
+// This class is a temporary workaround while waiting jackson
+// support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852
+public class RxDirectionSerializer extends StdSerializer<RxDirection> {
+    private static final long serialVersionUID = 1L;
+
+    public RxDirectionSerializer() {
+        super(RxDirection.class);
+    }
+
+    @Override
+    public void serialize(RxDirection value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+        if (value != null) {
+            gen.writeStartObject();
+            if (value.getPort() != null) {
+                gen.writeObjectField("port", value.getPort());
+            }
+            if (value.getLgx() != null) {
+                gen.writeObjectField("lgx", value.getLgx());
+            }
+            gen.writeEndObject();
+        }
+    }
+
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceAEndSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceAEndSerializer.java
new file mode 100644 (file)
index 0000000..55bfaea
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.config;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceAEnd;
+
+// This class is a temporary workaround while waiting jackson
+// support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852
+public class ServiceAEndSerializer extends StdSerializer<ServiceAEnd> {
+    private static final long serialVersionUID = 1L;
+
+    public ServiceAEndSerializer() {
+        super(ServiceAEnd.class);
+    }
+
+    @Override
+    public void serialize(ServiceAEnd value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+        if (value != null) {
+            gen.writeStartObject();
+            gen.writeStringField("clli", value.getClli());
+            if (value.getServiceFormat() != null) {
+                gen.writeStringField("service-format", value.getServiceFormat().getName());
+            }
+            if (value.getNodeId() != null) {
+                gen.writeStringField("node-id", value.getNodeId().getValue());
+            }
+            if (value.getServiceRate() != null) {
+                gen.writeNumberField("service-rate", value.getServiceRate().intValue());
+            }
+            if (value.getOpticType() != null) {
+                gen.writeStringField("optic-type", value.getOpticType().getName());
+            }
+            if (value.getTxDirection() != null) {
+                gen.writeObjectField("tx-direction", value.getTxDirection());
+            }
+            if (value.getRxDirection() != null) {
+                gen.writeObjectField("rx-direction", value.getRxDirection());
+            }
+            gen.writeEndObject();
+        }
+    }
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceZEndSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/ServiceZEndSerializer.java
new file mode 100644 (file)
index 0000000..1d65b11
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.config;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceZEnd;
+
+// This class is a temporary workaround while waiting jackson
+// support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852
+public class ServiceZEndSerializer extends StdSerializer<ServiceZEnd> {
+    private static final long serialVersionUID = 1L;
+
+    public ServiceZEndSerializer() {
+        super(ServiceZEnd.class);
+    }
+
+    @Override
+    public void serialize(ServiceZEnd value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+        if (value != null) {
+            gen.writeStartObject();
+            gen.writeStringField("clli", value.getClli());
+            if (value.getServiceFormat() != null) {
+                gen.writeStringField("service-format", value.getServiceFormat().getName());
+            }
+            if (value.getNodeId() != null) {
+                gen.writeStringField("node-id", value.getNodeId().getValue());
+            }
+            if (value.getServiceRate() != null) {
+                gen.writeNumberField("service-rate", value.getServiceRate().intValue());
+            }
+            if (value.getOpticType() != null) {
+                gen.writeStringField("optic-type", value.getOpticType().getName());
+            }
+            if (value.getTxDirection() != null) {
+                gen.writeObjectField("tx-direction", value.getTxDirection());
+            }
+            if (value.getRxDirection() != null) {
+                gen.writeObjectField("rx-direction", value.getRxDirection());
+            }
+            gen.writeEndObject();
+        }
+    }
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/TxDirectionSerializer.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/config/TxDirectionSerializer.java
new file mode 100644 (file)
index 0000000..90942a8
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.config;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirection;
+
+// This class is a temporary workaround while waiting jackson
+// support in yang tools https://git.opendaylight.org/gerrit/c/yangtools/+/94852
+public class TxDirectionSerializer extends StdSerializer<TxDirection> {
+    private static final long serialVersionUID = 1L;
+
+    public TxDirectionSerializer() {
+        super(TxDirection.class);
+    }
+
+    @Override
+    public void serialize(TxDirection value, JsonGenerator gen, SerializerProvider provider) throws IOException {
+        if (value != null) {
+            gen.writeStartObject();
+            if (value.getPort() != null) {
+                gen.writeObjectField("port", value.getPort());
+            }
+            if (value.getLgx() != null) {
+                gen.writeObjectField("lgx", value.getLgx());
+            }
+            gen.writeEndObject();
+        }
+    }
+}
diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/model/CreatedEvent.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/resource/model/CreatedEvent.java
new file mode 100644 (file)
index 0000000..aa39efc
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class CreatedEvent {
+
+    @JsonProperty("serverTimeMs")
+    private Integer serverTimeMs;
+
+    @JsonProperty("count")
+    private Integer count;
+
+    public Integer getServerTimeMs() {
+        return serverTimeMs;
+    }
+
+    public void setServerTimeMs(Integer serverTimeMs) {
+        this.serverTimeMs = serverTimeMs;
+    }
+
+    public Integer getCount() {
+        return count;
+    }
+
+    public void setCount(Integer count) {
+        this.count = count;
+    }
+
+    @Override
+    public String toString() {
+        return new StringBuilder()
+                .append("CreatedEvent [serverTimeMs=")
+                .append(serverTimeMs).append(", count=")
+                .append(count).append("]")
+                .toString();
+    }
+}
diff --git a/dmaap-client/src/main/resources/OSGI-INF/blueprint/dmaap-blueprint.xml b/dmaap-client/src/main/resources/OSGI-INF/blueprint/dmaap-blueprint.xml
new file mode 100644 (file)
index 0000000..459848e
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!-- Copyright © 2021 Orange 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 -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+    odl:use-default-for-reference-types="true">
+    <cm:property-placeholder persistent-id="org.opendaylight.transportpce.dmaap" update-strategy="reload">
+        <cm:default-properties>
+            <cm:property name="dmaap.baseUrl" value="http://localhost:8080" />
+            <cm:property name="dmaap.username" value="" />
+             <cm:property name="dmaap.password" value="" />
+        </cm:default-properties>
+    </cm:property-placeholder>
+    <reference id="notificationService" interface="org.opendaylight.mdsal.binding.api.NotificationService"/>
+
+    <bean id="provider"
+        class="org.opendaylight.transportpce.dmaap.client.impl.DmaapClientProvider"
+        init-method="init" destroy-method="close">
+        <argument ref="notificationService" />
+        <argument value="${dmaap.baseUrl}"></argument>
+        <argument value="${dmaap.username}"></argument>
+        <argument value="${dmaap.password}"></argument>
+    </bean>
+</blueprint>
diff --git a/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProviderTest.java b/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/impl/DmaapClientProviderTest.java
new file mode 100644 (file)
index 0000000..1ebfade
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.impl;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.transportpce.dmaap.client.listener.NbiNotificationsListenerImpl;
+
+
+public class DmaapClientProviderTest {
+
+    @Mock
+    private NotificationService notificationService;
+
+    @Before
+    public void init() {
+        MockitoAnnotations.openMocks(this);
+
+    }
+
+    @Test
+    public void testInitRegisterNbiNotificationsToRpcRegistry() {
+        DmaapClientProvider provider =  new DmaapClientProvider(notificationService, "http://localhost", "username", "password");
+        provider.init();
+        (verify(notificationService, times(1)))
+                .registerNotificationListener(Mockito.any(NbiNotificationsListenerImpl.class));
+    }
+
+}
diff --git a/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImplTest.java b/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImplTest.java
new file mode 100644 (file)
index 0000000..710bf1b
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.listener;
+
+import static org.junit.Assert.assertEquals;
+
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.read.ListAppender;
+import java.util.List;
+import javax.ws.rs.core.Application;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.TestProperties;
+import org.junit.Test;
+import org.opendaylight.transportpce.dmaap.client.resource.EventsApiStub;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NbiNotificationsListener;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceZEndBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.slf4j.LoggerFactory;
+
+public class NbiNotificationsListenerImplTest extends JerseyTest {
+    @Override
+    protected Application configure() {
+        enable(TestProperties.LOG_TRAFFIC);
+        enable(TestProperties.DUMP_ENTITY);
+        return new ResourceConfig(EventsApiStub.class);
+    }
+
+    @Test
+    public void onPublishNotificationServiceTest() {
+        Logger logger = (Logger) LoggerFactory.getLogger(NbiNotificationsListenerImpl.class);
+        ListAppender<ILoggingEvent> listAppender = new ListAppender<>();
+        listAppender.start();
+        logger.addAppender(listAppender);
+        NbiNotificationsListener listener = new NbiNotificationsListenerImpl("http://localhost:9998", null, null);
+        PublishNotificationService notification = new PublishNotificationServiceBuilder().setCommonId("CommonId")
+                .setMessage("Service implemented")
+                .setOperationalState(State.InService)
+                .setTopic("topic")
+                .setConnectionType(ConnectionType.Service)
+                .setServiceAEnd(new ServiceAEndBuilder()
+                        .setClli("clli")
+                        .setNodeId(new org.opendaylight.yang.gen.v1.http
+                                .org.openroadm.common.node.types.rev181130.NodeIdType("nodeidtype"))
+                        .setServiceFormat(ServiceFormat.Ethernet)
+                        .setServiceRate(Uint32.valueOf(100))
+                        .setRxDirection(new RxDirectionBuilder().build())
+                        .setTxDirection(new TxDirectionBuilder().build())
+                        .build())
+                .setServiceZEnd(new ServiceZEndBuilder()
+                        .setClli("clli")
+                        .setNodeId(new org.opendaylight.yang.gen.v1.http
+                                .org.openroadm.common.node.types.rev181130.NodeIdType("nodeidtype"))
+                        .setServiceFormat(ServiceFormat.Ethernet)
+                        .setServiceRate(Uint32.valueOf(100))
+                        .setRxDirection(new RxDirectionBuilder().build())
+                        .setTxDirection(new TxDirectionBuilder().build())
+                        .build())
+                .build();
+        listener.onPublishNotificationService(notification);
+        // as onPublishNotificationService is a void method, we check log message to be sur everything went well
+        List<ILoggingEvent> logsList = listAppender.list;
+        assertEquals("Response received CreatedEvent [serverTimeMs=1, count=1]", logsList.get(1).getFormattedMessage());
+
+    }
+}
diff --git a/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApiStub.java b/dmaap-client/src/test/java/org/opendaylight/transportpce/dmaap/client/resource/EventsApiStub.java
new file mode 100644 (file)
index 0000000..c71e0a9
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.dmaap.client.resource;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.opendaylight.transportpce.dmaap.client.resource.model.CreatedEvent;
+
+@Path("/events")
+public class EventsApiStub {
+
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Path("/{topic}")
+    public CreatedEvent sendEvent(@PathParam("topic") String topic, String event) {
+        CreatedEvent response = new CreatedEvent();
+        response.setCount(1);
+        response.setServerTimeMs(1);
+        return response;
+    }
+
+}
diff --git a/features/odl-transportpce-dmaap-client/pom.xml b/features/odl-transportpce-dmaap-client/pom.xml
new file mode 100644 (file)
index 0000000..1095400
--- /dev/null
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright © 2021 Orange 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 INTERNAL -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.odlparent</groupId>
+        <artifactId>single-feature-parent</artifactId>
+        <version>8.1.0</version>
+        <relativePath />
+    </parent>
+    <groupId>org.opendaylight.transportpce</groupId>
+    <artifactId>odl-transportpce-dmaap-client</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+    <packaging>feature</packaging>
+
+    <name>OpenDaylight :: transportpce :: dmaap-client</name>
+    <properties>
+    <!-- skipped because we are using config file as artifact and it is not installed before running test -->
+        <skip.karaf.featureTest>true</skip.karaf.featureTest>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.transportpce</groupId>
+            <artifactId>odl-transportpce</artifactId>
+            <version>${project.version}</version>
+            <classifier>features</classifier>
+            <type>xml</type>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.glassfish.jersey.inject</groupId>
+                    <artifactId>jersey-hk2</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.transportpce</groupId>
+            <artifactId>transportpce-dmaap-client</artifactId>
+            <version>${project.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.glassfish.jersey.inject</groupId>
+                    <artifactId>jersey-hk2</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-dmaap-artifact</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>${basedir}/src/main/resources/org.opendaylight.transportpce.dmaap.cfg</file>
+                                    <type>cfg</type>
+                                    <classifier>config</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/features/odl-transportpce-dmaap-client/src/main/feature/feature.xml b/features/odl-transportpce-dmaap-client/src/main/feature/feature.xml
new file mode 100644 (file)
index 0000000..0031ef8
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Copyright © 2021 Orange 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 INTERNAL -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-transportpce-dmaap-client">
+    <feature name="odl-transportpce-dmaap-client">
+        <configfile finalname="etc/org.opendaylight.transportpce.dmaap.cfg" override="false">
+            mvn:${project.groupId}/${project.artifactId}/${project.version}/cfg/config
+        </configfile>
+    </feature>
+</features>
\ No newline at end of file
diff --git a/features/odl-transportpce-dmaap-client/src/main/resources/org.opendaylight.transportpce.dmaap.cfg b/features/odl-transportpce-dmaap-client/src/main/resources/org.opendaylight.transportpce.dmaap.cfg
new file mode 100644 (file)
index 0000000..db11068
--- /dev/null
@@ -0,0 +1,3 @@
+dmaap.baseUrl=${env:DMAAP_BASE_URL:-http://localhost:8080}
+dmaap.username=${env:DMAAP_USERNAME:+username}
+dmaap.password=${env:DMAAP_PASSWORD:+password}
\ No newline at end of file
diff --git a/features/odl-transportpce-nbinotifications/pom.xml b/features/odl-transportpce-nbinotifications/pom.xml
new file mode 100644 (file)
index 0000000..29469b1
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright © 2021 Orange 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 INTERNAL -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.opendaylight.odlparent</groupId>
+        <artifactId>single-feature-parent</artifactId>
+        <version>8.1.0</version>
+        <relativePath />
+    </parent>
+
+    <groupId>org.opendaylight.transportpce</groupId>
+    <artifactId>odl-transportpce-nbinotifications</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+    <packaging>feature</packaging>
+
+    <name>OpenDaylight :: transportpce :: nbinotifications</name>
+    <properties>
+    <!-- skipped because we are using config file as artifact and it is not installed before running test -->
+        <skip.karaf.featureTest>true</skip.karaf.featureTest>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.transportpce</groupId>
+            <artifactId>odl-transportpce</artifactId>
+            <version>${project.version}</version>
+            <classifier>features</classifier>
+            <type>xml</type>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>transportpce-nbinotifications</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-dmaap-artifact</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>${basedir}/src/main/resources/org.opendaylight.transportpce.nbinotifications.cfg</file>
+                                    <type>cfg</type>
+                                    <classifier>config</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/features/odl-transportpce-nbinotifications/src/main/feature/feature.xml b/features/odl-transportpce-nbinotifications/src/main/feature/feature.xml
new file mode 100644 (file)
index 0000000..5e99a52
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Copyright © 2021 Orange 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 INTERNAL -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-transportpce-nbinotifications">
+    <feature name="odl-transportpce-nbinotifications">
+        <configfile finalname="etc/org.opendaylight.transportpce.nbinotififications.cfg" override="false">
+            mvn:${project.groupId}/${project.artifactId}/${project.version}/cfg/config
+        </configfile>
+    </feature>
+</features>
\ No newline at end of file
diff --git a/features/odl-transportpce-nbinotifications/src/main/resources/org.opendaylight.transportpce.nbinotifications.cfg b/features/odl-transportpce-nbinotifications/src/main/resources/org.opendaylight.transportpce.nbinotifications.cfg
new file mode 100644 (file)
index 0000000..ea5c7c0
--- /dev/null
@@ -0,0 +1,2 @@
+suscriber.server=${env:KAFKA_SERVER:-localhost:9092}
+publisher.server=${env:KAFKA_SERVER:-localhost:9092}
index 95532599fb9766e0aa6a1858f6b1ee20defdf109..8434611e9244eacf9e80eadcf22a943c692e0a64 100644 (file)
@@ -26,5 +26,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <module>odl-transportpce</module>
     <module>odl-transportpce-tapi</module>
     <module>odl-transportpce-inventory</module>
+    <module>odl-transportpce-nbinotifications</module>
+    <module>odl-transportpce-dmaap-client</module>
   </modules>
 </project>
index f71a9d80b0da30cf16cb030d6756a12820f26348..570926de42da0721d9f5699bd9b3130186c09249 100644 (file)
@@ -66,7 +66,22 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <type>xml</type>
       <scope>runtime</scope>
     </dependency>
-
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>odl-transportpce-nbinotifications</artifactId>
+      <version>${project.version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>odl-transportpce-dmaap-client</artifactId>
+      <version>${project.version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+      <scope>runtime</scope>
+    </dependency>
   </dependencies>
 
   <build>
index 8ee8a1275341ed380a2efdae2f9186ac5779192c..891b72caf049dcbb0e4195bd60f2f4c4f9a2f43a 100644 (file)
     </properties>
 
     <dependencies>
+        <!-- for parsing command line arguments -->
+        <dependency>
+            <groupId>commons-cli</groupId>
+            <artifactId>commons-cli</artifactId>
+            <version>1.4</version>
+        </dependency>
 
         <!-- TPCE Models - BEGIN -->
         <dependency>
             <artifactId>transportpce-tapi</artifactId>
             <version>${transportpce.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.transportpce</groupId>
+            <artifactId>transportpce-nbinotifications</artifactId>
+            <version>${transportpce.version}</version>
+        </dependency>
         <!-- TPCE bundles - END -->
 
         <dependency>
index 9cba68c009e353678721847f44d3f422c18f1df0..b979e08477de27bcd9b9171215b74d531d88caa5 100644 (file)
@@ -34,21 +34,32 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.concurrent.ExecutionException;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class Main {
 
+    private static final String RESTCONF_OPTION_NAME = "restconf";
+
+    private static final String NBINOTIFICATION_OPTION_NAME = "nbinotification";
+
     private static final Logger LOG = LoggerFactory.getLogger(Main.class);
 
     private ShutdownHook shutdownHook;
 
     public void start() {
-        start(new String[] {}, false);
+        start(null, false, false);
     }
 
     @SuppressWarnings("checkstyle:Illegalcatch")
-    public void start(String[] args, boolean registerShutdownHook) {
+    public void start(String restConfConfigurationFile, boolean activateNbiNotification, boolean registerShutdownHook) {
         long startTime = System.nanoTime();
         TpceBanner.print();
         RestConfConfiguration restConfConfig = null;
@@ -57,8 +68,8 @@ public class Main {
             ControllerConfiguration singleNodeConfiguration = ControllerConfigUtils
                     .getDefaultSingleNodeConfiguration(TPCEUtils.getYangModels());
             // 2. get RESTCONF NBP configuration
-            if (args.length == 1) {
-                Path configPath = Paths.get(args[0]);
+            if (restConfConfigurationFile != null) {
+                Path configPath = Paths.get(restConfConfigurationFile);
                 LOG.info("Using restconf configuration from file {} ...", configPath);
                 restConfConfig = RestConfConfigUtils.getRestConfConfiguration(Files.newInputStream(configPath));
 
@@ -72,7 +83,7 @@ public class Main {
             restConfConfig.setJsonRestconfServiceType(JsonRestConfServiceType.DRAFT_02);
             // 3. NETCONF SBP configuration
             NetconfConfiguration netconfSBPConfig = NetconfConfigUtils.createDefaultNetconfConfiguration();
-            startLighty(singleNodeConfiguration, restConfConfig, netconfSBPConfig, registerShutdownHook);
+            startLighty(singleNodeConfiguration, restConfConfig, netconfSBPConfig, registerShutdownHook, activateNbiNotification);
             float duration = (System.nanoTime() - startTime) / 1_000_000f;
             LOG.info("lighty.io and RESTCONF-NETCONF started in {}ms", duration);
         } catch (ConfigurationException | ExecutionException | IOException e) {
@@ -91,9 +102,33 @@ public class Main {
         }
     }
 
+    /**
+     * Build options for command line arguments
+     * @return
+     */
+    private static Options buildOptions() {
+        Option restconfFileOption = Option.builder(RESTCONF_OPTION_NAME)
+                .desc("Restconf configuration file")
+                .argName(RESTCONF_OPTION_NAME)
+                .hasArg(true)
+                .required(false)
+                .build();
+        Option useNbiNotificationsOption = Option.builder(NBINOTIFICATION_OPTION_NAME)
+                .desc("Activate NBI notifications feature")
+                .argName(NBINOTIFICATION_OPTION_NAME)
+                .hasArg(false)
+                .required(false)
+                .build();
+        Options options = new Options();
+        options.addOption(restconfFileOption);
+        options.addOption(useNbiNotificationsOption);
+        return options;
+    }
+
     private void startLighty(ControllerConfiguration controllerConfiguration,
             RestConfConfiguration restConfConfiguration, NetconfConfiguration netconfSBPConfiguration,
-            boolean registerShutdownHook) throws ConfigurationException, ExecutionException, InterruptedException {
+            boolean registerShutdownHook, boolean activateNbiNotification)
+                    throws ConfigurationException, ExecutionException, InterruptedException {
 
         // 1. initialize and start Lighty controller (MD-SAL, Controller, YangTools,
         // Akka)
@@ -121,7 +156,7 @@ public class Main {
         netconfSouthboundPlugin.start().get();
 
         // 4. start TransportPCE beans
-        TransportPCE transportPCE = new TransportPCEImpl(lightyController.getServices());
+        TransportPCE transportPCE = new TransportPCEImpl(lightyController.getServices(), activateNbiNotification);
         transportPCE.start().get();
 
         // 5. Register shutdown hook for graceful shutdown.
@@ -136,8 +171,23 @@ public class Main {
     }
 
     public static void main(String[] args) {
-        Main app = new Main();
-        app.start(args, true);
+        Options options = buildOptions();
+        try {
+            CommandLine commandLine = new DefaultParser().parse(options, args);
+            String restConfConfigurationFile = commandLine.getOptionValue(RESTCONF_OPTION_NAME, null);
+            boolean useNbiNotifications = commandLine.hasOption(NBINOTIFICATION_OPTION_NAME);
+            Main app = new Main();
+            app.start(restConfConfigurationFile, useNbiNotifications, true);
+        } catch (ParseException e) {
+            HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp(
+                    "java -ms<size> -mx<size> -XX:MaxMetaspaceSize=<size> -jar tpce.jar "
+                    + "[-restconf <restconfConfigurationFile>] [-nbinotification]"
+                    +" e.g. java -ms128m -mx512m -XX:MaxMetaspaceSize=128m -jar tpce.jar"
+                    + "-restconf ../src/test/resources/config.json -nbinotification",
+                    options);
+            System.exit(1);
+        }
     }
 
     private static class ShutdownHook extends Thread {
index df72b07f11c77b0d1dfce50ab059418b79ff4793..63e6442b8a6462536f74313caa6c7f00df960104 100644 (file)
@@ -9,6 +9,10 @@ package io.lighty.controllers.tpce.module;
 
 import io.lighty.core.controller.api.AbstractLightyModule;
 import io.lighty.core.controller.api.LightyServices;
+
+import java.util.Arrays;
+import java.util.List;
+
 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl121;
@@ -29,6 +33,7 @@ import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfa
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl121;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl221;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl710;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
 import org.opendaylight.transportpce.networkmodel.NetConfTopologyListener;
 import org.opendaylight.transportpce.networkmodel.NetworkModelProvider;
 import org.opendaylight.transportpce.networkmodel.NetworkUtilsImpl;
@@ -99,8 +104,15 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP
     private final TapiProvider tapiProvider;
     // service-handler beans
     private final ServicehandlerProvider servicehandlerProvider;
+    // nbi-notifications beans
+    private NbiNotificationsProvider nbiNotificationsProvider;
+    /**
+     * List of publisher topics.
+     */
+    private final List<String> publisherTopicList =
+            Arrays.asList("PceListener", "ServiceHandlerOperations", "ServiceHandler", "RendererListener");
 
-    public TransportPCEImpl(LightyServices lightyServices) {
+    public TransportPCEImpl(LightyServices lightyServices, boolean activateNbiNotification) {
         LOG.info("Initializing transaction providers ...");
         deviceTransactionManager = new DeviceTransactionManagerImpl(lightyServices.getBindingMountPointService(),
                 MAX_DURATION_TO_SUBMIT_TRANSACTION);
@@ -176,6 +188,12 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP
                 serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
                 servicehandler);
         tapiProvider = initTapi(lightyServices, servicehandler);
+        if(activateNbiNotification) {
+            LOG.info("Creating nbi-notifications beans ...");
+            nbiNotificationsProvider = new NbiNotificationsProvider(
+                    publisherTopicList, null, null, lightyServices.getRpcProviderService(),
+                    lightyServices.getNotificationService(), lightyServices.getAdapterContext().currentSerializer());
+        }
     }
 
     @Override
@@ -192,12 +210,16 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP
         servicehandlerProvider.init();
         LOG.info("Initializing tapi provider ...");
         tapiProvider.init();
+        LOG.info("Initializing nbi-notifications provider ...");
+        nbiNotificationsProvider.init();
         LOG.info("Init done.");
         return true;
     }
 
     @Override
     protected boolean stopProcedure() {
+        nbiNotificationsProvider.close();
+        LOG.info("Shutting down nbi-notifications provider ...");
         tapiProvider.close();
         LOG.info("Shutting down service-handler provider ...");
         servicehandlerProvider.close();
index ff76b3fb151d3f60b7c128f944a5536450d1f62c..9c2cfc1a615d69aba53f593fefeb9de2d62817aa 100644 (file)
@@ -203,7 +203,7 @@ public final class TPCEUtils {
                     .getInstance(),
             org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.$YangModuleInfoImpl
                     .getInstance(),
-            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.$YangModuleInfoImpl
+            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.$YangModuleInfoImpl
                     .getInstance(),
             org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128
                     .$YangModuleInfoImpl.getInstance(),
@@ -218,7 +218,7 @@ public final class TPCEUtils {
             org.opendaylight.yang.gen.v1.gnpy.gnpy.eqpt.config.rev181119.$YangModuleInfoImpl.getInstance(),
             org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.$YangModuleInfoImpl.getInstance(),
             org.opendaylight.yang.gen.v1.gnpy.path.rev200909.$YangModuleInfoImpl.getInstance(),
-            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012
+            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310
                     .$YangModuleInfoImpl.getInstance(),
             org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210
                     .$YangModuleInfoImpl.getInstance(),
@@ -255,6 +255,8 @@ public final class TPCEUtils {
             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.$YangModuleInfoImpl
                     .getInstance(),
             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.$YangModuleInfoImpl
+                    .getInstance(),
+            org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.$YangModuleInfoImpl
                     .getInstance());
 
     private static final Set<YangModuleInfo> TPCE_YANG_MODEL = Stream.concat(
index 096c25d34a1bfad0b1dbc4800e7361f5d582b5eb..de130a4db56548b2e51af3d34c31aa2051ea95b0 100644 (file)
@@ -48,7 +48,7 @@ public class MaintTest {
 
     @Test
     public void startNoConfigFileTest() throws Exception {
-        main.start(new String[0], true);
+        main.start(null, false, true);
         ContentResponse response = client.GET("http://localhost:8181/restconf/config/ietf-network:networks/network/openroadm-topology");
         assertEquals("Response code should be 200", 200, response.getStatus());
     }
@@ -56,8 +56,7 @@ public class MaintTest {
     @Test
     public void startConfigFileTest() throws Exception {
         File configFile = new File("src/test/resources/config.json");
-        String[] args = {configFile.getAbsolutePath()};
-        main.start(args, true);
+        main.start(configFile.getAbsolutePath(), false, true);
         ContentResponse response = client.GET("http://localhost:8888/restconfCustom/config/ietf-network:networks/network/openroadm-topology");
         assertEquals("Response code should be 200", 200, response.getStatus());
     }
diff --git a/nbinotifications/pom.xml b/nbinotifications/pom.xml
new file mode 100644 (file)
index 0000000..a1b0d9e
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright © 2020 Orange 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 INTERNAL -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.opendaylight.mdsal</groupId>
+        <artifactId>binding-parent</artifactId>
+        <version>7.0.5</version>
+        <relativePath />
+    </parent>
+
+    <groupId>org.opendaylight.transportpce</groupId>
+    <artifactId>transportpce-nbinotifications</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <kafka.version>2.6.0</kafka.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>transportpce-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>transportpce-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}.ordmodels</groupId>
+            <artifactId>transportpce-ordmodels-service</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.kafka</groupId>
+            <artifactId>kafka-clients</artifactId>
+            <version>${kafka.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-binding-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-binding-dom-adapter</artifactId>
+        </dependency>
+        <!-- Testing Dependencies -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>test-common</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/consumer/Subscriber.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/consumer/Subscriber.java
new file mode 100644 (file)
index 0000000..cb044b1
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.consumer;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import org.apache.kafka.clients.consumer.Consumer;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.apache.kafka.clients.consumer.ConsumerRecords;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.nbinotifications.serialization.ConfigConstants;
+import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceDeserializer;
+import org.opendaylight.transportpce.nbinotifications.utils.NbiNotificationsUtils;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Subscriber {
+    private static final Logger LOG = LoggerFactory.getLogger(Subscriber.class);
+
+    private final Consumer<String, NotificationService> consumer;
+
+    public Subscriber(String id, String groupId, String suscriberServer,
+            JsonStringConverter<org.opendaylight.yang.gen.v1
+                .nbi.notifications.rev201130.NotificationService> deserializer) {
+        Properties propsConsumer = NbiNotificationsUtils.loadProperties("subscriber.properties");
+        propsConsumer.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
+        propsConsumer.put(ConsumerConfig.CLIENT_ID_CONFIG, id);
+        propsConsumer.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
+        propsConsumer.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG , NotificationServiceDeserializer.class);
+        propsConsumer.put(ConfigConstants.CONVERTER , deserializer);
+        if (suscriberServer != null && !suscriberServer.isBlank()) {
+            propsConsumer.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, suscriberServer);
+        }
+        LOG.info("Suscribing for group id {}, client config id {} with properties {}", groupId, id, propsConsumer);
+        consumer = new KafkaConsumer<>(propsConsumer);
+    }
+
+    public List<NotificationService> subscribeService(String topicName) {
+        LOG.info("Subscribe request to topic '{}' ", topicName);
+        consumer.subscribe(Collections.singleton(topicName));
+        final ConsumerRecords<String, NotificationService> consumerRecords = consumer.poll(Duration.ofMillis(1000));
+        List<NotificationService> notificationServiceList = new ArrayList<>();
+        YangInstanceIdentifier.of(NotificationService.QNAME);
+        for (ConsumerRecord<String, NotificationService> record : consumerRecords) {
+            if (record.value() != null) {
+                notificationServiceList.add(record.value());
+            }
+        }
+        LOG.info("Getting records '{}' ", notificationServiceList);
+        consumer.unsubscribe();
+        consumer.close();
+        return notificationServiceList;
+    }
+
+    @VisibleForTesting public Subscriber(Consumer<String, NotificationService> consumer) {
+        this.consumer = consumer;
+    }
+}
diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImpl.java
new file mode 100644 (file)
index 0000000..073ce49
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.impl;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.nbinotifications.consumer.Subscriber;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.GetNotificationsServiceInput;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.GetNotificationsServiceOutput;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.GetNotificationsServiceOutputBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NbiNotificationsService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NbiNotificationsImpl implements NbiNotificationsService {
+    private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsImpl.class);
+    private final JsonStringConverter<org.opendaylight.yang.gen.v1
+        .nbi.notifications.rev201130.NotificationService> converter;
+    private final String server;
+
+    public NbiNotificationsImpl(JsonStringConverter<org.opendaylight.yang.gen.v1
+            .nbi.notifications.rev201130.NotificationService> converter, String server) {
+        this.converter = converter;
+        this.server = server;
+    }
+
+    @Override
+    public ListenableFuture<RpcResult<GetNotificationsServiceOutput>> getNotificationsService(
+            GetNotificationsServiceInput input) {
+        LOG.info("RPC getNotificationsService received");
+        if (input == null || input.getIdConsumer() == null || input.getGroupId() == null) {
+            LOG.warn("Missing mandatory params for input {}", input);
+            return RpcResultBuilder.success(new GetNotificationsServiceOutputBuilder().build()).buildFuture();
+        }
+        Subscriber subscriber = new Subscriber(input.getIdConsumer(), input.getGroupId(), server, converter);
+        List<NotificationService> notificationServiceList = subscriber
+                .subscribeService(input.getConnectionType().getName());
+        GetNotificationsServiceOutputBuilder output = new GetNotificationsServiceOutputBuilder()
+                .setNotificationService(notificationServiceList);
+        return RpcResultBuilder.success(output.build()).buildFuture();
+    }
+}
diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java
new file mode 100644 (file)
index 0000000..5f41034
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.nbinotifications.listener.NbiNotificationsListenerImpl;
+import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NbiNotificationsListener;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NbiNotificationsService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NbiNotificationsProvider {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsProvider.class);
+    private static Map<String, Publisher> publishersMap =  new HashMap<>();
+
+    private final RpcProviderService rpcService;
+    private ObjectRegistration<NbiNotificationsService> rpcRegistration;
+    private ListenerRegistration<NbiNotificationsListener> listenerRegistration;
+    private NotificationService notificationService;
+    private final JsonStringConverter<org.opendaylight.yang.gen.v1
+        .nbi.notifications.rev201130.NotificationService> converter;
+    private final String suscriberServer;
+
+
+    public NbiNotificationsProvider(List<String> topics,
+            String suscriberServer, String publisherServer,
+            RpcProviderService rpcProviderService, NotificationService notificationService,
+            BindingDOMCodecServices bindingDOMCodecServices) {
+        this.rpcService = rpcProviderService;
+        this.notificationService = notificationService;
+        converter =  new JsonStringConverter<>(bindingDOMCodecServices);
+        for (String topic: topics) {
+            LOG.info("Creating publisher for topic {}", topic);
+            publishersMap.put(topic, new Publisher(topic, publisherServer, converter));
+        }
+        this.suscriberServer = suscriberServer;
+    }
+
+    /**
+     * Method called when the blueprint container is created.
+     */
+    public void init() {
+        LOG.info("NbiNotificationsProvider Session Initiated");
+        rpcRegistration = rpcService.registerRpcImplementation(NbiNotificationsService.class,
+                new NbiNotificationsImpl(converter, suscriberServer));
+        listenerRegistration = notificationService.registerNotificationListener(
+                new NbiNotificationsListenerImpl(publishersMap));
+    }
+
+    /**
+     * Method called when the blueprint container is destroyed.
+     */
+    public void close() {
+        for (Publisher publisher : publishersMap.values()) {
+            publisher.close();
+        }
+        rpcRegistration.close();
+        listenerRegistration.close();
+        LOG.info("NbiNotificationsProvider Closed");
+    }
+
+}
diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImpl.java
new file mode 100644 (file)
index 0000000..0bcdf6b
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.listener;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NbiNotificationsListener;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NbiNotificationsListenerImpl implements NbiNotificationsListener {
+    private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsListenerImpl.class);
+    private Map<String, Publisher> publishersMap =  new HashMap<>();
+
+    public NbiNotificationsListenerImpl(Map<String, Publisher> publishersMap) {
+        this.publishersMap = publishersMap;
+    }
+
+    @Override
+    public void onPublishNotificationService(PublishNotificationService notification) {
+        LOG.info("Receiving request for publishing notification service");
+        String topic = notification.getTopic();
+        if (!publishersMap.containsKey(topic)) {
+            LOG.error("Unknown topic {}", topic);
+            return;
+        }
+        Publisher publisher = publishersMap.get(topic);
+        publisher.sendEvent(new NotificationServiceBuilder().setCommonId(notification.getCommonId())
+                .setConnectionType(notification.getConnectionType()).setMessage(notification.getMessage())
+                .setOperationalState(notification.getOperationalState())
+                .setResponseFailed(notification.getResponseFailed())
+                .setServiceAEnd(notification.getServiceAEnd()).setServiceName(notification.getServiceName())
+                .setServiceZEnd(notification.getServiceZEnd()).build());
+
+    }
+
+}
diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/producer/Publisher.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/producer/Publisher.java
new file mode 100644 (file)
index 0000000..21295a9
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.producer;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.util.Properties;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.Producer;
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.nbinotifications.serialization.ConfigConstants;
+import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceSerializer;
+import org.opendaylight.transportpce.nbinotifications.utils.NbiNotificationsUtils;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Publisher {
+    private static final Logger LOG = LoggerFactory.getLogger(Publisher.class);
+
+    private final String id;
+    private final Producer<String, NotificationService> producer;
+
+    public Publisher(String id, String publisherServer, JsonStringConverter<NotificationService> serializer) {
+        Properties properties = NbiNotificationsUtils.loadProperties("publisher.properties");
+        properties.put(ProducerConfig.CLIENT_ID_CONFIG, id);
+        if (publisherServer != null && !publisherServer.isBlank()) {
+            properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, publisherServer);
+        }
+        properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
+        properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG , NotificationServiceSerializer.class);
+        properties.put(ConfigConstants.CONVERTER , serializer);
+        LOG.info("Creationg publisher for id {} with properties {}", id, properties);
+        producer = new KafkaProducer<>(properties);
+        this.id = id;
+    }
+
+    @VisibleForTesting Publisher(String id, Producer<String, NotificationService> producer) {
+        this.producer = producer;
+        this.id = id;
+    }
+
+    public void close() {
+        producer.close();
+    }
+
+    public void sendEvent(NotificationService notificationService) {
+        LOG.info("SendEvent request to topic '{}' ", notificationService.getConnectionType().getName());
+        producer.send(new ProducerRecord<>(notificationService.getConnectionType().getName(), id, notificationService));
+        producer.flush();
+    }
+}
diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/ConfigConstants.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/ConfigConstants.java
new file mode 100644 (file)
index 0000000..b10b016
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.serialization;
+
+public final class ConfigConstants {
+    private ConfigConstants() {
+    }
+
+    public static final String CONVERTER = "converter";
+
+}
diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java
new file mode 100644 (file)
index 0000000..95f10fb
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.serialization;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import org.apache.kafka.common.serialization.Deserializer;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationServiceBuilder;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NotificationServiceDeserializer implements Deserializer<NotificationService> {
+    private static final Logger LOG = LoggerFactory.getLogger(NotificationServiceDeserializer.class);
+    private JsonStringConverter<org.opendaylight.yang.gen.v1
+        .nbi.notifications.rev201130.NotificationService> converter;
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void configure(Map<String, ?> configs, boolean isKey) {
+        LOG.info("Deserializer configuration {}", configs);
+        if (configs.containsKey(ConfigConstants.CONVERTER)
+                && configs.get(ConfigConstants.CONVERTER) instanceof JsonStringConverter<?>) {
+            converter = (JsonStringConverter<org.opendaylight.yang.gen.v1
+                    .nbi.notifications.rev201130.NotificationService>) configs
+                    .get(ConfigConstants.CONVERTER);
+        }
+    }
+
+    @Override
+    public NotificationService deserialize(String topic, byte[] data) {
+        if (converter == null) {
+            throw new IllegalArgumentException(
+                    "Converter should be configured through configure method of deserializer");
+        }
+        String value = new String(data, StandardCharsets.UTF_8);
+        // The message published is
+        // org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService
+        // we have to map it to
+        // org.opendaylight.yang.gen
+        // .v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService
+        org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService mappedString = converter
+                .createDataObjectFromJsonString(YangInstanceIdentifier.of(
+                        org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService.QNAME),
+                        value,
+                        JSONCodecFactorySupplier.RFC7951);
+        if (mappedString != null) {
+            LOG.info("Reading event {}", mappedString);
+            return new NotificationServiceBuilder().setCommonId(mappedString.getCommonId())
+                    .setConnectionType(mappedString.getConnectionType()).setMessage(mappedString.getMessage())
+                    .setOperationalState(mappedString.getOperationalState())
+                    .setResponseFailed(mappedString.getResponseFailed()).setServiceName(mappedString.getServiceName())
+                    .setServiceAEnd(mappedString.getServiceAEnd()).setServiceZEnd(mappedString.getServiceZEnd())
+                    .build();
+        }
+        return null;
+    }
+
+}
diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializer.java
new file mode 100644 (file)
index 0000000..eb99874
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.serialization;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import org.apache.kafka.common.serialization.Serializer;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NotificationServiceSerializer implements Serializer<NotificationService> {
+    private static final Logger LOG = LoggerFactory.getLogger(NotificationServiceSerializer.class);
+    private JsonStringConverter<NotificationService> converter;
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void configure(Map<String, ?> configs, boolean isKey) {
+        LOG.info("Deserializer configuration {}", configs);
+        if (configs.containsKey(ConfigConstants.CONVERTER)
+                && configs.get(ConfigConstants.CONVERTER) instanceof JsonStringConverter<?>) {
+            converter = (JsonStringConverter<NotificationService>) configs.get(ConfigConstants.CONVERTER);
+        }
+    }
+
+    @Override
+    public byte[] serialize(String topic, NotificationService data) {
+        if (converter == null) {
+            throw new IllegalArgumentException(
+                    "Converter should be" + "configured through configure method of serializer");
+        }
+        if (data == null) {
+            return new byte[0];
+        }
+        try {
+            InstanceIdentifier<NotificationService> iid = InstanceIdentifier.builder(NotificationService.class).build();
+            String serialized = converter.createJsonStringFromDataObject(iid, data, JSONCodecFactorySupplier.RFC7951);
+            LOG.info("Serialized event {}", serialized);
+            return serialized.getBytes(StandardCharsets.UTF_8);
+        } catch (IOException e) {
+            return new byte[0];
+        }
+    }
+}
diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/NbiNotificationsUtils.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/utils/NbiNotificationsUtils.java
new file mode 100644 (file)
index 0000000..d1a4cee
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class NbiNotificationsUtils {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsUtils.class);
+
+    private NbiNotificationsUtils() {
+    }
+
+    public static Properties loadProperties(String propertyFileName) {
+        Properties props = new Properties();
+        InputStream inputStream = NbiNotificationsUtils.class.getClassLoader()
+                .getResourceAsStream(propertyFileName);
+        try {
+            if (inputStream != null) {
+                props.load(inputStream);
+            } else {
+                LOG.warn("Kafka property file '{}' is empty", propertyFileName);
+            }
+        } catch (IOException e) {
+            LOG.warn("Kafka property file '{}' was not found in the classpath", propertyFileName);
+        }
+        return props;
+    }
+}
diff --git a/nbinotifications/src/main/resources/OSGI-INF/blueprint/nobinotifications-blueprint.xml b/nbinotifications/src/main/resources/OSGI-INF/blueprint/nobinotifications-blueprint.xml
new file mode 100644 (file)
index 0000000..9b3a3bd
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!-- Copyright © 2020 Orange 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 -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+    odl:use-default-for-reference-types="true">
+    <cm:property-placeholder persistent-id="org.opendaylight.transportpce.nbinotifications" update-strategy="reload">
+        <cm:default-properties>
+            <cm:property name="suscriber.server" value="" />
+            <cm:property name="publisher.server" value="" />
+        </cm:default-properties>
+    </cm:property-placeholder>
+    <reference id="rpcService" interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
+    <reference id="notificationService" interface="org.opendaylight.mdsal.binding.api.NotificationService"/>
+    <reference id="bindingDOMCodecServices" interface="org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices" />
+    <bean id="provider"
+        class="org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider"
+        init-method="init" destroy-method="close">
+        <argument>
+            <list value-type="java.lang.String">
+                <value>PceListener</value>
+                <value>ServiceHandlerOperations</value>
+                <value>ServiceHandler</value>
+                <value>RendererListener</value>
+            </list>
+        </argument>
+        <argument value="${suscriber.server}"/>
+        <argument value="${publisher.server}"/>
+        <argument ref="rpcService" />
+        <argument ref="notificationService" />
+        <argument ref="bindingDOMCodecServices" />
+    </bean>
+</blueprint>
diff --git a/nbinotifications/src/main/resources/publisher.properties b/nbinotifications/src/main/resources/publisher.properties
new file mode 100644 (file)
index 0000000..ecbc156
--- /dev/null
@@ -0,0 +1,8 @@
+#Kafka Producer/AdminClient properties
+bootstrap.servers=localhost:9092
+acks=all
+retries=3
+max.in.flight.requests.per.connection=1
+batch.size=16384
+linger.ms=1
+buffer.memory=33554432
diff --git a/nbinotifications/src/main/resources/subscriber.properties b/nbinotifications/src/main/resources/subscriber.properties
new file mode 100644 (file)
index 0000000..0c3e96e
--- /dev/null
@@ -0,0 +1,5 @@
+#Kafka Consumer properties
+bootstrap.servers=localhost:9092
+enable.auto.commit=true
+auto.commit.interval.ms=1000
+auto.offset.reset=earliest
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/consumer/SubscriberTest.java
new file mode 100644 (file)
index 0000000..de58a49
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.consumer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.apache.kafka.clients.consumer.MockConsumer;
+import org.apache.kafka.clients.consumer.OffsetResetStrategy;
+import org.apache.kafka.common.TopicPartition;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.transportpce.nbinotifications.utils.NotificationServiceDataUtils;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService;
+
+public class SubscriberTest extends AbstractTest {
+    private static final String TOPIC = "topic";
+    private static final int PARTITION = 0;
+    private MockConsumer<String, NotificationService> mockConsumer;
+    private Subscriber subscriber;
+
+    @Before
+    public void setUp() {
+        mockConsumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
+        subscriber = new Subscriber(mockConsumer);
+    }
+
+    @Test
+    public void subscribeServiceShouldBeSuccessful() {
+        // from https://www.baeldung.com/kafka-mockconsumer
+        ConsumerRecord<String, NotificationService> record = new ConsumerRecord<String, NotificationService>(
+                TOPIC, PARTITION, 0L, "key", NotificationServiceDataUtils.buildReceivedEvent());
+        mockConsumer.schedulePollTask(() -> {
+            mockConsumer.rebalance(Collections.singletonList(new TopicPartition(TOPIC, PARTITION)));
+            mockConsumer.addRecord(record);
+        });
+
+        Map<TopicPartition, Long> startOffsets = new HashMap<>();
+        TopicPartition tp = new TopicPartition(TOPIC, PARTITION);
+        startOffsets.put(tp, 0L);
+        mockConsumer.updateBeginningOffsets(startOffsets);
+        List<NotificationService> result = subscriber.subscribeService(TOPIC);
+        assertEquals("There should be 1 record", 1, result.size());
+        assertTrue("Consumer should be closed", mockConsumer.closed());
+    }
+}
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java
new file mode 100644 (file)
index 0000000..da82550
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.impl;
+
+import static org.junit.Assert.assertNull;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.ExecutionException;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.GetNotificationsServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.GetNotificationsServiceOutput;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+public class NbiNotificationsImplTest extends AbstractTest {
+    private NbiNotificationsImpl nbiNotificationsImpl;
+
+    @Before
+    public void setUp() {
+        JsonStringConverter<org.opendaylight.yang.gen.v1
+            .nbi.notifications.rev201130.NotificationService> converter = new JsonStringConverter<>(
+                getDataStoreContextUtil().getBindingDOMCodecServices());
+        nbiNotificationsImpl = new NbiNotificationsImpl(converter, "localhost:8080");
+    }
+
+    public void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException {
+        ListenableFuture<RpcResult<GetNotificationsServiceOutput>> result =
+                nbiNotificationsImpl.getNotificationsService(new GetNotificationsServiceInputBuilder().build());
+        assertNull("Should be null", result.get().getResult().getNotificationService());
+    }
+
+    @Test
+    public void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
+        GetNotificationsServiceInputBuilder builder = new GetNotificationsServiceInputBuilder();
+        builder.setGroupId("groupId");
+        builder.setIdConsumer("consumerId");
+        builder.setConnectionType(ConnectionType.Service);
+        ListenableFuture<RpcResult<GetNotificationsServiceOutput>> result =
+                nbiNotificationsImpl.getNotificationsService(builder.build());
+        assertNull("Should be null", result.get().getResult().getNotificationService());
+    }
+}
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProviderTest.java
new file mode 100644 (file)
index 0000000..178fc42
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.impl;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.Arrays;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.transportpce.nbinotifications.listener.NbiNotificationsListenerImpl;
+import org.opendaylight.transportpce.test.AbstractTest;
+
+public class NbiNotificationsProviderTest  extends AbstractTest {
+
+    @Mock
+    RpcProviderService rpcProviderRegistry;
+
+    @Mock
+    private NotificationService notificationService;
+
+    @Before
+    public void init() {
+        MockitoAnnotations.openMocks(this);
+
+    }
+
+    @Test
+    public void initTest() {
+        NbiNotificationsProvider provider = new NbiNotificationsProvider(
+                Arrays.asList("topic1", "topic2"), "localhost:8080", "localhost:8080",
+                rpcProviderRegistry, notificationService,
+                getDataStoreContextUtil().getBindingDOMCodecServices());
+        provider.init();
+        verify(rpcProviderRegistry, times(1))
+                .registerRpcImplementation(any(), any(NbiNotificationsImpl.class));
+        verify(notificationService, times(1))
+                .registerNotificationListener(any(NbiNotificationsListenerImpl.class));
+    }
+}
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java
new file mode 100644 (file)
index 0000000..cb8faf2
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.listener;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationServiceBuilder;
+
+public class NbiNotificationsListenerImplTest extends AbstractTest {
+    @Mock
+    private Publisher publisher;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.openMocks(this);
+    }
+
+    @Test
+    public void onPublishNotificationServiceTest() {
+        NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisher));
+        PublishNotificationService notification = new PublishNotificationServiceBuilder().setTopic("test")
+                .setCommonId("commonId").setConnectionType(ConnectionType.Service).setMessage("Service deleted")
+                .setOperationalState(State.OutOfService).setServiceName("service name").build();
+        listener.onPublishNotificationService(notification);
+        verify(publisher, times(1)).sendEvent(any());
+    }
+
+    @Test
+    public void onPublishNotificationServiceWrongTopicTest() {
+        NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisher));
+        PublishNotificationService notification = new PublishNotificationServiceBuilder().setTopic("wrongtopic")
+                .setCommonId("commonId").setConnectionType(ConnectionType.Service).setMessage("Service deleted")
+                .setOperationalState(State.OutOfService).setServiceName("service name").build();
+        listener.onPublishNotificationService(notification);
+        verify(publisher, times(0)).sendEvent(any());
+    }
+}
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/producer/PublisherTest.java
new file mode 100644 (file)
index 0000000..b3a5b2e
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.producer;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Map;
+import org.apache.kafka.clients.producer.MockProducer;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.nbinotifications.serialization.ConfigConstants;
+import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceSerializer;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
+
+public class PublisherTest extends AbstractTest {
+    private JsonStringConverter<NotificationService> converter;
+    private Publisher publisher;
+    private MockProducer<String, NotificationService> mockProducer;
+
+    @Before
+    public void setUp() {
+        NotificationServiceSerializer serializer = new NotificationServiceSerializer();
+        Map<String, Object> properties = Map.of(ConfigConstants.CONVERTER , serializer);
+        serializer.configure(properties, false);
+        mockProducer =  new MockProducer<>(true, new StringSerializer(), serializer);
+        converter = new JsonStringConverter<NotificationService>(
+                getDataStoreContextUtil().getBindingDOMCodecServices());
+        publisher = new Publisher("test",mockProducer);
+    }
+
+    @Test
+    public void sendEventShouldBeSuccessful() throws IOException {
+        String json = Files.readString(Paths.get("src/test/resources/event.json"));
+        NotificationService notificationService = converter
+                .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationService.QNAME),
+                        json, JSONCodecFactorySupplier.RFC7951);
+        publisher.sendEvent(notificationService);
+        assertEquals("We should have one message", 1, mockProducer.history().size());
+        assertEquals("Key should be test", "test",mockProducer.history().get(0).key());
+    }
+
+}
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializerTest.java
new file mode 100644 (file)
index 0000000..928c247
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.serialization;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Map;
+import org.junit.Test;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService;
+
+public class NotificationServiceDeserializerTest extends AbstractTest {
+
+    @Test
+    public void deserializeTest() throws IOException {
+        JsonStringConverter<org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService> converter =
+                new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
+        NotificationServiceDeserializer deserializer = new NotificationServiceDeserializer();
+        Map<String, Object> configs = Map.of(ConfigConstants.CONVERTER, converter);
+        deserializer.configure(configs, false);
+        NotificationService readEvent = deserializer.deserialize("Test",
+                Files.readAllBytes(Paths.get("src/test/resources/event.json")));
+        deserializer.close();
+        assertEquals("Service name should be service1", "service1", readEvent.getServiceName());
+    }
+}
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceSerializerTest.java
new file mode 100644 (file)
index 0000000..3fe658b
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.serialization;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Map;
+import org.junit.Test;
+import org.opendaylight.transportpce.common.converter.JsonStringConverter;
+import org.opendaylight.transportpce.test.AbstractTest;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
+
+public class NotificationServiceSerializerTest extends AbstractTest {
+
+    @Test
+    public void serializeTest() throws IOException {
+        JsonStringConverter<NotificationService> converter =
+                new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
+        String json = Files.readString(Paths.get("src/test/resources/event.json"));
+        NotificationService notificationService = converter
+                .createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationService.QNAME),
+                        json, JSONCodecFactorySupplier.RFC7951);
+        NotificationServiceSerializer serializer = new NotificationServiceSerializer();
+        Map<String, Object> configs = Map.of(ConfigConstants.CONVERTER, converter);
+        serializer.configure(configs, false);
+        byte[] data = serializer.serialize("test", notificationService);
+        serializer.close();
+        assertNotNull("Serialized data should not be null", data);
+        String expectedJson = Files.readString(Paths.get("src/test/resources/expected_event.json"));
+        assertEquals("The event should be equals", expectedJson, new String(data, StandardCharsets.UTF_8));
+    }
+}
diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/utils/NotificationServiceDataUtils.java
new file mode 100644 (file)
index 0000000..44b6958
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.nbinotifications.utils;
+
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirection;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirection;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceZEndBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+
+public final class NotificationServiceDataUtils {
+
+    private NotificationServiceDataUtils() {
+    }
+
+    public static NotificationService buildSendEventInput() {
+        NotificationServiceBuilder notificationServiceBuilder = new NotificationServiceBuilder()
+                .setMessage("message")
+                .setServiceName("service1")
+                .setOperationalState(State.InService)
+                .setResponseFailed("")
+                .setCommonId("commond-id")
+                .setConnectionType(ConnectionType.Service)
+                .setServiceZEnd(getServiceZEndBuild().build())
+                .setServiceAEnd(getServiceAEndBuild().build());
+
+        return notificationServiceBuilder.build();
+    }
+
+    public static org.opendaylight.yang.gen.v1
+        .nbi.notifications.rev201130.get.notifications.service.output.NotificationService buildReceivedEvent() {
+        org.opendaylight.yang.gen.v1
+            .nbi.notifications.rev201130.get.notifications.service.output.NotificationServiceBuilder
+            notificationServiceBuilder = new org.opendaylight.yang.gen.v1
+            .nbi.notifications.rev201130.get.notifications.service.output.NotificationServiceBuilder()
+                .setMessage("message")
+                .setServiceName("service1")
+                .setOperationalState(State.InService)
+                .setResponseFailed("")
+                .setCommonId("commond-id")
+                .setConnectionType(ConnectionType.Service)
+                .setServiceZEnd(getServiceZEndBuild().build())
+                .setServiceAEnd(getServiceAEndBuild().build());
+
+        return notificationServiceBuilder.build();
+    }
+
+    public static ServiceAEndBuilder getServiceAEndBuild() {
+        return new ServiceAEndBuilder()
+                .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
+                .setNodeId(new NodeIdType("XPONDER-1-2"))
+                .setTxDirection(getTxDirection())
+                .setRxDirection(getRxDirection());
+    }
+
+    public static ServiceZEndBuilder getServiceZEndBuild() {
+        return new ServiceZEndBuilder()
+                .setClli("clli").setServiceFormat(ServiceFormat.OC).setServiceRate(Uint32.valueOf(1))
+                .setNodeId(new NodeIdType("XPONDER-1-2"))
+                .setTxDirection(getTxDirection())
+                .setRxDirection(getRxDirection());
+    }
+
+    private static TxDirection getTxDirection() {
+        return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service
+                .endpoint.TxDirectionBuilder().setPort(new PortBuilder().setPortDeviceName("device name")
+                .setPortName("port name").setPortRack("port rack").setPortShelf("port shelf")
+                .setPortSlot("port slot").setPortSubSlot("port subslot").setPortType("port type").build())
+                .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name").setLgxPortName("lgx port name")
+                        .setLgxPortRack("lgx port rack").setLgxPortShelf("lgx port shelf").build())
+                .build();
+    }
+
+    private static RxDirection getRxDirection() {
+        return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service
+                .endpoint.RxDirectionBuilder()
+                .setPort(new PortBuilder().setPortDeviceName("device name").setPortName("port name")
+                        .setPortRack("port rack").setPortShelf("port shelf").setPortSlot("port slot")
+                        .setPortSubSlot("port subslot").setPortType("port type").build())
+                .setLgx(new LgxBuilder().setLgxDeviceName("lgx device name")
+                        .setLgxPortName("lgx port name").setLgxPortRack("lgx port rack")
+                        .setLgxPortShelf("lgx port shelf").build())
+                .build();
+    }
+}
diff --git a/nbinotifications/src/test/resources/event.json b/nbinotifications/src/test/resources/event.json
new file mode 100644 (file)
index 0000000..63c7bec
--- /dev/null
@@ -0,0 +1,90 @@
+{
+    "notification-service": {
+        "service-name": "service1",
+        "service-a-end": {
+            "service-format": "OC",
+            "node-id": "XPONDER-1-2",
+            "service-rate": 1,
+            "clli": "clli",
+            "tx-direction": {
+                "port": {
+                    "port-slot": "port slot",
+                    "port-device-name": "device name",
+                    "port-rack": "port rack",
+                    "port-shelf": "port shelf",
+                    "port-type": "port type",
+                    "port-sub-slot": "port subslot",
+                    "port-name": "port name"
+                },
+                "lgx": {
+                    "lgx-port-name": "lgx port name",
+                    "lgx-port-shelf": "lgx port shelf",
+                    "lgx-port-rack": "lgx port rack",
+                    "lgx-device-name": "lgx device name"
+                }
+            },
+            "rx-direction": {
+                "port": {
+                    "port-slot": "port slot",
+                    "port-device-name": "device name",
+                    "port-rack": "port rack",
+                    "port-shelf": "port shelf",
+                    "port-type": "port type",
+                    "port-sub-slot": "port subslot",
+                    "port-name": "port name"
+                },
+                "lgx": {
+                    "lgx-port-name": "lgx port name",
+                    "lgx-port-shelf": "lgx port shelf",
+                    "lgx-port-rack": "lgx port rack",
+                    "lgx-device-name": "lgx device name"
+                }
+            }
+        },
+        "common-id": "commond-id",
+        "operational-state": "inService",
+        "connection-type": "service",
+        "service-z-end": {
+            "service-format": "OC",
+            "node-id": "XPONDER-1-2",
+            "service-rate": 1,
+            "clli": "clli",
+            "tx-direction": {
+                "port": {
+                    "port-slot": "port slot",
+                    "port-device-name": "device name",
+                    "port-rack": "port rack",
+                    "port-shelf": "port shelf",
+                    "port-type": "port type",
+                    "port-sub-slot": "port subslot",
+                    "port-name": "port name"
+                },
+                "lgx": {
+                    "lgx-port-name": "lgx port name",
+                    "lgx-port-shelf": "lgx port shelf",
+                    "lgx-port-rack": "lgx port rack",
+                    "lgx-device-name": "lgx device name"
+                }
+            },
+            "rx-direction": {
+                "port": {
+                    "port-slot": "port slot",
+                    "port-device-name": "device name",
+                    "port-rack": "port rack",
+                    "port-shelf": "port shelf",
+                    "port-type": "port type",
+                    "port-sub-slot": "port subslot",
+                    "port-name": "port name"
+                },
+                "lgx": {
+                    "lgx-port-name": "lgx port name",
+                    "lgx-port-shelf": "lgx port shelf",
+                    "lgx-port-rack": "lgx port rack",
+                    "lgx-device-name": "lgx device name"
+                }
+            }
+        },
+        "message": "message",
+        "response-failed": ""
+    }
+}
diff --git a/nbinotifications/src/test/resources/expected_event.json b/nbinotifications/src/test/resources/expected_event.json
new file mode 100644 (file)
index 0000000..2b8924d
--- /dev/null
@@ -0,0 +1 @@
+{"notification-service":{"service-name":"service1","service-a-end":{"service-format":"OC","node-id":"XPONDER-1-2","service-rate":1,"clli":"clli","tx-direction":{"port":{"port-slot":"port slot","port-device-name":"device name","port-rack":"port rack","port-shelf":"port shelf","port-type":"port type","port-sub-slot":"port subslot","port-name":"port name"},"lgx":{"lgx-port-name":"lgx port name","lgx-port-shelf":"lgx port shelf","lgx-port-rack":"lgx port rack","lgx-device-name":"lgx device name"}},"rx-direction":{"port":{"port-slot":"port slot","port-device-name":"device name","port-rack":"port rack","port-shelf":"port shelf","port-type":"port type","port-sub-slot":"port subslot","port-name":"port name"},"lgx":{"lgx-port-name":"lgx port name","lgx-port-shelf":"lgx port shelf","lgx-port-rack":"lgx port rack","lgx-device-name":"lgx device name"}}},"common-id":"commond-id","operational-state":"inService","connection-type":"service","service-z-end":{"service-format":"OC","node-id":"XPONDER-1-2","service-rate":1,"clli":"clli","tx-direction":{"port":{"port-slot":"port slot","port-device-name":"device name","port-rack":"port rack","port-shelf":"port shelf","port-type":"port type","port-sub-slot":"port subslot","port-name":"port name"},"lgx":{"lgx-port-name":"lgx port name","lgx-port-shelf":"lgx port shelf","lgx-port-rack":"lgx port rack","lgx-device-name":"lgx device name"}},"rx-direction":{"port":{"port-slot":"port slot","port-device-name":"device name","port-rack":"port rack","port-shelf":"port shelf","port-type":"port type","port-sub-slot":"port subslot","port-name":"port name"},"lgx":{"lgx-port-name":"lgx port name","lgx-port-shelf":"lgx port shelf","lgx-port-rack":"lgx port rack","lgx-device-name":"lgx device name"}}},"message":"message","response-failed":""}}
\ No newline at end of file
diff --git a/nbinotifications/src/test/resources/publisher.properties b/nbinotifications/src/test/resources/publisher.properties
new file mode 100644 (file)
index 0000000..ecbc156
--- /dev/null
@@ -0,0 +1,8 @@
+#Kafka Producer/AdminClient properties
+bootstrap.servers=localhost:9092
+acks=all
+retries=3
+max.in.flight.requests.per.connection=1
+batch.size=16384
+linger.ms=1
+buffer.memory=33554432
diff --git a/nbinotifications/src/test/resources/subscriber.properties b/nbinotifications/src/test/resources/subscriber.properties
new file mode 100644 (file)
index 0000000..0c3e96e
--- /dev/null
@@ -0,0 +1,5 @@
+#Kafka Consumer properties
+bootstrap.servers=localhost:9092
+enable.auto.commit=true
+auto.commit.interval.ms=1000
+auto.offset.reset=earliest
index 0796a7fd24f33e62527d783f8824b04292182cfe..7673e653fa1de61e326b02ef43a657b1d78ab605 100644 (file)
@@ -25,11 +25,11 @@ import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.networkmodel.util.TopologyUtils;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev170818.InitRoadmNodesInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegree;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegree;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev170929.Direction;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Protocols;
index b870eb560c4f3d540c04a64e2ab99779a0de726c..01ee19f309558a7964542c26d514a685f1d4a9b0 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.transportpce.networkmodel.dto;
 
 import java.util.List;
 import java.util.Map;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes;
 
 public class OtnTopoNode {
index 048baf1558fb7fd86752f6715695ebbd6b497b0d..9e98800ef2901c7cc057b5c4c5492d03f5bd8b61 100644 (file)
@@ -37,8 +37,8 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmo
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.topology.update.result.OrdTopologyChanges;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.topology.update.result.OrdTopologyChangesBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.topology.update.result.OrdTopologyChangesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1Builder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
index 62ddbf444ba7e3901a991320ac0f24f4a4e52cd1..80bbc87c8fba382191997742c3a78d9e97ee41eb 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.transportpce.networkmodel.util;
 
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.clli.network.rev191129.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.clli.network.rev191129.Node1Builder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
index 9dd0ac9da1fc030c3a79d9ccb380f778de869490..d9d7108326cc1040855f16c2b0d1bd7c0c14553c 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.transportpce.networkmodel.util;
 
 import com.google.common.collect.ImmutableMap;
 import org.opendaylight.transportpce.common.NetworkUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.rev200529.Node1Builder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
index e2b5172e3d14f9f4e311d0e9edafc5ccdfb9fa23..08428537b08a78f2a91aafe21bf5525c7db2e8bf 100644 (file)
@@ -18,8 +18,8 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.transportpce.common.NetworkUtils;
 import org.opendaylight.transportpce.networkmodel.dto.OtnTopoNode;
 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 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.XpdrNodeTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
index d6812834613f5a3c8de0f422d2c3a8ef5b2db43f..e8561c2f3125f10339b18b9ac5369149dc82cc3c 100644 (file)
@@ -22,8 +22,8 @@ import org.opendaylight.transportpce.common.NetworkUtils;
 import org.opendaylight.transportpce.common.fixedflex.GridUtils;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
index 4b6e449efb3784d2eee5df30749dda5b269e14b2..d9983f4ea88bfe910f3d1095c3a941b1da5f2829 100644 (file)
@@ -11,9 +11,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
 import org.junit.Test;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.clli.network.rev191129.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.clli.network.rev191129.Node1Builder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
index 42891b3555c7923f7531016f553b9027704a2978..bc70f817328112077d57c7d74c35bd331d2f5844 100644 (file)
@@ -16,9 +16,9 @@ import java.util.List;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.transportpce.common.NetworkUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
index df155cebfc60c23e271c5a1f6e529fb20e97d19e..edc3a825acd09db094e324408bb742728e52fac7 100644 (file)
@@ -35,13 +35,13 @@ import org.junit.Test;
 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
 import org.opendaylight.transportpce.networkmodel.util.test.JsonUtil;
 import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
@@ -86,7 +86,7 @@ public class OpenRoadmOtnTopologyTest {
         try (Reader reader = new FileReader("src/test/resources/portMapping.json", StandardCharsets.UTF_8);
                 JsonReader portMappingReader = new JsonReader(reader)) {
             Network portMapping = (Network) JsonUtil.getInstance().getDataObjectFromJson(portMappingReader,
-                    QName.create("http://org/opendaylight/transportpce/portmapping", "2020-10-12", "network"));
+                    QName.create("http://org/opendaylight/transportpce/portmapping", "2021-03-10", "network"));
             for (Nodes nodes : portMapping.nonnullNodes().values()) {
                 if (nodes.getNodeId().equals("XPDR-A1")) {
                     this.portMappingTpdr = nodes;
index 9ca2a5d9ad7ad9a95c4fdf85e97a29bec65c7c1e..e791bfa58e8aa6818af6a62fc6afbb26e8fea2da 100644 (file)
@@ -42,7 +42,7 @@ import org.opendaylight.transportpce.common.fixedflex.GridConstant;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.networkmodel.dto.TopologyShard;
 import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1;
index 854bfeb1226fca9fab304f3ee450eab14132eb13..78ff02f5252365698ae30fcb9785f92f63b712e7 100644 (file)
@@ -13,12 +13,12 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.opendaylight.transportpce.common.NetworkUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.PortQual;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
index f786b181ae4d1e2857bb09468f0b40f2d591509e..b310ffbbaee35cd22cdd655b127478800f9f1bad 100644 (file)
@@ -22,10 +22,10 @@ import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfa
 import org.opendaylight.transportpce.olm.util.OlmUtils;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.OpticalControlMode;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
index d726b8187345f65394b150de256e370e3e57f3f4..530c04a8a35425668048f5cde643be9053eb89de 100644 (file)
@@ -62,8 +62,8 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev17
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.calculate.spanloss.base.output.Spans;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.calculate.spanloss.base.output.SpansBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.get.pm.output.Measurements;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RatioDB;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface;
index 19dc86b694bae5b648dd75a9773120dcddcb8ca0..ff1d08e8ced19d6d94f8fdd96d5679492223e802 100644 (file)
@@ -17,10 +17,10 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 91638d623e83d40406c56f67dbf370c9f7dcd118..c597a4cd35bec4c3500c34ec8ad02fe215c4c267 100644 (file)
@@ -47,15 +47,15 @@ import org.opendaylight.transportpce.olm.util.OlmPowerServiceRpcImplUtil;
 import org.opendaylight.transportpce.olm.util.OlmUtils;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.OpticalControlMode;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RatioDB;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceBuilder;
index 99b426bab7b2f640b30f3ab28c5626b50ff7607e..bc9bf5cb9a9d19eee5eb76aaf8401fb41677e917 100644 (file)
@@ -17,8 +17,8 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.FiberPmd;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.RatioDB;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.Direction;
index 7fa6f7dcef1541446d284819bc7ca221f6ca155e..182edb41b5da66923c00341b2d4534fc1f8ae802 100644 (file)
@@ -19,18 +19,18 @@ import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.NetworkUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegree;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegreeBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.CpToDegreeKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegree;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegreeBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.CpToDegreeKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo.OpenroadmVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.FiberPmd;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.RatioDB;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
index 6d11ddf2196781ac05cdc60e70a22b6996b2c877..9e5fc4bcd6c7252ac1e442d9453f2e9b8320bb9e 100644 (file)
@@ -92,6 +92,7 @@ public class PcePathDescription {
                     .getOrDefault(Uint32.valueOf(rc.getRate()), ModulationFormat.DpQpsk).getName())
             .setAToZ(atozMap);
         switch (rc.getServiceType()) {
+            case StringConstants.SERVICE_TYPE_400GE:
             case StringConstants.SERVICE_TYPE_100GE:
             case StringConstants.SERVICE_TYPE_OTU4:
                 atoZDirectionBldr.setAToZMaxFrequency(new FrequencyTHz(rc.getMaxFreq()));
@@ -113,6 +114,7 @@ public class PcePathDescription {
                 }
                 break;
             default:
+                LOG.warn("unknown service type : unable to set Min/Max frequencies");
                 break;
         }
         return atoZDirectionBldr;
@@ -129,6 +131,7 @@ public class PcePathDescription {
                         .getOrDefault(Uint32.valueOf(rc.getRate()), ModulationFormat.DpQpsk).getName())
                 .setZToA(ztoaMap);
         switch (rc.getServiceType()) {
+            case StringConstants.SERVICE_TYPE_400GE:
             case StringConstants.SERVICE_TYPE_100GE:
             case StringConstants.SERVICE_TYPE_OTU4:
                 ztoADirectionBldr.setZToAMaxFrequency(new FrequencyTHz(rc.getMaxFreq()));
@@ -150,6 +153,7 @@ public class PcePathDescription {
                 }
                 break;
             default:
+                LOG.warn("unknown service type : unable to set Min/Max frequencies");
                 break;
         }
         return ztoADirectionBldr;
index d0610c8cf1c9868d0cd9ab1ad6a744fe4ed2d7ce..c0da36d19750160fe9d52a8b8092d174faef445f 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.transportpce.pce;
 
 import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
 import org.opendaylight.transportpce.pce.constraints.PceConstraintsCalc;
@@ -59,6 +60,7 @@ public class PceSendingPceRPCs {
     private String message;
     private String responseCode;
     private final GnpyConsumer gnpyConsumer;
+    private PortMapping portMapping;
 
     public PceSendingPceRPCs(GnpyConsumer gnpyConsumer) {
         setPathDescription(null);
@@ -68,13 +70,14 @@ public class PceSendingPceRPCs {
     }
 
     public PceSendingPceRPCs(PathComputationRequestInput input,
-        NetworkTransactionService networkTransaction, GnpyConsumer gnpyConsumer) {
+        NetworkTransactionService networkTransaction, GnpyConsumer gnpyConsumer, PortMapping portMapping) {
         this.gnpyConsumer = gnpyConsumer;
         setPathDescription(null);
 
         // TODO compliance check to check that input is not empty
         this.input = input;
         this.networkTransaction = networkTransaction;
+        this.portMapping = portMapping;
     }
 
     public void cancelResourceReserve() {
@@ -93,7 +96,7 @@ public class PceSendingPceRPCs {
     public void pathComputationWithConstraints(PceConstraints hardConstraints, PceConstraints softConstraints) {
 
         PceCalculation nwAnalizer =
-            new PceCalculation(input, networkTransaction, hardConstraints, softConstraints, rc);
+            new PceCalculation(input, networkTransaction, hardConstraints, softConstraints, rc, portMapping);
         nwAnalizer.retrievePceNetwork();
         rc = nwAnalizer.getReturnStructure();
         String serviceType = nwAnalizer.getServiceType();
index 0c90ce290f3cd350867bf8006c122957a837d7d2..2b199309eb831afc3f5b6cac6f537ec994d4b8ac 100644 (file)
@@ -97,7 +97,7 @@ public class PceGraph {
                     pceResult.getResponseCode(), ResponseCodes.RESPONSE_OK);
 
             if (!pceResult.getResponseCode().equals(ResponseCodes.RESPONSE_OK)) {
-                LOG.info("In calcPath: post algo validations DROPPED the path {}", path);
+                LOG.warn("In calcPath: post algo validations DROPPED the path {}", path);
                 continue;
             }
 
@@ -111,6 +111,7 @@ public class PceGraph {
             switch (serviceType) {
 
                 case StringConstants.SERVICE_TYPE_100GE:
+                case StringConstants.SERVICE_TYPE_400GE:
                 case StringConstants.SERVICE_TYPE_OTU4:
                     LOG.info(
                         "In calcPath Path FOUND path for wl [{}], min Freq assignment {}, max Freq assignment {},"
index 7560e4c48ca5444637a71d35385b0524f9c59ee0..171af2f7c5bf8e69401263f5dccf2483daa3d7c5 100644 (file)
@@ -54,14 +54,18 @@ public class PostAlgoPathValidator {
             return pceResult;
         }
         int tribSlotNb = 1;
+        int spectralWidthSlotNumber = GridConstant.SPECTRAL_WIDTH_SLOT_NUMBER_MAP
+            .getOrDefault(serviceType, GridConstant.NB_SLOTS_100G);
+        SpectrumAssignment spectrumAssignment = null;
         //variable to deal with 1GE (Nb=1) and 10GE (Nb=10) cases
         switch (serviceType) {
-
+            case StringConstants.SERVICE_TYPE_400GE:
+                spectralWidthSlotNumber = GridConstant.SPECTRAL_WIDTH_SLOT_NUMBER_MAP
+                    .getOrDefault(serviceType, GridConstant.NB_SLOTS_400G);
+            //fallthrough
             case StringConstants.SERVICE_TYPE_100GE:
             case StringConstants.SERVICE_TYPE_OTU4:
-                int spectralWidthSlotNumber = GridConstant.SPECTRAL_WIDTH_SLOT_NUMBER_MAP
-                    .getOrDefault(serviceType, GridConstant.NB_SLOTS_100G);
-                SpectrumAssignment spectrumAssignment = getSpectrumAssignment(path,
+                spectrumAssignment = getSpectrumAssignment(path,
                         allPceNodes, spectralWidthSlotNumber);
                 pceResult.setServiceType(serviceType);
                 if (spectrumAssignment.getBeginIndex() == 0 && spectrumAssignment.getStopIndex() == 0) {
@@ -108,9 +112,7 @@ public class PostAlgoPathValidator {
 
                 pceResult.setRC(ResponseCodes.RESPONSE_OK);
                 pceResult.setLocalCause(PceResult.LocalCause.NONE);
-
                 break;
-
             case StringConstants.SERVICE_TYPE_10GE:
                 tribSlotNb = 8;
             //fallthrough
@@ -129,19 +131,16 @@ public class PostAlgoPathValidator {
                         tribPort, tribSlot, tribSlotNb);
                 }
                 break;
-
             case StringConstants.SERVICE_TYPE_ODU4:
                 pceResult.setRC(ResponseCodes.RESPONSE_OK);
                 LOG.info("In PostAlgoPathValidator: ODU4 path found {}", path);
                 break;
-
             default:
                 pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
                 LOG.warn("In PostAlgoPathValidator checkPath: unsupported serviceType {} found {}",
                     serviceType, path);
                 break;
         }
-
         return pceResult;
     }
 
index 508191f3a350c67fb66fbc5cfda4041b02b7554f..ad6ca37dd973ad9e849696fcf997a005f63658de 100644 (file)
@@ -25,10 +25,11 @@ import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
 import org.opendaylight.transportpce.common.mapping.MappingUtils;
 import org.opendaylight.transportpce.common.mapping.MappingUtilsImpl;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilities;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.McCapabilities;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
@@ -81,6 +82,7 @@ public class PceCalculation {
     private Map<LinkId, PceLink> allPceLinks = new HashMap<>();
     private Set<LinkId> linksToExclude = new HashSet<>();
     private PceResult returnStructure;
+    private PortMapping portMapping;
 
     private enum ConstraintTypes {
         NONE, HARD_EXCLUDE, HARD_INCLUDE, HARD_DIVERSITY, SOFT_EXCLUDE, SOFT_INCLUDE, SOFT_DIVERSITY;
@@ -89,13 +91,15 @@ public class PceCalculation {
     private MappingUtils mappingUtils;
 
     public PceCalculation(PathComputationRequestInput input, NetworkTransactionService networkTransactionService,
-            PceConstraints pceHardConstraints, PceConstraints pceSoftConstraints, PceResult rc) {
+            PceConstraints pceHardConstraints, PceConstraints pceSoftConstraints, PceResult rc,
+            PortMapping portMapping) {
         this.input = input;
         this.networkTransactionService = networkTransactionService;
         this.returnStructure = rc;
 
         this.pceHardConstraints = pceHardConstraints;
         this.mappingUtils = new MappingUtilsImpl(networkTransactionService.getDataBroker());
+        this.portMapping = portMapping;
         parseInput();
     }
 
@@ -155,7 +159,9 @@ public class PceCalculation {
             //Maybe HashMap and similar options should also be considered here.
         } else if ("Ethernet".equals(serviceFormatA)) {
         //only rate 100L is currently supported except in Ethernet
-            if (serviceRate == 10L) {
+            if (serviceRate == 400L) {
+                serviceType = StringConstants.SERVICE_TYPE_400GE;
+            } else if (serviceRate == 10L) {
                 serviceType = StringConstants.SERVICE_TYPE_10GE;
             } else if (serviceRate == 1L) {
                 serviceType = StringConstants.SERVICE_TYPE_1GE;
@@ -184,14 +190,13 @@ public class PceCalculation {
     private boolean readMdSal() {
         InstanceIdentifier<Network> nwInstanceIdentifier = null;
         Network nw = null;
-        if (("OC".equals(serviceFormatA)) || ("OTU".equals(serviceFormatA)) || (("Ethernet".equals(serviceFormatA))
-            && (serviceRate == 100L))) {
-
+        if (("OC".equals(serviceFormatA)) || ("OTU".equals(serviceFormatA))
+            || ("Ethernet".equals(serviceFormatA) && ((serviceRate == 100L) || (serviceRate == 400L)))) {
             LOG.info("readMdSal: network {}", NetworkUtils.OVERLAY_NETWORK_ID);
             nwInstanceIdentifier = InstanceIdentifier.builder(Networks.class)
                 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
-        } else if ("ODU".equals(serviceFormatA) || ("Ethernet".equals(serviceFormatA) && serviceRate == 10L)
-            || ("Ethernet".equals(serviceFormatA) && serviceRate == 1L)) {
+        } else if ("ODU".equals(serviceFormatA)
+            || ("Ethernet".equals(serviceFormatA) && ((serviceRate == 10L) || (serviceRate == 1L)))) {
             LOG.info("readMdSal: network {}", NetworkUtils.OTN_NETWORK_ID);
             nwInstanceIdentifier = InstanceIdentifier.builder(Networks.class)
                 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID))).build();
@@ -251,8 +256,9 @@ public class PceCalculation {
 
         LOG.debug("analyzeNw: allNodes size {}, allLinks size {}", allNodes.size(), allLinks.size());
 
-        if ((StringConstants.SERVICE_TYPE_100GE.equals(serviceType))
-                || (StringConstants.SERVICE_TYPE_OTU4.equals(serviceType))) {
+        if (StringConstants.SERVICE_TYPE_100GE.equals(serviceType)
+                || StringConstants.SERVICE_TYPE_OTU4.equals(serviceType)
+                || StringConstants.SERVICE_TYPE_400GE.equals(serviceType)) {
             // 100GE service and OTU4 service are handled at the openroadm-topology layer
             for (Node node : allNodes) {
                 validateNode(node);
@@ -374,9 +380,10 @@ public class PceCalculation {
             return false;
         }
 
-        if ((StringConstants.SERVICE_TYPE_100GE.equals(serviceType))
-                || (StringConstants.SERVICE_TYPE_OTU4.equals(serviceType))) {
-            // 100GE or OTU4 services are handled at WDM Layer
+        if (StringConstants.SERVICE_TYPE_100GE.equals(serviceType)
+                || StringConstants.SERVICE_TYPE_OTU4.equals(serviceType)
+                || StringConstants.SERVICE_TYPE_400GE.equals(serviceType)) {
+            // 100GE or 400GE or OTU4 services are handled at WDM Layer
             PceLink pcelink = new PceLink(link, source, dest);
             if (!pcelink.isValid()) {
                 dropOppositeLink(link);
@@ -486,18 +493,18 @@ public class PceCalculation {
 
     }
 
-    private boolean validateNode(Node node) {
+    private void validateNode(Node node) {
         LOG.debug("validateNode: node {} ", node);
         // PceNode will be used in Graph algorithm
         Node1 node1 = node.augmentation(Node1.class);
         if (node1 == null) {
             LOG.error("getNodeType: no Node1 (type) Augmentation for node: [{}]. Node is ignored", node.getNodeId());
-            return false;
+            return;
         }
         if (State.OutOfService.equals(node1.getOperationalState())) {
             LOG.error("getNodeType: node is ignored due to operational state - {}", node1.getOperationalState()
                     .getName());
-            return false;
+            return;
         }
         OpenroadmNodeType nodeType = node1.getNodeType();
         String deviceNodeId = MapUtils.getSupNetworkNode(node);
@@ -506,18 +513,19 @@ public class PceCalculation {
         if (deviceNodeId == null || deviceNodeId.isBlank()) {
             deviceNodeId = node.getNodeId().getValue();
         }
+
         LOG.info("Device node id {} for {}", deviceNodeId, node);
-        PceOpticalNode pceNode = new PceOpticalNode(node, nodeType, mappingUtils.getOpenRoadmVersion(deviceNodeId),
-                getSlotWidthGranularity(deviceNodeId, node.getNodeId()));
+        PceOpticalNode pceNode = new PceOpticalNode(deviceNodeId, this.serviceType, portMapping, node, nodeType,
+            mappingUtils.getOpenRoadmVersion(deviceNodeId), getSlotWidthGranularity(deviceNodeId, node.getNodeId()));
         pceNode.validateAZxponder(anodeId, znodeId, input.getServiceAEnd().getServiceFormat());
         pceNode.initFrequenciesBitSet();
 
         if (!pceNode.isValid()) {
             LOG.warn(" validateNode: Node is ignored");
-            return false;
+            return;
         }
         if (validateNodeConstraints(pceNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
-            return false;
+            return;
         }
         if (endPceNode(nodeType, pceNode.getNodeId(), pceNode) && this.aendPceNode == null
             && isAZendPceNode(this.serviceFormatA, pceNode, anodeId, "A")) {
@@ -530,7 +538,7 @@ public class PceCalculation {
 
         allPceNodes.put(pceNode.getNodeId(), pceNode);
         LOG.debug("validateNode: node is saved {}", pceNode.getNodeId().getValue());
-        return true;
+        return;
     }
 
     private boolean isAZendPceNode(String serviceFormat, PceOpticalNode pceNode, String azNodeId, String azEndPoint) {
@@ -557,7 +565,7 @@ public class PceCalculation {
         }
     }
 
-    private boolean validateOtnNode(Node node) {
+    private void validateOtnNode(Node node) {
         LOG.info("validateOtnNode: {} ", node.getNodeId().getValue());
         // PceOtnNode will be used in Graph algorithm
         if (node.augmentation(Node1.class) != null) {
@@ -568,10 +576,10 @@ public class PceCalculation {
 
             if (!pceOtnNode.isValid()) {
                 LOG.warn(" validateOtnNode: Node {} is ignored", node.getNodeId().getValue());
-                return false;
+                return;
             }
             if (validateNodeConstraints(pceOtnNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
-                return false;
+                return;
             }
             if (pceOtnNode.getNodeId().getValue().equals(anodeId) && this.aendPceNode == null) {
                 this.aendPceNode = pceOtnNode;
@@ -581,10 +589,10 @@ public class PceCalculation {
             }
             allPceNodes.put(pceOtnNode.getNodeId(), pceOtnNode);
             LOG.info("validateOtnNode: node {} is saved", node.getNodeId().getValue());
-            return true;
+            return;
         } else {
             LOG.error("ValidateOtnNode: no node-type augmentation. Node {} is ignored", node.getNodeId().getValue());
-            return false;
+            return;
         }
     }
 
index 210a2c653cfb64fb4a2ba673d3d98aa6f6ec42cd..80f8ab694b9b750edee35e6d9be78e9b165c0bf0 100644 (file)
@@ -18,7 +18,9 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.TreeMap;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.pce.SortPortsByName;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1;
 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;
@@ -26,6 +28,8 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev20052
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.available.freq.map.AvailFreqMapsKey;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOTUCnODUCn;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
@@ -40,9 +44,12 @@ public class PceOpticalNode implements PceNode {
 
     private Node node;
     private NodeId nodeId;
+    private String deviceNodeId;
     private OpenroadmNodeType nodeType;
     private AdminStates adminStates;
     private State state;
+    private String serviceType;
+    private PortMapping portMapping;
 
     private Map<String, OpenroadmTpType> availableSrgPp = new TreeMap<>();
     private Map<String, OpenroadmTpType> availableSrgCp = new TreeMap<>();
@@ -54,12 +61,19 @@ public class PceOpticalNode implements PceNode {
     private String version;
     private BigDecimal slotWidthGranularity;
 
-    public PceOpticalNode(Node node, OpenroadmNodeType nodeType, String version, BigDecimal slotWidthGranularity) {
-        if (node != null
+    public PceOpticalNode(String deviceNodeId, String serviceType, PortMapping portMapping, Node node,
+        OpenroadmNodeType nodeType, String version, BigDecimal slotWidthGranularity) {
+        if (deviceNodeId != null
+                && serviceType != null
+                && portMapping != null
+                && node != null
                 && node.getNodeId() != null
                 && nodeType != null
                 && version != null
                 && slotWidthGranularity != null) {
+            this.deviceNodeId = deviceNodeId;
+            this.serviceType = serviceType;
+            this.portMapping = portMapping;
             this.node = node;
             this.nodeId = node.getNodeId();
             this.nodeType = nodeType;
@@ -150,6 +164,33 @@ public class PceOpticalNode implements PceNode {
                         availableByteArray);
     }
 
+    private boolean isTpWithGoodCapabilities(
+        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node
+        .TerminationPoint tp) {
+        Mapping mapping = this.portMapping.getMapping(deviceNodeId, tp.getTpId().getValue());
+        if (mapping == null || mapping.getSupportedInterfaceCapability() == null) {
+            return true;
+        }
+        switch (this.serviceType) {
+            case "400GE":
+                if (mapping.getSupportedInterfaceCapability().contains(IfOTUCnODUCn.class)) {
+                    return true;
+                } else {
+                    return false;
+                }
+            case "100GE":
+                if (mapping.getSupportedInterfaceCapability().contains(
+                        org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev181019.IfOCH.class)
+                    || mapping.getSupportedInterfaceCapability().contains(IfOCH.class)) {
+                    return true;
+                } else {
+                    return false;
+                }
+            default:
+                return true;
+        }
+    }
+
     public void initFrequenciesBitSet() {
         if (!isValid()) {
             return;
@@ -223,18 +264,22 @@ public class PceOpticalNode implements PceNode {
         for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
             .node.TerminationPoint tp : allTps) {
             TerminationPoint1 cntp1 = tp.augmentation(TerminationPoint1.class);
-            org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev200529.TerminationPoint1 nttp1 = tp
-                .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev200529
-                .TerminationPoint1.class);
             if (cntp1.getTpType() != OpenroadmTpType.XPONDERNETWORK) {
                 LOG.warn("initXndrTps: {} is not an Xponder network port", cntp1.getTpType().getName());
                 continue;
             }
+            if (!isTpWithGoodCapabilities(tp)) {
+                LOG.warn("initXndrTps: {} network port has not correct if-capabilities", tp.getTpId().getValue());
+                continue;
+            }
             if (!State.InService.equals(cntp1.getOperationalState())) {
                 LOG.warn("initXndrTps: XPONDER tp = {} is OOS/degraded", tp.getTpId().getValue());
                 this.valid = false;
                 continue;
             }
+            org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev200529.TerminationPoint1 nttp1 = tp
+                .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev200529
+                .TerminationPoint1.class);
             if (nttp1 != null && nttp1.getXpdrNetworkAttributes().getWavelength() != null) {
                 this.usedXpndrNWTps.add(tp.getTpId().getValue());
                 LOG.info("initXndrTps: XPONDER tp = {} is used", tp.getTpId().getValue());
index 24ec30ff404eeab453df8520f2fb82d41ee5c609..d3536def95575a62112371c9c7b1572fa06bf6ac 100644 (file)
@@ -17,6 +17,7 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.Executors;
 import java.util.stream.Collectors;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.pce.PceComplianceCheck;
 import org.opendaylight.transportpce.pce.PceComplianceCheckResult;
@@ -62,14 +63,16 @@ public class PathComputationServiceImpl implements PathComputationService {
     private final ListeningExecutorService executor;
     private ServicePathRpcResult notification = null;
     private final GnpyConsumer gnpyConsumer;
+    private PortMapping portMapping;
 
     public PathComputationServiceImpl(NetworkTransactionService networkTransactionService,
                                       NotificationPublishService notificationPublishService,
-                                      GnpyConsumer gnpyConsumer) {
+                                      GnpyConsumer gnpyConsumer, PortMapping portMapping) {
         this.notificationPublishService = notificationPublishService;
         this.networkTransactionService = networkTransactionService;
         this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5));
         this.gnpyConsumer = gnpyConsumer;
+        this.portMapping = portMapping;
     }
 
     public void init() {
@@ -158,7 +161,7 @@ public class PathComputationServiceImpl implements PathComputationService {
                 String message = "";
                 String responseCode = "";
                 PceSendingPceRPCs sendingPCE = new PceSendingPceRPCs(input, networkTransactionService,
-                        gnpyConsumer);
+                        gnpyConsumer, portMapping);
                 sendingPCE.pathComputation();
                 message = sendingPCE.getMessage();
                 responseCode = sendingPCE.getResponseCode();
index 2b7415a72870f9403aaf85bf373953fba1a6f61c..1716b4aeb1917511b7ee1d797d47a250f7bb48b2 100755 (executable)
@@ -22,18 +22,11 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
     </cm:property-placeholder>
 
   <reference id="networkTransactionImpl" interface="org.opendaylight.transportpce.common.network.NetworkTransactionService" />
-
   <reference id="bindingDOMCodecServices" interface="org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices" />
-
-
-  <reference id="dataBroker"
-        interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
-
-  <reference id="rpcService"
-        interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
-
-  <reference id="notificationPublishService"
-        interface="org.opendaylight.mdsal.binding.api.NotificationPublishService"/>
+  <reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
+  <reference id="rpcService" interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
+  <reference id="notificationPublishService" interface="org.opendaylight.mdsal.binding.api.NotificationPublishService"/>
+  <reference id="portMapping" interface="org.opendaylight.transportpce.common.mapping.PortMapping"/>
 
   <bean id="pceServiceImpl"
         class="org.opendaylight.transportpce.pce.service.PathComputationServiceImpl"
@@ -41,6 +34,7 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
     <argument ref="networkTransactionImpl"/>
     <argument ref="notificationPublishService" />
     <argument ref="gnpyConsumer" />
+    <argument ref="portMapping" />
   </bean>
 
   <bean id="gnpyConsumer"
index 323f0c454dccd5bb7bc37c84df8e16fb509df0dc..6ea97283817cbb25c3d1b97977c8e8d174bb75c5 100644 (file)
@@ -13,8 +13,11 @@ import java.util.Map;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.RequestProcessor;
 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
@@ -40,9 +43,14 @@ public class PcePathDescriptionTests extends AbstractTest {
     private PceLink pceLink = null;
     private Link link = null;
     private Node node = null;
+    private String deviceNodeId = "device node";
+    private String serviceType = "100GE";
+    @Mock
+    private PortMapping portMapping;
 
     @Before
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
         // Build Link
         link = NodeUtils.createRoadmToRoadm("OpenROADM-3-2-DEG1",
                 "OpenROADM-3-1-DEG1",
@@ -52,9 +60,9 @@ public class PcePathDescriptionTests extends AbstractTest {
 
         NodeBuilder node1Builder = NodeUtils.getNodeBuilder(NodeUtils.geSupportingNodes());
         node = node1Builder.setNodeId(new NodeId("test")).build();
-        PceOpticalNode pceOpticalNode = new PceOpticalNode(node,
+        PceOpticalNode pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
-        PceOpticalNode pceOpticalNode2 = new PceOpticalNode(node,
+        PceOpticalNode pceOpticalNode2 = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
 
         pceLink = new PceLink(link, pceOpticalNode, pceOpticalNode2);
@@ -67,7 +75,6 @@ public class PcePathDescriptionTests extends AbstractTest {
         Map<LinkId, PceLink> map = Map.of(new LinkId("OpenROADM-3-1-DEG1-to-OpenROADM-3-2-DEG1"), pceLink);
         pcePathDescription = new PcePathDescription(List.of(pceLink),
                 map, pceResult);
-
     }
 
     // TODO fix opposite link
index 299d9379ea61ffb2ef559f32cf0c2884cb1bb5a7..5ce1b63f7cc82b9c6d41f643bd0f49576ece4cf7 100644 (file)
@@ -16,6 +16,7 @@ import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.RequestProcessor;
 import org.opendaylight.transportpce.pce.gnpy.JerseyServer;
@@ -38,6 +39,8 @@ public class PceSendingPceRPCsTest extends AbstractTest {
     private JerseyServer jerseyServer = new JerseyServer();
     private DataBroker dataBroker;
     private GnpyConsumer gnpyConsumer;
+    @Mock
+    private PortMapping portMapping;
 
 
     @Before
@@ -48,7 +51,7 @@ public class PceSendingPceRPCsTest extends AbstractTest {
         gnpyConsumer = new GnpyConsumerImpl("http://localhost:9998",
                 "mylogin", "mypassword", getDataStoreContextUtil().getBindingDOMCodecServices());
         pceSendingPceRPCs = new PceSendingPceRPCs(PceTestData.getPCE_test1_request_54(),
-                        networkTransaction, gnpyConsumer);
+                        networkTransaction, gnpyConsumer, portMapping);
     }
 
     @Test
@@ -62,7 +65,7 @@ public class PceSendingPceRPCsTest extends AbstractTest {
         jerseyServer.setUp();
         pceSendingPceRPCs =
                 new PceSendingPceRPCs(PceTestData.getGnpyPCERequest("XPONDER-1", "XPONDER-2"),
-                        networkTransaction, gnpyConsumer);
+                        networkTransaction, gnpyConsumer, portMapping);
 
         pceSendingPceRPCs.pathComputation();
         Assert.assertTrue(gnpyConsumer.isAvailable());
index 74f1051ad85132813c1c1231ea0cf6e363528904..be90393f870da0ada03609b22a512e553ce663e9 100644 (file)
@@ -107,7 +107,7 @@ public class PceConstraintsTest extends AbstractTest {
     @Test
     public void getIncludePceNodesTest() {
         Assert.assertTrue(pceConstraints.getIncludePceNodes().size() == 0);
-        pceConstraints.setIncludePceNode(new PceOpticalNode(null, null, null, null));
+        pceConstraints.setIncludePceNode(new PceOpticalNode(null, null, null, null, null, null, null));
         Assert.assertTrue(pceConstraints.getIncludePceNodes().size() == 1);
 
     }
index 9e8a61dc4617619154f57729da250fa5958a51ff..b7e38cbc9e028a87f0b900add2484ad26851034e 100644 (file)
@@ -11,8 +11,11 @@ package org.opendaylight.transportpce.pce.graph;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceOpticalNode;
 import org.opendaylight.transportpce.pce.utils.NodeUtils;
@@ -26,10 +29,15 @@ public class PceGraphEdgeTest {
     private Node node = null;
     private PceLink pceLink = null;
     private PceGraphEdge pceGraphEdge = null;
+    private String deviceNodeId = "device node";
+    private String serviceType = "100GE";
+    @Mock
+    private PortMapping portMapping;
 
 
     @Before
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
         // Build Link
         link = NodeUtils.createRoadmToRoadm("OpenROADM-3-2-DEG1",
                 "OpenROADM-3-1-DEG1",
@@ -38,9 +46,9 @@ public class PceGraphEdgeTest {
         //  Link link=genereateLinkBuilder();
         node =  NodeUtils.getNodeBuilder(NodeUtils.geSupportingNodes()).build();
 
-        PceOpticalNode pceOpticalNode = new PceOpticalNode(node,
+        PceOpticalNode pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
-        PceOpticalNode pceOpticalNode2 = new PceOpticalNode(node,
+        PceOpticalNode pceOpticalNode2 = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
 
         pceLink = new PceLink(link, pceOpticalNode, pceOpticalNode2);
index cedf39046d1780fe1b35cf08f2fe962c04acbe6a..1b89575f88f1f3beb28f41916a7c000f19fec0c3 100644 (file)
@@ -13,8 +13,11 @@ import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
 import org.opendaylight.transportpce.pce.networkanalyzer.PceNode;
@@ -45,9 +48,14 @@ public class PceGraphTest {
     private PceOpticalNode pceOpticalNode = null;
     private PceOpticalNode pceOpticalNode2 = null;
     private Map<NodeId, PceNode> allPceNodes = null;
+    private String deviceNodeId = "device node";
+    private String serviceType = "100GE";
+    @Mock
+    private PortMapping portMapping;
 
     @Before
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
         // Build Link
         link = NodeUtils.createRoadmToRoadm("OpenROADM-3-2-DEG1",
                 "OpenROADM-3-1-DEG1",
@@ -57,12 +65,12 @@ public class PceGraphTest {
         node = NodeUtils.getNodeBuilder(NodeUtils.geSupportingNodes())
                 .setNodeId(nodeId).withKey(new NodeKey(nodeId))
                 .build();
-        pceOpticalNode = new PceOpticalNode(node,
+        pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.DEGREE, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         NodeId nodeId2 = new NodeId("OpenROADM-3-1-DEG1");
         Node node2 = NodeUtils.getNodeBuilder(NodeUtils.geSupportingNodes())
                 .setNodeId(nodeId2).withKey(new NodeKey(nodeId2)).build();
-        pceOpticalNode2 = new PceOpticalNode(node2,
+        pceOpticalNode2 = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node2,
                 OpenroadmNodeType.DEGREE, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceLink = new PceLink(link, pceOpticalNode, pceOpticalNode2);
         pceLink.setClient("XPONDER-CLIENT");
index 1a69d3db4ad54bcfe3208fe69c723986efd73915..4f2bf07dc1c96c1a277b121271554ca665431e05 100644 (file)
@@ -42,7 +42,7 @@ public class PceProviderTest extends AbstractTest {
         requestProcessor = Mockito.mock(RequestProcessor.class);
         networkTransaction = new NetworkTransactionImpl(requestProcessor);
         pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
-                null);
+                null, null);
         pceProvider = new PceProvider(rpcService, pathComputationService);
     }
 
index 3e953ea865150766e57eeb6ef351bc15c9e60319..48fdc779438fe3f60ce4353f47c4d31b7add7b46 100644 (file)
@@ -13,7 +13,9 @@ import static org.junit.Assert.assertNotNull;
 import java.util.concurrent.ExecutionException;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.RequestProcessor;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
@@ -32,6 +34,8 @@ public class PceServiceRPCImplTest extends AbstractTest {
     private NotificationPublishService notificationPublishService;
     private NetworkTransactionImpl networkTransaction;
     private PceServiceRPCImpl pceServiceRPC;
+    @Mock
+    private PortMapping portMapping;
 
     @Before
     public void setUp() throws ExecutionException, InterruptedException {
@@ -40,7 +44,7 @@ public class PceServiceRPCImplTest extends AbstractTest {
         notificationPublishService = new NotificationPublishServiceMock();
         networkTransaction =  new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker()));
         pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
-                null);
+                null, portMapping);
         pceServiceRPC = new PceServiceRPCImpl(pathComputationService);
 
     }
index 4aeed59ab6340e15366d8478530089a753ef72d2..46c78cab7c0f3184c4ff423262ef164acc5c06c3 100644 (file)
@@ -42,7 +42,8 @@ public class PceCalculationTest extends AbstractTest {
                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
                 pceConstraintsCalc.getPceHardConstraints(),
                 pceConstraintsCalc.getPceSoftConstraints(),
-                pceResult);
+                pceResult,
+                null);
     }
 
     @Test
@@ -64,7 +65,7 @@ public class PceCalculationTest extends AbstractTest {
                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
                 pceConstraintsCalc.getPceHardConstraints(),
                 pceConstraintsCalc.getPceSoftConstraints(),
-                pceResult);
+                pceResult, null);
         pceCalculation.retrievePceNetwork();
         Assert.assertEquals(StringConstants.SERVICE_TYPE_100GE, pceCalculation.getServiceType());
         Assert.assertNotNull(pceCalculation.getReturnStructure());
@@ -85,7 +86,7 @@ public class PceCalculationTest extends AbstractTest {
                 new NetworkTransactionImpl(new RequestProcessor(this.getDataBroker())),
                 pceConstraintsCalc.getPceHardConstraints(),
                 pceConstraintsCalc.getPceSoftConstraints(),
-                pceResult);
+                pceResult, null);
 
         pceCalculation.retrievePceNetwork();
 //        Assert.assertEquals(StringConstants.SERVICE_TYPE_100GE, pceCalculation.getServiceType());
index d07c0140799d8cb15be007111562a993399f6198..243a1bb17d52b6936879e55eed12a706128d23d8 100644 (file)
@@ -14,9 +14,12 @@ import java.util.Map;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.opendaylight.transportpce.common.NetworkUtils;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.RatioDB;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder;
@@ -58,10 +61,14 @@ public class PceLinkTest extends AbstractTest {
 
     private static final String LINK_ID_FORMAT = "%1$s-%2$sto%3$s-%4$s";
     private PceLink pceLink = null;
+    private String deviceNodeId = "device node";
+    private String serviceType = "100GE";
+    @Mock
+    private PortMapping portMapping;
 
     @Before
     public void setup() {
-
+        MockitoAnnotations.initMocks(this);
     }
 
     @Test
@@ -71,7 +78,7 @@ public class PceLinkTest extends AbstractTest {
                 "srcTp", "destTp").build();
         NodeBuilder node1Builder = getNodeBuilder(geSupportingNodes());
         Node node = node1Builder.setNodeId(new NodeId("test")).build();
-        PceOpticalNode pceOpticalNode = new PceOpticalNode(node,
+        PceOpticalNode pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceLink = new PceLink(link, pceOpticalNode, pceOpticalNode);
     }
@@ -84,7 +91,7 @@ public class PceLinkTest extends AbstractTest {
 
         NodeBuilder node1Builder = getNodeBuilder(geSupportingNodes());
         Node node = node1Builder.setNodeId(new NodeId("test")).build();
-        PceOpticalNode pceOpticalNode = new PceOpticalNode(node,
+        PceOpticalNode pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceLink = new PceLink(link, pceOpticalNode, pceOpticalNode);
     }
@@ -97,7 +104,7 @@ public class PceLinkTest extends AbstractTest {
 
         NodeBuilder node1Builder = getNodeBuilder(geSupportingNodes());
         Node node = node1Builder.setNodeId(new NodeId("test")).build();
-        PceOpticalNode pceOpticalNode = new PceOpticalNode(node,
+        PceOpticalNode pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceLink = new PceLink(link, pceOpticalNode, pceOpticalNode);
 
@@ -111,7 +118,7 @@ public class PceLinkTest extends AbstractTest {
 
         NodeBuilder node1Builder = getNodeBuilder(geSupportingNodes());
         Node node = node1Builder.setNodeId(new NodeId("test")).build();
-        PceOpticalNode pceOpticalNode = new PceOpticalNode(node,
+        PceOpticalNode pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceLink = new PceLink(link, pceOpticalNode, pceOpticalNode);
     }
@@ -124,7 +131,7 @@ public class PceLinkTest extends AbstractTest {
 
         NodeBuilder node1Builder = getNodeBuilder(geSupportingNodes());
         Node node = node1Builder.setNodeId(new NodeId("test")).build();
-        PceOpticalNode pceOpticalNode = new PceOpticalNode(node,
+        PceOpticalNode pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceLink = new PceLink(link, pceOpticalNode, pceOpticalNode);
         Assert.assertNotNull(MapUtils.getOmsAttributesSpan(link));
index 935a5d8a57581fc6a3a0263bfbdcec6e9e714512..da0144307aeaf1a29820cc4f7a10f92eff4393f6 100644 (file)
@@ -16,10 +16,13 @@ import java.util.Map;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.opendaylight.transportpce.common.NetworkUtils;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
 import org.opendaylight.transportpce.common.fixedflex.GridUtils;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1Builder;
@@ -65,26 +68,31 @@ public class PceOpticalNodeTest extends AbstractTest {
     private Node node;
     private BitSet usedBitSet = new BitSet(8);
     private BitSet availableBitSet = new BitSet(8);
+    private String deviceNodeId = "device node";
+    private String serviceType = "100GE";
+    @Mock
+    private PortMapping portMapping;
 
     @Before
     public void setUp() {
         NodeBuilder node1Builder = getNodeBuilder(geSupportingNodes(), OpenroadmTpType.SRGTXRXPP);
         node = node1Builder.setNodeId(new NodeId("test")).build();
         availableBitSet.set(0,8);
+        MockitoAnnotations.initMocks(this);
     }
 
     @Test
     public void isValidTest() {
         OpenroadmNodeType nodeType = OpenroadmNodeType.ROADM;
-        pceOpticalNode = new PceOpticalNode(node, nodeType, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1,
-                GridConstant.SLOT_WIDTH_50);
+        pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node, nodeType,
+            StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         Assert.assertTrue(pceOpticalNode.isValid());
     }
 
     @Test
     public void testInitSrgTps() {
 
-        pceOpticalNode = new PceOpticalNode(node,
+        pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initSrgTps();
         pceOpticalNode.initXndrTps(ServiceFormat.OMS);
@@ -101,7 +109,7 @@ public class PceOpticalNodeTest extends AbstractTest {
     public void testInitXndrTpSrgTypes() {
         NodeBuilder node1Builder = getNodeBuilder(geSupportingNodes(), OpenroadmTpType.XPONDERNETWORK);
         Node specificNode = node1Builder.build();
-        pceOpticalNode = new PceOpticalNode(specificNode,
+        pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, specificNode,
                 OpenroadmNodeType.SRG, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initFrequenciesBitSet();
         Assert.assertTrue(pceOpticalNode.isValid());
@@ -111,7 +119,7 @@ public class PceOpticalNodeTest extends AbstractTest {
 
     @Test
     public void testInitXndrTpDegTypes() {
-        pceOpticalNode = new PceOpticalNode(node,
+        pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.DEGREE, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initFrequenciesBitSet();
         Assert.assertTrue(pceOpticalNode.isValid());
@@ -121,7 +129,7 @@ public class PceOpticalNodeTest extends AbstractTest {
 
     @Test
     public void testInitXndrTpXpondrTypes() {
-        pceOpticalNode = new PceOpticalNode(node,
+        pceOpticalNode = new PceOpticalNode(deviceNodeId, serviceType, portMapping, node,
                 OpenroadmNodeType.XPONDER, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initFrequenciesBitSet();
         Assert.assertTrue(pceOpticalNode.isValid());
@@ -131,7 +139,7 @@ public class PceOpticalNodeTest extends AbstractTest {
 
     @Test
     public void testinitFrequenciesBitSet() {
-        pceOpticalNode = new PceOpticalNode(node,
+        pceOpticalNode = new PceOpticalNode(null, null, null, node,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initXndrTps(ServiceFormat.OMS);
         pceOpticalNode.initFrequenciesBitSet();
@@ -142,7 +150,7 @@ public class PceOpticalNodeTest extends AbstractTest {
 
     @Test
     public void testGetRdmSrgClient() {
-        pceOpticalNode = new PceOpticalNode(node,
+        pceOpticalNode = new PceOpticalNode(null, null, null, node,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initSrgTps();
         Assert.assertNull(pceOpticalNode.getRdmSrgClient("7"));
@@ -155,7 +163,7 @@ public class PceOpticalNodeTest extends AbstractTest {
     public void testGetRdmSrgClientEmpty() {
         NodeBuilder node1Builder = getNodeBuilderEmpty(geSupportingNodes(), OpenroadmTpType.SRGTXRXPP);
         Node specificNode = node1Builder.setNodeId(new NodeId("test")).build();
-        pceOpticalNode = new PceOpticalNode(specificNode,
+        pceOpticalNode = new PceOpticalNode(null, null, null, specificNode,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initSrgTps();
         pceOpticalNode.initFrequenciesBitSet();
@@ -168,7 +176,7 @@ public class PceOpticalNodeTest extends AbstractTest {
 
     @Test
     public void testGetRdmSrgClientDeg() {
-        pceOpticalNode = new PceOpticalNode(node,
+        pceOpticalNode = new PceOpticalNode(null, null, null, node,
                 OpenroadmNodeType.DEGREE, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initSrgTps();
         Assert.assertNull(pceOpticalNode.getRdmSrgClient("7"));
@@ -181,7 +189,7 @@ public class PceOpticalNodeTest extends AbstractTest {
     public void testGetRdmSrgClientsrgtxcp() {
         NodeBuilder node1Builder = getNodeBuilder(geSupportingNodes(), OpenroadmTpType.SRGTXCP);
         Node specificNode = node1Builder.build();
-        pceOpticalNode = new PceOpticalNode(specificNode,
+        pceOpticalNode = new PceOpticalNode(null, null, null, specificNode,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initSrgTps();
         Assert.assertFalse(pceOpticalNode.isValid());
@@ -194,7 +202,7 @@ public class PceOpticalNodeTest extends AbstractTest {
     public void testGetRdmSrgClientDegreerxtpp() {
         NodeBuilder node1Builder = getNodeBuilder(geSupportingNodes(), OpenroadmTpType.DEGREERXTTP);
         node = node1Builder.build();
-        pceOpticalNode = new PceOpticalNode(node,
+        pceOpticalNode = new PceOpticalNode(null, null, null, node,
                 OpenroadmNodeType.ROADM, StringConstants.OPENROADM_DEVICE_VERSION_2_2_1, GridConstant.SLOT_WIDTH_50);
         pceOpticalNode.initSrgTps();
         Assert.assertNull(pceOpticalNode.getRdmSrgClient("2"));
index 0ab6d1c1e1227526f53eeb798889bba2b26ee2d5..29d40e3299c60ce4ff8fe56d2cf83c78005a191b 100644 (file)
@@ -49,7 +49,7 @@ public class PathComputationServiceImplTest extends AbstractTest {
         gnpyResult = Mockito.mock(GnpyResult.class);
         pathComputationServiceImpl = new PathComputationServiceImpl(
                 networkTransactionService,
-                this.getNotificationPublishService(), null);
+                this.getNotificationPublishService(), null, null);
         pathComputationServiceImpl.init();
     }
 
index 6a2fd205e5d641a4e6f8641251477a36e8865c1e..c4fa274d0c2932607f401958e05bf1f7f120e05e 100644 (file)
@@ -19,8 +19,8 @@ import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.fixedflex.GridUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.FiberPmd;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.RatioDB;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1Builder;
diff --git a/pom.xml b/pom.xml
index 7d26a84342d4e27c0efadb078e1794bb9afe1849..b3395f990a2a5cd0fa3e23eb2fee0cb2ca3d6b20 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
         <module>pce</module>
         <module>servicehandler</module>
         <module>tapi</module>
+        <module>nbinotifications</module>
+        <module>dmaap-client</module>
         <module>features</module>
         <module>karaf</module>
     </modules>
index f44d0b41664be36114b61284d14330d515c1cd43..7cd3f2629afad0fb6b7343226986c1c25d0735dc 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.PowerDBm;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey;
index 270ddfcdfc0df848ae3c4d89f4dab6b9ce90873e..c8f96d64b6ef3cd42175cb32f7d6b9c6abcacf23 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.FrequencyGHz;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.FrequencyTHz;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.ModulationFormat;
index e170fca76f3e67dd6ce21685429958958c74ef69..53c253b649eeb82dbb1c20371b7970d3b398cf05 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.transportpce.common.fixedflex.GridConstant;
 import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
 import org.opendaylight.transportpce.common.mapping.MappingUtils;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index e6fdd831a1522d921f57b5cc6f5c6527bb792569..03f10a9c830c4b8a3c320602abc2283077810bf8 100644 (file)
@@ -13,7 +13,7 @@ import java.util.stream.IntStream;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.InterfaceBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.InterfaceKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev171215.AdminStates;
index bda5eed97cc5cb18cc7008d798d798151e478fce..8c574109fee3a0f6c71905c3746a8e6302f7125c 100644 (file)
@@ -61,7 +61,7 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.re
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.renderer.rollback.output.FailedToRollback;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.renderer.rollback.output.FailedToRollbackBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.renderer.rollback.output.FailedToRollbackKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.Topology;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceList;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
index 9e1133633378f9171addb0ccf0fa52a8200e692b..67415ae23fda41ebac946018769d8f7b91b3342b 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
 import org.opendaylight.yangtools.yang.common.Uint32;
 
 @Ignore
index a58b2919f0c2e72e796f04291b401e91565a5880..eb16f143e2569a70526a9d194cbb52fb5afe0330 100644 (file)
@@ -49,12 +49,12 @@ import org.opendaylight.transportpce.test.AbstractTest;
 import org.opendaylight.transportpce.test.stub.MountPointServiceStub;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.CreateOtsOmsInput;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.CreateOtsOmsOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 @Ignore
index 4d12e4b6986acff2f8a3077c52f0de8f40a8af00..100756dd5928a4435228db4f972be28716f711fa 100644 (file)
@@ -17,12 +17,12 @@ import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.test.stub.MountPointStub;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrailOutput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrailOutputBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceService;
index ce05db6003cd3ef1f6d52b5d4be9dedf77d23e75..15c90048cfbed7a22a0e01959765baeb63c70a4d 100644 (file)
@@ -80,6 +80,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.TempSer
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfo.TailRetention;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.delete.input.ServiceDeleteReqInfoBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceZEndBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
@@ -106,13 +110,16 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
     private PceListenerImpl pceListenerImpl;
     private RendererListenerImpl rendererListenerImpl;
     private NetworkModelListenerImpl networkModelListenerImpl;
+    private NotificationPublishService notificationPublishService;
+    private final String topic;
 
     //TODO: remove private request fields as they are in global scope
 
     public ServicehandlerImpl(DataBroker databroker, PathComputationService pathComputationService,
             RendererServiceOperations rendererServiceOperations, NotificationPublishService notificationPublishService,
             PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl,
-            NetworkModelListenerImpl networkModelListenerImpl, ServiceDataStoreOperations serviceDataStoreOperations) {
+            NetworkModelListenerImpl networkModelListenerImpl, ServiceDataStoreOperations serviceDataStoreOperations,
+            String topic) {
         this.db = databroker;
         this.serviceDataStoreOperations = serviceDataStoreOperations;
         this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService, notificationPublishService);
@@ -120,6 +127,8 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
         this.pceListenerImpl = pceListenerImpl;
         this.rendererListenerImpl = rendererListenerImpl;
         this.networkModelListenerImpl = networkModelListenerImpl;
+        this.notificationPublishService =  notificationPublishService;
+        this.topic = topic;
     }
 
 
@@ -169,6 +178,17 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
                     input, ResponseCodes.FINAL_ACK_YES,
                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
         }
+        PublishNotificationService nbiNotification = new PublishNotificationServiceBuilder()
+                .setServiceName(input.getServiceName())
+                .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
+                .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
+                .setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType())
+                .setResponseFailed("")
+                .setMessage("ServiceCreate request received ...")
+                .setOperationalState(State.OutOfService)
+                .setTopic(topic)
+                .build();
+        sendNbiNotification(nbiNotification);
         this.pceListenerImpl.setInput(new ServiceInput(input));
         this.pceListenerImpl.setServiceReconfigure(false);
         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
@@ -179,6 +199,12 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
         PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
         if (output == null) {
             LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
+            nbiNotification = new PublishNotificationServiceBuilder(nbiNotification)
+                    .setResponseFailed(LogMessages.ABORT_PCE_FAILED)
+                    .setMessage("ServiceCreate request failed ...")
+                    .setOperationalState(State.Degraded)
+                    .build();
+            sendNbiNotification(nbiNotification);
             return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
         }
@@ -219,6 +245,17 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
                     LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
         }
         service = serviceOpt.get();
+        PublishNotificationService nbiNotification = new PublishNotificationServiceBuilder()
+                .setServiceName(service.getServiceName())
+                .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
+                .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
+                .setCommonId(service.getCommonId()).setConnectionType(service.getConnectionType())
+                .setMessage("ServiceDelete request received ...")
+                .setOperationalState(State.OutOfService)
+                .setResponseFailed("")
+                .setTopic(topic)
+                .build();
+        sendNbiNotification(nbiNotification);
         LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
         this.pceListenerImpl.setInput(new ServiceInput(input));
         this.pceListenerImpl.setServiceReconfigure(false);
@@ -235,6 +272,12 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
 
         if (output == null) {
             LOG.error(SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
+            nbiNotification = new PublishNotificationServiceBuilder(nbiNotification)
+                    .setMessage("ServiceCreate request failed ...")
+                    .setOperationalState(State.OutOfService)
+                    .setResponseFailed(LogMessages.ABORT_PCE_FAILED)
+                    .build();
+            sendNbiNotification(nbiNotification);
             return ModelMappingUtils.createDeleteServiceReply(
                     input, ResponseCodes.FINAL_ACK_YES,
                     LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
@@ -625,4 +668,16 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
         return null;
     }
 
+    /**
+     * Send notification to NBI notification in order to publish message.
+     * @param service PublishNotificationService
+     */
+    private void sendNbiNotification(PublishNotificationService service) {
+        try {
+            notificationPublishService.putNotification(service);
+        } catch (InterruptedException e) {
+            LOG.warn("Cannot send notification to nbi", e);
+            Thread.currentThread().interrupt();
+        }
+    }
 }
index c5da973eb8860c29a77e6730486ff48f1babb269..bd7564419d3a0f416b60c05dbd31b3fff72a7b63 100644 (file)
@@ -47,7 +47,6 @@ public class ServicehandlerProvider {
     private NetworkModelListenerImpl networkModelListenerImpl;
     private ServicehandlerImpl servicehandler;
 
-
     public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderService rpcProviderService,
             NotificationService notificationService, ServiceDataStoreOperations serviceDataStoreOperations,
             PceListenerImpl pceListenerImpl, RendererListenerImpl rendererListenerImpl,
index 43668620bc88b6c8e23e37eeb4d043ba2829ac5f..1ecc6a246e868ef593f5faa0fe5301a7c4cd6e5c 100644 (file)
@@ -23,15 +23,21 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev20
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.service.path.rpc.result.PathDescription;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.service.path.rpc.result.PathDescriptionBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.RpcStatusEx;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.response.parameters.sp.ResponseParameters;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.response.parameters.sp.ResponseParametersBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceZEndBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class PceListenerImpl implements TransportpcePceListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(PceListenerImpl.class);
+    private static final String TOPIC = "PceListener";
 
     private ServicePathRpcResult servicePathRpcResult;
     private RendererServiceOperations rendererServiceOperations;
@@ -41,6 +47,7 @@ public class PceListenerImpl implements TransportpcePceListener {
     private Boolean serviceReconfigure;
     private Boolean tempService;
     private Boolean serviceFeasiblity;
+    private NotificationPublishService notificationPublishService;
 
     public PceListenerImpl(RendererServiceOperations rendererServiceOperations,
             PathComputationService pathComputationService, NotificationPublishService notificationPublishService,
@@ -52,6 +59,7 @@ public class PceListenerImpl implements TransportpcePceListener {
         setInput(null);
         setTempService(false);
         setServiceFeasiblity(false);
+        this.notificationPublishService = notificationPublishService;
     }
 
     @Override
@@ -80,20 +88,11 @@ public class PceListenerImpl implements TransportpcePceListener {
      * @param notification the result notification.
      */
     private void onPathComputationResult(ServicePathRpcResult notification) {
-        LOG.info("PCE '{}' Notification received : {}",servicePathRpcResult.getNotificationType().getName(),
+        LOG.info("PCE '{}' Notification received : {}", servicePathRpcResult.getNotificationType().getName(),
                 notification);
-        if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) {
-            LOG.error("PCE path computation failed !");
-            return;
-        } else if (servicePathRpcResult.getStatus() == RpcStatusEx.Pending) {
-            LOG.warn("PCE path computation returned a Penging RpcStatusEx code!");
-            return;
-        } else if (servicePathRpcResult.getStatus() != RpcStatusEx.Successful) {
-            LOG.error("PCE path computation returned an unknown RpcStatusEx code!");
+        if (!checkStatus(notification)) {
             return;
         }
-
-        LOG.info("PCE calculation done OK !");
         if (servicePathRpcResult.getPathDescription() == null) {
             LOG.error("'PathDescription' parameter is null ");
             return;
@@ -124,10 +123,9 @@ public class PceListenerImpl implements TransportpcePceListener {
             }
         }
         ResponseParameters responseParameters = new ResponseParametersBuilder()
-                .setPathDescription(new org.opendaylight.yang.gen.v1.http.org
-                        .transportpce.b.c._interface.service.types.rev200128
-                        .response.parameters.sp.response.parameters
-                        .PathDescriptionBuilder(pathDescription).build())
+                .setPathDescription(new org.opendaylight.yang.gen.v1.http
+                        .org.transportpce.b.c._interface.service.types.rev200128
+                        .response.parameters.sp.response.parameters.PathDescriptionBuilder(pathDescription).build())
                 .build();
         PathComputationRequestOutput pceResponse = new PathComputationRequestOutputBuilder()
                 .setResponseParameters(responseParameters).build();
@@ -142,6 +140,57 @@ public class PceListenerImpl implements TransportpcePceListener {
         this.rendererServiceOperations.serviceImplementation(serviceImplementationRequest);
     }
 
+    /**
+     * Check status of notification and send nbi notification.
+     * @param notification ServicePathRpcResult the notification to check.
+     * @return true is status is Successful, false otherwise.
+     */
+    private boolean checkStatus(ServicePathRpcResult notification) {
+        PublishNotificationService nbiNotification = getPublishNotificationService(notification);
+        PublishNotificationServiceBuilder publishNotificationServiceBuilder = new PublishNotificationServiceBuilder(
+                nbiNotification);
+        switch (servicePathRpcResult.getStatus()) {
+            case Failed:
+                LOG.error("PCE path computation failed !");
+                nbiNotification = publishNotificationServiceBuilder.setMessage("ServiceCreate request failed ...")
+                        .setResponseFailed("PCE path computation failed !")
+                        .setOperationalState(State.Degraded).build();
+                sendNbiNotification(nbiNotification);
+                return false;
+            case Pending:
+                LOG.warn("PCE path computation returned a Penging RpcStatusEx code!");
+                return false;
+            case Successful:
+                LOG.info("PCE calculation done OK !");
+                nbiNotification = publishNotificationServiceBuilder.setMessage("PCE calculation done OK !")
+                        .setResponseFailed("").setOperationalState(State.OutOfService).build();
+                sendNbiNotification(nbiNotification);
+                return true;
+            default:
+                LOG.error("PCE path computation returned an unknown RpcStatusEx code {}",
+                        servicePathRpcResult.getStatus());
+                nbiNotification = publishNotificationServiceBuilder.setMessage("ServiceCreate request failed ...")
+                        .setResponseFailed("PCE path computation returned an unknown RpcStatusEx code!")
+                        .setOperationalState(State.Degraded).build();
+                sendNbiNotification(nbiNotification);
+                return false;
+        }
+    }
+
+    private PublishNotificationService getPublishNotificationService(ServicePathRpcResult notification) {
+        PublishNotificationServiceBuilder nbiNotificationBuilder = new PublishNotificationServiceBuilder();
+        if (input != null) {
+            nbiNotificationBuilder.setServiceName(input.getServiceName())
+                    .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
+                    .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
+                    .setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType());
+        } else {
+            nbiNotificationBuilder.setServiceName(notification.getServiceName());
+        }
+        nbiNotificationBuilder.setTopic(TOPIC);
+        return nbiNotificationBuilder.build();
+    }
+
     /**
      * Process cancel resource result.
      */
@@ -228,4 +277,16 @@ public class PceListenerImpl implements TransportpcePceListener {
         this.serviceFeasiblity = serviceFeasiblity;
     }
 
+    /**
+     * Send notification to NBI notification in order to publish message.
+     * @param service PublishNotificationService
+     */
+    private void sendNbiNotification(PublishNotificationService service) {
+        try {
+            notificationPublishService.putNotification(service);
+        } catch (InterruptedException e) {
+            LOG.warn("Cannot send notification to nbi", e);
+            Thread.currentThread().interrupt();
+        }
+    }
 }
index b79bcb518ca988ab810a36416586a8638fc43f32..38a054917d87801f1532290d3a528d71c88a0885 100644 (file)
@@ -21,6 +21,11 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.serviceha
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ServiceNotificationTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev181130.AdminStates;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.notification.service.ServiceZEndBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -32,6 +37,7 @@ import org.slf4j.LoggerFactory;
  */
 public class RendererListenerImpl implements TransportpceRendererListener {
 
+    private static final String TOPIC = "RendererListener";
     private static final Logger LOG = LoggerFactory.getLogger(RendererListenerImpl.class);
     private RendererRpcResultSp serviceRpcResultSp;
     private ServiceDataStoreOperations serviceDataStoreOperations;
@@ -91,6 +97,21 @@ public class RendererListenerImpl implements TransportpceRendererListener {
                 LOG.error("Renderer service delete returned an unknown RpcStatusEx code!");
                 return;
         }
+        Services service = serviceDataStoreOperations.getService(notification.getServiceName()).get();
+        PublishNotificationService nbiNotification = new PublishNotificationServiceBuilder()
+                .setServiceName(service.getServiceName())
+                .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
+                .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
+                .setCommonId(service.getCommonId())
+                .setConnectionType(service.getConnectionType())
+                .setResponseFailed("")
+                .setMessage("Service deleted !")
+                .setOperationalState(org.opendaylight.yang.gen.v1.http
+                        .org.openroadm.common.state.types.rev181130.State.Degraded)
+                .setTopic(TOPIC)
+                .build();
+        sendNbiNotification(nbiNotification);
+        LOG.info("Service '{}' deleted !", notification.getServiceName());
         if (this.input == null) {
             LOG.error("ServiceInput parameter is null !");
             return;
@@ -128,6 +149,18 @@ public class RendererListenerImpl implements TransportpceRendererListener {
      */
     private void onSuccededServiceImplementation(RendererRpcResultSp notification) {
         LOG.info("Service implemented !");
+        PublishNotificationService nbiNotification = new PublishNotificationServiceBuilder()
+                .setServiceName(input.getServiceName())
+                .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
+                .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
+                .setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType())
+                .setResponseFailed("")
+                .setMessage("Service implemented !")
+                .setOperationalState(org.opendaylight.yang.gen.v1.http
+                        .org.openroadm.common.state.types.rev181130.State.InService)
+                .setTopic(TOPIC)
+                .build();
+        sendNbiNotification(nbiNotification);
         if (serviceDataStoreOperations == null) {
             LOG.debug("serviceDataStoreOperations is null");
             return;
@@ -141,9 +174,7 @@ public class RendererListenerImpl implements TransportpceRendererListener {
             }
         } else {
             operationResult = this.serviceDataStoreOperations.modifyService(
-                    serviceRpcResultSp.getServiceName(),
-                    State.InService,
-                    AdminStates.InService);
+                    serviceRpcResultSp.getServiceName(), State.InService, AdminStates.InService);
             if (!operationResult.isSuccess()) {
                 LOG.warn("Service status not updated in datastore !");
             } else {
@@ -236,4 +267,17 @@ public class RendererListenerImpl implements TransportpceRendererListener {
     public void setTempService(Boolean tempService) {
         this.tempService = tempService;
     }
+
+    /**
+     * Send notification to NBI notification in order to publish message.
+     * @param service PublishNotificationService
+     */
+    private void sendNbiNotification(PublishNotificationService service) {
+        try {
+            notificationPublishService.putNotification(service);
+        } catch (InterruptedException e) {
+            LOG.warn("Cannot send notification to nbi", e);
+            Thread.currentThread().interrupt();
+        }
+    }
 }
index d3e7a2727c98dc7aa972c7199aa32770a2844676..5813d31abca9f5ca8fc7e13a2c6f458f123a0a87 100644 (file)
@@ -61,6 +61,7 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
         <argument ref="rendererListener" />
         <argument ref="networkModelListener" />
         <argument ref="serviceDatastoreOperation" />
+        <argument value="ServiceHandler" />
     </bean>
 
     <bean id="provider"
index 46289d95be7ea9ba040e5806952aa3edbfe6f6cb..641c107a341cddf1e2e9622f8443f2d2e14c0780 100644 (file)
@@ -103,7 +103,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
             new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                serviceDataStoreOperations);
+                serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceCreateOutput>> result =
             servicehandlerImpl.serviceCreate(new ServiceCreateInputBuilder().build());
         result.addListener(new Runnable() {
@@ -129,7 +129,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
             new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                serviceDataStoreOperations);
+                serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceCreateOutput>> result =  servicehandlerImpl.serviceCreate(input);
         result.addListener(new Runnable() {
             @Override
@@ -151,7 +151,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
             new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                serviceDataStoreOperations);
+                serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceDeleteOutput>> result =
             servicehandlerImpl.serviceDelete(new ServiceDeleteInputBuilder()
                 .setServiceDeleteReqInfo(new ServiceDeleteReqInfoBuilder().setServiceName("").build()).build());
@@ -176,7 +176,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
             new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                serviceDataStoreOperations);
+                serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceDeleteOutput>> result = servicehandlerImpl.serviceDelete(input);
         result.addListener(new Runnable() {
             @Override
@@ -200,7 +200,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
             new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
                 notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                serviceDataStoreOperations);
+                serviceDataStoreOperations, "ServiceHandler");
         ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
         serviceDataStoreOperations.createService(createInput);
         ServiceDeleteInput input = ServiceDataUtils.buildServiceDeleteInput();
@@ -226,7 +226,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
                 servicehandlerImpl.serviceFeasibilityCheck(new ServiceFeasibilityCheckInputBuilder().build());
         result.addListener(new Runnable() {
@@ -252,7 +252,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceFeasibilityCheckOutput>> result =
             servicehandlerImpl.serviceFeasibilityCheck(input);
         result.addListener(new Runnable() {
@@ -275,7 +275,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceReconfigureOutput>> result =
                 servicehandlerImpl.serviceReconfigure(new ServiceReconfigureInputBuilder().setServiceName("").build());
         result.addListener(new Runnable() {
@@ -302,7 +302,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceReconfigureOutput>> result = servicehandlerImpl.serviceReconfigure(input);
 
         result.addListener(new Runnable() {
@@ -332,7 +332,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
         serviceDataStoreOperations.createService(createInput);
 
@@ -360,7 +360,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceRestorationOutput>> result =
                 servicehandlerImpl.serviceRestoration(new ServiceRestorationInputBuilder().setServiceName("").build());
         result.addListener(new Runnable() {
@@ -387,7 +387,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceRestorationOutput>> result = servicehandlerImpl.serviceRestoration(input);
 
         result.addListener(new Runnable() {
@@ -417,7 +417,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
         serviceDataStoreOperations.createService(createInput);
 
@@ -445,7 +445,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceRerouteOutput>> result =
                 servicehandlerImpl.serviceReroute(new ServiceRerouteInputBuilder().setServiceName("").build());
         result.addListener(new Runnable() {
@@ -471,7 +471,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<ServiceRerouteOutput>> result = servicehandlerImpl.serviceReroute(input);
 
         result.addListener(new Runnable() {
@@ -501,7 +501,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ServiceCreateInput createInput = ServiceDataUtils.buildServiceCreateInput();
         serviceDataStoreOperations.createService(createInput);
 
@@ -529,7 +529,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result =
                 servicehandlerImpl.tempServiceDelete(new TempServiceDeleteInputBuilder()
                         .setCommonId("").build());
@@ -557,7 +557,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<TempServiceDeleteOutput>> result = servicehandlerImpl.tempServiceDelete(input);
         result.addListener(new Runnable() {
             @Override
@@ -583,7 +583,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(dataBroker, pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         TempServiceCreateInput createInput = ServiceDataUtils.buildTempServiceCreateInput();
         serviceDataStoreOperations.createTempService(createInput);
 
@@ -610,7 +610,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
         ListenableFuture<RpcResult<TempServiceCreateOutput>> result =
                 servicehandlerImpl.tempServiceCreate(new TempServiceCreateInputBuilder().build());
         result.addListener(new Runnable() {
@@ -638,7 +638,7 @@ public class ServicehandlerImplTest extends AbstractTest  {
         ServicehandlerImpl servicehandlerImpl =
                 new ServicehandlerImpl(getNewDataBroker(), pathComputationService, rendererServiceOperations,
                         notificationPublishService, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
-                        serviceDataStoreOperations);
+                        serviceDataStoreOperations, "ServiceHandler");
 
         ListenableFuture<RpcResult<TempServiceCreateOutput>> result =  servicehandlerImpl.tempServiceCreate(input);
         result.addListener(new Runnable() {
index 423533c3be4b31f0bdfb72ed6f54d95c803912d7..e9f97530d1e6bd31969ce3b4a7e601c6b1ee8b44 100644 (file)
@@ -27,10 +27,10 @@ import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.InstanceIdentifiers;
 import org.opendaylight.transportpce.common.NetworkUtils;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.network.nodes.MappingKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmLinkType;
@@ -288,7 +288,7 @@ public class TapiTopologyImpl implements TapiTopologyService {
         }
         @NonNull
         KeyedInstanceIdentifier<Mapping, MappingKey> pmIID = InstanceIdentifier.create(
-            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network.class)
+            org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network.class)
             .child(Nodes.class, new NodesKey(nodeIdPortMap)).child(Mapping.class, new MappingKey(networkLcp));
         @NonNull
         FluentFuture<Optional<Mapping>> mappingOpt = dataBroker.newReadOnlyTransaction().read(
index a5f3220f6e077f1d9bed9b6fc713209d5db5eaa8..cfcd7577b85893454d26dbedcb410f75846f8240 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.test.DataStoreContext;
 import org.opendaylight.transportpce.test.converter.XMLDataObjectConverter;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210310.Network;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
index 10eac2cdcb48e40df3767aee5f7a0acadfe7f919..c95df62f5e20f5237c69055ead20fcb6d48365a3 100755 (executable)
@@ -1,4 +1,4 @@
-#/bin/bash
+#!/bin/bash
 
 set -x
 
index d88dc8857881369f9fea6ec243122ee47af8869b..41db54fd7d772c4ef6cd39264ca7e135465a0d9e 100755 (executable)
@@ -1,4 +1,4 @@
-#/bin/sh
+#!/bin/sh
 
 #set -x
 
@@ -20,7 +20,7 @@ do
     case "$VERSION" in
         "1.2.1") PLUGIN_VERSION=1.0.4
         ;;
-        "2.2.1") PLUGIN_VERSION=2.0.5
+        "2.2.1") PLUGIN_VERSION=2.0.6
         ;;
         "7.1") PLUGIN_VERSION=7.1.2
         ;;
index 035a88c7bb886819857131dcc9cb5a3074a06f4e..2fc28d9e6b5b2c46bc9ee5b5f5cb909ffdcc6f43 100755 (executable)
@@ -1,3 +1,3 @@
-#/bin/bash
+#!/bin/sh
 
 sudo docker build  -t tpce/inventory .
index fb8ca02c9a8b8a87086f76c6b3e650127eb4a761..22a5a2bd920c98ddc0ae73085020ef0915b2dc5e 100755 (executable)
@@ -1,4 +1,4 @@
-#/bin/bash
+#!/bin/sh
 
 #to use unix socket, we need to bind the host and container directories
 #since UID are different, we also need to change the directory permissions on the host system
diff --git a/tests/nbinotifications/docker-compose.yml b/tests/nbinotifications/docker-compose.yml
new file mode 100644 (file)
index 0000000..b13f6b9
--- /dev/null
@@ -0,0 +1,15 @@
+version: '2'
+services:
+  zookeeper:
+    image: wurstmeister/zookeeper
+    container_name: nbinotifications_zookeeper
+    ports:
+      - "2181:2181"
+  kafka:
+    image: wurstmeister/kafka
+    container_name: nbinotifications_kafka
+    ports:
+      - "9092:9092"
+    environment:
+      KAFKA_ADVERTISED_HOST_NAME: localhost
+      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
\ No newline at end of file
index 51694b5683ef88a8eddf2a4c221e381626fd37bd..5cc4c14ddfadb014e57196f720756de55d3eaf23 100644 (file)
@@ -86,7 +86,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertIn(
             {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0',
-             'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_05_rdm_portmapping_SRG1_PP7_TXRX(self):
@@ -95,7 +96,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertIn(
             {'supporting-port': 'C7', 'supporting-circuit-pack-name': '4/0',
-             'logical-connection-point': 'SRG1-PP7-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'SRG1-PP7-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_06_rdm_portmapping_SRG3_PP1_TXRX(self):
@@ -104,7 +106,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertIn(
             {'supporting-port': 'C1', 'supporting-circuit-pack-name': '5/0',
-             'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_07_xpdr_device_connection(self):
@@ -141,7 +144,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
             {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK1', 'port-direction': 'bidirectional',
              'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network',
-             'lcp-hash-val': 'OSvMgUyP+mE='},
+             'lcp-hash-val': 'OSvMgUyP+mE=',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_11_xpdr_portmapping_NETWORK2(self):
@@ -152,7 +156,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
             {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
              'connection-map-lcp': 'XPDR1-CLIENT3', 'port-qual': 'xpdr-network',
-             'lcp-hash-val': 'OSvMgUyP+mI='},
+             'lcp-hash-val': 'OSvMgUyP+mI=',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_12_xpdr_portmapping_CLIENT1(self):
@@ -164,7 +169,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
              'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
              'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
-             'lcp-hash-val': 'AO9UFkY/TLYw'},
+             'lcp-hash-val': 'AO9UFkY/TLYw',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_13_xpdr_portmapping_CLIENT2(self):
@@ -176,7 +182,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
              'supporting-circuit-pack-name': '1/0/C2-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional',
              'port-qual': 'xpdr-client',
-             'lcp-hash-val': 'AO9UFkY/TLYz'},
+             'lcp-hash-val': 'AO9UFkY/TLYz',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_14_xpdr_portmapping_CLIENT3(self):
@@ -188,7 +195,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
              'supporting-circuit-pack-name': '1/0/C3-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT3',
              'connection-map-lcp': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
-             'port-qual': 'xpdr-client', 'lcp-hash-val': 'AO9UFkY/TLYy'},
+             'port-qual': 'xpdr-client', 'lcp-hash-val': 'AO9UFkY/TLYy',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_15_xpdr_portmapping_CLIENT4(self):
@@ -199,7 +207,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
             {'supporting-port': 'C4',
              'supporting-circuit-pack-name': '1/0/C4-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT4', 'port-direction': 'bidirectional',
-             'port-qual': 'xpdr-client', 'lcp-hash-val': 'AO9UFkY/TLY1'},
+             'port-qual': 'xpdr-client', 'lcp-hash-val': 'AO9UFkY/TLY1',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_16_xpdr_device_disconnection(self):
index b57f578746ef3a64c0adccd51c4b77e174a40279..9787e40710157f3f23a49160fcd426c21c89f4c1 100644 (file)
@@ -52,11 +52,13 @@ class TransportPCERendererTesting(unittest.TestCase):
         res = response.json()
         self.assertIn(
             {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0',
-             'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['nodes'][0]['mapping'])
         self.assertIn(
             {'supporting-port': 'C7', 'supporting-circuit-pack-name': '4/0',
-             'logical-connection-point': 'SRG1-PP7-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'SRG1-PP7-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['nodes'][0]['mapping'])
 
     def test_04_xpdr_portmapping(self):
@@ -67,14 +69,16 @@ class TransportPCERendererTesting(unittest.TestCase):
             {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK1', 'port-direction': 'bidirectional',
              'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network',
-             'lcp-hash-val': 'OSvMgUyP+mE='},
+             'lcp-hash-val': 'OSvMgUyP+mE=',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['nodes'][0]['mapping'])
         self.assertIn(
             {'supporting-port': 'C1',
              'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
              'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
-             'lcp-hash-val': 'AO9UFkY/TLYw'},
+             'lcp-hash-val': 'AO9UFkY/TLYw',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['nodes'][0]['mapping'])
 
     def test_05_service_path_create(self):
diff --git a/tests/transportpce_tests/2.2.1/test_nbinotifications.py b/tests/transportpce_tests/2.2.1/test_nbinotifications.py
new file mode 100644 (file)
index 0000000..b772b36
--- /dev/null
@@ -0,0 +1,354 @@
+#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2020 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
+##############################################################################
+
+# pylint: disable=no-member
+# pylint: disable=too-many-public-methods
+
+import os
+import sys
+import unittest
+import time
+import requests
+from common import test_utils
+
+
+class TransportNbiNotificationstesting(unittest.TestCase):
+    processes = None
+    cr_serv_sample_data = {"input": {
+        "sdnc-request-header": {
+            "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58",
+            "rpc-action": "service-create",
+            "request-system-id": "appname",
+            "notification-url": "http://localhost:8585/NotificationServer/notify"
+        },
+        "service-name": "service1",
+        "common-id": "ASATT1234567",
+        "connection-type": "service",
+        "service-a-end": {
+            "service-rate": "100",
+            "node-id": "XPDR-A1",
+            "service-format": "Ethernet",
+            "clli": "SNJSCAMCJP8",
+            "tx-direction": {
+                "port": {
+                    "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+                    "port-type": "router",
+                    "port-name": "Gigabit Ethernet_Tx.ge-5/0/0.0",
+                    "port-rack": "000000.00",
+                    "port-shelf": "00"
+                },
+                "lgx": {
+                    "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+                    "lgx-port-name": "LGX Back.3",
+                    "lgx-port-rack": "000000.00",
+                    "lgx-port-shelf": "00"
+                }
+            },
+            "rx-direction": {
+                "port": {
+                    "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
+                    "port-type": "router",
+                    "port-name": "Gigabit Ethernet_Rx.ge-5/0/0.0",
+                    "port-rack": "000000.00",
+                    "port-shelf": "00"
+                },
+                "lgx": {
+                    "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
+                    "lgx-port-name": "LGX Back.4",
+                    "lgx-port-rack": "000000.00",
+                    "lgx-port-shelf": "00"
+                }
+            },
+            "optic-type": "gray"
+        },
+        "service-z-end": {
+            "service-rate": "100",
+            "node-id": "XPDR-C1",
+            "service-format": "Ethernet",
+            "clli": "SNJSCAMCJT4",
+            "tx-direction": {
+                "port": {
+                    "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+                    "port-type": "router",
+                    "port-name": "Gigabit Ethernet_Tx.ge-1/0/0.0",
+                    "port-rack": "000000.00",
+                    "port-shelf": "00"
+                },
+                "lgx": {
+                    "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+                    "lgx-port-name": "LGX Back.29",
+                    "lgx-port-rack": "000000.00",
+                    "lgx-port-shelf": "00"
+                }
+            },
+            "rx-direction": {
+                "port": {
+                    "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
+                    "port-type": "router",
+                    "port-name": "Gigabit Ethernet_Rx.ge-1/0/0.0",
+                    "port-rack": "000000.00",
+                    "port-shelf": "00"
+                },
+                "lgx": {
+                    "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
+                    "lgx-port-name": "LGX Back.30",
+                    "lgx-port-rack": "000000.00",
+                    "lgx-port-shelf": "00"
+                }
+            },
+            "optic-type": "gray"
+        },
+        "due-date": "2016-11-28T00:00:01Z",
+        "operator-contact": "pw1234"
+    }
+    }
+
+    WAITING = 20  # nominal value is 300
+
+    @classmethod
+    def setUpClass(cls):
+        # TODO: for lighty manage the activation of NBI notification feature
+        cls.processes = test_utils.start_tpce()
+        # NBI notification feature is not installed by default in Karaf
+        if "USE_LIGHTY" not in os.environ or os.environ['USE_LIGHTY'] != 'True':
+            print("installing NBI notification feature...")
+            result = test_utils.install_karaf_feature("odl-transportpce-nbinotifications")
+            if result.returncode != 0:
+                cls.init_failed = True
+            print("Restarting OpenDaylight...")
+            test_utils.shutdown_process(cls.processes[0])
+            cls.processes[0] = test_utils.start_karaf()
+            test_utils.process_list[0] = cls.processes[0]
+            cls.init_failed = not test_utils.wait_until_log_contains(
+                test_utils.KARAF_LOG, test_utils.KARAF_OK_START_MSG, time_to_wait=60)
+        if cls.init_failed:
+            print("NBI notification installation feature failed...")
+            test_utils.shutdown_process(cls.processes[0])
+            sys.exit(2)
+        cls.processes = test_utils.start_sims(['xpdra', 'roadma', 'roadmc', 'xpdrc'])
+
+    @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):  # instruction executed before each test method
+        print("execution of {}".format(self.id().split(".")[-1]))
+
+    def test_01_connect_xpdrA(self):
+        response = test_utils.mount_device("XPDR-A1", 'xpdra')
+        self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
+
+    def test_02_connect_xpdrC(self):
+        response = test_utils.mount_device("XPDR-C1", 'xpdrc')
+        self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
+
+    def test_03_connect_rdmA(self):
+        response = test_utils.mount_device("ROADM-A1", 'roadma')
+        self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
+
+    def test_04_connect_rdmC(self):
+        response = test_utils.mount_device("ROADM-C1", 'roadmc')
+        self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
+
+    def test_05_connect_xprdA_N1_to_roadmA_PP1(self):
+        response = test_utils.connect_xpdr_to_rdm_request("XPDR-A1", "1", "1",
+                                                          "ROADM-A1", "1", "SRG1-PP1-TXRX")
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"])
+        time.sleep(2)
+
+    def test_06_connect_roadmA_PP1_to_xpdrA_N1(self):
+        response = test_utils.connect_rdm_to_xpdr_request("XPDR-A1", "1", "1",
+                                                          "ROADM-A1", "1", "SRG1-PP1-TXRX")
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('Roadm Xponder links created successfully', res["output"]["result"])
+        time.sleep(2)
+
+    def test_07_connect_xprdC_N1_to_roadmC_PP1(self):
+        response = test_utils.connect_xpdr_to_rdm_request("XPDR-C1", "1", "1",
+                                                          "ROADM-C1", "1", "SRG1-PP1-TXRX")
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"])
+        time.sleep(2)
+
+    def test_08_connect_roadmC_PP1_to_xpdrC_N1(self):
+        response = test_utils.connect_rdm_to_xpdr_request("XPDR-C1", "1", "1",
+                                                          "ROADM-C1", "1", "SRG1-PP1-TXRX")
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('Roadm Xponder links created successfully', res["output"]["result"])
+        time.sleep(2)
+
+    def test_09_get_notifications_service1(self):
+        data = {
+            "input": {
+                "connection-type": "service",
+                "id-consumer": "consumer",
+                "group-id": "transportpceTest"
+            }
+        }
+        response = test_utils.get_notifications_service_request(data)
+        self.assertEqual(response.status_code, requests.codes.no_content)
+        time.sleep(2)
+
+    def test_10_create_eth_service1(self):
+        self.cr_serv_sample_data["input"]["service-name"] = "service1"
+        response = test_utils.service_create_request(self.cr_serv_sample_data)
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('PCE calculation in progress',
+                      res['output']['configuration-response-common']['response-message'])
+        time.sleep(self.WAITING)
+
+    def test_11_get_notifications_service1(self):
+        data = {
+            "input": {
+                "connection-type": "service",
+                "id-consumer": "consumer",
+                "group-id": "transportpceTest"
+            }
+        }
+        response = test_utils.get_notifications_service_request(data)
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertEqual(res['output']['notification-service'][-2]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-2]['connection-type'], 'service')
+        self.assertEqual(res['output']['notification-service'][-2]['message'], 'ServiceCreate request received ...')
+        self.assertEqual(res['output']['notification-service'][-1]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-1]['message'], 'ServiceCreate request failed ...')
+        self.assertEqual(res['output']['notification-service'][-1]['response-failed'],
+                         'PCE path computation failed !')
+        time.sleep(2)
+
+    def test_12_add_omsAttributes_ROADMA_ROADMC(self):
+        # Config ROADMA-ROADMC oms-attributes
+        data = {"span": {
+            "auto-spanloss": "true",
+            "spanloss-base": 11.4,
+            "spanloss-current": 12,
+            "engineered-spanloss": 12.2,
+            "link-concatenation": [{
+                "SRLG-Id": 0,
+                "fiber-type": "smf",
+                "SRLG-length": 100000,
+                "pmd": 0.5}]}}
+        response = test_utils.add_oms_attr_request("ROADM-A1-DEG2-DEG2-TTP-TXRXtoROADM-C1-DEG1-DEG1-TTP-TXRX", data)
+        self.assertEqual(response.status_code, requests.codes.created)
+
+    def test_13_add_omsAttributes_ROADMC_ROADMA(self):
+        # Config ROADMC-ROADMA oms-attributes
+        data = {"span": {
+            "auto-spanloss": "true",
+            "spanloss-base": 11.4,
+            "spanloss-current": 12,
+            "engineered-spanloss": 12.2,
+            "link-concatenation": [{
+                "SRLG-Id": 0,
+                "fiber-type": "smf",
+                "SRLG-length": 100000,
+                "pmd": 0.5}]}}
+        response = test_utils.add_oms_attr_request("ROADM-C1-DEG1-DEG1-TTP-TXRXtoROADM-A1-DEG2-DEG2-TTP-TXRX", data)
+        self.assertEqual(response.status_code, requests.codes.created)
+
+    # test service-create for Eth service from xpdr to xpdr
+    def test_14_create_eth_service1(self):
+        self.cr_serv_sample_data["input"]["service-name"] = "service1"
+        response = test_utils.service_create_request(self.cr_serv_sample_data)
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('PCE calculation in progress',
+                      res['output']['configuration-response-common']['response-message'])
+        time.sleep(self.WAITING)
+
+    def test_15_get_eth_service1(self):
+        response = test_utils.get_service_list_request("services/service1")
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertEqual(
+            res['services'][0]['administrative-state'], 'inService')
+        self.assertEqual(
+            res['services'][0]['service-name'], 'service1')
+        self.assertEqual(
+            res['services'][0]['connection-type'], 'service')
+        self.assertEqual(
+            res['services'][0]['lifecycle-state'], 'planned')
+        time.sleep(2)
+
+    def test_16_get_notifications_service1(self):
+        data = {
+            "input": {
+                "connection-type": "service",
+                "id-consumer": "consumer",
+                "group-id": "transportpceTest"
+            }
+        }
+        response = test_utils.get_notifications_service_request(data)
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertEqual(res['output']['notification-service'][-3]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-3]['connection-type'], 'service')
+        self.assertEqual(res['output']['notification-service'][-3]['message'], 'ServiceCreate request received ...')
+        self.assertEqual(res['output']['notification-service'][-2]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-2]['message'], 'PCE calculation done OK !')
+        self.assertEqual(res['output']['notification-service'][-1]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-1]['message'], 'Service implemented !')
+        time.sleep(2)
+
+    def test_17_delete_eth_service1(self):
+        response = test_utils.service_delete_request("service1")
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertIn('Renderer service delete in progress',
+                      res['output']['configuration-response-common']['response-message'])
+        time.sleep(20)
+
+    def test_18_get_notifications_service1(self):
+        data = {
+            "input": {
+                "connection-type": "service",
+                "id-consumer": "consumer",
+                "group-id": "transportpceTest"
+            }
+        }
+        response = test_utils.get_notifications_service_request(data)
+        self.assertEqual(response.status_code, requests.codes.ok)
+        res = response.json()
+        self.assertEqual(res['output']['notification-service'][-2]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-2]['connection-type'], 'service')
+        self.assertEqual(res['output']['notification-service'][-2]['message'], 'ServiceDelete request received ...')
+        self.assertEqual(res['output']['notification-service'][-1]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-1]['message'], 'Service deleted !')
+        time.sleep(2)
+
+    def test_19_disconnect_XPDRA(self):
+        response = test_utils.unmount_device("XPDR-A1")
+        self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
+
+    def test_20_disconnect_XPDRC(self):
+        response = test_utils.unmount_device("XPDR-C1")
+        self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
+
+    def test_21_disconnect_ROADMA(self):
+        response = test_utils.unmount_device("ROADM-A1")
+        self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
+
+    def test_22_disconnect_ROADMC(self):
+        response = test_utils.unmount_device("ROADM-C1")
+        self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
+
+
+if __name__ == "__main__":
+    unittest.main(verbosity=2)
index 20356b2976ae3dc3928205db916f017fdc35742a..a275c2ab4c9aaf7df399a72ad4fef3eac82c4f23 100644 (file)
@@ -21,6 +21,18 @@ from common import test_utils
 class TransportPCEtesting(unittest.TestCase):
 
     processes = None
+    NETWORK1_CHECK_DICT = {"logical-connection-point": "XPDR1-NETWORK1",
+                           "supporting-port": "CP1-CFP0-P1",
+                           "supported-interface-capability": [
+                               "org-openroadm-port-types:if-OCH-OTU4-ODU4"
+                           ],
+                           "port-direction": "bidirectional",
+                           "port-qual": "xpdr-network",
+                           "supporting-circuit-pack-name": "CP1-CFP0",
+                           "xponder-type": "mpdr",
+                           'lcp-hash-val': 'Swfw02qXGyI=',
+                           'port-admin-state': 'InService',
+                           'port-oper-state': 'InService'}
 
     @classmethod
     def setUpClass(cls):
@@ -59,6 +71,8 @@ class TransportPCEtesting(unittest.TestCase):
         self.assertEqual('bidirectional', res_mapping['port-direction'])
         self.assertEqual('xpdr-client', res_mapping['port-qual'])
         self.assertEqual('FqlcrxV7p3g=', res_mapping['lcp-hash-val'])
+        self.assertEqual('InService', res_mapping['port-admin-state'])
+        self.assertEqual('InService', res_mapping['port-oper-state'])
         self.assertIn('org-openroadm-port-types:if-10GE-ODU2e', res_mapping['supported-interface-capability'])
         self.assertIn('org-openroadm-port-types:if-10GE-ODU2', res_mapping['supported-interface-capability'])
         self.assertIn('org-openroadm-port-types:if-10GE', res_mapping['supported-interface-capability'])
@@ -68,23 +82,14 @@ class TransportPCEtesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn(
-            {"logical-connection-point": "XPDR1-NETWORK1",
-             "supporting-port": "CP1-CFP0-P1",
-             "supported-interface-capability": [
-                 "org-openroadm-port-types:if-OCH-OTU4-ODU4"
-             ],
-                "port-direction": "bidirectional",
-                "port-qual": "xpdr-network",
-                "supporting-circuit-pack-name": "CP1-CFP0",
-                "xponder-type": "mpdr",
-             'lcp-hash-val': 'Swfw02qXGyI='},
+            self.NETWORK1_CHECK_DICT,
             res['mapping'])
 
     def test_04_service_path_create_OCH_OTU4(self):
         response = test_utils.service_path_request("create", "service_OCH_OTU4", "1",
                                                    [{"node-id": "SPDR-SA1", "dest-tp": "XPDR1-NETWORK1"}],
                                                    196.1, 40, 196.075, 196.125, 761,
-                                                    768)
+                                                   768)
         time.sleep(3)
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
@@ -100,16 +105,7 @@ class TransportPCEtesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn(
-            {"logical-connection-point": "XPDR1-NETWORK1",
-             "supporting-port": "CP1-CFP0-P1",
-             "supported-interface-capability": [
-                 "org-openroadm-port-types:if-OCH-OTU4-ODU4"
-             ],
-                "port-direction": "bidirectional",
-                "port-qual": "xpdr-network",
-                "supporting-circuit-pack-name": "CP1-CFP0",
-                "xponder-type": "mpdr",
-                "lcp-hash-val": "Swfw02qXGyI="},
+            self.NETWORK1_CHECK_DICT,
             res['mapping'])
 
     def test_06_check_interface_och(self):
@@ -172,19 +168,9 @@ class TransportPCEtesting(unittest.TestCase):
         response = test_utils.portmapping_request("SPDR-SA1/mapping/XPDR1-NETWORK1")
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
+        self.NETWORK1_CHECK_DICT["supporting-odu4"] = "XPDR1-NETWORK1-ODU4"
         self.assertIn(
-            {"logical-connection-point": "XPDR1-NETWORK1",
-             "supporting-port": "CP1-CFP0-P1",
-             "supported-interface-capability": [
-                 "org-openroadm-port-types:if-OCH-OTU4-ODU4"
-             ],
-                "port-direction": "bidirectional",
-                "port-qual": "xpdr-network",
-                "supporting-circuit-pack-name": "CP1-CFP0",
-                "xponder-type": "mpdr",
-                "supporting-odu4": "XPDR1-NETWORK1-ODU4",
-                "lcp-hash-val": "Swfw02qXGyI="
-             },
+            self.NETWORK1_CHECK_DICT,
             res['mapping'])
 
     def test_10_check_interface_ODU4(self):
@@ -369,7 +355,7 @@ class TransportPCEtesting(unittest.TestCase):
         response = test_utils.service_path_request("delete", "service_OCH_OTU4", "1",
                                                    [{"node-id": "SPDR-SA1", "dest-tp": "XPDR1-NETWORK1"}],
                                                    196.1, 40, 196.075, 196.125, 761,
-                                                    768)
+                                                   768)
         time.sleep(3)
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
index 7692c3246168bb75a9336832da361ce39558f1c2..831cf0d99c514285deee720d23b7b3578025d5cd 100644 (file)
@@ -70,7 +70,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertIn(
             {'supporting-port': 'L1', 'supporting-circuit-pack-name': '1/0',
-             'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_05_rdm_portmapping_DEG2_TTP_TXRX_with_ots_oms(self):
@@ -81,7 +82,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
             {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0',
              'logical-connection-point': 'DEG2-TTP-TXRX',
              'supporting-oms': 'OMS-DEG2-TTP-TXRX', 'supporting-ots': 'OTS-DEG2-TTP-TXRX',
-             'port-direction': 'bidirectional'},
+             'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_06_rdm_portmapping_SRG1_PP3_TXRX(self):
@@ -90,7 +92,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertIn(
             {'supporting-port': 'C3', 'supporting-circuit-pack-name': '3/0',
-             'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_07_rdm_portmapping_SRG3_PP1_TXRX(self):
@@ -99,7 +102,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertIn(
             {'supporting-port': 'C1', 'supporting-circuit-pack-name': '5/0',
-             'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_08_xpdr_device_connection(self):
@@ -137,7 +141,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
              'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-network',
              'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1',
-             'lcp-hash-val': 'AMkDwQ7xTmRI'},
+             'lcp-hash-val': 'AMkDwQ7xTmRI',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_12_xpdr_portmapping_NETWORK2(self):
@@ -149,7 +154,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
              'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional',
              'connection-map-lcp': 'XPDR1-CLIENT2', 'port-qual': 'xpdr-network',
-             'lcp-hash-val': 'AMkDwQ7xTmRL'},
+             'lcp-hash-val': 'AMkDwQ7xTmRL',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_13_xpdr_portmapping_CLIENT1(self):
@@ -162,7 +168,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
              'supporting-circuit-pack-name': '1/0/1-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
              'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
-             'lcp-hash-val': 'AJUUr6I5fALj'},
+             'lcp-hash-val': 'AJUUr6I5fALj',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_14_xpdr_portmapping_CLIENT2(self):
@@ -175,7 +182,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
              'supporting-circuit-pack-name': '1/0/2-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional',
              'connection-map-lcp': 'XPDR1-NETWORK2', 'port-qual': 'xpdr-client',
-             'lcp-hash-val': 'AJUUr6I5fALg'},
+             'lcp-hash-val': 'AJUUr6I5fALg',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['mapping'])
 
     def test_15_xpdr_device_disconnection(self):
index e1dfb0df6b78fa775c9b3cfa9708c7cfe7fae998..432ae129413efbe5468af56d0ba2f92288c57f81 100644 (file)
@@ -48,11 +48,13 @@ class TransportPCERendererTesting(unittest.TestCase):
         res = response.json()
         self.assertIn(
             {'supporting-port': 'L1', 'supporting-circuit-pack-name': '1/0',
-             'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['nodes'][0]['mapping'])
         self.assertIn(
             {'supporting-port': 'C3', 'supporting-circuit-pack-name': '3/0',
-             'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional'},
+             'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['nodes'][0]['mapping'])
 
     def test_04_xpdr_portmapping(self):
@@ -64,7 +66,8 @@ class TransportPCERendererTesting(unittest.TestCase):
              'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-network',
              'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1',
-             'lcp-hash-val': 'AMkDwQ7xTmRI'},
+             'lcp-hash-val': 'AMkDwQ7xTmRI',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['nodes'][0]['mapping'])
         self.assertIn(
             {'supported-interface-capability': ['org-openroadm-port-types:if-100GE'],
@@ -72,7 +75,8 @@ class TransportPCERendererTesting(unittest.TestCase):
              'supporting-circuit-pack-name': '1/0/1-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
              'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
-             'lcp-hash-val': 'AJUUr6I5fALj'},
+             'lcp-hash-val': 'AJUUr6I5fALj',
+             'port-admin-state': 'InService', 'port-oper-state': 'InService'},
             res['nodes'][0]['mapping'])
 
     def test_05_service_path_create(self):
index c2447a992fb8577cf73af4d559661aec17fa1870..1026df7e0583d20f743b32f57bd84a11fa224be5 100644 (file)
@@ -45,6 +45,7 @@ URL_CONFIG_CLLI_NET = "{}/config/ietf-network:networks/network/clli-network/"
 URL_CONFIG_ORDM_NET = "{}/config/ietf-network:networks/network/openroadm-network/"
 URL_PORTMAPPING = "{}/config/transportpce-portmapping:network/nodes/"
 URL_OPER_SERV_LIST = "{}/operational/org-openroadm-service:service-list/"
+URL_GET_NBINOTIFICATIONS_SERV = "{}/operations/nbi-notifications:get-notifications-service/"
 URL_SERV_CREATE = "{}/operations/org-openroadm-service:service-create"
 URL_SERV_DELETE = "{}/operations/org-openroadm-service:service-delete"
 URL_SERVICE_PATH = "{}/operations/transportpce-device-renderer:service-path"
@@ -337,6 +338,10 @@ def portmapping_request(suffix: str):
     return get_request(url)
 
 
+def get_notifications_service_request(attr):
+    return post_request(URL_GET_NBINOTIFICATIONS_SERV, attr)
+
+
 def get_service_list_request(suffix: str):
     url = URL_OPER_SERV_LIST + suffix
     return get_request(url)
diff --git a/tox.ini b/tox.ini
index bcc41929d4e79ae82eb3b00925cac2aadcbcf243..037d646abfde12f7c5ecc8825bfab5875d002bf7 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -3,6 +3,7 @@ minversion = 1.6
 envlist = py3
     docs
     docs-linkcheck
+    checkbashisms
 skipsdist = true
 setupdir = tests/
 
@@ -18,23 +19,23 @@ whitelist_externals = sh
 changedir={toxinidir}/tests
 commands =
 #install maven and JDK11 on the Gate since they are not there by default
-  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "if [ ! `which mvn` ]; then ./installMavenCentOS.sh  ; fi"
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "which mvn >/dev/null || ./installMavenCentOS.sh"
 #install honeynode 1.2.1 simulators
   {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end}: - sh -c "./install_honeynode.sh 1.2.1"
 #patch OLM constant to speed up tests, unnecessary for PCE
-  {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otn-topology,olm221,otnend2end,end2end221,tapi221}: - sh -c "sed -i'_' 's@=.*//#FUNCTESTVAL=@=@g' ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java"
+  {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otn-topology,olm221,otnend2end,end2end221,tapi221,nbinotifications}: - sh -c "sed -i'_' 's@=.*//#FUNCTESTVAL=@=@g' ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java"
 #build controller, source JDK_JAVA_OPTIONS to remove illegal reflective acces warnings introduced by Java11
-  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c ". $PWD/reflectwarn.sh && cd .. && mvn clean install -s tests/odl_settings.xml -DskipTests -Dmaven.javadoc.skip=true -Dodlparent.spotbugs.skip -Dodlparent.checkstyle.skip"
-  {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otn-topology,olm221,otnend2end,end2end221,tapi221}: - sh -c "mv  ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java_  ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java"
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy,nbinotifications}: - sh -c ". $PWD/reflectwarn.sh && cd .. && mvn clean install -s tests/odl_settings.xml -DskipTests -Dmaven.javadoc.skip=true -Dodlparent.spotbugs.skip -Dodlparent.checkstyle.skip"
+  {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otn-topology,olm221,otnend2end,end2end221,tapi221,nbinotifications}: - sh -c "mv  ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java_  ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java"
 #patch Karaf exec for the same reason at runtime
-  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "sed -i'_' 's@!/bin/sh@!/bin/sh\'$'\n. $(dirname $0)/../../../../tests/reflectwarn.sh@' ../karaf/target/assembly/bin/karaf"
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy,nbinotifications}: - sh -c "sed -i'_' 's@!/bin/sh@!/bin/sh\'$'\n. $(dirname $0)/../../../../tests/reflectwarn.sh@' ../karaf/target/assembly/bin/karaf"
   # the following command would be the straight and right way to support both BSD and GNU sed versions
   # sh -c "sed -i'_' '1 a\'$'\n. \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\n' ../karaf/target/assembly/bin/karaf"
   # but tox reinterprets the quotes as
   # sh -c 'sed -i'"'"'_'"'"' '"'"'1 a\'"'"'$'"'"'\n. \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\n'"'"' ../karaf/target/assembly/bin/karaf'
   # ,what results in an unexpected different formating (with a $ on the second line and the dot on the third)
 #build Lighty if needed
-  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c 'if [ "$USE_LIGHTY" = "True" ]; then (cd ../lighty && ./build.sh); fi'
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy,nbinotifications}: - sh -c 'if [ "$USE_LIGHTY" = "True" ]; then (cd ../lighty && ./build.sh); fi'
 #run 1.2.1 functional tests
   {py3,portmapping}: nosetests --with-xunit transportpce_tests/1.2.1/test_portmapping.py
   {py3,topoPortMapping}: nosetests --with-xunit transportpce_tests/1.2.1/test_topo_portmapping.py
@@ -45,7 +46,7 @@ commands =
   #E2E 1.2.1 moved at the end before 2.2.1 E2E
 #run 2.2.1 functional tests
 #install honeynode 2.2.1 simulators
-  {py3,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221}: - sh -c "./install_honeynode.sh 2.2.1"
+  {py3,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,nbinotifications}: - sh -c "./install_honeynode.sh 2.2.1"
   {py3,portmapping221}: nosetests --with-xunit transportpce_tests/2.2.1/test_portmapping.py
   {py3,topology221}: nosetests --with-xunit transportpce_tests/2.2.1/test_topology.py
   {py3,otntopology}: nosetests --with-xunit transportpce_tests/2.2.1/test_otn_topology.py
@@ -62,6 +63,9 @@ commands =
   {gnpy}: - sudo docker run -d -p 8008:5000 --name gnpy_tpce_rest1 atriki/gnpyrest:v1.2
   {gnpy}: nosetests --with-xunit transportpce_tests/1.2.1/test_gnpy.py
   {gnpy}: - sudo docker container rm -f gnpy_tpce_rest1
+  {nbinotifications}: - sudo docker-compose -f ./nbinotifications/docker-compose.yml up -d
+  {nbinotifications}: nosetests --with-xunit transportpce_tests/2.2.1/test_nbinotifications.py
+  {nbinotifications}: - sudo docker-compose -f ./nbinotifications/docker-compose.yml down --rmi all
 
 [testenv:docs]
 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
@@ -76,6 +80,16 @@ basepython = python3
 deps = -rdocs/requirements.txt
 commands = sphinx-build -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
 
+[testenv:checkbashisms]
+deps =
+whitelist_externals = sh
+                      checkbashisms
+                      sudo
+                      find
+commands =
+    sh -c 'command checkbashisms>/dev/null || sudo yum install devscripts-minimal || (echo "checkbashisms command not found - please install it (e.g. sudo apt-get install devscripts | yum install devscripts-minimal )" >&2 && exit 1)'
+    find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
+
 [testenv:spelling]
 basepython = python3
 deps =