summaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dg/appc-dg-shared')
-rw-r--r--appc-dg/appc-dg-shared/.gitignore1
-rw-r--r--appc-dg/appc-dg-shared/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-dg/appc-dg-shared/README.txt1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/.gitignore1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/pom.xml85
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java35
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java122
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java112
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/resources/OSGI-INF/blueprint/blueprint.xml31
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIClientMock.java544
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java260
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/.gitignore1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/pom.xml81
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/DCAEReporterPlugin.java34
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/JsonDgUtil.java33
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/LegacyUtil.java40
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/Constants.java57
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImpl.java121
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImpl.java66
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/LegacyUtilImpl.java55
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/objects/ConnectionDetails.java65
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JAXBUtil.java50
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JSONUtil.java80
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml41
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/org/openecomp/appc/default.properties47
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/xsd/vf-license-model.xsd88
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImplTest.java154
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/EventSenderMock.java61
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImplTest.java145
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-license-manager/.gitignore1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-license-manager/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-license-manager/pom.xml57
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/LicenseManagerPlugin.java53
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/impl/LicenseManagerPluginImpl.java145
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/resources/OSGI-INF/blueprint/blueprint.xml38
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/.gitignore1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/pom.xml89
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/NetconfClientPlugin.java39
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/NetconfDBPlugin.java37
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/impl/NetconfClientPluginImpl.java316
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/impl/NetconfDBPluginImpl.java122
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/main/resources/OSGI-INF/blueprint/blueprint.xml43
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/DAOServiceMock.java97
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/MockOperationalStateValidatorImpl.java61
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientFactoryMock.java43
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientJschMock.java100
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientPluginImplTest.java678
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfDBPluginImplTest.java250
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/ObjectMapperMock.java45
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/OperationStateValidatorFactoryMock.java47
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-shared-features/.gitignore1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-shared-features/pom.xml85
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-shared-features/src/main/resources/features.xml38
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-shared-installer/.gitignore1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-shared-installer/pom.xml132
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-shared-installer/src/assembly/assemble_installer_zip.xml59
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-shared-installer/src/assembly/assemble_mvnrepo_zip.xml47
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-shared-installer/src/main/resources/etc/org.apache.cxf.osgi.cfg1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-shared-installer/src/main/resources/scripts/install-feature.sh40
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/.gitignore1
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/pom.xml69
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/SshDBPlugin.java32
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/SshService.java106
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/impl/SshDBPluginImpl.java74
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/impl/SshServiceImpl.java106
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/src/main/resources/OSGI-INF/blueprint/blueprint.xml42
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-ssh/src/test/java/org/openecomp/appc/dg/ssh/impl/SshServiceImplTest.java170
-rw-r--r--appc-dg/appc-dg-shared/pom.xml21
72 files changed, 5722 insertions, 0 deletions
diff --git a/appc-dg/appc-dg-shared/.gitignore b/appc-dg/appc-dg-shared/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dg/appc-dg-shared/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dg/appc-dg-shared/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-dg/appc-dg-shared/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-dg/appc-dg-shared/README.txt b/appc-dg/appc-dg-shared/README.txt
new file mode 100644
index 000000000..960d51885
--- /dev/null
+++ b/appc-dg/appc-dg-shared/README.txt
@@ -0,0 +1 @@
+This project contains set of DG-ready reusable APP-C utility classes, such as utility for executing a command on remote machine via SSH and more. \ No newline at end of file
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/.gitignore b/appc-dg/appc-dg-shared/appc-dg-aai/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-dg/appc-dg-shared/appc-dg-aai/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/pom.xml b/appc-dg/appc-dg-shared/appc-dg-aai/pom.xml
new file mode 100644
index 000000000..a1bdfbfcd
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/pom.xml
@@ -0,0 +1,85 @@
+<?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-dg-shared</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dg-aai</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-common</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.adaptors</groupId>
+ <artifactId>aai-service-provider</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-dg-aai</Bundle-SymbolicName>
+ <Export-Package>org.openecomp.appc.dg.aai</Export-Package>
+ <Private-Package>org.openecomp.appc.dg.aai.impl.*</Private-Package>
+ <Import-Package>
+ !org.apache.log,!org.apache.commons.logging,!groovy.lang,!javax.jms,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.jasypt.*,*
+ </Import-Package>
+ <Embed-Dependency>
+ appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false
+ </Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java
new file mode 100644
index 000000000..e220182f2
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.aai;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+public interface AAIPlugin extends SvcLogicJavaPlugin {
+ void postGenericVnfData(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void getGenericVnfData(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java
new file mode 100644
index 000000000..6eae559e8
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.aai.impl;
+
+import org.openecomp.appc.dg.aai.AAIPlugin;
+import org.openecomp.appc.dg.aai.impl.Constants;
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicException;
+import org.openecomp.sdnc.sli.SvcLogicResource;
+import org.openecomp.sdnc.sli.aai.AAIClient;
+import org.openecomp.sdnc.sli.aai.AAIService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class AAIPluginImpl implements AAIPlugin {
+ private AAIClient aaiClient;
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(AAIPluginImpl.class);
+
+ public AAIPluginImpl() {
+ BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+ ServiceReference sref = bctx.getServiceReference(AAIService.class);
+ aaiClient = (AAIClient) bctx.getService(sref);
+ }
+
+ @Override
+ public void postGenericVnfData(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ String vnf_id = ctx.getAttribute(Constants.VNF_ID_PARAM_NAME);
+ String prefix = ctx.getAttribute(Constants.AAI_PREFIX_PARAM_NAME);
+
+ String key = "vnf-id = '" + vnf_id + "'";
+
+ Map<String, String> data = new HashMap<>();
+ for (Map.Entry<String, String> entry : params.entrySet()) {
+ String paramKey = entry.getKey();
+ int pos = paramKey.indexOf(Constants.AAI_INPUT_DATA);
+ if (pos == 0) {
+ data.put(paramKey.substring(Constants.AAI_INPUT_DATA.length()+1), entry.getValue());
+ }
+ }
+
+ try {
+ SvcLogicResource.QueryStatus response = aaiClient.update("generic-vnf", key, data, prefix, ctx);
+ if (SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)) {
+ String errorMessage = String.format("VNF not found for vnf_id = %s", vnf_id);
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
+ throw new APPCException(errorMessage);
+ }
+ logger.info("AAIResponse: " + response.toString());
+ if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) {
+ String errorMessage = String.format("Error Querying AAI with vnfID = %s", vnf_id);
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
+ throw new APPCException(errorMessage);
+ }
+ } catch (SvcLogicException e) {
+ String errorMessage = String.format("Error in postVnfdata %s", e);
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
+ logger.error(errorMessage);
+ throw new APPCException(e);
+ }
+ }
+
+ @Override
+ public void getGenericVnfData(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ String vnf_id = ctx.getAttribute(Constants.VNF_ID_PARAM_NAME);
+ String prefix = ctx.getAttribute(Constants.AAI_PREFIX_PARAM_NAME);
+
+ String key = "vnf-id = '" + vnf_id + "'";
+ try {
+ SvcLogicResource.QueryStatus response = aaiClient.query("generic-vnf", false, null, key, prefix, null, ctx);
+ if (SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)) {
+ String errorMessage = String.format("VNF not found for vnf_id = %s", vnf_id);
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
+ throw new APPCException(errorMessage);
+ } else if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) {
+ String errorMessage = String.format("Error Querying AAI with vnfID = %s", vnf_id);
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
+ throw new APPCException(errorMessage);
+ }
+ String aaiEntitlementPoolUuid = ctx.getAttribute(Constants.AAI_ENTITLMENT_POOL_UUID_NAME);
+ if (null == aaiEntitlementPoolUuid) aaiEntitlementPoolUuid = "";
+ String aaiLicenseKeyGroupUuid = ctx.getAttribute(Constants.AAI_LICENSE_KEY_UUID_NAME);
+ if (null == aaiLicenseKeyGroupUuid) aaiLicenseKeyGroupUuid = "";
+
+ ctx.setAttribute(Constants.IS_RELEASE_ENTITLEMENT_REQUIRE, Boolean.toString(!aaiEntitlementPoolUuid.isEmpty()));
+ ctx.setAttribute(Constants.IS_RELEASE_LICENSE_REQUIRE, Boolean.toString(!aaiLicenseKeyGroupUuid.isEmpty()));
+
+ logger.info("AAIResponse: " + response.toString());
+ } catch (SvcLogicException e) {
+ String errorMessage = String.format("Error in getVnfdata %s", e);
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
+ logger.error(errorMessage);
+ throw new APPCException(e);
+ }
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java
new file mode 100644
index 000000000..3feab4795
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.aai.impl;
+
+
+public class Constants {
+ public final static String VNF_ID_PARAM_NAME = "aai.vnfID";
+ public static final String AAI_PREFIX_PARAM_NAME = "aai.prefix";
+ public static final String AAI_INPUT_DATA = "aai.input.data";
+ public static final String AAI_ERROR_MESSAGE = "org.openecomp.appc.dg.error";
+
+ public static final String CONFIGURE_PATH = "/restconf/config/opendaylight-inventory:nodes/node/";
+ public static final String CONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules";
+ public static final String CHECK_CONNECTION_PATH = "/restconf/operational/opendaylight-inventory:nodes/node/";
+ public static final String DISCONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/";
+
+ public static final String CONTROLLER_IP = "127.0.0.1";
+ public static final int CONTROLLER_PORT = 8181;
+ public static final String PROTOCOL = "http";
+
+ public static final String VF_LICENSE = "VF_LICENSE";
+
+ // tables and fields
+ public static final String NETCONF_SCHEMA = "sdnctl";
+ public static final String SDNCTL_SCHEMA = "sdnctl";
+ public static final String DEVICE_AUTHENTICATION_TABLE_NAME = "DEVICE_AUTHENTICATION";
+ public static final String CONFIGFILES_TABLE_NAME = "CONFIGFILES";
+ public static final String DEVICE_INTERFACE_LOG_TABLE_NAME = "DEVICE_INTERFACE_LOG";
+ public static final String FILE_CONTENT_TABLE_FIELD_NAME = "FILE_CONTENT";
+ public static final String FILE_NAME_TABLE_FIELD_NAME = "FILE_NAME";
+ public static final String USER_NAME_TABLE_FIELD_NAME = "USER_NAME";
+ public static final String PASSWORD_TABLE_FIELD_NAME = "PASSWORD";
+ public static final String PORT_NUMBER_TABLE_FIELD_NAME = "PORT_NUMBER";
+ public static final String VNF_TYPE_TABLE_FIELD_NAME = "VNF_TYPE";
+ public static final String SERVICE_INSTANCE_ID_FIELD_NAME = "SERVICE_INSTANCE_ID";
+ public static final String REQUEST_ID_FIELD_NAME = "REQUEST_ID";
+ public static final String CREATION_DATE_FIELD_NAME = "CREATION_DATE";
+ public static final String LOG_FIELD_NAME = "LOG";
+ public static final String ASDC_ARTIFACTS_TABLE_NAME = "ASDC_ARTIFACTS";
+
+ // input fields names
+ public static final String PAYLOAD = "payload";
+
+ // constants fo DG
+ public static final String VNF_TYPE_FIELD_NAME = "org.openecomp.appc.vftype";
+ public static final String VNF_VERSION_FIELD_NAME = "org.openecomp.appc.vfversion";
+ public static final String VNF_RESOURCE_VERSION_FIELD_NAME = "org.openecomp.appc.resource-version";
+ public static final String TARGET_VNF_TYPE = "target-vnf-type";
+ public static final String FILE_CONTENT_FIELD_NAME = "file-content";
+ public static final String CONNECTION_DETAILS_FIELD_NAME = "connection-details";
+ public static final String CONFIGURATION_FILE_FIELD_NAME = "configuration-file-name";
+ public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address";
+ public static final String UPGRADE_VERSION = "upgrade-version";
+ public static final String DG_ERROR_FIELD_NAME = "org.openecomp.appc.dg.error";
+ public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+ public static final String RESOURCEKEY = "resourceKey";
+ public static final String REQ_ID_FIELD_NAME = "org.openecomp.appc.reqid";
+ public static final String API_VERSION_FIELD_NAME = "org.openecomp.appc.apiversion";
+ public static final String MODEL_ENTITLMENT_POOL_UUID_NAME = "model.entitlement.pool.uuid";
+ public static final String MODEL_LICENSE_KEY_UUID_NAME = "model.license.key.uuid";
+ public static final String ENTITLMENT_POOL_UUID_NAME = "entitlement.pool.uuid";
+ public static final String LICENSE_KEY_UUID_NAME = "license.key.uuid";
+ public static final String IS_ACQUIRE_LICENSE_REQUIRE ="is.acquire-license.require";
+ public static final String IS_RELEASE_LICENSE_REQUIRE ="is.release-license.require";
+
+ public static final String AAI_ENTITLMENT_POOL_UUID_NAME = "aai.input.data.entitlement-assignment-group-uuid";
+ public static final String AAI_LICENSE_KEY_UUID_NAME = "aai.input.data.license-assignment-group-uuid";
+ public static final String AAI_LICENSE_KEY_VALUE = "aai.input.data.license-key";
+ public static final String IS_AAI_ENTITLEMENT_UPDATE_REQUIRE = "is.aai-entitlement-update.require";
+ public static final String IS_AAI_LICENSE_UPDATE_REQUIRE = "is.aai-license-update.require";
+ public static final String IS_ACQUIRE_ENTITLEMENT_REQUIRE ="is.acquire-entitlement.require";
+ public static final String IS_RELEASE_ENTITLEMENT_REQUIRE ="is.release-entitlement.require";
+
+ public enum ASDC_ARTIFACTS_FIELDS {
+ SERVICE_UUID,
+ DISTRIBUTION_ID,
+ SERVICE_NAME,
+ SERVICE_DESCRIPTION,
+ RESOURCE_UUID,
+ RESOURCE_INSTANCE_NAME,
+ RESOURCE_NAME,
+ RESOURCE_VERSION,
+ RESOURCE_TYPE,
+ ARTIFACT_UUID,
+ ARTIFACT_TYPE,
+ ARTIFACT_VERSION,
+ ARTIFACT_DESCRIPTION,
+ INTERNAL_VERSION,
+ CREATION_DATE,
+ ARTIFACT_NAME,
+ ARTIFACT_CONTENT
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..260b218d6
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T 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=========================================================
+ -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <service id="aaiServicePlugin" interface="org.openecomp.appc.dg.aai.AAIPlugin">
+ <bean class="org.openecomp.appc.dg.aai.impl.AAIPluginImpl"/>
+ </service>
+
+</blueprint>
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIClientMock.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIClientMock.java
new file mode 100644
index 000000000..fc4379dd2
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIClientMock.java
@@ -0,0 +1,544 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.aai.impl;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicException;
+import org.openecomp.sdnc.sli.SvcLogicResource;
+import org.openecomp.sdnc.sli.aai.AAIClient;
+import org.openecomp.sdnc.sli.aai.AAIServiceException;
+import org.openecomp.sdnc.sli.aai.data.*;
+import org.openecomp.sdnc.sli.aai.data.notify.NotifyEvent;
+import org.openecomp.sdnc.sli.aai.data.v1507.VServer;
+import org.openecomp.sdnc.sli.aai.update.Update;
+
+
+public class AAIClientMock implements AAIClient {
+
+ Map<String, String> mockAAI = new HashMap<>();
+
+ public void setMockAAI(Map<String, String> mockAAI) {
+ this.mockAAI = mockAAI;
+ }
+
+ @Override
+ public AAIResponse requestSdnZoneQuery(String s, String s1, String s2) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postNetworkVceData(String s, Vce vce) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public Vce requestNetworkVceData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean deleteNetworkVceData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public ServiceInstance requestServiceInterfaceData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public ServiceInstance requestServiceInterfaceData(String s, String s1, String s2) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postServiceInterfaceData(String s, String s1, String s2, ServiceInstance serviceInstance) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public SearchResults requestServiceInstanceURL(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public Vpe requestNetworkVpeData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postNetworkVpeData(String s, Vpe vpe) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deleteNetworkVpeData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public Vserver requestVServerData(String s, String s1, String s2, String s3) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postVServerData(String s, String s1, String s2, String s3, Vserver vserver) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deleteVServerData(String s, String s1, String s2, String s3, String s4) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public URL requestVserverURLNodeQuery(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public String getTenantIdFromVserverUrl(URL url) {
+ return null;
+ }
+
+ @Override
+ public String getCloudOwnerFromVserverUrl(URL url) {
+ return null;
+ }
+
+ @Override
+ public String getCloudRegionFromVserverUrl(URL url) {
+ return null;
+ }
+
+ @Override
+ public String getVServerIdFromVserverUrl(URL url, String s) {
+ return null;
+ }
+
+ @Override
+ public Vserver requestVServerDataByURL(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public VplsPe requestNetworkVplsPeData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postNetworkVplsPeData(String s, VplsPe vplsPe) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deleteNetworkVplsPeData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public Complex requestNetworkComplexData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postNetworkComplexData(String s, Complex complex) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deleteNetworkComplexData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public CtagPool requestCtagPoolData(String s, String s1, String s2) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public VServer dataChangeRequestVServerData(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public CtagPool dataChangeRequestCtagPoolData(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public VplsPe dataChangeRequestVplsPeData(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public Vpe dataChangeRequestVpeData(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public DvsSwitch dataChangeRequestDvsSwitchData(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public PServer dataChangeRequestPServerData(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public OamNetwork dataChangeRequestOAMNetworkData(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public AvailabilityZone dataChangeRequestAvailabilityZoneData(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public Complex dataChangeRequestComplexData(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean dataChangeDeleteVServerData(URL url) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean dataChangeDeleteCtagPoolData(URL url) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean dataChangeDeleteVplsPeData(URL url) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean dataChangeDeleteVpeData(URL url) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean dataChangeDeleteDvsSwitchData(URL url) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean dataChangeDeleteOAMNetworkData(URL url) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean dataChangeDeleteAvailabilityZoneData(URL url) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean dataChangeDeleteComplexData(URL url) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public GenericVnf requestGenericVnfData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postGenericVnfData(String s, GenericVnf genericVnf) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deleteGenericVnfData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public DvsSwitch requestDvsSwitchData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postDvsSwitchData(String s, DvsSwitch dvsSwitch) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deleteDvsSwitchData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public PInterface requestPInterfaceData(String s, String s1) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postPInterfaceData(String s, String s1, PInterface pInterface) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deletePInterfaceData(String s, String s1, String s2) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public PhysicalLink requestPhysicalLinkData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postPhysicalLinkData(String s, PhysicalLink physicalLink) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deletePhysicalLinkData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public PServer requestPServerData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postPServerData(String s, PServer pServer) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deletePServerData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public L3Network requestL3NetworkData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public L3Network requestL3NetworkQueryByName(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postL3NetworkData(String s, L3Network l3Network) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deleteL3NetworkData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public VpnBinding requestVpnBindingData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean deleteVpnBindingData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public VnfImage requestVnfImageData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public VnfImage requestVnfImageDataByVendorModel(String s, String s1) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public VnfImage requestVnfImageDataByVendorModelVersion(String s, String s1, String s2) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean sendNotify(NotifyEvent notifyEvent, String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public SitePairSet requestSitePairSetData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postSitePairSetData(String s, SitePairSet sitePairSet) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deleteSitePairSetData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public Service requestServiceData(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postServiceData(String s, Service service) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean deleteServiceData(String s, String s1) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public QueryResponse requestNodeQuery(String s, String s1, String s2) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public String requestDataByURL(URL url) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public GenericVnf requestGenericVnfeNodeQuery(String s) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public Tenant requestTenantData(String s, String s1, String s2) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public Tenant requestTenantDataByName(String s, String s1, String s2) throws AAIServiceException {
+ return null;
+ }
+
+ @Override
+ public boolean postTenantData(String s, String s1, String s2, Tenant tenant) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public boolean updateAnAIEntry(Update update) throws AAIServiceException {
+ return false;
+ }
+
+ @Override
+ public QueryStatus backup(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
+ return null;
+ }
+
+ @Override
+ public QueryStatus restore(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
+ return null;
+ }
+
+ @Override
+ public QueryStatus isAvailable(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
+ return null;
+ }
+
+ @Override
+ public QueryStatus exists(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
+ return null;
+ }
+
+ @Override
+ public QueryStatus query(String s, boolean b, String s1, String key, String prefix, String s4, SvcLogicContext ctx) throws SvcLogicException {
+ if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) {
+ for (Map.Entry<String, String> entry : mockAAI.entrySet()) {
+ ctx.setAttribute(prefix + "." + entry.getKey(), entry.getValue());
+ }
+ return QueryStatus.SUCCESS;
+
+
+ } else if (key.equals("vnf-id = 'test_VNF1'")){
+ return QueryStatus.NOT_FOUND;
+ }
+ else if (key.equals("vnf-id = 'test_VNF3'")){
+ throw new SvcLogicException();
+ }
+ else {
+ return QueryStatus.FAILURE;
+ }
+
+
+ }
+
+ @Override
+ public QueryStatus reserve(String s, String s1, String s2, String s3, SvcLogicContext svcLogicContext) throws SvcLogicException {
+ return null;
+ }
+
+ @Override
+ public QueryStatus save(String s, boolean b, boolean b1, String s1, Map<String, String> map, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
+ return null;
+ }
+
+ @Override
+ public QueryStatus release(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
+ return null;
+ }
+
+ @Override
+ public QueryStatus delete(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
+ return null;
+ }
+
+ @Override
+ public QueryStatus notify(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
+ return null;
+ }
+
+ @Override
+ public QueryStatus update(String s, String key, Map<String, String> data, String prefix, SvcLogicContext ctx) throws SvcLogicException {
+ if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) {
+ for (Map.Entry<String, String> entry : data.entrySet()) {
+ mockAAI.put(entry.getKey(), entry.getValue());
+ }
+ return QueryStatus.SUCCESS;
+
+
+ } else if (key.equals("vnf-id = 'test_VNF1'")){
+ return QueryStatus.NOT_FOUND;
+ }
+ else if (key.equals("vnf-id = 'test_VNF3'")){
+ throw new SvcLogicException();
+ }
+ else {
+ return QueryStatus.FAILURE;
+ }
+
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java
new file mode 100644
index 000000000..8d6fea0cf
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java
@@ -0,0 +1,260 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.aai.impl;
+
+import org.junit.*;
+import org.junit.runner.RunWith;
+import org.mockito.*;
+import org.openecomp.appc.dg.aai.Constants;
+import org.openecomp.appc.dg.aai.impl.AAIPluginImpl;
+import org.openecomp.appc.dg.common.dao.DAOService;
+import org.openecomp.appc.dg.common.impl.LicenseManagerImpl;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicResource;
+import org.openecomp.sdnc.sli.aai.AAIClient;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+import static org.powermock.api.support.SuppressCode.suppressConstructor;
+
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({AAIPluginImpl.class, FrameworkUtil.class})
+public class AAIPluginImplTest {
+ private AAIPluginImpl aaiPlugin;
+ private AAIClientMock aaiClient;
+
+ private final BundleContext bundleContext= Mockito.mock(BundleContext.class);
+ private final Bundle bundleService=Mockito.mock(Bundle.class);
+ private final ServiceReference sref=Mockito.mock(ServiceReference.class);
+
+ String prefix = "aai.input.data";
+ String vnfId = "test_VNF";
+ String vnfId1 = "test_VNF1";
+ String vnfId2 = "test_VNF2";
+ String vnfId3 = "test_VNF3";
+
+ @Before
+ public void setUp() throws NoSuchFieldException, IllegalAccessException {
+ aaiClient = new AAIClientMock();
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ PowerMockito.when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService);
+ PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext);
+ PowerMockito.when(bundleContext.getServiceReference(Matchers.any(Class.class))).thenReturn(sref);
+ PowerMockito.when(bundleContext.getService(sref)).thenReturn(aaiClient);
+ aaiPlugin = new AAIPluginImpl();
+
+
+ }
+
+
+
+
+ @Test
+ public void testPostGenericVnfData() throws Exception {
+ Map<String, String> params = new HashMap<>();
+ params.put(prefix+"."+"license-key-uuid", "123");
+ params.put(prefix+"."+"license-assignment-group-uuid", "1234");
+ params.put(prefix+"."+"data.license-key", "12345");
+
+ HashMap<String, String> mockAAI = new HashMap<>();
+ aaiClient.setMockAAI(mockAAI);
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("aai.vnfID", vnfId);
+ ctx.setAttribute("aai.prefix", prefix);
+
+ aaiPlugin.postGenericVnfData(params, ctx);
+
+ Assert.assertEquals("wrong license-key-uuid","123", mockAAI.get("license-key-uuid"));
+ Assert.assertEquals("wrong license-assignment-group-uuid","1234", mockAAI.get("license-assignment-group-uuid"));
+ Assert.assertEquals("wrong data.license-key","12345", mockAAI.get("data.license-key"));
+ }
+
+
+ @Test
+ public void testPostGenericVnfDataNegativeVnfNotFound() throws Exception {
+ Map<String, String> params = new HashMap<>();
+ params.put(prefix+"."+"license-key-uuid", "123");
+ params.put(prefix+"."+"license-assignment-group-uuid", "1234");
+ params.put(prefix+"."+"data.license-key", "12345");
+
+ HashMap<String, String> mockAAI = new HashMap<>();
+
+ aaiClient.setMockAAI(mockAAI);
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("aai.vnfID", vnfId1);
+ ctx.setAttribute("aai.prefix", prefix);
+
+ try {
+ aaiPlugin.postGenericVnfData(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ }
+
+ }
+
+
+ @Test
+ public void testPostGenericVnfDataNegativeFailure() throws Exception {
+ Map<String, String> params = new HashMap<>();
+ params.put(prefix+"."+"license-key-uuid", "123");
+ params.put(prefix+"."+"license-assignment-group-uuid", "1234");
+ params.put(prefix+"."+"data.license-key", "12345");
+
+ HashMap<String, String> mockAAI = new HashMap<>();
+
+ aaiClient.setMockAAI(mockAAI);
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("aai.vnfID", vnfId2);
+ ctx.setAttribute("aai.prefix", prefix);
+
+ try {
+ aaiPlugin.postGenericVnfData(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ }
+
+ }
+
+
+ @Test
+ public void testPostGenericVnfDataNegativeSvcLogicException() throws Exception {
+ Map<String, String> params = new HashMap<>();
+ params.put(prefix+"."+"license-key-uuid", "123");
+ params.put(prefix+"."+"license-assignment-group-uuid", "1234");
+ params.put(prefix+"."+"data.license-key", "12345");
+
+ HashMap<String, String> mockAAI = new HashMap<>();
+
+ aaiClient.setMockAAI(mockAAI);
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("aai.vnfID", vnfId3);
+ ctx.setAttribute("aai.prefix", prefix);
+
+ try {
+ aaiPlugin.postGenericVnfData(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ }
+
+ }
+
+ @Test
+ public void testGetGenericVnfData() throws Exception {
+ String vnfNameKey = "vnf-name";
+ String vnfType = "VSCP";
+ String vnfTypeKey = "vnf-type";
+ String provStatus = "Active";
+ String provStatusKey = "prov-status";
+ String orchestrationStatus = "Running";
+ String orchestrationStatusKey = "orchestration-status";
+
+ Map<String, String> params = new HashMap<>();
+ HashMap<String, String> mockAAI = new HashMap<>();
+ mockAAI.put(vnfNameKey,vnfId);
+ mockAAI.put(vnfTypeKey,vnfType);
+ mockAAI.put(provStatusKey, provStatus);
+ mockAAI.put(orchestrationStatusKey, orchestrationStatus);
+ aaiClient.setMockAAI(mockAAI);
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("aai.vnfID", vnfId);
+ ctx.setAttribute("aai.prefix", prefix);
+
+
+ aaiPlugin.getGenericVnfData(params, ctx);
+
+ Assert.assertEquals("wrong "+vnfNameKey,vnfId, ctx.getAttribute(prefix + "." + vnfNameKey));
+ Assert.assertEquals("wrong "+orchestrationStatusKey,orchestrationStatus, ctx.getAttribute(prefix + "." + orchestrationStatusKey));
+ Assert.assertEquals("wrong "+vnfTypeKey,vnfType, ctx.getAttribute(prefix + "." + vnfTypeKey));
+ Assert.assertEquals("wrong "+provStatusKey,provStatus, ctx.getAttribute(prefix + "." + provStatusKey ));
+ }
+
+
+
+
+ @Test
+ public void testGetGenericVnfDataNegativeVnfNotFound() throws Exception {
+
+ Map<String, String> params = new HashMap<>();
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("aai.vnfID", vnfId1);
+ ctx.setAttribute("aai.prefix", prefix);
+
+
+ try {
+ aaiPlugin.getGenericVnfData(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ }
+ }
+
+
+ @Test
+ public void testGetGenericVnfDataNegativeFailure() throws Exception {
+
+ Map<String, String> params = new HashMap<>();
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("aai.vnfID", vnfId2);
+ ctx.setAttribute("aai.prefix", prefix);
+
+ try {
+ aaiPlugin.getGenericVnfData(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ }
+ }
+
+
+ @Test
+ public void testGetGenericVnfDataNegativeSvcLogicException() throws Exception {
+
+ Map<String, String> params = new HashMap<>();
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("aai.vnfID", vnfId3);
+ ctx.setAttribute("aai.prefix", prefix);
+
+ try {
+ aaiPlugin.getGenericVnfData(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ }
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/.gitignore b/appc-dg/appc-dg-shared/appc-dg-common/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-dg/appc-dg-shared/appc-dg-common/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/pom.xml b/appc-dg/appc-dg-shared/appc-dg-common/pom.xml
new file mode 100644
index 000000000..e41a3cb86
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/pom.xml
@@ -0,0 +1,81 @@
+<?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-dg-shared</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dg-common</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dmaap-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-easymock</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-dg-common</Bundle-SymbolicName>
+ <Export-Package>org.openecomp.appc.dg.common,org.openecomp.appc.dg.common.objects,org.openecomp.appc.dg.common.utils</Export-Package>
+ <Private-Package>org.openecomp.appc.dg.common.impl.*</Private-Package>
+ <Import-Package>!org.apache.log,!org.apache.commons.logging,!groovy.lang,!javax.jms,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.jasypt.*,*</Import-Package>
+ <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/DCAEReporterPlugin.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/DCAEReporterPlugin.java
new file mode 100644
index 000000000..a99038063
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/DCAEReporterPlugin.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+public interface DCAEReporterPlugin extends SvcLogicJavaPlugin {
+ void report(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void reportSuccess(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/JsonDgUtil.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/JsonDgUtil.java
new file mode 100644
index 000000000..2b3fbf793
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/JsonDgUtil.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+public interface JsonDgUtil extends SvcLogicJavaPlugin {
+ void flatAndAddToContext(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/LegacyUtil.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/LegacyUtil.java
new file mode 100644
index 000000000..a356a1546
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/LegacyUtil.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+
+public interface LegacyUtil extends SvcLogicJavaPlugin {
+
+ void prepareRequest(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void convertPositiveResponse(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void convertNegativeResponse(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/Constants.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/Constants.java
new file mode 100644
index 000000000..92d23e3a6
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/Constants.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.impl;
+
+
+
+class Constants {
+
+ public static final String DG_ERROR_FIELD_NAME = "org.openecomp.appc.dg.error";
+ public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+ public static final String API_VERSION_FIELD_NAME = "org.openecomp.appc.apiversion";
+ public static final String REQ_ID_FIELD_NAME = "org.openecomp.appc.reqid";
+ public static final String PAYLOAD = "payload";
+
+ enum LegacyAttributes {
+ Action("org.openecomp.appc.action"),
+ VMID("org.openecomp.appc.vmid"),
+ IdentityURL("org.openecomp.appc.identity.url"),
+ TenantID("org.openecomp.appc.tenant.id");
+
+ private String value;
+ LegacyAttributes(String value) {this.value = value;}
+ String getValue() {return value;}
+ };
+
+ enum LCMAttributes {
+ Action("input.action"),
+ Payload("input.payload"),
+ VMID("vm-id"),
+ IdentityURL("identity-url"),
+ TenantID("tenant.id");
+
+ private String value;
+ LCMAttributes(String value) {this.value = value;}
+ String getValue() {return value;}
+ };
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImpl.java
new file mode 100644
index 000000000..4458de10b
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImpl.java
@@ -0,0 +1,121 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.impl;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.appc.adapter.dmaap.EventSender;
+import org.openecomp.appc.adapter.dmaap.DmaapDestination;
+import org.openecomp.appc.adapter.dmaap.event.EventHeader;
+import org.openecomp.appc.adapter.dmaap.event.EventMessage;
+import org.openecomp.appc.adapter.dmaap.event.EventStatus;
+import org.openecomp.appc.dg.common.DCAEReporterPlugin;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Map;
+
+public class DCAEReporterPluginImpl implements DCAEReporterPlugin {
+
+ private EventSender eventSender;
+
+ public DCAEReporterPluginImpl() {
+ BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+ ServiceReference sref = bctx.getServiceReference(EventSender.class);
+ eventSender = (EventSender) bctx.getService(sref);
+ }
+
+ @Override
+ public void report(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Integer errorReportCode = 501;
+ boolean bwcMode = Boolean.parseBoolean(ctx.getAttribute("isBwcMode"));
+ String errorDescription,apiVersion,eventId ;
+ errorDescription = getErrorDescriptionAndAddToCtx(bwcMode,params,ctx);
+ if(!bwcMode){
+ apiVersion = ctx.getAttribute("input.common-header.api-ver");
+ eventId = ctx.getAttribute("input.common-header.request-id");
+ }else {
+ apiVersion = ctx.getAttribute(Constants.API_VERSION_FIELD_NAME);
+ eventId = ctx.getAttribute(Constants.REQ_ID_FIELD_NAME);
+ }
+
+ EventMessage eventMessage = new EventMessage(new EventHeader((new java.util.Date()).toString(), apiVersion, eventId), new EventStatus(errorReportCode, errorDescription));
+ eventSender.sendEvent(DmaapDestination.DCAE, eventMessage);
+ }
+
+ private String getErrorDescriptionAndAddToCtx(boolean bwcMode, Map<String, String> params, SvcLogicContext ctx) {
+ String errorDescription;
+ if(!bwcMode) {
+ errorDescription = params.get(Constants.DG_OUTPUT_STATUS_MESSAGE);
+ if(StringUtils.isEmpty(errorDescription)) {
+ errorDescription = ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE);
+ }else {
+ addToContextIfNotContains(bwcMode,errorDescription,ctx);
+ }
+ }else{
+ errorDescription = params.get(Constants.DG_ERROR_FIELD_NAME);
+ if(StringUtils.isEmpty(errorDescription)) {
+ errorDescription = ctx.getAttribute("org.openecomp.appc.dg.error");
+ }else {
+ addToContextIfNotContains(bwcMode, errorDescription,ctx);
+ }
+ }
+
+ if(StringUtils.isEmpty(errorDescription)) {
+ errorDescription = "Unknown";
+ }
+ return errorDescription;
+ }
+
+ private void addToContextIfNotContains(boolean bwcMode, String errorDescription, SvcLogicContext ctx) {
+ String errorDescriptionFromCtx;
+ if(!StringUtils.isEmpty(errorDescription)) {
+ String outputStatusMessageProperty = bwcMode ? "org.openecomp.appc.dg.error" : Constants.DG_OUTPUT_STATUS_MESSAGE;
+ errorDescriptionFromCtx = ctx.getAttribute(outputStatusMessageProperty);
+ if(StringUtils.isEmpty(errorDescriptionFromCtx)){
+ ctx.setAttribute(outputStatusMessageProperty, errorDescription);
+ }else if (!errorDescriptionFromCtx.contains(errorDescription)){
+ ctx.setAttribute(outputStatusMessageProperty, errorDescriptionFromCtx+ " | "+ errorDescription);
+ }
+ }
+ }
+
+
+ @Override
+ public void reportSuccess(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Integer successReportCode = 500;
+ String successDescription, apiVersion, eventId;
+ successDescription = params.get(Constants.DG_OUTPUT_STATUS_MESSAGE);
+ apiVersion = ctx.getAttribute("input.common-header.api-ver");
+ eventId = ctx.getAttribute("input.common-header.request-id");
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, successDescription);
+
+ if (null == successDescription) {
+ successDescription = "Success";
+ }
+ EventMessage eventMessage = new EventMessage(new EventHeader((new java.util.Date()).toString(), apiVersion, eventId), new EventStatus(successReportCode, successDescription));
+ eventSender.sendEvent(DmaapDestination.DCAE, eventMessage);
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImpl.java
new file mode 100644
index 000000000..95191132a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImpl.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.impl;
+
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.appc.dg.common.JsonDgUtil;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.util.JsonUtil;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import java.util.Map;
+
+
+public class JsonDgUtilImpl implements JsonDgUtil {
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(JsonDgUtilImpl.class);
+
+ @Override
+ public void flatAndAddToContext(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to flatAndAddToContext with params = "+ ObjectUtils.toString(params)+", SvcLogicContext = "+ObjectUtils.toString(ctx));
+ }
+ try {
+ String paramName = Constants.PAYLOAD;
+ String payload = params.get(paramName);
+ if (payload == "")
+ payload = ctx.getAttribute("input.payload");
+ if (!StringUtils.isEmpty(payload)) {
+ Map<String, String> flatMap = JsonUtil.convertJsonStringToFlatMap(payload);
+ if (flatMap != null && flatMap.size() > 0) {
+ for (Map.Entry<String, String> entry : flatMap.entrySet()) {
+ ctx.setAttribute(entry.getKey(), entry.getValue());
+ }
+ }
+ } else {
+ logger.warn("input payload param value is empty (\"\") or null");
+ }
+ } catch (Exception e) {
+ logger.error(e.toString());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.toString());
+ throw new APPCException(e);
+ }
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/LegacyUtilImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/LegacyUtilImpl.java
new file mode 100644
index 000000000..6354b2044
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/impl/LegacyUtilImpl.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.impl;
+
+import java.util.Map;
+
+import org.openecomp.appc.dg.common.LegacyUtil;
+import org.openecomp.appc.dg.common.utils.JSONUtil;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+
+
+public class LegacyUtilImpl implements LegacyUtil {
+
+ @Override public void prepareRequest(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ ctx.setAttribute(Constants.LegacyAttributes.Action.getValue(), ctx.getAttribute(Constants.LCMAttributes.Action.getValue()).toLowerCase());
+
+ String payloadStr = ctx.getAttribute(Constants.LCMAttributes.Payload.getValue());
+ Map<String,String> payloads = JSONUtil.extractPlainValues(payloadStr,
+ Constants.LCMAttributes.VMID.getValue(), Constants.LCMAttributes.IdentityURL.getValue(), Constants.LCMAttributes.TenantID.getValue());
+
+ ctx.setAttribute(Constants.LegacyAttributes.VMID.getValue(), payloads.get(Constants.LCMAttributes.VMID.getValue()));
+ ctx.setAttribute(Constants.LegacyAttributes.IdentityURL.getValue(), payloads.get(Constants.LCMAttributes.IdentityURL.getValue()));
+ ctx.setAttribute(Constants.LegacyAttributes.TenantID.getValue(), payloads.get(Constants.LCMAttributes.TenantID.getValue()));
+
+ }
+
+ @Override
+ public void convertPositiveResponse(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ }
+
+ @Override
+ public void convertNegativeResponse(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/objects/ConnectionDetails.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/objects/ConnectionDetails.java
new file mode 100644
index 000000000..d576555c4
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/objects/ConnectionDetails.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.objects;
+
+
+
+public class ConnectionDetails {
+
+ private String host;
+ private int port;
+ private String username;
+ private String password;
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JAXBUtil.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JAXBUtil.java
new file mode 100644
index 000000000..a298e9cca
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JAXBUtil.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.utils;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+
+
+public class JAXBUtil {
+
+ public static <T> T toObject(String xml, Class<T> type) throws JAXBException {
+
+ //create JAXB context
+ JAXBContext context = JAXBContext.newInstance(type);
+
+ //Create Unmarshaller using JAXB context
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+
+ InputStream xmlInputStream = new ByteArrayInputStream(xml.getBytes());
+ BufferedReader reader = new BufferedReader(new InputStreamReader(xmlInputStream));
+
+ return type.cast(unmarshaller.unmarshal(reader));
+
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JSONUtil.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JSONUtil.java
new file mode 100644
index 000000000..fe7197482
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/openecomp/appc/dg/common/utils/JSONUtil.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.utils;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.*;
+
+
+public class JSONUtil {
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ public static <T> T fromJson(String json, Class<T> clazz) {
+
+ try {
+ return OBJECT_MAPPER.readValue(json, clazz);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static <T> T fromJson(Reader reader, Class<T> clazz) {
+
+ try {
+ return OBJECT_MAPPER.readValue(reader, clazz);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static String toJson(Object object) {
+
+ try {
+ return OBJECT_MAPPER.writeValueAsString(object);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Map<String,String> extractPlainValues(String json, String ... names) {
+ if (null == names) return Collections.emptyMap();
+ Map<String,String> values = new HashMap<>();
+ try {
+ final JsonNode jsonNode = OBJECT_MAPPER.readTree(json);
+ for (String name : names) {
+ values.put(name, jsonNode.path(name).asText());
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return values;
+ }
+
+
+
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..53b5367e4
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T 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=========================================================
+ -->
+
+<!--
+ Starter Blueprint Camel Definition appc-aai-adapter-blueprint
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <bean id="JsonDgUtilBean" class="org.openecomp.appc.dg.common.impl.JsonDgUtilImpl"/>
+ <service id="JsonDgUtil" interface="org.openecomp.appc.dg.common.JsonDgUtil" ref="JsonDgUtilBean"/>
+
+ <reference id="eventSenderRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.adapter.dmaap.EventSender" />
+
+ <bean id="DCAEReporterPluginBean" class="org.openecomp.appc.dg.common.impl.DCAEReporterPluginImpl" scope="singleton"/>
+ <service id="DCAEReporterPlugin" interface="org.openecomp.appc.dg.common.DCAEReporterPlugin" ref="DCAEReporterPluginBean"/>
+
+ <bean id="legacyUtilBean" class="org.openecomp.appc.dg.common.impl.LegacyUtilImpl" scope="singleton"/>
+ <service id="legacyUtil" interface="org.openecomp.appc.dg.common.LegacyUtil" ref="legacyUtilBean"/>
+
+</blueprint>
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/org/openecomp/appc/default.properties b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..d8451ee8b
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,47 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T 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=========================================================
+###
+
+org.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+org.openecomp.appc.netconf.db.url.netconfctl=jdbc:mysql://127.0.0.1:3306/test
+org.openecomp.appc.netconf.db.user.netconfctl=test
+org.openecomp.appc.netconf.db.pass.netconfctl=123456
+
+org.openecomp.appc.db.url.sdnctl=jdbc:mysql://127.0.0.1:3306/test
+org.openecomp.appc.db.user.sdnctl=test
+org.openecomp.appc.db.pass.sdnctl=123456
+
+org.openecomp.appc.netconf.db.url.sdnctl=jdbc:mysql://127.0.0.1:3306/test
+org.openecomp.appc.netconf.db.user.sdnctl=test
+org.openecomp.appc.netconf.db.pass.sdnctl=123456
+
+### ###
+### Properties commented out below provided in appc.properties ###
+### ###
+#event.pool.members=<MY_DMAAP_URL>
+event.topic.write=APPC-TEST1
+event.client.key=VIlbtVl6YLhNUrtU
+event.client.secret=64AG2hF4pYeG2pq7CT6XwUOT
+#restconf.user=<RESTCONF_USER>
+#restconf.pass=<RESTCONF_PASSWORD>
+
+org.openecomp.appc.adapter.netconf.VNFOperationalStateValidatorImpl-CONFIG_FILE=VnfGetOperationalStates
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/xsd/vf-license-model.xsd b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/xsd/vf-license-model.xsd
new file mode 100644
index 000000000..9fb979609
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/resources/xsd/vf-license-model.xsd
@@ -0,0 +1,88 @@
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="vf-license-model">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="vnf-id"/>
+ <xs:element type="xs:string" name="vendor-name"/>
+ <xs:element name="feature-group-list">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="feature-group">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="feature-group-uuid"/>
+ <xs:element type="xs:string" name="name"/>
+ <xs:element type="xs:string" name="description"/>
+ <xs:element type="xs:string" name="att-part-number"/>
+ <xs:element name="entitlement-pool-list">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="entitlement-pool">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="entitlement-pool-uuid"/>
+ <xs:element type="xs:string" name="name"/>
+ <xs:element type="xs:string" name="description"/>
+ <xs:element type="xs:string" name="manufacturer-reference-number"/>
+ <xs:element name="threshold-value">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:byte" name="value"/>
+ <xs:element type="xs:string" name="unit"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="entitlement-metric">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="value"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element type="xs:string" name="increments"/>
+ <xs:element name="aggregation-function">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="value"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="time">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="value"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="license-key-group-list">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="license-key-group">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element type="xs:string" name="license-key-group-uuid"/>
+ <xs:element type="xs:string" name="name"/>
+ <xs:element type="xs:string" name="description"/>
+ <xs:element type="xs:string" name="type"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImplTest.java
new file mode 100644
index 000000000..9b8290004
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/DCAEReporterPluginImplTest.java
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.impl;
+
+import org.junit.*;
+import org.junit.runner.RunWith;
+import org.mockito.*;
+import org.openecomp.appc.adapter.dmaap.EventSender;
+import org.openecomp.appc.adapter.dmaap.DmaapDestination;
+import org.openecomp.appc.adapter.dmaap.event.EventMessage;
+import org.openecomp.appc.dg.common.impl.Constants;
+import org.openecomp.appc.dg.common.impl.DCAEReporterPluginImpl;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import java.util.HashMap;
+import java.util.Map;
+
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({DCAEReporterPluginImpl.class, FrameworkUtil.class})
+public class DCAEReporterPluginImplTest {
+ private SvcLogicContext ctx;
+ private Map<String, String> params;
+
+ private final BundleContext bundleContext=Mockito.mock(BundleContext.class);
+ private final Bundle bundleService=Mockito.mock(Bundle.class);
+ private final ServiceReference sref=Mockito.mock(ServiceReference.class);
+
+
+ private DCAEReporterPluginImpl dcaeReporterPlugin;
+ private EventSenderMock eventSender;
+
+ private String apiVer = "2.0.0";
+ private String requestId = "123";
+ private String error = "test-error";
+
+ @Before
+ public void setUp() throws NoSuchFieldException, IllegalAccessException {
+ eventSender = new EventSenderMock();
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ PowerMockito.when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService);
+ PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext);
+ PowerMockito.when(bundleContext.getServiceReference(Matchers.any(Class.class))).thenReturn(sref);
+ PowerMockito.when(bundleContext.getService(sref)).thenReturn(eventSender);
+ dcaeReporterPlugin = new DCAEReporterPluginImpl();
+
+ }
+
+
+
+
+ @Test
+ public void testReportBwcTrue() throws Exception {
+
+ ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ ctx.setAttribute("isBwcMode", "true");
+ params.put(Constants.DG_ERROR_FIELD_NAME, error);
+ ctx.setAttribute(Constants.API_VERSION_FIELD_NAME, apiVer);
+ ctx.setAttribute(Constants.REQ_ID_FIELD_NAME, requestId);
+
+ positiveAssert();
+ }
+
+ @Test
+ public void testReportErrorDescriptionNullBwcModeTrue() throws Exception {
+
+ ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ ctx.setAttribute("isBwcMode", "true");
+ params.put(Constants.DG_ERROR_FIELD_NAME, null);
+ ctx.setAttribute(Constants.API_VERSION_FIELD_NAME, apiVer);
+ ctx.setAttribute(Constants.REQ_ID_FIELD_NAME, requestId);
+
+ errorReasonNullAssert();
+ }
+
+ @Test
+ public void testReportErrorDescriptionNullBwcModeFalse() throws Exception {
+
+ ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ ctx.setAttribute("isBwcMode", "false");
+ params.put("output.status.message", null);
+ ctx.setAttribute("input.common-header.api-ver", apiVer);
+ ctx.setAttribute("input.common-header.request-id", requestId);
+
+ errorReasonNullAssert();
+ }
+
+
+ private void errorReasonNullAssert() throws APPCException {
+ dcaeReporterPlugin.report(params, ctx);
+ DmaapDestination destination = eventSender.getDestination();
+ EventMessage msg = eventSender.getMsg();
+ Assert.assertEquals("wrong API version", apiVer, msg.getEventHeader().getApiVer());
+ Assert.assertEquals("wrong requestId", requestId, msg.getEventHeader().getEventId());
+ Assert.assertEquals("wrong error message", "Unknown", msg.getEventStatus().getReason());
+ Assert.assertEquals("wrong destination", destination.name(), "DCAE");
+
+ }
+
+
+ private void positiveAssert() throws APPCException {
+ dcaeReporterPlugin.report(params, ctx);
+ DmaapDestination destination = eventSender.getDestination();
+ EventMessage msg = eventSender.getMsg();
+ Assert.assertEquals("wrong API version", apiVer, msg.getEventHeader().getApiVer());
+ Assert.assertEquals("wrong requestId", requestId, msg.getEventHeader().getEventId());
+ Assert.assertEquals("wrong error message", error, msg.getEventStatus().getReason());
+ Assert.assertEquals("wrong destination", destination.name(), "DCAE");
+
+ }
+
+
+ @Test
+ public void testReportBwcFalse() throws Exception {
+ ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ ctx.setAttribute("isBwcMode", "false");
+ params.put("output.status.message", error);
+ ctx.setAttribute("input.common-header.api-ver", apiVer);
+ ctx.setAttribute("input.common-header.request-id", requestId);
+
+ positiveAssert();
+
+ }
+ }
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/EventSenderMock.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/EventSenderMock.java
new file mode 100644
index 000000000..0e6b1651b
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/EventSenderMock.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.impl;
+
+import java.util.Map;
+
+import org.openecomp.appc.adapter.dmaap.EventSender;
+import org.openecomp.appc.adapter.dmaap.DmaapDestination;
+import org.openecomp.appc.adapter.dmaap.event.EventMessage;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+
+public class EventSenderMock implements EventSender {
+ EventMessage msg;
+ DmaapDestination destination;
+
+ @Override
+ public boolean sendEvent(DmaapDestination destination, EventMessage msg) {
+ if (destination != null && msg != null){
+ this.msg = msg;
+ this.destination = destination;
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+ @Override
+ public boolean sendEvent(DmaapDestination destination, Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ return false;
+ }
+
+ public EventMessage getMsg() {
+ return msg;
+ }
+
+ public DmaapDestination getDestination() {
+ return destination;
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImplTest.java
new file mode 100644
index 000000000..70534872d
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/openecomp/appc/dg/common/impl/JsonDgUtilImplTest.java
@@ -0,0 +1,145 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.common.impl;
+
+import ch.qos.logback.core.Appender;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.appc.dg.common.impl.JsonDgUtilImpl;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
+public class JsonDgUtilImplTest {
+
+ private final Appender appender = mock(Appender.class);
+
+
+ @Test
+ public void testFlatAndAddToContext() throws Exception {
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String key = "payload";
+ String testValueKey = "test-key";
+ String testValueValue = "test-value";
+ String testValueKey2 = "test-key2";
+ String testValueValue2 = "test-value2";
+ String payload = "{\"" + testValueKey + "\": \"" + testValueValue + "\",\""+testValueKey2+"\": \""+testValueValue2+"\"}";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ params.put(key, payload);
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+
+ Assert.assertEquals(ctx.getAttribute(testValueKey), testValueValue);
+ Assert.assertEquals(ctx.getAttribute(testValueKey2), testValueValue2);
+
+
+
+ }
+
+
+ @Test
+ public void testFlatAndAddToContextNegativeWrongPayload() throws Exception {
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String key = "payload";
+ String testValueKey = "test-key";
+ String testValueValue = "test-value";
+ String testValueKey2 = "test-key2";
+ String testValueValue2 = "test-value2";
+ String payload = "{{\"" + testValueKey + "\": \"" + testValueValue + "\",\""+testValueKey2+"\": \""+testValueValue2+"\"}";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ params.put(key, payload);
+ try {
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+ } catch (APPCException e) {
+ Assert.assertNull(ctx.getAttribute(testValueKey));
+ Assert.assertNull(ctx.getAttribute(testValueKey2));
+ Assert.assertNotNull(ctx.getAttribute("output.status.message"));
+ }
+
+
+ }
+
+
+ @Test
+ public void testFlatAndAddToContextPayloadFromContext() throws Exception {
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String key = "payload";
+ String testValueKey = "test-key";
+ String testValueValue = "test-value";
+ String testValueKey2 = "test-key2";
+ String testValueValue2 = "test-value2";
+ String payload = "{\"" + testValueKey + "\": \"" + testValueValue + "\",\""+testValueKey2+"\": \""+testValueValue2+"\"}";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ params.put(key, "");
+ ctx.setAttribute("input.payload", payload);
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+
+ Assert.assertEquals(ctx.getAttribute(testValueKey), testValueValue);
+ Assert.assertEquals(ctx.getAttribute(testValueKey2), testValueValue2);
+ }
+
+ @Test
+ public void testFlatAndAddToContextNegativeNullPayload() throws Exception {
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String testValueKey = "test-key";
+ String testValueKey2 = "test-key2";
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+
+ Assert.assertNull(ctx.getAttribute(testValueKey));
+ Assert.assertNull(ctx.getAttribute(testValueKey2));
+ }
+
+
+ @Test
+ public void testFlatAndAddToContextNegativeEmptyPayload() throws Exception {
+
+ JsonDgUtilImpl jsonDgUtil = new JsonDgUtilImpl();
+ String key = "payload";
+ String testValueKey = "test-key";
+ String testValueKey2 = "test-key2";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ params.put(key, "");
+ jsonDgUtil.flatAndAddToContext(params, ctx);
+
+ Assert.assertNull(ctx.getAttribute(testValueKey));
+ Assert.assertNull(ctx.getAttribute(testValueKey2));
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-license-manager/.gitignore b/appc-dg/appc-dg-shared/appc-dg-license-manager/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-license-manager/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dg/appc-dg-shared/appc-dg-license-manager/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-dg/appc-dg-shared/appc-dg-license-manager/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-license-manager/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-license-manager/pom.xml b/appc-dg/appc-dg-shared/appc-dg-license-manager/pom.xml
new file mode 100644
index 000000000..63cb7251c
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-license-manager/pom.xml
@@ -0,0 +1,57 @@
+<?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-dg-shared</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dg-license-manager</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-common</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-license-manager-api</artifactId>
+ <version>1.0.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-dg-license-manager</Bundle-SymbolicName>
+ <Export-Package>org.openecomp.appc.dg.licmgr</Export-Package>
+ <Export-Service>org.openecomp.appc.dg.licmgr.LicenseManagerPlugin</Export-Service>
+ <Private-Package>org.openecomp.appc.dg.licmgr.impl</Private-Package>
+ <Import-Package>org.openecomp.appc.licmgr,org.openecomp.appc.licmgr.exception,org.openecomp.appc.licmgr.objects,!org.apache.log,!org.apache.commons.logging,!groovy.lang,!javax.jms,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.jasypt.*,*</Import-Package>
+ <Embed-Dependency>appc-license-manager-api,appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/LicenseManagerPlugin.java b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/LicenseManagerPlugin.java
new file mode 100644
index 000000000..6ca6b6ab5
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/LicenseManagerPlugin.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.licmgr;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+
+public interface LicenseManagerPlugin extends SvcLogicJavaPlugin {
+ /**
+ * Retrieves license model from APPC database and populate flags into svc context
+ * @param params map with parameters:
+ * org.openecomp.appc.vftype - the vnf type / service type;
+ * org.openecomp.appc.resource-version - the vnf version / service version
+ * @param ctx service logic context
+ * 1. supposed properties already in context:
+ * aai.input.data.entitlement-assignment-group-uuid - entitlement-group-uuid asset tag already stored in AAI
+ * aai.input.data.license-assignment-group-uuid - license-key-uuid asset tag already stored in AAI
+ * 2. properties and flags stored in context after bean execution:
+ * model.entitlement.pool.uuid - entitlement-group-uuid from license model
+ * model.license.key.uuid - license-key-uuid from license model
+ * is.acquire-entitlement.require
+ * is.release-entitlement.require
+ * is.acquire-license.require
+ * is.release-license.require
+ *
+ * @throws APPCException throws in case of any error
+ */
+ void retrieveLicenseModel(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/impl/LicenseManagerPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/impl/LicenseManagerPluginImpl.java
new file mode 100644
index 000000000..536a9916e
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/impl/LicenseManagerPluginImpl.java
@@ -0,0 +1,145 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.licmgr.impl;
+
+import java.util.Map;
+
+import org.openecomp.appc.dg.licmgr.LicenseManagerPlugin;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.licmgr.Constants;
+import org.openecomp.appc.licmgr.LicenseManager;
+import org.openecomp.appc.licmgr.exception.DataAccessException;
+import org.openecomp.appc.licmgr.objects.LicenseModel;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+
+
+public class LicenseManagerPluginImpl implements LicenseManagerPlugin {
+
+ private static EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
+
+ // populated by blueprint framework
+ private LicenseManager licenseManager;
+
+ public void setLicenseManager(LicenseManager licenseManager) {
+ this.licenseManager = licenseManager;
+ }
+
+ /**
+ * Retrieves license model from APPC database and populate flags into svc context
+ * @param params map with parameters:
+ * org.openecomp.appc.vftype - the vnf type / service type;
+ * org.openecomp.appc.resource-version - the vnf version / service version
+ * @param ctx service logic context
+ * 1. supposed properties already in context:
+ * aai.input.data.entitlement-assignment-group-uuid - entitlement-group-uuid asset tag already stored in AAI
+ * aai.input.data.license-assignment-group-uuid - license-key-uuid asset tag already stored in AAI
+ * 2. properties and flags stored in context after bean execution:
+ * model.entitlement.pool.uuid - entitlement-group-uuid from license model
+ * model.license.key.uuid - license-key-uuid from license model
+ * is.acquire-entitlement.require
+ * is.release-entitlement.require
+ * is.acquire-license.require
+ * is.release-license.require
+ * is.aai-entitlement-update.require
+ * is.aai-license-update.require
+ *
+ * @throws APPCException throws in case of any error
+ */
+ @Override
+ public void retrieveLicenseModel(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+
+ try {
+
+ LicenseModel licenseModel = licenseManager.retrieveLicenseModel(params.get(Constants.VNF_TYPE_FIELD_NAME), params.get(Constants.VNF_RESOURCE_VERSION_FIELD_NAME));
+
+ String modelEntitlementPoolUuid = licenseModel.getEntitlementPoolUuid(); if (null == modelEntitlementPoolUuid) modelEntitlementPoolUuid = "";
+ String aaiEntitlementPoolUuid = ctx.getAttribute(Constants.AAI_ENTITLMENT_POOL_UUID_NAME); if (null == aaiEntitlementPoolUuid) aaiEntitlementPoolUuid = "";
+ boolean isAcquireEntitlementRequire = !modelEntitlementPoolUuid.isEmpty() && !modelEntitlementPoolUuid.equals(aaiEntitlementPoolUuid);
+ boolean isReleaseEntitlementRequire = !aaiEntitlementPoolUuid.isEmpty() && (isAcquireEntitlementRequire || modelEntitlementPoolUuid.isEmpty());
+ boolean isAAIEntitlementUpdateRequire = isAcquireEntitlementRequire || isReleaseEntitlementRequire;
+ ctx.setAttribute(Constants.MODEL_ENTITLMENT_POOL_UUID_NAME, modelEntitlementPoolUuid);
+ ctx.setAttribute(Constants.IS_ACQUIRE_ENTITLEMENT_REQUIRE, Boolean.toString(isAcquireEntitlementRequire));
+ ctx.setAttribute(Constants.IS_RELEASE_ENTITLEMENT_REQUIRE, Boolean.toString(isReleaseEntitlementRequire));
+ ctx.setAttribute(Constants.IS_AAI_ENTITLEMENT_UPDATE_REQUIRE, Boolean.toString(isAAIEntitlementUpdateRequire));
+
+
+ String modelLicenseKeyGroupUuid = licenseModel.getLicenseKeyGroupUuid(); if (null == modelLicenseKeyGroupUuid) modelLicenseKeyGroupUuid = "";
+ String aaiLicenseKeyGroupUuid = ctx.getAttribute(Constants.AAI_LICENSE_KEY_UUID_NAME); if (null == aaiLicenseKeyGroupUuid) aaiLicenseKeyGroupUuid = "";
+ String aaiLicenseKeyValue = ctx.getAttribute(Constants.AAI_LICENSE_KEY_VALUE); if (null == aaiLicenseKeyValue) aaiLicenseKeyValue = "";
+ boolean isAcquireLicenseRequire = !modelLicenseKeyGroupUuid.isEmpty() && !modelLicenseKeyGroupUuid.equals(aaiLicenseKeyGroupUuid);
+ boolean isReleaseLicenseRequire = !aaiLicenseKeyGroupUuid.isEmpty() && (isAcquireLicenseRequire || modelLicenseKeyGroupUuid.isEmpty());
+ boolean isAAILicenseUpdateRequire = isAcquireLicenseRequire || isReleaseLicenseRequire;
+ ctx.setAttribute(Constants.MODEL_LICENSE_KEY_UUID_NAME, modelLicenseKeyGroupUuid);
+ ctx.setAttribute(Constants.IS_ACQUIRE_LICENSE_REQUIRE, Boolean.toString(isAcquireLicenseRequire));
+ ctx.setAttribute(Constants.IS_RELEASE_LICENSE_REQUIRE, Boolean.toString(isReleaseLicenseRequire));
+ ctx.setAttribute(Constants.IS_AAI_LICENSE_UPDATE_REQUIRE, Boolean.toString(isAAILicenseUpdateRequire));
+
+ ctx.setAttribute("license-key", aaiLicenseKeyValue);
+
+ } catch (DataAccessException le) {
+ logger.error("Error " + le.getMessage());
+ ctx.setAttribute("output.status.message", le.getMessage());
+ throw new APPCException(le);
+ }
+
+ }
+
+
+
+ //////// code uses jaxb license model, should be fixed
+ /*
+ final VfLicenseModel.FeatureGroupList featureGroupList = licenseModel.getFeatureGroupList();
+ if (null != featureGroupList) {
+ final VfLicenseModel.FeatureGroupList.FeatureGroup featureGroup = featureGroupList.getFeatureGroup();
+ if (null != featureGroup) {
+ final VfLicenseModel.FeatureGroupList.FeatureGroup.EntitlementPoolList
+ entitlementPoolList = featureGroup.getEntitlementPoolList();
+ if (null != entitlementPoolList) {
+ final VfLicenseModel.FeatureGroupList.FeatureGroup.EntitlementPoolList.EntitlementPool
+ entitlementPool = entitlementPoolList.getEntitlementPool();
+ if (null != entitlementPool) {
+ final String entitlementPoolUuid = entitlementPool.getEntitlementPoolUuid();
+ // add entitlementPoolUuid into context
+ ctx.setAttribute(Constants.MODEL_ENTITLMENT_POOL_UUID_NAME, entitlementPoolUuid);
+ }
+ }
+
+ final VfLicenseModel.FeatureGroupList.FeatureGroup.LicenseKeyGroupList
+ licenseKeyGroupList = featureGroup.getLicenseKeyGroupList();
+ if (null != licenseKeyGroupList) {
+ final VfLicenseModel.FeatureGroupList.FeatureGroup.LicenseKeyGroupList.LicenseKeyGroup
+ licenseKeyGroup = licenseKeyGroupList.getLicenseKeyGroup();
+ if (null != licenseKeyGroup) {
+ final String licenseKeyGroupUuid = licenseKeyGroup.getLicenseKeyGroupUuid();
+ // add licenseKeyGroupUuid into context
+ ctx.setAttribute(Constants.MODEL_LICENSE_KEY_UUID_NAME, licenseKeyGroupUuid);
+ }
+ }
+ }
+ }
+ */
+
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..ab2df8ba9
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T 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=========================================================
+ -->
+
+<!--
+ Starter Blueprint Camel Definition appc-aai-adapter-blueprint
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+
+ <reference id="LicenseManagerRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.licmgr.LicenseManager" />
+
+ <bean id="LicenseManagerPluginBean" class="org.openecomp.appc.dg.licmgr.impl.LicenseManagerPluginImpl" scope="singleton">
+ <property name="licenseManager" ref="LicenseManagerRef" />
+ </bean>
+ <service id="LicenseManagerPlugin" interface="org.openecomp.appc.dg.licmgr.LicenseManagerPlugin" ref="LicenseManagerPluginBean"/>
+
+</blueprint>
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/.gitignore b/appc-dg/appc-dg-shared/appc-dg-netconf/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-dg/appc-dg-shared/appc-dg-netconf/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/pom.xml b/appc-dg/appc-dg-shared/appc-dg-netconf/pom.xml
new file mode 100644
index 000000000..c9ec4d9b8
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/pom.xml
@@ -0,0 +1,89 @@
+<?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-dg-shared</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dg-netconf</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-netconf-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-common</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+
+
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-dg-netconf</Bundle-SymbolicName>
+ <Export-Package>org.openecomp.appc.dg.netconf</Export-Package>
+ <Private-Package>org.openecomp.appc.dg.netconf.impl.*</Private-Package>
+ <Import-Package>!org.apache.log,!org.apache.commons.logging,!groovy.lang,!javax.jms,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.jasypt.*,*</Import-Package>
+ <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/NetconfClientPlugin.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/NetconfClientPlugin.java
new file mode 100644
index 000000000..3b75f4070
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/NetconfClientPlugin.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+
+public interface NetconfClientPlugin extends SvcLogicJavaPlugin {
+ void configure(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void operationStateValidation(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void modifyConfiguration(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void backupConfiguration(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void getConfig(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void getRunningConfig(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/NetconfDBPlugin.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/NetconfDBPlugin.java
new file mode 100644
index 000000000..a48be94c7
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/NetconfDBPlugin.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+
+public interface NetconfDBPlugin extends SvcLogicJavaPlugin {
+ void retrieveDSConfiguration(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void retrieveVMDSConfiguration(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void retrieveConfigFile(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ void retrieveConnectionDetails(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/impl/NetconfClientPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/impl/NetconfClientPluginImpl.java
new file mode 100644
index 000000000..d063b5d28
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/impl/NetconfClientPluginImpl.java
@@ -0,0 +1,316 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.appc.adapter.netconf.*;
+import org.openecomp.appc.adapter.netconf.util.Constants;
+import org.openecomp.appc.dg.netconf.NetconfClientPlugin;
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+
+
+
+public class NetconfClientPluginImpl implements NetconfClientPlugin {
+
+ private static final String NETCONF_CLIENT_FACTORY_NAME = "org.openecomp.appc.adapter.netconf.NetconfClientFactory";
+ private static ObjectMapper mapper = new ObjectMapper();
+ private static EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
+
+ private NetconfDataAccessService dao;
+ private NetconfClientFactory clientFactory;
+
+ public NetconfClientPluginImpl() {
+ BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+ ServiceReference srefNetconfClientFactory = bctx.getServiceReference(NetconfClientFactory.class);
+ clientFactory = (NetconfClientFactory) bctx.getService(srefNetconfClientFactory);
+ }
+
+ public void setDao(NetconfDataAccessService dao) {
+ this.dao = dao;
+ this.dao.setSchema(Constants.NETCONF_SCHEMA);
+ }
+
+ public void configure(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+
+ try {
+ NetconfClient client = clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ try {
+ NetconfConnectionDetails connectionDetails = mapper.readValue(params.get("connection-details"), NetconfConnectionDetails.class);
+ String netconfMessage = params.get("file-content");
+ client.connect(connectionDetails);
+ client.configure(netconfMessage);
+ } catch (IOException e) {
+ logger.error("Error " + e.getMessage());
+ throw new APPCException(e);
+ } finally {
+ client.disconnect();
+ }
+ } catch (Exception e) {
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ logger.error("Error " + e.getMessage());
+ throw e;
+ }
+ }
+
+ @Override
+ public void operationStateValidation(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to operationStateValidation with params = "+ ObjectUtils.toString(params)+", SvcLogicContext = "+ObjectUtils.toString(ctx));
+ }
+ try{
+ String paramName = Constants.VNF_TYPE_FIELD_NAME;
+ String vfType = params.get(paramName);
+ validateMandatoryParam(paramName, vfType);
+ VnfType vnfType = VnfType.getVnfType(vfType);
+
+ paramName = Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME;
+ String vnfHostIpAddress = params.get(paramName);
+ validateMandatoryParam(paramName, vnfHostIpAddress);
+
+ //get connectionDetails
+ String connectionDetailsStr = params.get(Constants.CONNECTION_DETAILS_FIELD_NAME);
+ NetconfConnectionDetails connectionDetails = null;
+ if(StringUtils.isEmpty(connectionDetailsStr)){
+ connectionDetails = retrieveConnectionDetails(vnfType);
+ connectionDetails.setHost(vnfHostIpAddress);
+ ctx.setAttribute(Constants.CONNECTION_DETAILS_FIELD_NAME, mapper.writeValueAsString(connectionDetails));
+ }else{
+ connectionDetails = mapper.readValue(connectionDetailsStr, NetconfConnectionDetails.class);
+ }
+ if(connectionDetails == null){
+ throw new IllegalStateException("missing connectionDetails for VnfType:"+vnfType.name());
+ }
+
+ //get operationsStateNetconfMessage
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(vnfType);
+ String configurationFileName = operationalStateValidator.getConfigurationFileName();
+ String operationsStateNetconfMessage = null;
+ if(!StringUtils.isEmpty(configurationFileName)){
+ operationsStateNetconfMessage = retrieveConfigurationFileContent(configurationFileName);
+ }
+
+ //connect checK Opertaions state and dissconnect
+ NetconfClient client = clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ try {
+ client.connect(connectionDetails);
+ String response = null;
+ if(!StringUtils.isEmpty(operationsStateNetconfMessage)) {
+ response = client.exchangeMessage(operationsStateNetconfMessage);
+ }
+ operationalStateValidator.validateResponse(response);
+ } finally {
+ client.disconnect();
+ }
+ } catch (APPCException e) {
+ logger.error(e.getMessage());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.toString());
+ throw e;
+ }
+ catch (Exception e) {
+ logger.error(e.toString());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.toString());
+ throw new APPCException(e);
+ }
+ }
+
+ @Override
+ public void modifyConfiguration(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ this.configure(params, ctx);
+ }
+
+ @Override
+ public void backupConfiguration(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+
+ NetconfClient client = null;
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Entered backup to DEVICE_INTERFACE_LOG");
+ }
+
+ client = clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ //get connection details
+ NetconfConnectionDetails connectionDetails = mapper.readValue(params.get("connection-details"), NetconfConnectionDetails.class);
+ //connect the client and get configuration
+ client.connect(connectionDetails);
+ String configuration = client.getConfiguration();
+
+ //store configuration in database
+ dao.logDeviceInteraction(null,null,getCurrentDateTime(),configuration);
+
+ } catch (Exception e) {
+ logger.error("Error " + e.getMessage());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw new APPCException(e);
+ } finally {
+ //disconnect the client
+ if(client != null) {
+ client.disconnect();
+ }
+ }
+ }
+
+ @Override
+ public void getConfig(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ NetconfClient client = null;
+ String confId=params.get("conf-id");
+ if(confId.equalsIgnoreCase("current")){
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Entered getConfig to DEVICE_INTERFACE_LOG");
+ }
+ //get netconf client to get configuration
+ BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+ ServiceReference sref = bctx.getServiceReference(NETCONF_CLIENT_FACTORY_NAME);
+ NetconfClientFactory clientFactory = (NetconfClientFactory) bctx.getService(sref);
+ client = clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ //get connection details
+ NetconfConnectionDetails connectionDetails = mapper.readValue(params.get("connection-details"), NetconfConnectionDetails.class);
+ //connect the client and get configuration
+ client.connect(connectionDetails);
+ String configuration = client.getConfiguration();
+ if(configuration !=null){
+ // logger.info("*************************************Configuration Output*************************************");
+ // logger.info(configuration);
+ String fullConfig = ctx.getAttribute("fullConfig");
+ fullConfig = fullConfig==null?"":fullConfig;
+ ctx.setAttribute("fullConfig",fullConfig + configuration);
+
+ ctx.setAttribute("getConfig_Result","Success");
+ String entityName=ctx.getAttribute("entity");//VM name
+ if(entityName!=null){
+ ctx.setAttribute(entityName+".Configuration",configuration);
+ }
+ }else{
+ ctx.setAttribute("getConfig_Result","failure");
+ }
+ //store configuration in database
+ /*NetconfJDBC dsImpl = new NetconfJDBCImpl();
+ dsImpl.logDeviceInteraction(null,null,getCurrentDateTime(),configuration);*/
+
+ } catch (Exception e) {
+ ctx.setAttribute("getConfig_Result","failure");
+ logger.error("Error " + e.getMessage());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw new APPCException(e);
+ } finally {
+ //disconnect the client
+ if(client != null) {
+ client.disconnect();
+ }
+ }
+ }else{
+ logger.info("Current Conf id value is not supported");
+ }
+
+ }
+
+
+ @Override
+ public void getRunningConfig(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ NetconfClient client = null;
+ try {
+ logger.info("Entered getRunningConfig to DEVICE_INTERFACE_LOG");
+ //get netconf client to get configuration
+ BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+ ServiceReference sref = bctx.getServiceReference(NETCONF_CLIENT_FACTORY_NAME);
+ NetconfClientFactory clientFactory = (NetconfClientFactory) bctx.getService(sref);
+ client = clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ //get connection details
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(params.get("host-ip-address"));
+ connectionDetails.setUsername(params.get("user-name"));
+ connectionDetails.setPassword(params.get("password"));
+ connectionDetails.setPort(!("".equalsIgnoreCase(params.get("port-number")))?Integer.parseInt(params.get("port-number")):NetconfConnectionDetails.DEFAULT_PORT);
+ //connect the client and get configuration
+ client.connect(connectionDetails);
+ String configuration = client.getConfiguration();
+ if(configuration !=null){
+ // logger.info("*************************************Configuration Output*************************************");
+ ctx.setAttribute("running-config", configuration);
+
+ ctx.setAttribute("getRunningConfig_Result","Success");
+ }else{
+ ctx.setAttribute("getRunningConfig_Result","failure");
+ }
+ } catch (Exception e) {
+ ctx.setAttribute("getRunningConfig_Result","failure");
+ logger.error("Error " + e.getMessage());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw new APPCException(e);
+ } finally {
+ //disconnect the client
+ if(client != null) {
+ client.disconnect();
+ }
+ }
+ }
+
+ private String getCurrentDateTime() {
+
+ DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+ Date date = new Date();
+ return dateFormat.format(date);
+ }
+
+ private int getPort(String s) {
+ int port = 830;
+ if((s != null) && !s.isEmpty()) {
+ port = Integer.parseInt(s);
+ }
+ return port;
+ }
+
+ void validateMandatoryParam(String paramName, String paramValue) {
+ if(StringUtils.isEmpty(paramValue)){
+ throw new IllegalArgumentException("input "+paramName+" param is empty");
+ }
+ }
+
+ public NetconfConnectionDetails retrieveConnectionDetails( VnfType vnfType) throws APPCException{
+
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ if (!dao.retrieveNetconfConnectionDetails(vnfType.getFamilyType().name(), connectionDetails)) {
+ logger.error("Missing configuration for " + vnfType.getFamilyType().name());
+ throw new APPCException("Missing configuration for " + vnfType.getFamilyType().name() + " in " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME);
+ }
+ return connectionDetails;
+ }
+
+ public String retrieveConfigurationFileContent(String configFileName){
+ return dao.retrieveConfigFileName(configFileName);
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/impl/NetconfDBPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/impl/NetconfDBPluginImpl.java
new file mode 100644
index 000000000..6fdfcc14c
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/java/org/openecomp/appc/dg/netconf/impl/NetconfDBPluginImpl.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.Map;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.NetconfDataAccessService;
+import org.openecomp.appc.adapter.netconf.exception.DataAccessException;
+import org.openecomp.appc.adapter.netconf.util.Constants;
+import org.openecomp.appc.dg.netconf.NetconfDBPlugin;
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+public class NetconfDBPluginImpl implements NetconfDBPlugin {
+
+ private static EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
+ private static ObjectMapper mapper = new ObjectMapper();
+
+ // populated by blueprint framework
+ private NetconfDataAccessService daoService;
+
+ public void setDaoService(NetconfDataAccessService daoService) {
+ this.daoService = daoService;
+ this.daoService.setSchema(Constants.NETCONF_SCHEMA);
+ }
+
+ public NetconfDBPluginImpl() {
+ }
+
+ public void retrieveDSConfiguration(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+
+ try {
+ String fileContent = daoService.retrieveConfigFileName(params.get(Constants.CONFIGURATION_FILE_FIELD_NAME));
+ ctx.setAttribute(Constants.FILE_CONTENT_FIELD_NAME, fileContent);
+ } catch(DataAccessException e) {
+ logger.error("Error " + e.getMessage());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw e;
+ }
+
+ getConnection(params, ctx);
+ }
+
+ @Override
+ public void retrieveVMDSConfiguration(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ logger.info("Setting entity value :" +params.get(Constants.RESOURCEKEY));
+ ctx.setAttribute("entity", params.get(Constants.RESOURCEKEY));
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ try {
+ if (!daoService.retrieveNetconfConnectionDetails(params.get(Constants.RESOURCEKEY), connectionDetails)) {
+ ctx.setAttribute("retrieveVMDSConfiguration_Result","failure");
+ logger.error("Missing configuration for " + params.get(Constants.VNF_TYPE_FIELD_NAME));
+ throw new APPCException("Missing configuration for " + params.get(Constants.VNF_TYPE_FIELD_NAME) + " in " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME);
+ }
+ // fileContent = dsImpl.retrieveConfigFileName(params.get(Constants.CONFIGURATION_FILE_FIELD_NAME));
+ // ctx.setAttribute(Constants.FILE_CONTENT_FIELD_NAME, fileContent);
+ ctx.setAttribute(Constants.CONNECTION_DETAILS_FIELD_NAME, mapper.writeValueAsString(connectionDetails));
+ ctx.setAttribute("retrieveVMDSConfiguration_Result","success");
+ } catch(APPCException e) {
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw e;
+ } catch(DataAccessException | JsonProcessingException e) {
+ logger.error("Error " + e.getMessage());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw new APPCException(e);
+ }
+ }
+
+ @Override
+ public void retrieveConfigFile(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ String fileContent = daoService.retrieveConfigFileName(params.get(Constants.CONFIGURATION_FILE_FIELD_NAME));
+ ctx.setAttribute(Constants.FILE_CONTENT_FIELD_NAME, fileContent);
+ }
+
+ public void retrieveConnectionDetails(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ getConnection(params, ctx);
+ }
+
+ private void getConnection(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ try {
+ if (!daoService.retrieveNetconfConnectionDetails(params.get(Constants.VNF_TYPE_FIELD_NAME), connectionDetails)) {
+ logger.error("Missing configuration for " + params.get(Constants.VNF_TYPE_FIELD_NAME));
+ throw new APPCException("Missing configuration for " + params.get(Constants.VNF_TYPE_FIELD_NAME) + " in " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME);
+ }
+ connectionDetails.setHost(params.get(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME));
+ ctx.setAttribute(Constants.CONNECTION_DETAILS_FIELD_NAME, mapper.writeValueAsString(connectionDetails));
+ } catch(APPCException e) {
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw e;
+ } catch(DataAccessException | JsonProcessingException e) {
+ logger.error("Error " + e.getMessage());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw new APPCException(e);
+ }
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..0b58ce0af
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T 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=========================================================
+ -->
+
+<!--
+ Starter Blueprint Camel Definition appc-aai-adapter-blueprint
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <reference id="DataAccessServiceRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.adapter.netconf.NetconfDataAccessService" />
+
+
+ <bean id="NetconfDBPluginBean" class="org.openecomp.appc.dg.netconf.impl.NetconfDBPluginImpl" scope="singleton">
+ <property name="daoService" ref="DataAccessServiceRef" />
+ </bean>
+ <service id="NetconfDBPlugin" interface="org.openecomp.appc.dg.netconf.NetconfDBPlugin" ref="NetconfDBPluginBean"/>
+
+ <bean id="NetconfClientPluginBean" class="org.openecomp.appc.dg.netconf.impl.NetconfClientPluginImpl" scope="singleton">
+ <property name="dao" ref="DataAccessServiceRef" />
+ </bean>
+ <service id="NetconfClientPlugin" interface="org.openecomp.appc.dg.netconf.NetconfClientPlugin" ref="NetconfClientPluginBean"/>
+
+</blueprint>
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/DAOServiceMock.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/DAOServiceMock.java
new file mode 100644
index 000000000..38d74c300
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/DAOServiceMock.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import java.util.HashMap;
+
+import org.openecomp.appc.adapter.netconf.ConnectionDetails;
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.NetconfDataAccessService;
+import org.openecomp.appc.adapter.netconf.exception.DataAccessException;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+
+class DAOServiceMock implements NetconfDataAccessService {
+
+ private String configFile;
+ private ConnectionDetails connection;
+ private HashMap<String, String> backupConf;
+
+ @Override
+ public void setSchema(String schema) {
+ }
+
+ @Override
+ public void setDbLibService(DbLibService dbLibService) {
+ }
+
+ void setConfigFile(String configFile) {
+ this.configFile = configFile;
+ }
+
+ public HashMap<String, String> getBackupConf() {
+ return backupConf;
+ }
+
+ public void setConnection(ConnectionDetails connection) {
+ this.connection = connection;
+ }
+
+ @Override
+ public String retrieveConfigFileName(String xmlID) throws DataAccessException {
+ if (!xmlID.equals("wrong")) {
+ return configFile;
+ } else {
+ throw new DataAccessException();
+ }
+ }
+
+ @Override
+ public boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws
+ DataAccessException {
+ return false;
+ }
+
+ @Override
+ public boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) throws
+ DataAccessException {
+ if (vnfType.equals("VNF")) {
+ connectionDetails.setHost(connection.getHost());
+ connectionDetails.setPassword(connection.getPassword());
+ connectionDetails.setPort(connection.getPort());
+ connectionDetails.setUsername(connection.getUsername());
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) throws
+ DataAccessException {
+ this.backupConf = new HashMap<>();
+ backupConf.put("creationDate", creationDate);
+ backupConf.put("logText", logText);
+ return true;
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/MockOperationalStateValidatorImpl.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/MockOperationalStateValidatorImpl.java
new file mode 100644
index 000000000..7109fe8e8
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/MockOperationalStateValidatorImpl.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import org.openecomp.appc.adapter.netconf.OperationalStateValidator;
+import org.openecomp.appc.adapter.netconf.VnfType;
+import org.openecomp.appc.exceptions.APPCException;
+
+
+public class MockOperationalStateValidatorImpl implements OperationalStateValidator {
+
+ private boolean validated;
+ private String configurationFileName;
+
+ public boolean isValidated() {
+ return validated;
+ }
+
+ @Override
+ public VnfType getVnfType() {
+ return null;
+ }
+
+ @Override
+ public String getConfigurationFileName() {
+ return configurationFileName;
+ }
+
+ @Override
+ public void validateResponse(String response) throws APPCException {
+ if (response.equals("wrong")) {
+ throw new APPCException();
+ } else {
+ this.validated = true;
+ }
+
+ }
+
+ public void setConfigurationFileName(String configurationFileName) {
+ this.configurationFileName = configurationFileName;
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientFactoryMock.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientFactoryMock.java
new file mode 100644
index 000000000..73dba9a29
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientFactoryMock.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import org.openecomp.appc.adapter.netconf.NetconfClient;
+import org.openecomp.appc.adapter.netconf.NetconfClientFactory;
+import org.openecomp.appc.adapter.netconf.NetconfClientType;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.adapter.netconf.odlconnector.NetconfClientRestconfImpl;
+
+
+public class NetconfClientFactoryMock extends NetconfClientFactory {
+
+ private final NetconfClientJschMock jschClient = new NetconfClientJschMock();
+
+ @Override
+ public NetconfClient GetNetconfClient(NetconfClientType type){
+
+ return jschClient;
+
+ }
+}
+
+
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientJschMock.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientJschMock.java
new file mode 100644
index 000000000..5c01724f1
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientJschMock.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import org.openecomp.appc.adapter.netconf.NetconfClient;
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.exceptions.APPCException;
+
+
+public class NetconfClientJschMock implements NetconfClient {
+
+ private boolean connection;
+ private String lastMessage;
+ private String answer = "answer";
+ private String configuration;
+ private NetconfConnectionDetails lastConnectionDetails;
+
+ public boolean isConnection() {
+ return connection;
+ }
+
+ public String getLastMessage() {
+ return lastMessage;
+ }
+
+ public String getAnswer() {
+ return answer;
+ }
+
+ public String getConf() {
+ return configuration;
+ }
+
+ public void setConf(String configuration) {
+ this.configuration = configuration;
+ }
+
+ public void setAnswer(String answer) {
+ this.answer = answer;
+ }
+
+ public NetconfConnectionDetails getLastConnectionDetails() {
+ return lastConnectionDetails;
+ }
+
+ @Override
+ public void connect(NetconfConnectionDetails connectionDetails) throws APPCException {
+ this.connection = true;
+ this.lastConnectionDetails = connectionDetails;
+
+ }
+
+ @Override
+ public String exchangeMessage(String message) throws APPCException {
+ if (connection) {
+ this.lastMessage = message;
+ return answer;
+ } else return null;
+ }
+
+ @Override
+ public void configure(String configuration) throws APPCException {
+ if (connection) {
+ this.configuration = configuration;
+ }
+
+ }
+
+ @Override
+ public String getConfiguration() throws APPCException {
+ if (connection) {
+ return configuration;
+ } else return null;
+ }
+
+ @Override
+ public void disconnect() throws APPCException {
+ this.connection = false;
+
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientPluginImplTest.java
new file mode 100644
index 000000000..b3bb4858a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfClientPluginImplTest.java
@@ -0,0 +1,678 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+import org.openecomp.appc.adapter.netconf.*;
+import org.openecomp.appc.adapter.netconf.util.Constants;
+import org.openecomp.appc.dg.netconf.impl.NetconfClientPluginImpl;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.lang.reflect.Field;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.powermock.api.mockito.PowerMockito.when;
+
+
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({OperationalStateValidatorFactory.class, NetconfClientPluginImpl.class, FrameworkUtil.class, ObjectMapper.class})
+
+public class NetconfClientPluginImplTest {
+ private NetconfClientPluginImpl netconfClientPlugin;
+ private NetconfDataAccessService dao;
+ private NetconfClientFactory clientFactory;
+ private Map<String, String> params;
+
+ private final BundleContext bundleContext = Mockito.mock(BundleContext.class);
+ private final Bundle bundleService = Mockito.mock(Bundle.class);
+ private final ServiceReference sref1 = Mockito.mock(ServiceReference.class);
+ private final ServiceReference sref2 = Mockito.mock(ServiceReference.class);
+ private final ServiceReference sref3 = Mockito.mock(ServiceReference.class);
+ private static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+
+
+ String host = "http://www.test.com";
+ String host1 = "http://www.test1.com";
+ String vnfType = "VNF";
+ int port = 8080;
+ String username = "test";
+ String password = "test";
+ String connectionDetails = "{\"host\":\"" + host + "\",\"port\":" + port + ",\"username\":\"" + username + "\",\"password\":\"" + password + "\",\"capabilities\":null,\"additionalProperties\":null}";
+ String fileContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ "\t<get-config>\n" +
+ "\t\t<source>\n" +
+ "\t\t\t<running/>\n" +
+ "\t\t </source>\n" +
+ "\t</get-config>\n" +
+ "</rpc>'";
+ String operationalState = "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <get>\n" +
+ " <filter>\n" +
+ " <ManagedElement xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomop:appc:Test\">\n" +
+ " <ProcessorManagement>\n" +
+ " <MatedPair>\n" +
+ " <operationalState/>\n" +
+ " <PayloadProcessor>\n" +
+ " <operationalState/>\n" +
+ " </PayloadProcessor>\n" +
+ " </MatedPair>\n" +
+ " <SystemController>\n" +
+ " <operationalState/>\n" +
+ " </SystemController>\n" +
+ " </ProcessorManagement>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </filter>\n" +
+ " </get>\n" +
+ "</rpc>\n";
+
+
+ @Before
+ public void setUp() throws NoSuchFieldException, IllegalAccessException {
+ clientFactory = new NetconfClientFactoryMock();
+
+ }
+
+
+ @Test
+ public void testConfigure() throws Exception {
+
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ params = new HashMap<>();
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails);
+ params.put(Constants.FILE_CONTENT_FIELD_NAME, fileContent);
+
+ netconfClientPlugin.configure(params, ctx);
+
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+
+ try {
+ Assert.assertEquals("wrong configuration", fileContent, client.getConf());
+ Assert.assertEquals("wrong host", host, client.getLastConnectionDetails().getHost());
+ Assert.assertEquals("wrong port", port, client.getLastConnectionDetails().getPort());
+ Assert.assertEquals("wrong username", username, client.getLastConnectionDetails().getUsername());
+ Assert.assertEquals("wrong password", password, client.getLastConnectionDetails().getPassword());
+ Assert.assertFalse(client.isConnection());
+ } catch (Exception e) {
+ Assert.fail("failed with because of " + e.getCause());
+ }
+
+
+ }
+
+
+ @Test
+ public void testConfigureNegativeIOException() throws Exception {
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ params = new HashMap<>();
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, "{" + connectionDetails);
+ params.put(Constants.FILE_CONTENT_FIELD_NAME, fileContent);
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+
+
+ try {
+ netconfClientPlugin.configure(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNull(client.getLastConnectionDetails());
+ Assert.assertNull(client.getConf());
+ }
+
+ }
+
+ @Test
+ public void testOperationStateValidation() throws Exception {
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ DAOServiceMock daoServiceMock = (DAOServiceMock) dao;
+ daoServiceMock.setConfigFile(fileContent);
+
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setAnswer(operationalState);
+
+
+ params = new HashMap<>();
+ params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType);
+ params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1);
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails);
+ MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl();
+ validatorMock.setConfigurationFileName("VnfGetRunningConfig");
+
+ PowerMockito.mockStatic(OperationalStateValidatorFactory.class);
+ when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock);
+
+ netconfClientPlugin.operationStateValidation(params, ctx);
+
+ Assert.assertTrue("validation process failed", validatorMock.isValidated());
+ Assert.assertEquals(fileContent, client.getLastMessage());
+ }
+
+
+ @Test
+ public void testOperationStateValidationNegativeJsonProcessingNullIllegalStateException() throws Exception {
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ DAOServiceMock daoServiceMock = (DAOServiceMock) dao;
+ daoServiceMock.setConfigFile(fileContent);
+
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setAnswer(operationalState);
+
+ params = new HashMap<>();
+ params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType);
+ params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1);
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails);
+ MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl();
+ validatorMock.setConfigurationFileName("VnfGetRunningConfig");
+
+ PowerMockito.mockStatic(OperationalStateValidatorFactory.class);
+ when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock);
+ substituteMapper(true);
+
+ try {
+ netconfClientPlugin.operationStateValidation(params, ctx);
+ substituteMapper(false);
+ } catch (APPCException e) {
+ substituteMapper(false);
+ Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE));
+ Assert.assertFalse(validatorMock.isValidated());
+ Assert.assertNull(client.getLastMessage());
+ }
+ }
+
+ @Test
+ public void testOperationStateValidationNegativeConnectionDetailsAreNullNullPointerException() throws Exception {
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ DAOServiceMock daoServiceMock = (DAOServiceMock) dao;
+ daoServiceMock.setConfigFile(fileContent);
+
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setAnswer(operationalState);
+
+
+ params = new HashMap<>();
+ params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType);
+ params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1);
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, null);
+ MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl();
+ validatorMock.setConfigurationFileName("VnfGetRunningConfig");
+
+ PowerMockito.mockStatic(OperationalStateValidatorFactory.class);
+ when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock);
+ ObjectMapper mapper = PowerMockito.mock(ObjectMapper.class);
+ final NetconfConnectionDetails netconfConnectionDetails = null;
+ when(mapper.readValue(Matchers.anyString(), Matchers.any(Class.class))).thenReturn(netconfConnectionDetails);
+
+
+ try {
+ netconfClientPlugin.operationStateValidation(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE));
+ Assert.assertFalse("validation process failed", validatorMock.isValidated());
+
+ }
+ }
+
+
+ @Test
+ public void testOperationStateValidationNegativeAppcException() throws Exception {
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ DAOServiceMock daoServiceMock = (DAOServiceMock) dao;
+ daoServiceMock.setConfigFile(fileContent);
+
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setAnswer("wrong");
+
+
+ params = new HashMap<>();
+ params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType);
+ params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1);
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails);
+ MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl();
+ validatorMock.setConfigurationFileName("VnfGetRunningConfig");
+
+ PowerMockito.mockStatic(OperationalStateValidatorFactory.class);
+ when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock);
+
+
+ try {
+ netconfClientPlugin.operationStateValidation(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE));
+ Assert.assertFalse("validation process failed", validatorMock.isValidated());
+
+ }
+ }
+
+
+ @Test
+ public void testOperationStateValidatioConnectionDetailsInParamsAreEmpty() throws Exception {
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ DAOServiceMock daoServiceMock = (DAOServiceMock) dao;
+ daoServiceMock.setConfigFile(fileContent);
+
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setAnswer(operationalState);
+ ((DAOServiceMock) dao).setConnection(getConnectionDetails());
+
+
+ params = new HashMap<>();
+ params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType);
+ params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1);
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, "");
+ MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl();
+ validatorMock.setConfigurationFileName("VnfGetRunningConfig");
+
+ PowerMockito.mockStatic(OperationalStateValidatorFactory.class);
+ when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock);
+
+ netconfClientPlugin.operationStateValidation(params, ctx);
+
+ Assert.assertTrue("validation process failed", validatorMock.isValidated());
+ Assert.assertEquals(fileContent, client.getLastMessage());
+ }
+
+ @Test
+ public void testOperationStateValidatioConnectionDetailsInParamsAreNull() throws Exception {
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ DAOServiceMock daoServiceMock = (DAOServiceMock) dao;
+ daoServiceMock.setConfigFile(fileContent);
+
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setAnswer(operationalState);
+ ((DAOServiceMock) dao).setConnection(getConnectionDetails());
+
+
+ params = new HashMap<>();
+ params.put(Constants.VNF_TYPE_FIELD_NAME, vnfType);
+ params.put(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME, host1);
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, null);
+ MockOperationalStateValidatorImpl validatorMock = new MockOperationalStateValidatorImpl();
+ validatorMock.setConfigurationFileName("VnfGetRunningConfig");
+
+ PowerMockito.mockStatic(OperationalStateValidatorFactory.class);
+ when(OperationalStateValidatorFactory.getOperationalStateValidator(Matchers.any(VnfType.class))).thenReturn(validatorMock);
+
+ netconfClientPlugin.operationStateValidation(params, ctx);
+
+ Assert.assertTrue("validation process failed", validatorMock.isValidated());
+ Assert.assertEquals(fileContent, client.getLastMessage());
+ }
+
+
+ @Test
+ public void testBackupConfiguration() throws Exception {
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails);
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setConf(fileContent);
+ netconfClientPlugin.backupConfiguration(params, ctx);
+
+ DAOServiceMock mockdao = (DAOServiceMock) dao;
+ DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
+ Date date = new Date();
+ String creationDateExpected = dateFormat.format(date);
+ String creationDateActual = mockdao.getBackupConf().get("creationDate").substring(0, 10);
+
+
+ Assert.assertEquals("wrong configuration in db", fileContent, mockdao.getBackupConf().get("logText"));
+ Assert.assertEquals(creationDateExpected, creationDateActual);
+
+
+ }
+
+
+ @Test
+ public void testBackupConfigurationNegativeDgErrorFieldName() throws Exception {
+ shortInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, "{" + connectionDetails);
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setConf(fileContent);
+ try {
+ netconfClientPlugin.backupConfiguration(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE));
+
+ DAOServiceMock mockdao = (DAOServiceMock) dao;
+ Assert.assertNull(mockdao.getBackupConf());
+ }
+
+ }
+
+ @Test
+ public void testGetConfig() throws Exception {
+ fullInit();
+ String entity = "123";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("entity", entity);
+
+ params = new HashMap<>();
+ params.put("conf-id", "current");
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails);
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setConf(fileContent);
+
+
+ netconfClientPlugin.getConfig(params, ctx);
+
+ Assert.assertEquals("Success", ctx.getAttribute("getConfig_Result"));
+ Assert.assertEquals(fileContent, ctx.getAttribute("fullConfig"));
+ Assert.assertNotNull(ctx.getAttribute(entity + ".Configuration"));
+ Assert.assertEquals(fileContent, ctx.getAttribute(entity + ".Configuration"));
+ }
+
+
+ @Test
+ public void testGetConfigNegativeConfigurationNull() throws Exception {
+ fullInit();
+ String entity = "123";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("entity", entity);
+
+ params = new HashMap<>();
+ params.put("conf-id", "current");
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails);
+
+
+ netconfClientPlugin.getConfig(params, ctx);
+
+ Assert.assertEquals("failure", ctx.getAttribute("getConfig_Result"));
+ Assert.assertNull(ctx.getAttribute("fullConfig"));
+ Assert.assertNull(ctx.getAttribute(entity + ".Configuration"));
+ Assert.assertNull(ctx.getAttribute(entity + ".Configuration"));
+ }
+
+
+ @Test
+ public void testGetConfigNegativeNotSupportedConfId() throws Exception {
+ fullInit();
+ String entity = "123";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("entity", entity);
+
+ params = new HashMap<>();
+ params.put("conf-id", "current1");
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, connectionDetails);
+
+
+ netconfClientPlugin.getConfig(params, ctx);
+
+ Assert.assertNull(ctx.getAttribute("getConfig_Result"));
+ Assert.assertNull(ctx.getAttribute("fullConfig"));
+ Assert.assertNull(ctx.getAttribute(entity + ".Configuration"));
+ Assert.assertNull(ctx.getAttribute(entity + ".Configuration"));
+ }
+
+ @Test
+ public void testGetConfigNegativeWronjJsonConnectionDetailsException() throws Exception {
+ fullInit();
+ String entity = "123";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("entity", entity);
+
+ params = new HashMap<>();
+ params.put("conf-id", "current");
+ params.put(Constants.CONNECTION_DETAILS_FIELD_NAME, "{" + connectionDetails);
+
+
+ try {
+ netconfClientPlugin.getConfig(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertEquals("failure", ctx.getAttribute("getConfig_Result"));
+ Assert.assertNull(ctx.getAttribute("fullConfig"));
+ Assert.assertNull(ctx.getAttribute(entity + ".Configuration"));
+ Assert.assertNull(ctx.getAttribute(entity + ".Configuration"));
+ Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE));
+ }
+
+
+ }
+
+ @Test
+ public void testGetRunningConfig() throws Exception {
+ fullInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ params.put("host-ip-address", host);
+ params.put("user-name", username);
+ params.put("password", password);
+ params.put("port-number", String.valueOf(port));
+
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setConf(fileContent);
+
+ netconfClientPlugin.getRunningConfig(params, ctx);
+
+ Assert.assertEquals("Success", ctx.getAttribute("getRunningConfig_Result"));
+ Assert.assertEquals(fileContent, ctx.getAttribute("running-config"));
+ Assert.assertEquals("success", ctx.getStatus());
+ }
+
+ @Test
+ public void testGetRunningConfigWithoutPortNumberDgErrorFieldNameException() throws Exception {
+ fullInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ params.put("host-ip-address", host);
+ params.put("user-name", username);
+ params.put("password", password);
+
+ NetconfClientJschMock client = (NetconfClientJschMock) clientFactory.GetNetconfClient(NetconfClientType.SSH);
+ client.setConf(fileContent);
+
+ try {
+ netconfClientPlugin.getRunningConfig(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertEquals("failure", ctx.getAttribute("getRunningConfig_Result"));
+ Assert.assertNull(ctx.getAttribute("running-config"));
+ Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE));
+ }
+
+
+ }
+
+ @Test
+ public void testGetRunningConfigNegativeConfigurationNull() throws Exception {
+ fullInit();
+ SvcLogicContext ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ params.put("host-ip-address", host);
+ params.put("user-name", username);
+ params.put("password", password);
+ params.put("port-number", String.valueOf(port));
+
+ netconfClientPlugin.getRunningConfig(params, ctx);
+
+ Assert.assertEquals("failure", ctx.getAttribute("getRunningConfig_Result"));
+ Assert.assertNull(ctx.getAttribute("running-config"));
+ }
+
+ @Test
+ public void testValidateMandatoryParamNegativeEmptyParamValue() throws Exception {
+ shortInit();
+ String paramName = "test";
+ String paramValue = "";
+
+ try {
+ netconfClientPlugin.validateMandatoryParam(paramName, paramValue);
+ Assert.assertTrue(false);
+ } catch (Exception e) {
+ Assert.assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testRetrieveConnectionDetails() throws Exception {
+ shortInit();
+ DAOServiceMock daoServiceMock = (DAOServiceMock) dao;
+ daoServiceMock.setConfigFile(fileContent);
+ ConnectionDetails connectionDetails1 = getConnectionDetails();
+ daoServiceMock.setConnection(connectionDetails1);
+
+ NetconfConnectionDetails connectionDetailsActual = netconfClientPlugin.retrieveConnectionDetails(VnfType.VNF);
+
+
+ Assert.assertEquals("wrong host", connectionDetails1.getHost(), connectionDetailsActual.getHost());
+ Assert.assertEquals("wrong password", connectionDetails1.getPassword(), connectionDetailsActual.getPassword());
+ Assert.assertEquals("wrong port", connectionDetails1.getPort(), connectionDetailsActual.getPort());
+ Assert.assertEquals("wrong usename", connectionDetails1.getUsername(), connectionDetailsActual.getUsername());
+ }
+
+
+ @Test
+ public void testRetrieveConnectionDetailsNegativeMissingConfiguration() throws Exception {
+ shortInit();
+ DAOServiceMock daoServiceMock = (DAOServiceMock) dao;
+ daoServiceMock.setConfigFile(fileContent);
+ ConnectionDetails connectionDetails1 = getConnectionDetails();
+ daoServiceMock.setConnection(connectionDetails1);
+
+ NetconfConnectionDetails connectionDetailsActual = null;
+ try {
+ connectionDetailsActual = netconfClientPlugin.retrieveConnectionDetails(VnfType.MOCK);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNull(connectionDetailsActual);
+ }
+
+
+ }
+
+ @Test
+ public void testRetrieveConfigurationFileContent() throws Exception {
+ shortInit();
+
+ DAOServiceMock daoServiceMock = (DAOServiceMock) dao;
+ daoServiceMock.setConfigFile(fileContent);
+
+ Assert.assertEquals("wrong config in a database", fileContent, netconfClientPlugin.retrieveConfigurationFileContent("VnfGetRunningConfig"));
+ }
+
+ private ConnectionDetails getConnectionDetails() {
+
+ ConnectionDetails connectionDetails = new ConnectionDetails();
+ connectionDetails.setPassword(password);
+ connectionDetails.setPort(port);
+ connectionDetails.setUsername(username);
+ connectionDetails.setHost(host);
+ return connectionDetails;
+ }
+
+
+ private void initDao() throws NoSuchFieldException, IllegalAccessException {
+ dao = new DAOServiceMock();
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService);
+ when(bundleService.getBundleContext()).thenReturn(bundleContext);
+ when(bundleContext.getServiceReference(NetconfDataAccessService.class)).thenReturn(sref1);
+ when(bundleContext.getService(sref1)).thenReturn(dao);
+
+
+ }
+
+ private void fullInit() throws NoSuchFieldException, IllegalAccessException {
+ initClientFactory();
+ initClientFactory2();
+ initDao();
+ netconfClientPlugin = new NetconfClientPluginImpl();
+ netconfClientPlugin.setDao(this.dao);
+ }
+
+ private void shortInit() throws NoSuchFieldException, IllegalAccessException {
+ initClientFactory();
+ initDao();
+ netconfClientPlugin = new NetconfClientPluginImpl();
+ netconfClientPlugin.setDao(this.dao);
+ }
+
+ private void initClientFactory() throws NoSuchFieldException, IllegalAccessException {
+
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService);
+ when(bundleService.getBundleContext()).thenReturn(bundleContext);
+ when(bundleContext.getServiceReference(NetconfClientFactory.class)).thenReturn(sref2);
+ when(bundleContext.getService(sref2)).thenReturn(clientFactory);
+
+ }
+
+ private void initClientFactory2() {
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService);
+ when(bundleService.getBundleContext()).thenReturn(bundleContext);
+ when(bundleContext.getServiceReference(Matchers.anyString())).thenReturn(sref3);
+ when(bundleContext.getService(sref3)).thenReturn(clientFactory);
+ }
+
+ private void substituteMapper(boolean command) throws NoSuchFieldException, IllegalAccessException {
+ ObjectMapper mapper = new ObjectMapperMock();
+ ObjectMapper mapper2 = new ObjectMapper();
+ Field field = NetconfClientPluginImpl.class.getDeclaredField("mapper");
+ field.setAccessible(true);
+ if (command) {
+ field.set(netconfClientPlugin, mapper);
+ } else {
+ field.set(netconfClientPlugin, mapper2);
+ }
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfDBPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfDBPluginImplTest.java
new file mode 100644
index 000000000..a591648c4
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/NetconfDBPluginImplTest.java
@@ -0,0 +1,250 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.*;
+import org.openecomp.appc.adapter.netconf.ConnectionDetails;
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.NetconfDataAccessService;
+import org.openecomp.appc.adapter.netconf.exception.DataAccessException;
+import org.openecomp.appc.dg.netconf.impl.NetconfDBPluginImpl;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.powermock.api.support.SuppressCode.suppressConstructor;
+
+public class NetconfDBPluginImplTest {
+ private NetconfDBPluginImpl netconfDBPlugin;
+ private NetconfDataAccessService daoService;
+ private DAOServiceMock daoMock;
+ private Map<String, String> params;
+ private static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+ String host = "http://www.test.com";
+ String host1 = "http://www.test1.com";
+ int port = 8080;
+ String username = "test";
+ String password = "test";
+ String configContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ "\t<get-config>\n" +
+ "\t\t<source>\n" +
+ "\t\t\t<running/>\n" +
+ "\t\t </source>\n" +
+ "\t</get-config>\n" +
+ "</rpc>'";
+
+
+ @Test
+ public void testRetrieveDSConfiguration() throws Exception {
+ init();
+ params = new HashMap<>();
+ params.put("org.openecomp.appc.vftype", "VNF");
+ params.put("configuration-file-name", "VnfGetRunningConfig");
+ SvcLogicContext ctx = new SvcLogicContext();
+ netconfDBPlugin.retrieveDSConfiguration(params, ctx);
+
+ Assert.assertEquals("lack of success of status", "success", ctx.getStatus());
+ Assert.assertEquals("wrong config file content", configContent, ctx.getAttribute("file-content"));
+ }
+
+
+ @Test
+ public void testRetrieveDSConfigurationNegativeErrorFieldNameDaoException() throws Exception {
+ init();
+ SvcLogicContext ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ params.put("configuration-file-name", "wrong");
+
+ try {
+ netconfDBPlugin.retrieveDSConfiguration(params, ctx);
+ } catch (DataAccessException e) {
+ //Assert.assertNotNull(ctx.getAttribute("org.openecomp.appc.dg.error"));
+ Assert.assertNull(ctx.getAttribute("file-content"));
+ }
+
+
+ }
+
+ @Test
+ public void testRetrieveVMDSConfiguration() throws Exception {
+ init();
+ params = new HashMap<>();
+ params.put("resourceKey", "VNF");
+ SvcLogicContext ctx = new SvcLogicContext();
+ netconfDBPlugin.retrieveVMDSConfiguration(params, ctx);
+
+ Assert.assertEquals("lack of success of retrieveVMDSConfiguration_Result", "success", ctx.getAttribute("retrieveVMDSConfiguration_Result"));
+ Assert.assertEquals("wrong entity", "VNF", ctx.getAttribute("entity"));
+ assertConnectionDetails(ctx, host);
+ }
+
+ @Test
+ public void testRetrieveVMDSConfigurationNegativeMissingConfiguration() throws Exception {
+ init();
+ SvcLogicContext ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ params.put("resourceKey", "MOCK");
+
+ try {
+ netconfDBPlugin.retrieveVMDSConfiguration(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+
+ Assert.assertEquals("failure", ctx.getAttribute("retrieveVMDSConfiguration_Result"));
+ }
+ }
+
+
+ @Test
+ public void testRetrieveVMDSConfigurationNegativeJsonProcessingException() throws Exception {
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ params.put("resourceKey", "VNF");
+
+ init();
+ substituteMapper(true);
+ try {
+ netconfDBPlugin.retrieveVMDSConfiguration(params, ctx);
+ substituteMapper(false);
+ Assert.assertTrue(false);
+
+ } catch (APPCException e) {
+ substituteMapper(false);
+ Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE));
+
+ }
+
+ }
+
+ @Test
+ public void testRetrieveConfigFile() throws Exception {
+ init();
+ SvcLogicContext ctx = new SvcLogicContext();
+ params = new HashMap<>();
+ params.put("configuration-file-name", "VnfGetRunningConfig");
+ netconfDBPlugin.retrieveConfigFile(params, ctx);
+
+ Assert.assertEquals("lack of success of status", "success", ctx.getStatus());
+ Assert.assertEquals("wrong config file content", configContent, ctx.getAttribute("file-content"));
+ }
+
+ @Test
+ public void testRetrieveConnectionDetails() throws Exception {
+ init();
+ params = new HashMap<>();
+ params.put("org.openecomp.appc.vftype", "VNF");
+ params.put("vnf-host-ip-address", host1);
+ SvcLogicContext ctx = new SvcLogicContext();
+ netconfDBPlugin.retrieveConnectionDetails(params, ctx);
+
+ assertConnectionDetails(ctx, host1);
+ }
+
+ @Test
+ public void testRetrieveConnectionDetailsNegativeJsonProcessingException() throws Exception {
+ init();
+ params = new HashMap<>();
+ params.put("org.openecomp.appc.vftype", "MOCK");
+ params.put("vnf-host-ip-address", host1);
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ try {
+ netconfDBPlugin.retrieveConnectionDetails(params, ctx);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ Assert.assertNull(ctx.getAttribute("connection-details"));
+ Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE));
+ }
+
+ }
+
+
+ @Test
+ public void testRetrieveConnectionDetailsNegativeMissingConfiguration() throws Exception {
+ init();
+ params = new HashMap<>();
+ params.put("org.openecomp.appc.vftype", "VNF");
+ params.put("vnf-host-ip-address", host1);
+ SvcLogicContext ctx = new SvcLogicContext();
+ substituteMapper(true);
+
+ try {
+ netconfDBPlugin.retrieveConnectionDetails(params, ctx);
+ substituteMapper(false);
+ Assert.assertTrue(false);
+ } catch (APPCException e) {
+ substituteMapper(false);
+ Assert.assertNull(ctx.getAttribute("connection-details"));
+ Assert.assertNotNull(ctx.getAttribute(DG_OUTPUT_STATUS_MESSAGE));
+ }
+
+ }
+
+ private void assertConnectionDetails(SvcLogicContext ctx, String host) throws IOException {
+ String sConnectionDetails = ctx.getAttribute("connection-details");
+ NetconfConnectionDetails connectionDetails = new ObjectMapper().readValue(sConnectionDetails, NetconfConnectionDetails.class);
+ Assert.assertEquals(host, connectionDetails.getHost());
+ Assert.assertEquals(port, connectionDetails.getPort());
+ Assert.assertEquals(username, connectionDetails.getUsername());
+ Assert.assertEquals(password, connectionDetails.getPassword());
+ Assert.assertNull(connectionDetails.getCapabilities());
+ Assert.assertNull(connectionDetails.getAdditionalProperties());
+ }
+
+ private void init() {
+ netconfDBPlugin = new NetconfDBPluginImpl();
+ daoService = new DAOServiceMock();
+ netconfDBPlugin.setDaoService(daoService);
+ daoMock = (DAOServiceMock) daoService;
+ daoMock.setConfigFile(configContent);
+ daoMock.setConnection(getConnectionDetails());
+
+ }
+
+ private ConnectionDetails getConnectionDetails() {
+ ConnectionDetails connectionDetails = new ConnectionDetails();
+ connectionDetails.setHost(host);
+ connectionDetails.setUsername(username);
+ connectionDetails.setPort(port);
+ connectionDetails.setPassword(password);
+ return connectionDetails;
+ }
+
+ private void substituteMapper(boolean command) throws NoSuchFieldException, IllegalAccessException {
+ ObjectMapper mapper = new ObjectMapperMock();
+ ObjectMapper mapper2 = new ObjectMapper();
+ Field field = NetconfDBPluginImpl.class.getDeclaredField("mapper");
+ field.setAccessible(true);
+ if (command) {
+ field.set(netconfDBPlugin, mapper);
+ } else {
+ field.set(netconfDBPlugin, mapper2);
+ }
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/ObjectMapperMock.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/ObjectMapperMock.java
new file mode 100644
index 000000000..6a7da63ee
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/ObjectMapperMock.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+
+
+public class ObjectMapperMock extends ObjectMapper {
+
+ @Override
+ public String writeValueAsString(Object var1) throws JsonProcessingException {
+ throw new JsonProcessingException("") {
+ };
+
+ }
+
+ @Override
+ public <T> T readValue(String var1, Class<T> var2) throws IOException, JsonParseException, JsonMappingException {
+ return null;
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/OperationStateValidatorFactoryMock.java b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/OperationStateValidatorFactoryMock.java
new file mode 100644
index 000000000..1dea8eb86
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-netconf/src/test/java/org/openecomp/appc/dg/netconf/impl/OperationStateValidatorFactoryMock.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.netconf.impl;
+
+import org.apache.commons.lang3.NotImplementedException;
+import org.openecomp.appc.adapter.netconf.*;
+
+
+public class OperationStateValidatorFactoryMock extends OperationalStateValidatorFactory {
+ public static OperationalStateValidator getOperationalStateValidator(String vnfType) {
+ VnfType vnfTypeEnum = null;
+ try {
+ vnfTypeEnum = VnfType.getVnfType(vnfType);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException("Illegal value in vnfType. vnfType=" + vnfType, e);
+ }
+ return getOperationalStateValidator(vnfTypeEnum);
+ }
+
+ public static OperationalStateValidator getOperationalStateValidator(VnfType vnfType) {
+
+ return new MockOperationalStateValidatorImpl();
+
+
+ }
+
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-shared-features/.gitignore b/appc-dg/appc-dg-shared/appc-dg-shared-features/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-shared-features/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dg/appc-dg-shared/appc-dg-shared-features/pom.xml b/appc-dg/appc-dg-shared/appc-dg-shared-features/pom.xml
new file mode 100644
index 000000000..edaecc2b8
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-shared-features/pom.xml
@@ -0,0 +1,85 @@
+<?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-dg-shared</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dg-shared-features</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-ssh</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-netconf</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-aai</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-license-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-common</artifactId>
+ <version>${project.version}</version>
+ </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-dg/appc-dg-shared/appc-dg-shared-features/src/main/resources/features.xml b/appc-dg/appc-dg-shared/appc-dg-shared-features/src/main/resources/features.xml
new file mode 100644
index 000000000..3271f7ab8
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-shared-features/src/main/resources/features.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T 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=========================================================
+ -->
+
+
+<features name="appc-dg-shared-${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.openecomp.appc/appc-ssh-adapter-features/${project.version}/xml/features</repository>
+ <repository>mvn:org.openecomp.appc/appc-netconf-adapter-features/${project.version}/xml/features</repository>
+ <feature name='appc-dg-shared' description="appc-dg-shared" version='${project.version}'>
+ <feature version='${project.version}'>appc-ssh-adapter</feature>
+ <feature version='${project.version}'>appc-netconf-adapter</feature>
+ <bundle>mvn:org.openecomp.appc/appc-dg-common/${project.version}</bundle>
+ <bundle>mvn:org.openecomp.appc/appc-dg-ssh/${project.version}</bundle>
+ <bundle start-level="85" start="true">mvn:org.openecomp.appc/appc-dg-netconf/${project.version}</bundle>
+ <bundle>mvn:org.openecomp.appc/appc-dg-license-manager/${project.version}</bundle>
+ <bundle start-level="85" start="true">mvn:org.openecomp.appc/appc-dg-aai/${project.version}</bundle>
+ </feature>
+</features>
diff --git a/appc-dg/appc-dg-shared/appc-dg-shared-installer/.gitignore b/appc-dg/appc-dg-shared/appc-dg-shared-installer/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-shared-installer/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dg/appc-dg-shared/appc-dg-shared-installer/pom.xml b/appc-dg/appc-dg-shared/appc-dg-shared-installer/pom.xml
new file mode 100644
index 000000000..0a00e4a08
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-shared-installer/pom.xml
@@ -0,0 +1,132 @@
+<?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-dg-shared</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dg-shared-installer</artifactId>
+ <name>APPC DG Shared - Karaf Installer</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <application.name>appc-dg-shared</application.name>
+ <features.boot>appc-dg-shared</features.boot>
+ <features.repositories>mvn:org.openecomp.appc/appc-dg-shared-features/${project.version}/xml/features</features.repositories>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-shared-features</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter-features</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-netconf-adapter-features</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>mavne-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>
+ <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>
+ </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>
+</project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/assembly/assemble_installer_zip.xml b/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/assembly/assemble_installer_zip.xml
new file mode 100644
index 000000000..9fbaad8c5
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/assembly/assemble_installer_zip.xml
@@ -0,0 +1,59 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T 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>adapter</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-dg/appc-dg-shared/appc-dg-shared-installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 000000000..1ac5a82bc
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,47 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T 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>adapter</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-dg/appc-dg-shared/appc-dg-shared-installer/src/main/resources/etc/org.apache.cxf.osgi.cfg b/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/main/resources/etc/org.apache.cxf.osgi.cfg
new file mode 100644
index 000000000..7ea1088a7
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/main/resources/etc/org.apache.cxf.osgi.cfg
@@ -0,0 +1 @@
+org.apache.cxf.servlet.context=/actions \ No newline at end of file
diff --git a/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/main/resources/scripts/install-feature.sh b/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/main/resources/scripts/install-feature.sh
new file mode 100644
index 000000000..1d769fada
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-shared-installer/src/main/resources/scripts/install-feature.sh
@@ -0,0 +1,40 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T 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=========================================================
+###
+
+#!/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-dg/appc-dg-shared/appc-dg-ssh/.gitignore b/appc-dg/appc-dg-shared/appc-dg-ssh/.gitignore
new file mode 100644
index 000000000..b83d22266
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-dg/appc-dg-shared/appc-dg-ssh/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/pom.xml b/appc-dg/appc-dg-shared/appc-dg-ssh/pom.xml
new file mode 100644
index 000000000..8a4315503
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/pom.xml
@@ -0,0 +1,69 @@
+<?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-dg-shared</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dg-ssh</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-common</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter-tests</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-dg-ssh</Bundle-SymbolicName>
+ <Export-Package>org.openecomp.appc.dg.ssh</Export-Package>
+ <Private-Package>org.openecomp.appc.dg.ssh.impl.*</Private-Package>
+ <Import-Package>!org.apache.log,!org.apache.commons.logging,!groovy.lang,!javax.jms,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.jasypt.*,*</Import-Package>
+ <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/SshDBPlugin.java b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/SshDBPlugin.java
new file mode 100644
index 000000000..71569bc7b
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/SshDBPlugin.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.ssh;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+public interface SshDBPlugin extends SvcLogicJavaPlugin {
+ void retrieveConnectionDetails(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/SshService.java b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/SshService.java
new file mode 100644
index 000000000..0d2927ec3
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/SshService.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.ssh;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+/**
+ * Set of common methods that can be called from DG.
+ */
+public interface SshService extends SvcLogicJavaPlugin {
+
+ /**
+ * Input parameter for SHH connection details
+ */
+ String PARAM_IN_connection_details = "connection_details";
+
+ /**
+ * Input parameter for SSH command to be executed.
+ */
+ String PARAM_IN_command = "command";
+
+ /*
+ String PARAM_IN_host = "host";
+ String PARAM_IN_port = "port";
+ String PARAM_IN_username = "username";
+ String PARAM_IN_password = "password";
+ */
+
+ /**
+ * Input parameter for SSH command timeout
+ */
+ String PARAM_IN_timeout = "timeout";
+
+ /**
+ * Output parameter - SSH command execution status.
+ */
+ String PARAM_OUT_status = "status";
+
+ /**
+ * Output parameter - content of SSH command stdout.
+ */
+ String PARAM_OUT_stdout = "stdout";
+
+ /**
+ * Output parameter - content of SSH command stderr.
+ */
+ String PARAM_OUT_stderr = "stderr";
+
+ /**
+ * Default SSH connection port.
+ */
+ int DEF_port = 22;
+
+ /**
+ * Default SSH command timeout
+ */
+ long DEF_timeout = 120000;
+
+ /**
+ * Default success status.
+ */
+ int DEF_SUCCESS_STATUS = 0;
+
+ /**
+ * Execute remote command over SSH.
+ *
+ * @param params contains list of input parameters required for the implementation
+ * @param ctx SLI service logic context
+ * @throws APPCException
+ */
+ void exec(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ /**
+ * Execute remote command over SSH and check return status assuming that success status is 0.
+ * If non-zero status is returned - fail the execution by throwing exception with content written
+ * by command to stderr.
+ *
+ * @param params contains list of input parameters required for the implementation
+ * @param ctx SLI service logic context
+ * @throws APPCException
+ */
+ void execWithStatusCheck(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/impl/SshDBPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/impl/SshDBPluginImpl.java
new file mode 100644
index 000000000..382d41894
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/impl/SshDBPluginImpl.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.ssh.impl;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.Map;
+
+import org.openecomp.appc.adapter.ssh.Constants;
+import org.openecomp.appc.adapter.ssh.SshConnectionDetails;
+import org.openecomp.appc.adapter.ssh.SshDataAccessException;
+import org.openecomp.appc.adapter.ssh.SshDataAccessService;
+import org.openecomp.appc.dg.ssh.SshDBPlugin;
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+public class SshDBPluginImpl implements SshDBPlugin {
+
+ private static EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
+ private static ObjectMapper mapper = new ObjectMapper();
+
+ private SshDataAccessService dataAccessService;
+
+ public void setDataAccessService(SshDataAccessService dataAccessService) {
+ this.dataAccessService = dataAccessService;
+ }
+
+ public void retrieveConnectionDetails(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ SshConnectionDetails connectionDetails = new SshConnectionDetails();
+ String vnfType = ctx.getAttribute("aai.prefix")+"."+"vnf-type";
+ try {
+ if (!dataAccessService.retrieveConnectionDetails(ctx.getAttribute(vnfType), connectionDetails)) {
+ logger.error("Missing configuration for " + params.get(vnfType));
+ throw new APPCException("Missing configuration for " + params.get(vnfType) + " in " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME);
+ }
+ connectionDetails.setHost(params.get(Constants.VNF_HOST_IP_ADDRESS_FIELD_NAME));
+ ctx.setAttribute(Constants.CONNECTION_DETAILS_FIELD_NAME, mapper.writeValueAsString(connectionDetails));
+ } catch(APPCException e) {
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw e;
+ } catch(SshDataAccessException e) {
+ logger.error("Error " + e.getMessage());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw e;
+ } catch (JsonProcessingException e) {
+ logger.error("Error " + e.getMessage());
+ ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, e.getMessage());
+ throw new APPCException(e);
+ }
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/impl/SshServiceImpl.java b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/impl/SshServiceImpl.java
new file mode 100644
index 000000000..5066f0a6f
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/java/org/openecomp/appc/dg/ssh/impl/SshServiceImpl.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.ssh.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Map;
+
+import org.openecomp.appc.adapter.ssh.SshAdapter;
+import org.openecomp.appc.adapter.ssh.SshConnection;
+import org.openecomp.appc.adapter.ssh.SshConnectionDetails;
+import org.openecomp.appc.dg.ssh.SshService;
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+
+public class SshServiceImpl implements SshService {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ private SshAdapter sshAdapter;
+
+ public void setSshAdapter(SshAdapter sshAdapter) {
+ this.sshAdapter = sshAdapter;
+ }
+
+ @Override
+ public void exec(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ SshConnectionDetails connectionDetails = resolveConnectionDetails(params.get(PARAM_IN_connection_details));
+ String command = params.get(PARAM_IN_command);
+ logger.debug("=> Connecting to SSH server...");
+ SshConnection sshConnection = sshAdapter.getConnection(connectionDetails.getHost(), connectionDetails.getPort(), connectionDetails.getUsername(), connectionDetails.getPassword());
+ sshConnection.connect();
+ try {
+ logger.debug("=> Connected to SSH server...");
+ logger.debug("=> Running SSH command...");
+ long timeout = DEF_timeout;
+ String stimeout = params.get(PARAM_IN_timeout);
+ if ((stimeout != null && !stimeout.isEmpty())) {
+ timeout = Long.parseLong(stimeout);
+ }
+ sshConnection.setExecTimeout(timeout);
+ ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+ ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+ int status = sshConnection.execCommand(command, stdout, stderr);
+ String stdoutRes = stdout.toString();
+ String stderrRes = stderr.toString();
+ logger.debug("=> executed SSH command");
+ ctx.setAttribute(PARAM_OUT_status, String.format("%01d", status));
+ ctx.setAttribute(PARAM_OUT_stdout, stdoutRes);
+ ctx.setAttribute(PARAM_OUT_stderr, stderrRes);
+ } finally {
+ sshConnection.disconnect();
+ }
+ }
+
+ private SshConnectionDetails resolveConnectionDetails(String connectionDetailsStr) throws APPCException {
+ SshConnectionDetails connectionDetails = null;
+ try {
+ connectionDetails = mapper.readValue(connectionDetailsStr, SshConnectionDetails.class);
+ if (0 == connectionDetails.getPort()) connectionDetails.setPort(DEF_port);
+ } catch (IOException e) {
+ throw new APPCException(e);
+ }
+ return connectionDetails;
+ }
+
+ @Override
+ public void execWithStatusCheck(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ exec(params, ctx);
+ int status = Integer.parseInt(ctx.getAttribute(PARAM_OUT_status));
+ if(status != DEF_SUCCESS_STATUS) {
+ StringBuilder errmsg = new StringBuilder();
+ errmsg.append("SSH command returned error status [").append(status).append(']');
+ String stderr = ctx.getAttribute(PARAM_OUT_stderr);
+ if((stderr != null) && !stderr.isEmpty()) {
+ errmsg.append(". Error: [").append(stderr).append(']');
+ }
+ throw new APPCException(errmsg.toString());
+ }
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..11ab24025
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T 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=========================================================
+ -->
+
+<!--
+ Starter Blueprint Camel Definition appc-aai-adapter-blueprint
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <reference id="sshAdapterRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.adapter.ssh.SshAdapter" />
+ <bean id="sshServiceBean" class="org.openecomp.appc.dg.ssh.impl.SshServiceImpl" scope="singleton">
+ <property name="sshAdapter" ref="sshAdapterRef" />
+ </bean>
+ <service id="sshService" interface="org.openecomp.appc.dg.ssh.SshService" ref="sshServiceBean"/>
+
+ <reference id="sshDAServiceRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.adapter.ssh.SshDataAccessService" />
+ <bean id="sshDBPluginBean" class="org.openecomp.appc.dg.ssh.impl.SshDBPluginImpl" scope="singleton">
+ <property name="dataAccessService" ref="sshDAServiceRef" />
+ </bean>
+ <service id="sshDBPlugin" interface="org.openecomp.appc.dg.ssh.SshDBPlugin" ref="sshDBPluginBean"/>
+
+</blueprint>
diff --git a/appc-dg/appc-dg-shared/appc-dg-ssh/src/test/java/org/openecomp/appc/dg/ssh/impl/SshServiceImplTest.java b/appc-dg/appc-dg-shared/appc-dg-ssh/src/test/java/org/openecomp/appc/dg/ssh/impl/SshServiceImplTest.java
new file mode 100644
index 000000000..a00d21100
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-ssh/src/test/java/org/openecomp/appc/dg/ssh/impl/SshServiceImplTest.java
@@ -0,0 +1,170 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.openecomp.appc.dg.ssh.impl;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openecomp.appc.adapter.ssh.SshAdapterMock;
+import org.openecomp.appc.adapter.ssh.SshConnectionDetails;
+import org.openecomp.appc.adapter.ssh.SshConnectionMock;
+import org.openecomp.appc.dg.ssh.SshService;
+import org.openecomp.appc.dg.ssh.impl.SshServiceImpl;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+public class SshServiceImplTest {
+
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testExec() throws APPCException, JsonProcessingException {
+ String host = "testhost";
+ String username = "testuser";
+ String password = "testpassword";
+ String command = "cat keystonerc_Test";
+
+ SshServiceImpl sshService = new SshServiceImpl();
+ SshAdapterMock sshAdapterMock = new SshAdapterMock();
+ sshService.setSshAdapter(sshAdapterMock);
+
+ System.out.println("=> Executing SSH command [" + command + "]...");
+
+ Map<String, String> params = new HashMap<>();
+ params.put(SshService.PARAM_IN_connection_details, createConnectionDetails(host,username,password));
+ params.put(SshService.PARAM_IN_command, command);
+ SvcLogicContext svcLogicContext = new SvcLogicContext(new Properties());
+ sshService.exec(params, svcLogicContext);
+ int status = Integer.parseInt(svcLogicContext.getAttribute(SshService.PARAM_OUT_status));
+ String stdout = svcLogicContext.getAttribute(SshService.PARAM_OUT_stdout);
+ String stderr = svcLogicContext.getAttribute(SshService.PARAM_OUT_stderr);
+ System.out.println("=> SSH command [" + command + "] status is [" + status + "]. stdout is [" + stdout + "]. stderr is [" + stderr + "]");
+
+ List<SshConnectionMock> connectionMocks = sshAdapterMock.getConnectionMocks();
+ Assert.assertEquals(1, connectionMocks.size());
+ SshConnectionMock connectionMock = connectionMocks.get(0);
+ Assert.assertNotNull(connectionMock);
+ Assert.assertEquals(host, connectionMock.getHost());
+ Assert.assertEquals(SshService.DEF_port, connectionMock.getPort());
+ Assert.assertEquals(username, connectionMock.getUsername());
+ Assert.assertEquals(password, connectionMock.getPassword());
+ Assert.assertEquals(1, connectionMock.getConnectCallCount());
+ Assert.assertEquals(1, connectionMock.getDisconnectCallCount());
+ List<String> executedCommands = connectionMock.getExecutedCommands();
+ Assert.assertEquals(1, executedCommands.size());
+ String executedCommand = executedCommands.get(0);
+ Assert.assertEquals(command, executedCommand);
+ }
+
+ @Test
+ public void testExecWithStatusCheck() throws APPCException, JsonProcessingException {
+ String host = "testhost";
+ String username = "testuser";
+ String password = "testpassword";
+ String command = "cat keystonerc_Test";
+
+ SshServiceImpl sshService = new SshServiceImpl();
+ SshAdapterMock sshAdapterMock = new SshAdapterMock();
+ sshService.setSshAdapter(sshAdapterMock);
+
+ System.out.println("=> Executing SSH command [" + command + "]...");
+ Map<String, String> params = new HashMap<>();
+ params.put(SshService.PARAM_IN_connection_details, createConnectionDetails(host,username,password));
+ params.put(SshService.PARAM_IN_command, command);
+ SvcLogicContext svcLogicContext = new SvcLogicContext(new Properties());
+ sshService.execWithStatusCheck(params, svcLogicContext);
+ int status = Integer.parseInt(svcLogicContext.getAttribute(SshService.PARAM_OUT_status));
+ String stdout = svcLogicContext.getAttribute(SshService.PARAM_OUT_stdout);
+ String stderr = svcLogicContext.getAttribute(SshService.PARAM_OUT_stderr);
+ System.out.println("=> SSH command [" + command + "] status is [" + status + "]. stdout is [" + stdout + "]. stderr is [" + stderr + "]");
+
+ List<SshConnectionMock> connectionMocks = sshAdapterMock.getConnectionMocks();
+ Assert.assertEquals(1, connectionMocks.size());
+ SshConnectionMock connectionMock = connectionMocks.get(0);
+ Assert.assertNotNull(connectionMock);
+ Assert.assertEquals(host, connectionMock.getHost());
+ Assert.assertEquals(SshService.DEF_port, connectionMock.getPort());
+ Assert.assertEquals(username, connectionMock.getUsername());
+ Assert.assertEquals(password, connectionMock.getPassword());
+ Assert.assertEquals(1, connectionMock.getConnectCallCount());
+ Assert.assertEquals(1, connectionMock.getDisconnectCallCount());
+ List<String> executedCommands = connectionMock.getExecutedCommands();
+ Assert.assertEquals(1, executedCommands.size());
+ String executedCommand = executedCommands.get(0);
+ Assert.assertEquals(command, executedCommand);
+ }
+
+ /**
+ * Checks that execWithStatusCheck() throws appropriate exception if execution status != 0.
+ *
+ * @throws APPCException
+ * @throws JsonProcessingException
+ */
+ @Test
+ public void testExecWithStatusCheckFail() throws APPCException, JsonProcessingException {
+ String host = "testhost";
+ String username = "testuser";
+ String password = "testpassword";
+ String command = "cat keystonerc_Test";
+
+ int expectedStatus = 2;
+ String expectedErr = "Test failure";
+
+ SshServiceImpl sshService = new SshServiceImpl();
+ SshAdapterMock sshAdapterMock = new SshAdapterMock();
+ sshAdapterMock.setReturnStatus(expectedStatus);
+ sshAdapterMock.setReturnStderr(expectedErr);
+ sshService.setSshAdapter(sshAdapterMock);
+
+ thrown.expect(APPCException.class);
+ thrown.expectMessage(CoreMatchers.containsString(expectedErr));
+
+ System.out.println("=> Executing SSH command [" + command + "]...");
+ Map<String, String> params = new HashMap<>();
+ params.put(SshService.PARAM_IN_connection_details, createConnectionDetails(host,username,password));
+ params.put(SshService.PARAM_IN_command, command);
+ SvcLogicContext svcLogicContext = new SvcLogicContext(new Properties());
+ // should fail, no need to perform further assertions
+ sshService.execWithStatusCheck(params, svcLogicContext);
+ }
+
+ private String createConnectionDetails(String host, String username, String password) throws JsonProcessingException {
+ SshConnectionDetails connDetails = new SshConnectionDetails();
+ connDetails.setHost(host);
+ connDetails.setUsername(username);
+ connDetails.setPassword(password);
+ return mapper.writeValueAsString(connDetails);
+ }
+
+}
diff --git a/appc-dg/appc-dg-shared/pom.xml b/appc-dg/appc-dg-shared/pom.xml
new file mode 100644
index 000000000..f2058bfb2
--- /dev/null
+++ b/appc-dg/appc-dg-shared/pom.xml
@@ -0,0 +1,21 @@
+<?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-dg</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dg-shared</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>appc-dg-common</module>
+ <module>appc-dg-ssh</module>
+ <module>appc-dg-aai</module>
+ <module>appc-dg-netconf</module>
+ <module>appc-dg-license-manager</module>
+ <module>appc-dg-shared-features</module>
+ <module>appc-dg-shared-installer</module>
+ </modules>
+</project>