aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--features/sdnc-northbound-all/pom.xml7
-rw-r--r--optical-service/features/features-optical-service/pom.xml33
-rw-r--r--optical-service/features/pom.xml23
-rw-r--r--optical-service/features/sdnc-optical-service/pom.xml40
-rw-r--r--optical-service/installer/pom.xml148
-rw-r--r--optical-service/installer/src/assembly/assemble_installer_zip.xml59
-rw-r--r--optical-service/installer/src/assembly/assemble_mvnrepo_zip.xml47
-rw-r--r--optical-service/installer/src/main/resources/scripts/install-feature.sh39
-rw-r--r--optical-service/model/pom.xml33
-rw-r--r--optical-service/model/src/main/yang/optical-service.yang150
-rw-r--r--optical-service/pom.xml26
-rw-r--r--optical-service/provider/pom.xml112
-rw-r--r--optical-service/provider/src/main/java/org/onap/sdnc/northbound/OpticalServiceClient.java144
-rw-r--r--optical-service/provider/src/main/java/org/onap/sdnc/northbound/OpticalServiceProvider.java227
-rw-r--r--optical-service/provider/src/main/java/org/onap/sdnc/northbound/asyncrequests/AsyncNotificationHandling.java162
-rw-r--r--optical-service/provider/src/main/java/org/onap/sdnc/northbound/asyncrequests/SdncOdlConnection.java150
-rw-r--r--optical-service/provider/src/main/resources/OSGI-INF/blueprint/optical-service-blueprint.xml32
-rw-r--r--optical-service/provider/src/main/resources/org/opendaylight/blueprint/optical-service-blueprint.xml32
-rw-r--r--optical-service/provider/src/test/java/org/onap/sdnc/northbound/OpticalServiceClientTest.java90
-rw-r--r--optical-service/provider/src/test/java/org/onap/sdnc/northbound/TestOpticalServiceProvider.java118
-rw-r--r--pom.xml1
21 files changed, 1673 insertions, 0 deletions
diff --git a/features/sdnc-northbound-all/pom.xml b/features/sdnc-northbound-all/pom.xml
index 27e0a07c..cd3852ac 100644
--- a/features/sdnc-northbound-all/pom.xml
+++ b/features/sdnc-northbound-all/pom.xml
@@ -35,6 +35,13 @@
<type>xml</type>
<classifier>features</classifier>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnc-optical-service</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sdnc-vnfapi</artifactId>
diff --git a/optical-service/features/features-optical-service/pom.xml b/optical-service/features/features-optical-service/pom.xml
new file mode 100644
index 00000000..5849967e
--- /dev/null
+++ b/optical-service/features/features-optical-service/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.onap.ccsdk.parent</groupId>
+ <artifactId>feature-repo-parent</artifactId>
+ <version>1.5.1</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>features-optical-service</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>sdnc-northbound :: optical-service :: ${project.artifactId}</name>
+
+ <properties>
+ <sdnc.northbound.version>${project.version}</sdnc.northbound.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnc-optical-service</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/optical-service/features/pom.xml b/optical-service/features/pom.xml
new file mode 100644
index 00000000..69c1dd09
--- /dev/null
+++ b/optical-service/features/pom.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.5.1</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>optical-service-features</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>sdnc-northbound :: optical-service:: ${project.artifactId}</name>
+
+ <modules>
+ <module>sdnc-optical-service</module>
+ <module>features-optical-service</module>
+ </modules>
+</project>
diff --git a/optical-service/features/sdnc-optical-service/pom.xml b/optical-service/features/sdnc-optical-service/pom.xml
new file mode 100644
index 00000000..c69170f8
--- /dev/null
+++ b/optical-service/features/sdnc-optical-service/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.onap.ccsdk.parent</groupId>
+ <artifactId>single-feature-parent</artifactId>
+ <version>1.5.1</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>sdnc-optical-service</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>sdnc-northbound :: optical-service :: ${project.artifactId}</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>ccsdk-sli</artifactId>
+ <version>${ccsdk.sli.core.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>optical-service-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>optical-service-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/optical-service/installer/pom.xml b/optical-service/installer/pom.xml
new file mode 100644
index 00000000..3610b801
--- /dev/null
+++ b/optical-service/installer/pom.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.5.1</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>optical-service-installer</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>sdnc-northbound :: optical-service :: ${project.artifactId}</name>
+
+ <properties>
+ <application.name>sdnc-optical-service</application.name>
+ <features.boot>${application.name}</features.boot>
+ <features.repositories>mvn:org.onap.sdnc.northbound/${features.boot}/${project.version}/xml/features</features.repositories>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>${application.name}</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>optical-service-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>optical-service-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>maven-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <attach>true</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>true</appendAssemblyId>
+ </configuration>
+ </execution>
+ <execution>
+ <id>installer-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <attach>true</attach>
+ <finalName>${application.name}-${project.version}-installer</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>false</transitive>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <includeGroupIds>org.onap.sdnc.northbound</includeGroupIds>
+ <scope>provided</scope>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-version</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals><!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/scripts</directory>
+ <includes>
+ <include>install-feature.sh</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/optical-service/installer/src/assembly/assemble_installer_zip.xml b/optical-service/installer/src/assembly/assemble_installer_zip.xml
new file mode 100644
index 00000000..8c0c947b
--- /dev/null
+++ b/optical-service/installer/src/assembly/assemble_installer_zip.xml
@@ -0,0 +1,59 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : SDN-C
+ ================================================================================
+ Copyright (C) 2019-2020 Fujitsu Limited Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>installer_zip</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/optical-service/installer/src/assembly/assemble_mvnrepo_zip.xml b/optical-service/installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 00000000..d1a29e5b
--- /dev/null
+++ b/optical-service/installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,47 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : SDN-C
+ ================================================================================
+ Copyright (C) 2019-2020 Fujitsu Limited Intelectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>repo</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/optical-service/installer/src/main/resources/scripts/install-feature.sh b/optical-service/installer/src/main/resources/scripts/install-feature.sh
new file mode 100644
index 00000000..0fb2c7e5
--- /dev/null
+++ b/optical-service/installer/src/main/resources/scripts/install-feature.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# ONAP : SDN-C
+# ================================================================================
+# Copyright (C) 2019-2020 Fujitsu Limited Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories}
+${ODL_KARAF_CLIENT} feature:install ${features.boot}
diff --git a/optical-service/model/pom.xml b/optical-service/model/pom.xml
new file mode 100644
index 00000000..2b4fdf88
--- /dev/null
+++ b/optical-service/model/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.5.1</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>optical-service-model</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>sdnc-northbound :: optical-service :: ${project.artifactId}</name>
+
+ <properties>
+ <sdnc.northbound.version>${project.version}</sdnc.northbound.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991</artifactId>
+ </dependency>
+
+
+ </dependencies>
+
+
+</project>
diff --git a/optical-service/model/src/main/yang/optical-service.yang b/optical-service/model/src/main/yang/optical-service.yang
new file mode 100644
index 00000000..911bd488
--- /dev/null
+++ b/optical-service/model/src/main/yang/optical-service.yang
@@ -0,0 +1,150 @@
+module opticalservice {
+
+ yang-version "1";
+
+ namespace "org:onap:sdnc:northbound:optical-service";
+
+ prefix opticalser;
+
+ organization "Fujitsu";
+
+ contact
+ "Mehreen Kaleem <mehreen.kaleem@us.fujitsu.com>,Franklin Dsilva
+ <franklin.dsilva@us.fujitsu.com>";
+
+ description
+ "Defines API interface for optical service create and service
+ delete";
+
+ revision "2019-12-06" {
+ description
+ "Initial draft";
+ }
+
+ grouping optical-service-create-request {
+
+ uses request-source-g;
+
+ leaf global-customer-id {
+ type string;
+ }
+
+ leaf service-type {
+ type string;
+ }
+
+ leaf service-id {
+ type string;
+ }
+
+ leaf notification-url {
+ type string;
+ }
+
+ container payload {
+
+ leaf domain-type {
+ type string;
+ }
+
+ leaf service-name {
+ type string;
+ }
+
+ leaf service-rate {
+ type string;
+ }
+ leaf service-protocol {
+ type string;
+ }
+
+ leaf coding-func {
+ type string;
+ }
+
+ container service-a-end {
+ uses service-end-g;
+ }
+
+ container service-z-end {
+ uses service-end-g;
+ }
+
+ leaf service-layer {
+ type string;
+ }
+ }
+ }
+
+ grouping service-end-g {
+
+ leaf port-id {
+ type string;
+ }
+
+ leaf port-name {
+ type string;
+ }
+ }
+
+ grouping request-source-g {
+
+ leaf request-id {
+ type string;
+ }
+
+ leaf source {
+ type string;
+ }
+ }
+
+ grouping optical-service-response {
+
+ leaf response-code {
+ type string;
+ }
+
+ leaf response-message {
+ type string;
+ }
+
+ leaf ack-final-indicator {
+ type string;
+ }
+
+ }
+
+ grouping optical-service-delete-request {
+
+ uses request-source-g;
+
+ container payload {
+
+ leaf service-name {
+ type string;
+ }
+ }
+ }
+
+ rpc optical-service-create {
+
+ input {
+ uses optical-service-create-request;
+ }
+
+ output {
+ uses optical-service-response;
+ }
+ }
+
+ rpc optical-service-delete {
+
+ input {
+ uses optical-service-delete-request;
+ }
+
+ output {
+ uses optical-service-response;
+ }
+ }
+}
diff --git a/optical-service/pom.xml b/optical-service/pom.xml
new file mode 100644
index 00000000..08c4c8af
--- /dev/null
+++ b/optical-service/pom.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.5.1</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>optical-service</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>sdnc-northbound :: optical-service</name>
+
+ <modules>
+ <module>model</module>
+ <module>features</module>
+ <module>provider</module>
+ <module>installer</module>
+ </modules>
+
+</project>
diff --git a/optical-service/provider/pom.xml b/optical-service/provider/pom.xml
new file mode 100644
index 00000000..7d3527dc
--- /dev/null
+++ b/optical-service/provider/pom.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.5.1</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>optical-service-provider</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>sdnc-northbound :: optical-service :: ${project.artifactId}</name>
+
+ <properties>
+ <sdnc.northbound.version>${project.version}</sdnc.northbound.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-core-artifacts</artifactId>
+ <version>${ccsdk.sli.core.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.sdnc.northbound</groupId>
+ <artifactId>optical-service-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ <version>1.4.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-engine-core</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-test-model</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <type>test-jar</type>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+</project>
diff --git a/optical-service/provider/src/main/java/org/onap/sdnc/northbound/OpticalServiceClient.java b/optical-service/provider/src/main/java/org/onap/sdnc/northbound/OpticalServiceClient.java
new file mode 100644
index 00000000..cdf51a19
--- /dev/null
+++ b/optical-service/provider/src/main/java/org/onap/sdnc/northbound/OpticalServiceClient.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2019-2020 Fujitsu Limited Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdnc.northbound;
+
+import java.util.Properties;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteOutputBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OpticalServiceClient {
+
+ private static final Logger LOG = LoggerFactory.getLogger(OpticalServiceClient.class);
+
+ private SvcLogicService svcLogicService = null;
+
+ public OpticalServiceClient(final SvcLogicService svcLogicService) {
+ this.svcLogicService = svcLogicService;
+ }
+
+ public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
+ return svcLogicService.hasGraph(module, rpc, version, mode);
+ }
+
+ public Properties execute(String module, String rpc, String version, String mode,
+ OpticalServiceCreateOutputBuilder serviceData) throws SvcLogicException {
+
+ Properties parms = new Properties();
+
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
+
+ public Properties execute(String module, String rpc, String version, String mode,
+ OpticalServiceCreateOutputBuilder serviceData, Properties parms) throws SvcLogicException {
+
+ Properties localProp;
+ localProp = MdsalHelper.toProperties(parms, serviceData);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
+
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
+
+ LOG.debug(parmName + " = " + parmValue);
+
+ }
+ }
+
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
+
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
+
+ LOG.debug(parmName + " = " + parmValue);
+
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
+
+ MdsalHelper.toBuilder(respProps, serviceData);
+
+ return respProps;
+ }
+
+ public Properties execute(String module, String rpc, String version, String mode,
+ OpticalServiceDeleteOutputBuilder serviceData) throws SvcLogicException {
+
+ Properties parms = new Properties();
+
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
+
+ public Properties execute(String module, String rpc, String version, String mode,
+ OpticalServiceDeleteOutputBuilder serviceData, Properties parms) throws SvcLogicException {
+
+ Properties localProp;
+ localProp = MdsalHelper.toProperties(parms, serviceData);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
+
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
+
+ LOG.debug(parmName + " = " + parmValue);
+
+ }
+ }
+
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
+
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
+
+ LOG.debug(parmName + " = " + parmValue);
+
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
+
+ MdsalHelper.toBuilder(respProps, serviceData);
+
+ return respProps;
+ }
+
+}
diff --git a/optical-service/provider/src/main/java/org/onap/sdnc/northbound/OpticalServiceProvider.java b/optical-service/provider/src/main/java/org/onap/sdnc/northbound/OpticalServiceProvider.java
new file mode 100644
index 00000000..3688547d
--- /dev/null
+++ b/optical-service/provider/src/main/java/org/onap/sdnc/northbound/OpticalServiceProvider.java
@@ -0,0 +1,227 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2019-2020 Fujitsu Limited Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdnc.northbound;
+
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalserviceService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Defines a base implementation for your provider. This class extends from a
+ * helper class which provides storage for the most commonly used components of
+ * the MD-SAL. Additionally the base class provides some basic LOGging and
+ * initialization / clean up methods.
+ *
+ */
+public class OpticalServiceProvider implements AutoCloseable, OpticalserviceService {
+
+ private static final Logger LOG = LoggerFactory.getLogger(OpticalServiceProvider.class);
+
+ private static final String APPLICATION_NAME = "optical-service";
+
+ private final ExecutorService executor;
+
+ protected DataBroker dataBroker;
+ protected NotificationPublishService notificationService;
+ protected RpcProviderRegistry rpcRegistry;
+ protected BindingAwareBroker.RpcRegistration<OpticalserviceService> rpcRegistration;
+ private final OpticalServiceClient opticalServiceClient;
+
+ public OpticalServiceProvider(final DataBroker dataBroker,
+ final NotificationPublishService notificationPublishService, final RpcProviderRegistry rpcProviderRegistry,
+ final OpticalServiceClient opticalServiceClient) {
+
+ LOG.info("Creating provider for {}", APPLICATION_NAME);
+ executor = Executors.newFixedThreadPool(1);
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationPublishService;
+ this.rpcRegistry = rpcProviderRegistry;
+ this.opticalServiceClient = opticalServiceClient;
+ initialize();
+ }
+
+ public void initialize() {
+ LOG.info("Initializing provider for {}", APPLICATION_NAME);
+ rpcRegistration = rpcRegistry.addRpcImplementation(OpticalserviceService.class, this);
+ LOG.info("Initialization complete for {}", APPLICATION_NAME);
+ }
+
+ protected void initializeChild() {
+ // Override if you have custom initialization intelligence
+ }
+
+ @Override
+ public void close() throws Exception {
+ LOG.info("Closing provider for {}", APPLICATION_NAME);
+ executor.shutdown();
+ rpcRegistration.close();
+ LOG.info("Successfully closed provider for {}", APPLICATION_NAME);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<OpticalServiceCreateOutput>> opticalServiceCreate(
+ OpticalServiceCreateInput input) {
+ final String svcOperation = "optical-service-create";
+
+ Properties parms = new Properties();
+ OpticalServiceCreateOutputBuilder serviceDataBuilder = new OpticalServiceCreateOutputBuilder();
+
+ LOG.info(svcOperation + " called.");
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("403");
+ RpcResult<OpticalServiceCreateOutput> rpcResult = RpcResultBuilder.<OpticalServiceCreateOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ OpticalServiceCreateInputBuilder inputBuilder = new OpticalServiceCreateInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+ Properties outputParams = new Properties();
+ String errorCode = null;
+
+ // Call SLI sync method
+ try {
+ if (opticalServiceClient.hasGraph(APPLICATION_NAME, svcOperation, null, "sync")) {
+ try {
+ outputParams = opticalServiceClient.execute(APPLICATION_NAME, svcOperation, null, "sync",
+ serviceDataBuilder, parms);
+ errorCode = outputParams.getProperty("error-code");
+ LOG.info("Response Code" + errorCode);
+ String errorMessage = outputParams.getProperty("error-message");
+ serviceDataBuilder.setResponseCode(errorCode);
+ serviceDataBuilder.setResponseMessage(errorMessage);
+
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service LOGic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service LOGic active for OpticalService: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service LOGic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ }
+
+ RpcResult<OpticalServiceCreateOutput> rpcResult = RpcResultBuilder.<OpticalServiceCreateOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<OpticalServiceDeleteOutput>> opticalServiceDelete(
+ OpticalServiceDeleteInput input) {
+ final String svcOperation = "optical-service-delete";
+
+ Properties parms = new Properties();
+ OpticalServiceDeleteOutputBuilder serviceDataBuilder = new OpticalServiceDeleteOutputBuilder();
+
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<OpticalServiceDeleteOutput> rpcResult = RpcResultBuilder.<OpticalServiceDeleteOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ OpticalServiceDeleteInputBuilder inputBuilder = new OpticalServiceDeleteInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+ Properties outputParams = new Properties();
+
+ // Call SLI sync method
+ try {
+
+ if (opticalServiceClient.hasGraph(APPLICATION_NAME, svcOperation, null, "sync")) {
+ LOG.info("OofpcipocClient has a Directed Graph for '" + svcOperation + "'");
+
+ try {
+ outputParams = opticalServiceClient.execute(APPLICATION_NAME, svcOperation, null, "sync",
+ serviceDataBuilder, parms);
+ String errorCode = outputParams.getProperty("error-code");
+ LOG.info("Response Code" + errorCode);
+ String errorMessage = outputParams.getProperty("error-message");
+ serviceDataBuilder.setResponseCode(errorCode);
+ serviceDataBuilder.setResponseMessage(errorMessage);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service LOGic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service LOGic active for Oofpcipoc: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service LOGic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ }
+
+ RpcResult<OpticalServiceDeleteOutput> rpcResult = RpcResultBuilder.<OpticalServiceDeleteOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+}
diff --git a/optical-service/provider/src/main/java/org/onap/sdnc/northbound/asyncrequests/AsyncNotificationHandling.java b/optical-service/provider/src/main/java/org/onap/sdnc/northbound/asyncrequests/AsyncNotificationHandling.java
new file mode 100644
index 00000000..955cbb48
--- /dev/null
+++ b/optical-service/provider/src/main/java/org/onap/sdnc/northbound/asyncrequests/AsyncNotificationHandling.java
@@ -0,0 +1,162 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2019-2020 Fujitsu Limited Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdnc.northbound.asyncrequests;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Properties;
+
+import java.io.Writer;
+import java.io.StringWriter;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.stream.Collectors;
+
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.Template;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.osgi.service.component.annotations.Component;
+
+@Component(immediate = true, property = {"alias=/asyncNotification", "servlet-name=AsyncNotification"})
+public class AsyncNotificationHandling extends HttpServlet implements Servlet {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Logger LOG = LoggerFactory.getLogger(AsyncNotificationHandling.class);
+
+ private static final String PARAMETER_NAME = "parameter-name";
+ private static final String STRING_VALUE = "string-value";
+ private static final String REQUEST_ID = "request-id";
+ private static final String SVC_REQUEST_ID = "svc-request-id";
+ private static final String RESPONSE_CODE = "response-code";
+ private static final String ACK_FINAL_INDICATOR = "ack-final-indicator";
+ private static final String CONFIGURATION_RESPONSE = "configuration-response-common";
+ private static final String PROPERTIES_PATH = "/opt/onap/ccsdk/data/properties/";
+ private static final String TEMPLATE_NAME = "rpc-message-sliapi-execute-async.vt";
+ private static final String UTF_8 = "UTF-8";
+
+ /**
+ * Handles async request for different domain controllers
+ */
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ LOG.info("Reached async servlet");
+ BufferedReader requestInput = null;
+ try {
+ requestInput = request.getReader();
+ } catch (Exception e) {
+ LOG.error("Unable to read input from request", e);
+ }
+
+ if (requestInput == null) {
+ return;
+ }
+ String json = requestInput.lines().collect(Collectors.joining());
+ LOG.info("Async Request payload {}", json);
+ if (json == null) {
+ return;
+ }
+
+ JSONObject jsonObj = new JSONObject(json);
+ JSONObject input = jsonObj.getJSONObject("input");
+
+ if (input.has(CONFIGURATION_RESPONSE)) {
+ JSONObject payloadString = null;
+
+ try {
+ payloadString = input.getJSONObject(CONFIGURATION_RESPONSE);
+ String rpcMessageBody = buildAsyncNotifRPCMsgRoadm(payloadString);
+ LOG.debug("rpc message body {}", rpcMessageBody);
+ invokeRPC(rpcMessageBody);
+ } catch (Exception e) {
+ LOG.error("Unable to build rpc message body::", e);
+ }
+ } else {
+ LOG.info("Async request received for wrong domain");
+ }
+
+ }
+
+ private void invokeRPC(String rpcMsgbody) {
+ try {
+ String odlUrlBase = "http://sdnc.onap:8282/restconf/operations"; // using cluster SDNC URL
+ String odlUser = "admin";
+ String odlPassword = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
+ String sdncEndpoint = "SLI-API:execute-graph";
+
+ if ((odlUrlBase != null) && (odlUrlBase.length() > 0)) {
+ SdncOdlConnection conn =
+ SdncOdlConnection.newInstance(odlUrlBase + "/" + sdncEndpoint, odlUser, odlPassword);
+
+ conn.send("POST", "application/json", rpcMsgbody);
+ } else {
+ LOG.info("POST message body would be:\n {}", rpcMsgbody);
+ }
+ } catch (Exception e) {
+ LOG.error("Unable to process message", e);
+ }
+ }
+
+ private String buildAsyncNotifRPCMsgRoadm(JSONObject payloadString) throws IOException {
+ VelocityEngine velocityEngine = new VelocityEngine();
+
+ Properties props = new Properties();
+ props.put("file.resource.loader.path", PROPERTIES_PATH);
+ velocityEngine.init(props);
+
+ String sliParameters = "sli_parameters";
+
+ JSONArray sliParametersArray = new JSONArray();
+
+ VelocityContext context = new VelocityContext();
+
+ context.put("rpc_name", "handle-async-notif");
+ String requestId = payloadString.getString(SVC_REQUEST_ID);
+ String responseCode = payloadString.getString(RESPONSE_CODE);
+ String ackIndicator = payloadString.getString(ACK_FINAL_INDICATOR);
+
+ sliParametersArray.put(new JSONObject().put(PARAMETER_NAME, REQUEST_ID).put(STRING_VALUE, requestId));
+ sliParametersArray.put(new JSONObject().put(PARAMETER_NAME, RESPONSE_CODE).put(STRING_VALUE, responseCode));
+ sliParametersArray
+ .put(new JSONObject().put(PARAMETER_NAME, ACK_FINAL_INDICATOR).put(STRING_VALUE, ackIndicator));
+
+ context.put(sliParameters, sliParametersArray);
+
+ Writer writer = new StringWriter();
+ velocityEngine.mergeTemplate(TEMPLATE_NAME, UTF_8, context, writer);
+ writer.flush();
+
+ return writer.toString();
+
+ }
+
+}
diff --git a/optical-service/provider/src/main/java/org/onap/sdnc/northbound/asyncrequests/SdncOdlConnection.java b/optical-service/provider/src/main/java/org/onap/sdnc/northbound/asyncrequests/SdncOdlConnection.java
new file mode 100644
index 00000000..860e84bb
--- /dev/null
+++ b/optical-service/provider/src/main/java/org/onap/sdnc/northbound/asyncrequests/SdncOdlConnection.java
@@ -0,0 +1,150 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2019-2020 Fujitsu Limited Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.sdnc.northbound.asyncrequests;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.URL;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class SdncOdlConnection {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SdncOdlConnection.class);
+
+ private HttpURLConnection httpConn = null;
+
+ private String url = null;
+ private String user = null;
+ private String password = null;
+
+ private class SdncAuthenticator extends Authenticator {
+
+ private String user;
+ private String passwd;
+
+ SdncAuthenticator(String user, String passwd) {
+ this.user = user;
+ this.passwd = passwd;
+ }
+
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(user, passwd.toCharArray());
+ }
+ }
+
+ private SdncOdlConnection() {
+
+ }
+
+ private SdncOdlConnection(String url, String user, String password) {
+ this.url = url;
+ this.user = user;
+ this.password = password;
+
+ try {
+ URL sdncUrl = new URL(url);
+ Authenticator.setDefault(new SdncAuthenticator(user, password));
+
+ this.httpConn = (HttpURLConnection) sdncUrl.openConnection();
+ } catch (Exception e) {
+ LOG.error("Unable to create http connection", e);
+ }
+ }
+
+ public static SdncOdlConnection newInstance(String url, String user, String password) {
+ return new SdncOdlConnection(url, user, password);
+ }
+
+
+ public String send(String method, String contentType, String msg) throws IOException {
+
+ LOG.info(String.format("Sending REST %s to %s", method, url));
+ LOG.info(String.format("Message body:%n%s", msg));
+ String authStr = user + ":" + password;
+ String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes()));
+
+ httpConn.addRequestProperty("Authentication", "Basic " + encodedAuthStr);
+
+ httpConn.setRequestMethod(method);
+ httpConn.setRequestProperty("Content-Type", contentType);
+ httpConn.setRequestProperty("Accept", contentType);
+
+ httpConn.setDoInput(true);
+ httpConn.setDoOutput(true);
+ httpConn.setUseCaches(false);
+
+ if (httpConn instanceof HttpsURLConnection) {
+ HostnameVerifier hostnameVerifier = new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ };
+ ((HttpsURLConnection) httpConn).setHostnameVerifier(hostnameVerifier);
+ }
+
+ // Write message
+ httpConn.setRequestProperty("Content-Length", Integer.toString(msg.length()));
+ DataOutputStream outStr = new DataOutputStream(httpConn.getOutputStream());
+ outStr.write(msg.getBytes());
+ outStr.close();
+
+ // Read response
+ BufferedReader respRdr;
+
+ LOG.info("Response: " + httpConn.getResponseCode() + " " + httpConn.getResponseMessage());
+
+ if (httpConn.getResponseCode() < 300) {
+
+ respRdr = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
+ } else {
+ respRdr = new BufferedReader(new InputStreamReader(httpConn.getErrorStream()));
+ }
+
+ StringBuilder respBuff = new StringBuilder();
+
+ String respLn;
+
+ while ((respLn = respRdr.readLine()) != null) {
+ respBuff.append(respLn).append("\n");
+ }
+ respRdr.close();
+
+ String respString = respBuff.toString();
+
+ LOG.info(String.format("Response body :%n%s", respString));
+
+ return respString;
+ }
+}
diff --git a/optical-service/provider/src/main/resources/OSGI-INF/blueprint/optical-service-blueprint.xml b/optical-service/provider/src/main/resources/OSGI-INF/blueprint/optical-service-blueprint.xml
new file mode 100644
index 00000000..871ab091
--- /dev/null
+++ b/optical-service/provider/src/main/resources/OSGI-INF/blueprint/optical-service-blueprint.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="svcLogicService"
+ interface="org.onap.ccsdk.sli.core.sli.provider.SvcLogicService" />
+
+ <bean id="client" class="org.onap.sdnc.northbound.OpticalServiceClient">
+ <argument ref="svcLogicService" />
+ </bean>
+
+ <reference id="dataBroker"
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+ odl:type="default" />
+
+ <reference id="notificationService"
+ interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"
+ odl:type="default" />
+
+ <reference id="rpcRegistry"
+ interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"
+ odl:type="default" />
+
+ <bean id="provider" class="org.onap.sdnc.northbound.OpticalServiceProvider">
+ <argument ref="dataBroker" />
+ <argument ref="notificationService" />
+ <argument ref="rpcRegistry" />
+ <argument ref="client" />
+ </bean>
+
+</blueprint>
diff --git a/optical-service/provider/src/main/resources/org/opendaylight/blueprint/optical-service-blueprint.xml b/optical-service/provider/src/main/resources/org/opendaylight/blueprint/optical-service-blueprint.xml
new file mode 100644
index 00000000..871ab091
--- /dev/null
+++ b/optical-service/provider/src/main/resources/org/opendaylight/blueprint/optical-service-blueprint.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="svcLogicService"
+ interface="org.onap.ccsdk.sli.core.sli.provider.SvcLogicService" />
+
+ <bean id="client" class="org.onap.sdnc.northbound.OpticalServiceClient">
+ <argument ref="svcLogicService" />
+ </bean>
+
+ <reference id="dataBroker"
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+ odl:type="default" />
+
+ <reference id="notificationService"
+ interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"
+ odl:type="default" />
+
+ <reference id="rpcRegistry"
+ interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"
+ odl:type="default" />
+
+ <bean id="provider" class="org.onap.sdnc.northbound.OpticalServiceProvider">
+ <argument ref="dataBroker" />
+ <argument ref="notificationService" />
+ <argument ref="rpcRegistry" />
+ <argument ref="client" />
+ </bean>
+
+</blueprint>
diff --git a/optical-service/provider/src/test/java/org/onap/sdnc/northbound/OpticalServiceClientTest.java b/optical-service/provider/src/test/java/org/onap/sdnc/northbound/OpticalServiceClientTest.java
new file mode 100644
index 00000000..430777a9
--- /dev/null
+++ b/optical-service/provider/src/test/java/org/onap/sdnc/northbound/OpticalServiceClientTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2019-2020 Fujitsu Limited Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
+import org.onap.sdnc.northbound.OpticalServiceClient;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteOutputBuilder;
+
+public class OpticalServiceClientTest {
+
+ SvcLogicService mockSvcLogicService;
+ String module = "test-module";
+ String rpc = "test-rpc";
+ String version = "test-version";
+ String mode = "test-mode";
+ Properties localProp = new Properties();
+
+ @Before
+ public void setUp() throws Exception {
+ mockSvcLogicService = mock(SvcLogicService.class);
+ when(mockSvcLogicService.hasGraph(module, rpc, version, mode)).thenReturn(true);
+ }
+
+ @Test
+ public void testOpticalServiceClientConstructor() {
+ OpticalServiceClient opticalServiceClient = new OpticalServiceClient(mockSvcLogicService);
+ assertNotNull(opticalServiceClient);
+ }
+
+ @Test
+ public void testHasGraph() throws SvcLogicException {
+ OpticalServiceClient opticalServiceClient = new OpticalServiceClient(mockSvcLogicService);
+ boolean result = opticalServiceClient.hasGraph(module, rpc, version, mode);
+ assertTrue(result);
+ }
+
+ @Test
+ public void testExecuteSvcLogicStatusFailureCreate() throws SvcLogicException {
+ OpticalServiceCreateOutputBuilder serviceData = mock(OpticalServiceCreateOutputBuilder.class);
+ Properties parms = mock(Properties.class);
+ SvcLogicService svcLogicService = mock(SvcLogicService.class);
+ Properties properties = new Properties();
+ properties.setProperty("SvcLogic.status", "failure");
+ when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties);
+ OpticalServiceClient sliClient = new OpticalServiceClient(svcLogicService);
+ Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties);
+ assertTrue(prop != null);
+ }
+
+ @Test
+ public void testExecuteSvcLogicStatusFailureDelete() throws SvcLogicException {
+ OpticalServiceDeleteOutputBuilder serviceData = mock(OpticalServiceDeleteOutputBuilder.class);
+ Properties parms = mock(Properties.class);
+ SvcLogicService svcLogicService = mock(SvcLogicService.class);
+ Properties properties = new Properties();
+ properties.setProperty("SvcLogic.status", "failure");
+ when(svcLogicService.execute(module, rpc, version, mode, properties)).thenReturn(properties);
+ OpticalServiceClient sliClient = new OpticalServiceClient(svcLogicService);
+ Properties prop = sliClient.execute(module, rpc, version, mode, serviceData, properties);
+ assertTrue(prop != null);
+ }
+} \ No newline at end of file
diff --git a/optical-service/provider/src/test/java/org/onap/sdnc/northbound/TestOpticalServiceProvider.java b/optical-service/provider/src/test/java/org/onap/sdnc/northbound/TestOpticalServiceProvider.java
new file mode 100644
index 00000000..5738aabb
--- /dev/null
+++ b/optical-service/provider/src/test/java/org/onap/sdnc/northbound/TestOpticalServiceProvider.java
@@ -0,0 +1,118 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2019-2020 Fujitsu Limited Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.sdnc.northbound;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.sdnc.northbound.OpticalServiceProvider;
+import org.onap.sdnc.northbound.OpticalServiceClient;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.optical.service.create.request.PayloadBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteOutput;
+
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class TestOpticalServiceProvider extends AbstractConcurrentDataBrokerTest {
+
+ private OpticalServiceProvider opticalServiceProvider;
+ private static final Logger LOG = LoggerFactory.getLogger(OpticalServiceProvider.class);
+ String module = "OpticalService";
+ String rpc = "optical-service-create";
+ String version = null;
+ String mode = "sync";
+
+ @Before
+ public void setUp() throws Exception {
+ if (null == opticalServiceProvider) {
+ DataBroker dataBroker = getDataBroker();
+ NotificationPublishService mockNotification = mock(NotificationPublishService.class);
+ RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class);
+ OpticalServiceClient mockSliClient = mock(OpticalServiceClient.class);
+ when(mockSliClient.hasGraph(module, rpc, version, mode)).thenReturn(false);
+ opticalServiceProvider = new OpticalServiceProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient);
+ }
+ }
+
+ //Should return error 503 when No service logic active for optical-service.
+ @Test
+ public void testOpticalServiceCreate() {
+
+ OpticalServiceCreateInputBuilder inputBuilder = new OpticalServiceCreateInputBuilder();
+
+ java.util.concurrent.Future<RpcResult<OpticalServiceCreateOutput>> future = opticalServiceProvider
+ .opticalServiceCreate(inputBuilder.build());
+ RpcResult<OpticalServiceCreateOutput> rpcResult = null;
+ try {
+ rpcResult = future.get();
+ } catch (Exception e) {
+ fail("Error : " + e);
+ }
+ assertEquals("503", rpcResult.getResult().getResponseCode());
+ }
+
+ @Test
+ public void testOpticalServiceDelete() {
+
+ OpticalServiceDeleteInputBuilder inputBuilder = new OpticalServiceDeleteInputBuilder();
+ java.util.concurrent.Future<RpcResult<OpticalServiceDeleteOutput>> future = opticalServiceProvider
+ .opticalServiceDelete(inputBuilder.build());
+ RpcResult<OpticalServiceDeleteOutput> rpcResult = null;
+ try {
+ rpcResult = future.get();
+ } catch (Exception e) {
+ fail("Error : " + e);
+ }
+ assertEquals("503", rpcResult.getResult().getResponseCode());
+ }
+
+
+
+
+ //Input parameter validation
+ @Test
+ public void testOpticalServiceCreateInputValidation() {
+
+ java.util.concurrent.Future<RpcResult<OpticalServiceCreateOutput>> future = opticalServiceProvider
+ .opticalServiceCreate(null);
+ RpcResult<OpticalServiceCreateOutput> rpcResult = null;
+ try {
+ rpcResult = future.get();
+ } catch (Exception e) {
+ fail("Error : " + e);
+ }
+ assertEquals("403", rpcResult.getResult().getResponseCode());
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index d677806a..a8eff7ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,6 +23,7 @@
<modules>
<module>generic-resource-api</module>
+ <module>optical-service</module>
<module>vnfapi</module>
<module>vnftools</module>
<module>features</module>