diff options
Diffstat (limited to 'appc-outbound/appc-network-inventory-client')
28 files changed, 1592 insertions, 0 deletions
diff --git a/appc-outbound/appc-network-inventory-client/.gitignore b/appc-outbound/appc-network-inventory-client/.gitignore new file mode 100755 index 000000000..b83d22266 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-outbound/appc-network-inventory-client/features/.gitignore b/appc-outbound/appc-network-inventory-client/features/.gitignore new file mode 100755 index 000000000..b83d22266 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/features/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-outbound/appc-network-inventory-client/features/pom.xml b/appc-outbound/appc-network-inventory-client/features/pom.xml new file mode 100755 index 000000000..23a2b2975 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/features/pom.xml @@ -0,0 +1,98 @@ +<?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.openecomp.appc</groupId> + <artifactId>appc-network-inventory-client</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <artifactId>appc-network-inventory-client-features</artifactId> + <name>APPC Network Inventory - Features</name> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-network-inventory-client-provider</artifactId> + </dependency> + + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.opendaylight.mdsal</groupId> + <artifactId>features-mdsal</artifactId> + <classifier>features</classifier> + <type>xml</type> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.opendaylight.yangtools</groupId> + <artifactId>features-yangtools</artifactId> + <classifier>features</classifier> + <type>xml</type> + <scope>runtime</scope> + </dependency> + + + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-core</artifactId> + </dependency> + + </dependencies> + + <build> + <resources> + <resource> + <filtering>true</filtering> + <directory>src/main/resources</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>filter</id> + <goals> + <goal>resources</goal> + </goals> + <phase>generate-resources</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-artifacts</id> + <goals> + <goal>attach-artifact</goal> + </goals> + <phase>package</phase> + <configuration> + <artifacts> + <artifact> + <file>${project.build.directory}/classes/${features.file}</file> + <type>xml</type> + <classifier>features</classifier> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/appc-outbound/appc-network-inventory-client/features/src/main/resources/features.xml b/appc-outbound/appc-network-inventory-client/features/src/main/resources/features.xml new file mode 100644 index 000000000..6eff11add --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/features/src/main/resources/features.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ONAP : APPC + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Copyright (C) 2017 Amdocs + ============================================================================= + 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. + + ECOMP is a trademark and service mark of AT&T Intellectual Property. + ============LICENSE_END========================================================= + --> + + +<features name="app-cntrl-instar-client-${project.version}" + xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> + + <repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features</repository> + + <feature name='app-cntrl-instar-client' description="Application Controller Instar Client" + version='${project.version}'> + <!-- Most applications will have a dependency on the ODL MD-SAL Broker --> + <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature> + <feature version= "${sdnctl.sli.version}">sdnc-sli</feature> + + <bundle>mvn:commons-lang/commons-lang/2.6</bundle> + <bundle>mvn:commons-collections/commons-collections/${common.collections.version}</bundle> + <bundle>wrap:mvn:com.att.eelf/eelf-core/${eelf.version}</bundle> + <bundle>mvn:com.sun.jersey/jersey-client/1.17</bundle> + <bundle>mvn:ch.qos.logback/logback-core/${logback.version}</bundle> + <bundle>mvn:ch.qos.logback/logback-classic/${logback.version}</bundle> + <bundle>mvn:org.openecomp.appc/appc-config-params-provider/${project.version}</bundle> + <bundle>mvn:org.openecomp.appc/appc-network-inventory-client-provider/${project.version}</bundle> + </feature> +</features> diff --git a/appc-outbound/appc-network-inventory-client/installer/.gitignore b/appc-outbound/appc-network-inventory-client/installer/.gitignore new file mode 100755 index 000000000..b83d22266 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/installer/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-outbound/appc-network-inventory-client/installer/pom.xml b/appc-outbound/appc-network-inventory-client/installer/pom.xml new file mode 100755 index 000000000..446721393 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/installer/pom.xml @@ -0,0 +1,131 @@ +<?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> + <artifactId>appc-network-inventory-client</artifactId> + <groupId>org.openecomp.appc</groupId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <name>APPC Network Inventory - Installer</name> + <packaging>pom</packaging> + + <properties> + <application.name>appc-network-inventory-client</application.name> + <features.boot>appc-network-inventory-client</features.boot> + <features.repositories>mvn:org.openecomp.appc/appc-network-inventory-features/${project.version}/xml/features</features.repositories> + <include.transitive.dependencies>false</include.transitive.dependencies> + </properties> + + <dependencies> + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-network-inventory-client-features</artifactId> + <classifier>features</classifier> + <type>xml</type> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-network-inventory-client-provider</artifactId> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>maven-repo-zip</id> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <attach>false</attach> + <finalName>stage/${application.name}-${project.version}</finalName> + <descriptors> + <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor> + </descriptors> + </configuration> + </execution> + <execution> + <id>installer-zip</id> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <attach>true</attach> + <finalName>${application.name}-${project.version}</finalName> + <descriptors> + <descriptor>src/assembly/assemble_installer_zip.xml</descriptor> + </descriptors> + </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> + <excludeGroupIds>org.opendaylight</excludeGroupIds> + <scope>provided</scope> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <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> + + <artifactId>appc-network-inventory-client-installer</artifactId> +</project> diff --git a/appc-outbound/appc-network-inventory-client/installer/src/assembly/assemble_installer_zip.xml b/appc-outbound/appc-network-inventory-client/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..e54eede04 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,62 @@ +<!-- + ============LICENSE_START======================================================= + ONAP : APPC + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Copyright (C) 2017 Amdocs + ============================================================================= + 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. + + ECOMP is a trademark and service mark of AT&T Intellectual Property. + ============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>controller</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/appc-outbound/appc-network-inventory-client/installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-outbound/appc-network-inventory-client/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..fc99e918e --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,50 @@ +<!-- + ============LICENSE_START======================================================= + ONAP : APPC + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Copyright (C) 2017 Amdocs + ============================================================================= + 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. + + ECOMP is a trademark and service mark of AT&T Intellectual Property. + ============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>controller</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/appc-outbound/appc-network-inventory-client/installer/src/main/resources/scripts/install-feature.sh b/appc-outbound/appc-network-inventory-client/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..05b4ae373 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,43 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APPC +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Copyright (C) 2017 Amdocs +# ============================================================================= +# 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. +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# ============LICENSE_END========================================================= +### + +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -n -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/appc-outbound/appc-network-inventory-client/pom.xml b/appc-outbound/appc-network-inventory-client/pom.xml new file mode 100755 index 000000000..2167d9ccc --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/pom.xml @@ -0,0 +1,51 @@ +<?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/maven-v4_0_0.xsd"> + <parent> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-outbound</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <packaging>pom</packaging> + <artifactId>appc-network-inventory-client</artifactId> + <name>APPC Network Inventory Client</name> + + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <logback.version>1.1.1</logback.version> + <common.collections.version>3.2.1</common.collections.version> + <common.io.version>2.5</common.io.version> + <jettison.version>1.3.7</jettison.version> + <velocity.version>1.7</velocity.version> + <jackson.version>2.3.2</jackson.version> + <snakeyaml.version>1.12</snakeyaml.version> + </properties> + + + <dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-network-inventory-client-features</artifactId> + <classifier>features</classifier> + <type>xml</type> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-network-inventory-client-provider</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </dependencyManagement> + <modules> + <module>provider</module> + <module>features</module> + <module>installer</module> + </modules> +</project> diff --git a/appc-outbound/appc-network-inventory-client/provider/.gitignore b/appc-outbound/appc-network-inventory-client/provider/.gitignore new file mode 100755 index 000000000..b83d22266 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-outbound/appc-network-inventory-client/provider/pom.xml b/appc-outbound/appc-network-inventory-client/provider/pom.xml new file mode 100755 index 000000000..7c91ffc74 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/pom.xml @@ -0,0 +1,93 @@ +<?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.openecomp.appc</groupId>
+ <artifactId>appc-network-inventory-client</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>appc-network-inventory-client-provider</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <name>APPC Network Client - Provider</name>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.att.eelf</groupId>
+ <artifactId>eelf-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-config-params-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.openecomp.appc.instar</Bundle-SymbolicName>
+ <Bundle-Activator>org.openecomp.appc.instar.InstarClientActivator</Bundle-Activator>
+ <Export-Package>org.openecomp.appc.instar</Export-Package>
+ <Import-Package>*</Import-Package>
+ <DynamicImport-Package>*</DynamicImport-Package>
+ </instructions>
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/InstarClientActivator.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/InstarClientActivator.java new file mode 100644 index 000000000..1f8f037b0 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/InstarClientActivator.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar; + +import java.util.LinkedList; +import java.util.List; + +import org.openecomp.appc.instar.node.InstarClientNode; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class InstarClientActivator implements BundleActivator{ + + private List<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>(); + private static final EELFLogger log = EELFManager.getInstance().getLogger(InstarClientActivator.class); + + @Override + public void start(BundleContext ctx) throws Exception + { + + InstarClientNode instarClientNode = new InstarClientNode(); + log.info("Registering service "+ instarClientNode.getClass().getName()); + registrations.add(ctx.registerService(instarClientNode.getClass().getName(), instarClientNode, null)); + log.info("Registering service sccessful for "+ instarClientNode.getClass().getName()); + + } + @Override + public void stop(BundleContext arg0) throws Exception + { + for (ServiceRegistration registration: registrations) + { + registration.unregister(); + registration = null; + } + + } + +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/dme2client/Dme2Client.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/dme2client/Dme2Client.java new file mode 100644 index 000000000..a0a57db54 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/dme2client/Dme2Client.java @@ -0,0 +1,184 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.dme2client; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URI; +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.Properties; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.MediaType; + +import org.apache.commons.io.IOUtils; +import org.openecomp.appc.instar.utils.InstarClientConstant; + + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; + + +public class Dme2Client { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(Dme2Client.class); + private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR"; + //DME2Client client = null; + Properties props = new Properties(); + String operationName ; + String appendContext; + + public Dme2Client(String optName, String subCtxt, HashMap<String, String> data) throws Exception{ + log.info("Setting Properties for DME2 Client for INSTAR connection"); + this.operationName=optName; + this.appendContext = data.get(subCtxt); + String propDir = System.getenv(SDNC_CONFIG_DIR_VAR); + if (propDir == null) + throw new Exception(" Cannot find Property file -" + SDNC_CONFIG_DIR_VAR); + String propFile = propDir + InstarClientConstant.OUTBOUND_PROPERTIES; + InputStream propStream = new FileInputStream(propFile); + try + { + props.load(propStream); + } + catch (Exception e) + { + throw new Exception("Could not load properties file " + propFile, e); + } + finally + { + try + { + propStream.close(); + } + catch (Exception e) + { + log.warn("Could not close FileInputStream", e); + } + } + } + + public ClientResponse sendtoInstar() throws Exception { + + log.info("Called Send with operation Name=" + this.operationName + "and = " + props.getProperty(operationName+InstarClientConstant.BASE_URL)); + String resourceUri = props.getProperty(operationName+InstarClientConstant.BASE_URL)+ + props.getProperty(operationName + InstarClientConstant.URL_SUFFIX) + + props.getProperty(operationName + InstarClientConstant.SUB_CONTEXT)+ appendContext ; + + log.info("DME Endpoint URI:" + resourceUri); + Client client = null; + WebResource webResource = null; + ClientResponse clientResponse = null; + String authorization = props.getProperty("authorization"); + String requestDataType = "application/json"; + String responseDataType= MediaType.APPLICATION_JSON; + String methodType = props.getProperty("getIpAddressByVnf_method"); + String request = ""; + String userId=props.getProperty("MechID"); + String password=props.getProperty("MechPass"); + + log.info("authorization = " + authorization + "methodType= " + methodType); + try{ + DefaultClientConfig defaultClientConfig = new DefaultClientConfig(); + System.setProperty("jsse.enableSNIExtension", "false"); + SSLContext sslContext = null; + SecureRestClientTrustManager secureRestClientTrustManager = new SecureRestClientTrustManager(); + sslContext = SSLContext.getInstance("SSL"); + sslContext.init(null, new javax.net.ssl.TrustManager[] { secureRestClientTrustManager }, null); + defaultClientConfig.getProperties().put( + com.sun.jersey.client.urlconnection.HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, + new com.sun.jersey.client.urlconnection.HTTPSProperties(getHostnameVerifier(), sslContext)); + client = Client.create(defaultClientConfig); + client.addFilter(new HTTPBasicAuthFilter(userId, password)); + + webResource = client.resource(new URI(resourceUri)); + webResource.setProperty("Content-Type", "application/json;charset=UTF-8"); + + if(HttpMethod.GET.equalsIgnoreCase(methodType)){ + clientResponse = webResource.accept(responseDataType).get(ClientResponse.class); + }else if(HttpMethod.POST.equalsIgnoreCase(methodType)){ + clientResponse = webResource.type(requestDataType).post(ClientResponse.class, request); + }else if(HttpMethod.PUT.equalsIgnoreCase(methodType)){ + clientResponse = webResource.type(requestDataType).put(ClientResponse.class,request); + }else if(HttpMethod.DELETE.equalsIgnoreCase(methodType)){ + clientResponse = webResource.delete(ClientResponse.class); + } + + return clientResponse; + + }catch (Exception e) { + log.info("failed in RESTCONT Action ("+methodType+") for the resource " + resourceUri + ", falut message :"+e.getMessage()); + throw new Exception("Error While gettting Data from INSTAR" + e.getMessage()); + } + finally { + // clean up. + webResource = null; + if(client != null){ + client.destroy(); + client = null; + } + } + + + } + + public String send() { + String response = null; + try{ + + if(props !=null && + props.getProperty(InstarClientConstant.MOCK_INSTAR) != null && + props.getProperty(InstarClientConstant.MOCK_INSTAR).equalsIgnoreCase("true")) + return IOUtils.toString(Dme2Client.class.getClassLoader().getResourceAsStream("/tmp/sampleResponse"), Charset.defaultCharset()); + + ClientResponse clientResponse = sendtoInstar(); + if(clientResponse != null){ + response = clientResponse.getEntity(String.class); + log.info(clientResponse.getStatus() + " Status, Response :" + response); + + } + } catch (Exception t) { + t.printStackTrace(); + } + return response; + } + + private HostnameVerifier getHostnameVerifier() { + return new HostnameVerifier() { + @Override + public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) { + return true; + } + }; + } + + +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/dme2client/SecureRestClientTrustManager.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/dme2client/SecureRestClientTrustManager.java new file mode 100644 index 000000000..21e313eaf --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/dme2client/SecureRestClientTrustManager.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.dme2client; + +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +import javax.net.ssl.X509TrustManager; + + +public class SecureRestClientTrustManager implements X509TrustManager { + + @Override + public void checkClientTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + + public boolean isClientTrusted(X509Certificate[] arg0) { + return true; + } + + public boolean isServerTrusted(X509Certificate[] arg0) { + return true; + } + +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaceImpl/InstarResponseHandlerImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaceImpl/InstarResponseHandlerImpl.java new file mode 100644 index 000000000..3292253da --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaceImpl/InstarResponseHandlerImpl.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.interfaceImpl; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.openecomp.appc.instar.interfaces.ResponseHandlerInterface; +import org.openecomp.appc.instar.utils.InstarClientConstant; +import org.openecomp.sdnc.config.params.data.ResponseKey; +import org.openecomp.sdnc.sli.SvcLogicContext; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class InstarResponseHandlerImpl implements ResponseHandlerInterface { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(InstarResponseHandlerImpl.class); + + ResponseKey resKey = null; + SvcLogicContext ctxt = null; + + public InstarResponseHandlerImpl(ResponseKey filterKeys, SvcLogicContext context) { + this.resKey = filterKeys; + this.ctxt = context; + + } + + @Override + public Object processResponse(String instarResponse, String instarKey) { + String fn = " InstarResponseHandlerImpl.processResponse "; + log.info(fn + " Instar Response :" + instarResponse); + + JSONObject instarKeyValues; + + log.info("Instar Data in Context : "+ ctxt.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES)); + if(ctxt.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES) != null){ + instarKeyValues = new JSONObject(ctxt.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES)); + log.info("Instar data already exsits : " + instarKeyValues.toString()); + } + else + instarKeyValues = new JSONObject(); + JSONArray instarResponses = new JSONObject(instarResponse).getJSONArray(InstarClientConstant.INSTAR_RESPONSE_BLOCK_NAME); + for (int i = 0; i < instarResponses.length(); i++){ + JSONObject res = instarResponses.getJSONObject(i); + log.info(fn + "Instar Block :" + i + " Values :" + res.toString()); + log.info(fn + "Appc Filter Key :" + ctxt.getAttribute(InstarClientConstant.VNF_NAME) + resKey.getUniqueKeyValue()); + + if(res.getString(InstarClientConstant.FDQN) != null && + res.getString(InstarClientConstant.FDQN).equalsIgnoreCase(ctxt.getAttribute(InstarClientConstant.VNF_NAME) + resKey.getUniqueKeyValue())){ + if(resKey.getFieldKeyName().equals(InstarClientConstant.V4_ADDRESS)) + instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V4_ADDRESS)); + else if(resKey.getFieldKeyName().equals(InstarClientConstant.V6_ADDRESS)) + instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V6_ADDRESS)); + break; + } + } + log.info(fn + "Instar KeyValues :" + instarKeyValues); + ctxt.setAttribute(InstarClientConstant.INSTAR_KEY_VALUES, instarKeyValues.toString()); + + + return instarKeyValues; + } + +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaceImpl/InstarRestClientImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaceImpl/InstarRestClientImpl.java new file mode 100644 index 000000000..e727ce10d --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaceImpl/InstarRestClientImpl.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.interfaceImpl; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.HashMap; + +import org.apache.commons.io.IOUtils; +import org.openecomp.appc.instar.dme2client.Dme2Client; +import org.openecomp.appc.instar.interfaces.RestClientInterface; +import org.openecomp.appc.instar.utils.InstarClientConstant; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class InstarRestClientImpl implements RestClientInterface { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(InstarRestClientImpl.class); + HashMap<String, String> requestData = null; + Dme2Client dme2Client; + + public InstarRestClientImpl(HashMap<String, String> instarRequestData) { + + this.requestData = instarRequestData; + } + + @Override + public String sendRequest(String operation) throws Exception { + + String instarResponse = null; + try { + if(operation !=null && operation.equalsIgnoreCase(InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME)){ + dme2Client = new Dme2Client(operation, InstarClientConstant.VNF_NAME, requestData); + } + instarResponse = dme2Client.send(); + log.info("Resposne in InstarRestClientImpl = " + instarResponse); + if(instarResponse == null || instarResponse.length() < 0) + throw new Exception ("No Data received from Instar for this call " + operation); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + return instarResponse; + } + + + +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaceImpl/InterfaceIpAddressImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaceImpl/InterfaceIpAddressImpl.java new file mode 100644 index 000000000..2d94331aa --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaceImpl/InterfaceIpAddressImpl.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.interfaceImpl; + +import java.util.HashMap; +import java.util.List; + +import org.openecomp.appc.instar.interfaces.ResponseHandlerInterface; +import org.openecomp.appc.instar.interfaces.RestClientInterface; +import org.openecomp.appc.instar.interfaces.RuleHandlerInterface; +import org.openecomp.appc.instar.node.InstarClientNode; +import org.openecomp.appc.instar.utils.InstarClientConstant; +import org.openecomp.sdnc.config.params.data.Parameter; +import org.openecomp.sdnc.config.params.data.ResponseKey; +import org.openecomp.sdnc.sli.SvcLogicContext; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class InterfaceIpAddressImpl implements RuleHandlerInterface { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(InterfaceIpAddressImpl.class); + private Parameter parameters; + private SvcLogicContext context; + + public InterfaceIpAddressImpl(Parameter params, SvcLogicContext ctx) { + this.parameters = params; + this.context = ctx; + } + + @Override + public void processRule() throws Exception { + + String fn = "InterfaceIpAddressHandler.processRule"; + log.info(fn + "Processing rule :" + parameters.getRuleType()); + String operationName ; + + RestClientInterface restClient = null; + ResponseHandlerInterface responseHandler = null; + + List<ResponseKey> responseKeyList = parameters.getResponseKeys(); + if(responseKeyList != null && responseKeyList.size() > 0){ + for(ResponseKey filterKeys : responseKeyList){ + //response.setUniqueKeyValue(response.getUniqueKeyValue()+ context.getAttribute(InstarClientConstant.VNF_NAME)); + switch(parameters.getSource()){ + case InstarClientConstant.SOURCE_SYSTEM_INSTAR: + restClient = new InstarRestClientImpl(createInstarRequestData(context)); + responseHandler = new InstarResponseHandlerImpl(filterKeys, context ); + operationName = "getIpAddressByVnf"; + break; + default: + throw new Exception("No Client registered for : " + parameters.getSource()); + + } + responseHandler.processResponse(restClient.sendRequest(operationName),parameters.getName() ); + } + } + else + { + throw new Exception("NO response Keys set for : " + parameters.getRuleType()); + } + } + + private HashMap<String, String> createInstarRequestData(SvcLogicContext ctxt) { + HashMap<String, String> requestParams = new HashMap<String, String>(); + requestParams.put(InstarClientConstant.VNF_NAME, ctxt.getAttribute(InstarClientConstant.VNF_NAME)); + return requestParams; + } +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaces/ResponseHandlerInterface.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaces/ResponseHandlerInterface.java new file mode 100644 index 000000000..816bbdb5d --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaces/ResponseHandlerInterface.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.interfaces; + +public interface ResponseHandlerInterface { + + public Object processResponse(String response, String instarKey); + +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaces/RestClientInterface.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaces/RestClientInterface.java new file mode 100644 index 000000000..448429163 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaces/RestClientInterface.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.interfaces; + +public interface RestClientInterface { + + + public String sendRequest(String operation) throws Exception; + +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaces/RuleHandlerInterface.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaces/RuleHandlerInterface.java new file mode 100644 index 000000000..ad13c96e0 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/interfaces/RuleHandlerInterface.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.interfaces; + + +public interface RuleHandlerInterface { + + public void processRule() throws Exception; + +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/node/InstarClientNode.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/node/InstarClientNode.java new file mode 100644 index 000000000..17ce64422 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/node/InstarClientNode.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.node; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.appc.instar.interfaceImpl.InstarRestClientImpl; +import org.openecomp.appc.instar.interfaceImpl.InterfaceIpAddressImpl; +import org.openecomp.appc.instar.interfaces.RestClientInterface; +import org.openecomp.appc.instar.interfaces.RuleHandlerInterface; +import org.openecomp.appc.instar.utils.InstarClientConstant; +import org.openecomp.sdnc.config.params.data.Parameter; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + +public class InstarClientNode implements SvcLogicJavaPlugin +{ + private static final EELFLogger log = EELFManager.getInstance().getLogger(InstarClientNode.class); + + public void getInstarInfo(Map<String, String> inParams, SvcLogicContext ctx) + throws SvcLogicException{ + log.info("Received getInstarInfo call with params : " + inParams); + String responsePrefix = (String)inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX); + try + { + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : ""; + String [] instarKeys = getInstarKeys(inParams.get(InstarClientConstant.INSTAR_KEYS)); + for (String instarKey : instarKeys){ + log.info("Processing Key : " + instarKey); + log.info("Searching key for : " + "INSTAR." + instarKey); + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + RuleHandlerInterface handler = null; + log.info("Received Context : " + ctx.getAttribute("INSTAR." + instarKey)); + Parameter params = mapper.readValue(ctx.getAttribute(InstarClientConstant.SOURCE_SYSTEM_INSTAR + "." + instarKey), Parameter.class); + + log.info("Processing rule Type : " + params.getRuleType()); + switch(params.getRuleType()){ + case InstarClientConstant.INTERFACE_IP_ADDRESS: + handler = new InterfaceIpAddressImpl(params, ctx); + break; + default: + throw new Exception("No Rule Defined to process :" + params.getRuleType()); + } + handler.processRule(); + + } + log.info("responsePrefix =" + responsePrefix); + ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES, ctx.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES)); + ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_SUCCESS); + ctx.setAttribute(InstarClientConstant.INSTAR_KEY_VALUES, null); + } + catch (Exception e) + { + ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + log.error("Failed processing Instar request" + e.getMessage()); + e.printStackTrace(); + throw new SvcLogicException(e.getMessage()); + } + } + private static String[] getInstarKeys(String keyString) { + String fn = "InstarClientNode.getInstarKeys"; + System.out.println("Received instar Key String as :" + keyString); + + keyString = keyString.replace("[",""); + keyString = keyString.replace("]", ""); + keyString = keyString.replace("\"", ""); + if(keyString.contains(",")) + { + String[] keys = keyString.split(","); + return keys; + } + else{ + String[] keys = {keyString}; + return keys; + } + } + public void getInstarData(Map<String, String> inParams, SvcLogicContext ctx) + throws SvcLogicException{ + log.info("Received getInstarData call with params : " + inParams); + String responsePrefix = (String)inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX); + try + { + HashMap<String, String> input = new HashMap<String, String>(); + input.putAll(inParams); + RestClientInterface rcINterface = new InstarRestClientImpl(input); + String response = rcINterface.sendRequest(inParams.get("operationName")); + + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : ""; + ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_SUCCESS); + ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES, response); + + } + catch (Exception e) + { + ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + log.error("Failed processing Instar request" + e.getMessage()); + e.printStackTrace(); + throw new SvcLogicException(e.getMessage()); + } + } + +} diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/utils/InstarClientConstant.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/utils/InstarClientConstant.java new file mode 100644 index 000000000..790651f12 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/openecomp/appc/instar/utils/InstarClientConstant.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.utils; + +public class InstarClientConstant +{ + public static String INPUT_PARAM_RESPONSE_PRIFIX = "responsePrefix"; + public static String OUTPUT_PARAM_STATUS = "status"; + public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; + public static String OUTPUT_STATUS_SUCCESS = "success"; + public static String OUTPUT_STATUS_FAILURE = "failure"; + + + + public static final String INSTAR_KEYS = "instarKeys"; + + public static final String INTERFACE_IP_ADDRESS = "interface-ip-address"; + public static final String SOURCE_SYSTEM_INSTAR = "INSTAR"; + public static final String VNF_TYPE = "vnf-type"; + public static final String ADDRESSFDQN = "addressfqdn"; + public static final String VNF_NAME = "vnf-name"; + public static final String INSTAR_KEY_VALUES = "INSTAR-KEY-VALUES"; + public static final String INSTAR_RESPONSE_BLOCK_NAME = "vnfConfigurationParameterDetails"; + public static final String FDQN = "fqdn"; + + + public static final String MOCK_INSTAR="mock_instar"; + public static final String AFT_LATITUDE="aft_latitude"; + public static final String AFT_LONGITUDE="aft_latitude"; + public static final String AFT_ENVIRONMENT="aft_environment"; + public static final String SCLD_PLATFORM="scld_platform"; + public static final String AUTHORIZATION="authorization"; + public static final String DME2_CLIENT_TIMEOUTMS="dme2_client_timeoutms"; + public static final String DME2_CLIENT_SENDANDWAIT="dme2_client_sendandwait"; + public static final String BASE_URL="_base_url"; + public static final String HTTP_HEADERS="_http_headers"; + + public static final String V6_ADDRESS="ipaddress-v6"; + public static final String INSTAR_V6_ADDRESS="v6IPAddress"; + + + public static final String V4_ADDRESS="ipaddress-v4"; + public static final String INSTAR_V4_ADDRESS="v4IPAddress"; + + public static final String SUB_CONTEXT="_sub_context"; + public static final String URL_SUFFIX="_suffix"; + public static final String VERSION="_version"; + public static final String ENV_CONTEXT="_env_context"; + public static final String ROUTEOFFER="_routeoffer"; + public static final String APPC_PROPERTIES = "appc.properties"; + public static final String METHOD="_method"; + public static final String OPERATION_GET_IPADDRESS_BY_VNF_NAME = "getIpAddressByVnf"; + + public static final String OUTBOUND_PROPERTIES= "/outbound.properties"; + + public static String CONTENT_TYPE = "application/json"; + public static String RETURNED_RESPONSE_TYPE = "application/json"; + +} + diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/resources/adaptor.properties b/appc-outbound/appc-network-inventory-client/provider/src/main/resources/adaptor.properties new file mode 100644 index 000000000..205a8f884 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/resources/adaptor.properties @@ -0,0 +1,29 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APPC +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Copyright (C) 2017 Amdocs +# ============================================================================= +# 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. +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# ============LICENSE_END========================================================= +### + +adaptorName= +vSphere.url= +vSphere.user= +vSphere.passwd= +org.xml.sax.driver=org.apache.xerces.parsers.SAXParser diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/resources/outbound.properties b/appc-outbound/appc-network-inventory-client/provider/src/main/resources/outbound.properties new file mode 100644 index 000000000..ede337681 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/resources/outbound.properties @@ -0,0 +1,39 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APPC +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Copyright (C) 2017 Amdocs +# ============================================================================= +# 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. +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# ============LICENSE_END========================================================= +### + +MechID= +MechPass= +SCLD_PLATFORM=NON-PROD +dme2_client_timeoutms=100000 +dme2_client_sendandwait=1000000 +DME2.DEBUG=true + +#appc-instar service base context +getIpAddressByVnf_base_url= +getIpAddressByVnf_sub_context=vnfs/ +getIpAddressByVnf_suffix=vnfconfigparameters/ +getIpAddressByVnf_method=GET +getIpAddressByVnf_http_headers=X-CSI-MessageId=123 + + diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/resources/templates/sampleInstarResponse b/appc-outbound/appc-network-inventory-client/provider/src/main/resources/templates/sampleInstarResponse new file mode 100755 index 000000000..7433aea62 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/resources/templates/sampleInstarResponse @@ -0,0 +1,24 @@ +{
+"vnfConfigurationParameterDetails": [
+ {
+ "addressfqdn": "XXXXXX",
+ "ipaddress-purpose": "vNIC1/Data NIC",
+ "ipaddress-v4": "00.00.00.00",
+ "v4-subnet": "00.00.00.00/25",
+ "v4-default-gateway": "00.00.00.00",
+ "ipaddress-v6": "2001:1890:FC:28::1:2",
+ "v6-subnet": "2001:1890:FC:28::/64",
+ "v6-default-gateway": "2001:1890:FC:28::3"
+ },
+ {
+ "addressfqdn": "XXXXXX",
+ "ipaddress-purpose": "vNIC1/Data NIC",
+ "ipaddress-v4": "00.00.00.00",
+ "v4-subnet": "00.00.00.00/25",
+ "v4-default-gateway": "00.00.00.00",
+ "ipaddress-v6": "2001:1890:FC:28::1:4",
+ "v6-subnet": "2001:1890:FC:28::/64",
+ "v6-default-gateway": "2001:1890:FC:28::3"
+ }
+ ]
+}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/resources/templates/sampleKeyContents b/appc-outbound/appc-network-inventory-client/provider/src/main/resources/templates/sampleKeyContents new file mode 100755 index 000000000..90e3ec789 --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/main/resources/templates/sampleKeyContents @@ -0,0 +1 @@ +{"name":"LOCAL_ACCESS_IP_ADDR","description":"this is the node0 tacplus server IP address","type":"ipv4_address","required":true,"source":"INSTAR","rule-type":"interface-ip-address","default":null,"request-keys":null,"response-keys":[{"unique-key-name":"addressfqdn","unique-key-value":"00000000000000","field-key-name":"ipaddress-v4"}]}
\ No newline at end of file diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestInstarClientNode.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestInstarClientNode.java new file mode 100644 index 000000000..ca88d54db --- /dev/null +++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestInstarClientNode.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.appc.instar.node; + +import java.net.URI; +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.Map; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.ws.rs.HttpMethod; + +import org.apache.commons.io.IOUtils; +import org.json.JSONObject; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.appc.instar.dme2client.SecureRestClientTrustManager; +import org.openecomp.appc.instar.utils.InstarClientConstant; +import org.openecomp.sdnc.sli.SvcLogicContext; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; + + +public class TestInstarClientNode { + + //ONAP Migration +} |