aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle
diff options
context:
space:
mode:
Diffstat (limited to 'appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle')
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml189
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java130
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java64
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java45
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java61
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java40
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java70
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java28
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java92
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java82
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java32
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java52
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java132
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java55
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java44
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java44
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java129
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java103
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java53
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java154
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java94
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java60
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java171
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java233
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java64
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties41
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java197
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java88
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java60
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java93
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java93
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java91
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java87
34 files changed, 2975 insertions, 0 deletions
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/.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-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml
new file mode 100644
index 000000000..861529836
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml
@@ -0,0 +1,189 @@
+<?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-netconf-adapter</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-netconf-adapter-bundle</artifactId>
+ <packaging>bundle</packaging>
+ <name>NETCONF Adapter - bundle</name>
+ <properties>
+ <exam.version>4.9.1</exam.version>
+ <url.version>1.6.0</url.version>
+ <sal-netconf-connector.version>1.3.1-Beryllium-SR1</sal-netconf-connector.version>
+ </properties>
+
+ <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>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>7.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-openstack</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ </dependency>
+
+ <!-- Jersey support needed for OpenStack connector and API version logic -->
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+
+ <!-- Needed to run test cases -->
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ <version>1.9.12</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</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>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.vmware</groupId>
+ <artifactId>vijava</artifactId>
+ <version>5.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xerces</artifactId>
+ <version>2.4.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>${apache.httpcomponents.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-netconf-adapter</Bundle-SymbolicName>
+ <Bundle-Activator>org.openecomp.appc.adapter.netconf.AppcNetconfAdapterActivator</Bundle-Activator>
+ <Export-Package>org.openecomp.appc.adapter.netconf,org.openecomp.appc.adapter.netconf.dao,org.openecomp.appc.adapter.netconf.util,org.openecomp.appc.adapter.netconf.exception</Export-Package>
+ <Import-Package>
+ org.w3c.dom.*,com.sun.org.apache.xerces.*,javax.sql.*,javax.sql.rowset.*,javax.xml.*,org.openecomp.appc.adapter.dmaap.*,javax.crypto.*,org.openecomp.appc.common.exception.*,com.mysql.*,org.openecomp.sdnc.sli.*,org.osgi.framework.*,org.slf4j.*,com.vmware.*,org.apache.xerces.*,javax.net.*,javax.net.ssl.*,org.xml.sax.*,javax.xml.bind.*,javax.naming.*
+ </Import-Package>
+ <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|dblib-provider|org.eclipse.osgi|slf4j-api|jcl-over-slf4j|mysql-connector-java|xml-apis|appc-dmaap-adapter-bundle</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java
new file mode 100644
index 000000000..aac49c288
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java
@@ -0,0 +1,130 @@
+/*-
+ * ============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.adapter.netconf;
+
+import org.openecomp.appc.adapter.netconf.internal.NetconfDataAccessServiceImpl;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+public class AppcNetconfAdapterActivator implements BundleActivator {
+
+ /**
+ * The bundle registration
+ */
+ private ServiceRegistration registration = null;
+ private ServiceRegistration reporterRegistration = null;
+ private ServiceRegistration factoryRegistration = null;
+ private ServiceRegistration dbRegistration = null;
+
+ /**
+ * The reference to the actual implementation object that implements the services
+ */
+ private NetconfClientFactory clientFactory;
+ private NetconfDataAccessService DAService;
+
+ /**
+ * The logger to be used
+ */
+ //private static final EELFLogger logger = EELFManager.getInstance().getLogger(AppcNetconfAdapterActivator.class);
+
+ /**
+ * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary to start
+ * this bundle. This method can be used to register services or to allocate any resources that this bundle needs.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @param context
+ * The execution context of the bundle being started.
+ * @throws java.lang.Exception
+ * If this method throws an exception, this bundle is marked as stopped and the Framework will remove
+ * this bundle's listeners, unregister all services registered by this bundle, and release all services
+ * used by this bundle.
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+
+ if (registration == null) {
+ clientFactory = new NetconfClientFactory();
+ factoryRegistration = context.registerService(NetconfClientFactory.class, clientFactory, null);
+
+ DAService = new NetconfDataAccessServiceImpl();
+ //set dblib service
+ DbLibService dblibSvc = null;
+ ServiceReference sref = context.getServiceReference(DbLibService.class.getName());
+ dblibSvc = (DbLibService)context.getService(sref);
+ DAService.setDbLibService(dblibSvc);
+ ///////////////////////////////////
+ factoryRegistration = context.registerService(NetconfDataAccessService.class, DAService, null);
+ }
+
+ //logger.info(Msg.COMPONENT_INITIALIZED, "NETCONF adapter");
+ }
+
+ /**
+ * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary to stop
+ * the bundle. In general, this method should undo the work that the BundleActivator.start method started. There
+ * should be no active threads that were started by this bundle when this bundle returns. A stopped bundle must not
+ * call any Framework objects.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @param context
+ * The execution context of the bundle being stopped.
+ * @throws java.lang.Exception
+ * If this method throws an exception, the bundle is still marked as stopped, and the Framework will
+ * remove the bundle's listeners, unregister all services registered by the bundle, and release all
+ * services used by the bundle. *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ if (registration != null) {
+ registration.unregister();
+ registration = null;
+ }
+ if (reporterRegistration != null) {
+ reporterRegistration.unregister();
+ reporterRegistration = null;
+ }
+
+ if (null != factoryRegistration) {
+ factoryRegistration.unregister();
+ factoryRegistration = null;
+ }
+
+ if (dbRegistration != null) {
+ dbRegistration.unregister();
+ dbRegistration = null;
+ }
+ }
+
+ public String getName() {
+ return "APPC NETCONF adapter";
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java
new file mode 100644
index 000000000..71fe16f6b
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java
@@ -0,0 +1,64 @@
+/*-
+ * ============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.adapter.netconf;
+
+
+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-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java
new file mode 100644
index 000000000..95eae28af
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.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.adapter.netconf;
+
+import org.openecomp.appc.exceptions.APPCException;
+
+
+public class MockOperationalStateValidatorImpl implements OperationalStateValidator {
+ @Override
+ public VnfType getVnfType() {
+ return VnfType.MOCK;
+ }
+
+ @Override
+ public String getConfigurationFileName() {
+ String configFileName = OperationalStateValidatorFactory.configuration.getProperty(this.getClass().getCanonicalName() + CONFIG_FILE_PROPERTY_SUFFIX);
+ return configFileName;
+ }
+
+ @Override
+ public void validateResponse(String response) throws APPCException {
+ if(response != null && response.toUpperCase().contains("INVALID")){
+ throw new APPCException("INVALID");
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java
new file mode 100644
index 000000000..904155273
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.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.adapter.netconf;
+
+import org.openecomp.appc.exceptions.APPCException;
+
+
+
+public interface NetconfClient {
+
+ /**
+ * Open connection to netconf device.
+ *
+ * @param connectionDetails object providing details required for netconf connection
+ */
+ void connect(NetconfConnectionDetails connectionDetails) throws APPCException;
+
+ /**
+ * Send Netconf message to device and receive response.
+ *
+ * @param message input netconf xml message
+ * @return output netconf xml message
+ */
+ String exchangeMessage(String message) throws APPCException;
+
+ /**
+ * send configuration to Netconf server
+ *
+ * @param configuration - xml configuration payload
+ */
+ void configure(String configuration) throws APPCException;
+
+ /**
+ * returns running configuration of Netconf server
+ */
+ String getConfiguration() throws APPCException;
+
+ /**
+ * Disconnect from netconf device.
+ */
+ void disconnect() throws APPCException;
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java
new file mode 100644
index 000000000..20fec5c49
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.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.adapter.netconf;
+
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.adapter.netconf.odlconnector.NetconfClientRestconfImpl;
+
+
+public class NetconfClientFactory {
+
+ public NetconfClient GetNetconfClient(NetconfClientType type){
+
+ if(type==NetconfClientType.RESTCONF) {
+ return new NetconfClientRestconfImpl();
+ }else if(type == NetconfClientType.SSH){
+ return new NetconfClientJsch();
+ }
+
+ return null;
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java
new file mode 100644
index 000000000..04368615a
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java
@@ -0,0 +1,70 @@
+/*-
+ * ============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.adapter.netconf;
+
+import org.openecomp.appc.exceptions.APPCException;
+
+
+
+public interface NetconfClientRestconf {
+
+ /*
+ mount device to controller
+ @param deviceMountPointName - the name of the mounting point in controller
+ @param payload - json data describing device info
+ */
+ void connect(String deviceMountPointName, String payload) throws APPCException;
+
+ /*
+ check connection to device
+ @param deviceMountPointName - the name of the mounting point in controller
+ */
+ boolean checkConnection(String deviceMountPointName) throws APPCException;
+
+ /*
+ send configuration to Netconf server
+ @param configuration - xml configuration payload
+ @param deviceMountPointName - the name of the mounting point in controller
+ @param moduleName - name of the yang model
+ @param nodeName - name of the node created in server
+ */
+ void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException;
+
+ /*
+ backup device configuration
+ @param deviceMountPointName - the name of the mounting point in controlle
+ */
+ //void backupConfiguration(String deviceMountPointName);
+ /*
+ returns configuration of Netconf server
+ @param deviceMountPointName - the name of the mounting point in controller
+ @param moduleName - name of the yang model
+ @param nodeName - name of the node created in server
+ */
+ String getConfiguration(String deviceName, String moduleName, String nodeName) throws APPCException;
+
+ /*
+ unmount device
+ @param deviceMountPointName - the name of the mounting point in controller
+ */
+ void disconnect(String deviceMountPointName) throws APPCException;
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java
new file mode 100644
index 000000000..9757ae9ec
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.adapter.netconf;
+
+
+public enum NetconfClientType {
+ RESTCONF,
+ SSH
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java
new file mode 100644
index 000000000..fdbda2916
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java
@@ -0,0 +1,92 @@
+/*-
+ * ============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.adapter.netconf;
+
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Provides details required for connecting to netconf device.
+ */
+public class NetconfConnectionDetails {
+
+ private String host;
+ private int port;
+ private String username;
+ private String password;
+
+ public static int DEFAULT_PORT = 830;
+ private List<String> capabilities;
+ private Properties additionalProperties;
+
+ public NetconfConnectionDetails() {
+ super();
+ setPort(DEFAULT_PORT);
+ }
+ 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;
+ }
+
+ public List<String> getCapabilities() {
+ return capabilities;
+ }
+
+ public void setCapabilities(List<String> capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ public Properties getAdditionalProperties() {
+ return additionalProperties;
+ }
+
+ public void setAdditionalProperties(Properties additionalProperties) {
+ this.additionalProperties = additionalProperties;
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java
new file mode 100644
index 000000000..3536cf3b9
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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.adapter.netconf;
+
+import org.openecomp.appc.adapter.netconf.exception.DataAccessException;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+
+
+@SuppressWarnings("JavaDoc")
+public interface NetconfDataAccessService {
+
+ /**
+ *
+ * @param schema
+ */
+ void setSchema(String schema);
+
+ /**
+ *
+ * @param dbLibService
+ */
+ void setDbLibService(DbLibService dbLibService);
+
+ /**
+ *
+ * @param xmlID
+ * @return
+ * @throws DataAccessException
+ */
+ String retrieveConfigFileName(String xmlID) throws DataAccessException;
+
+ /**
+ *
+ * @param vnfType
+ * @param connectionDetails
+ * @return
+ * @throws DataAccessException
+ */
+ boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws DataAccessException;
+
+ /**
+ *
+ * @param vnfType
+ * @param connectionDetails
+ * @return
+ * @throws DataAccessException
+ */
+ boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) throws
+ DataAccessException;
+
+ /**
+ *
+ * @param instanceId
+ * @param requestId
+ * @param creationDate
+ * @param logText
+ * @return
+ * @throws DataAccessException
+ */
+ boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) throws
+ DataAccessException;
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java
new file mode 100644
index 000000000..fb9aba002
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.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.adapter.netconf;
+
+import org.openecomp.appc.exceptions.APPCException;
+
+
+public interface OperationalStateValidator {
+ public VnfType getVnfType();
+ public String getConfigurationFileName();
+ public void validateResponse(String response) throws APPCException;
+ final public static String CONFIG_FILE_PROPERTY_SUFFIX = "-CONFIG_FILE";
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java
new file mode 100644
index 000000000..94b87f497
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.adapter.netconf;
+
+import org.apache.commons.lang3.NotImplementedException;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+
+public class OperationalStateValidatorFactory {
+ protected static final Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ 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) {
+ switch (vnfType) {
+ case VNF:
+ case VNF_MOCK:
+ return new VNFOperationalStateValidatorImpl();
+ case MOCK:
+ return new MockOperationalStateValidatorImpl();
+ default:
+ throw new NotImplementedException("missing implementaion for the given vnfType:" + vnfType.name());
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java
new file mode 100644
index 000000000..fa84ea1a1
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java
@@ -0,0 +1,132 @@
+/*-
+ * ============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.adapter.netconf;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.*;
+
+public class VNFOperationalStateValidatorImpl implements OperationalStateValidator {
+ private static final String OPERATIONAL_STATE_ELEMENT_NAME = "operationalState";
+ @Override
+ public VnfType getVnfType() {
+ return VnfType.VNF;
+ }
+
+ @Override
+ public String getConfigurationFileName() {
+ String configFileName = OperationalStateValidatorFactory.configuration.getProperty(this.getClass().getCanonicalName() + CONFIG_FILE_PROPERTY_SUFFIX);
+ configFileName = configFileName == null? "VnfGetOperationalStates" : configFileName;
+ return configFileName;
+ }
+
+ @Override
+ public void validateResponse(String response) throws APPCException {
+ if(StringUtils.isEmpty(response)) {
+ throw new APPCException("empty response");
+ }
+
+ boolean isValid = false;
+ String errorMsg = "unexpected response";
+ try {
+ List<Map.Entry> operationalStateList = getOperationalStateList(response);
+ if(operationalStateList != null && !operationalStateList.isEmpty()) {
+ for (Map.Entry stateEntry : operationalStateList) {
+ if(!((String)stateEntry.getValue()).equalsIgnoreCase("ENABLED")){
+ errorMsg = "at least one "+OPERATIONAL_STATE_ELEMENT_NAME+" is not in valid satae. "+operationalStateList.toString();
+ isValid = false;
+ break;
+ }else{
+ isValid =true;
+ }
+ }
+ }else {
+ errorMsg = "response without any "+OPERATIONAL_STATE_ELEMENT_NAME+" element";
+ }
+ } catch (Exception e ) {
+ isValid = false;
+ errorMsg = e.toString();
+ }
+ if(!isValid) throw new APPCException(errorMsg);
+ }
+
+ private static List<Map.Entry> getOperationalStateList(String xmlText) throws IOException, ParserConfigurationException, SAXException {
+ List<Map.Entry> entryList = null;
+ if(StringUtils.isNotEmpty(xmlText)) {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ Document document = builder.parse(new ByteArrayInputStream(xmlText.getBytes("UTF-8")));
+ if(document != null) {
+ Element rootElement = document.getDocumentElement();
+ NodeList nodeList = rootElement.getElementsByTagName(OPERATIONAL_STATE_ELEMENT_NAME);
+ if (nodeList != null && nodeList.getLength() > 0) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ String text = node.getTextContent();
+ String id = getElementID(node);
+ entryList = (entryList == null) ? new ArrayList<Map.Entry>() : entryList;
+ Map.Entry entry = new AbstractMap.SimpleEntry<String, String>(id, text);
+ entryList.add(entry);
+ }
+ }
+ }
+ }
+ return entryList;
+ }
+
+ private static String getElementID(Node node) {
+ String id = null;
+ Node parentNode = node.getParentNode();
+ if (parentNode != null) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ NodeList nodeList = ((Element) parentNode).getElementsByTagName("id");
+ if (nodeList != null && nodeList.getLength() > 0) {
+ Node idNode = nodeList.item(0);
+ id = idNode != null ? idNode.getTextContent() : null;
+ }
+ }else {
+ id = parentNode.getNodeValue()+"|"+parentNode.getTextContent();
+ }
+ }
+
+ id = StringUtils.isEmpty(id) ? null : StringUtils.normalizeSpace(id);
+ id = StringUtils.isBlank(id) ? null : id;
+ id = id != null ? id : "unknown-id";
+ return id;
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java
new file mode 100644
index 000000000..18f334fa1
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.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.adapter.netconf;
+
+public enum VnfType {
+ VNF("VNF"),
+ MOCK("MOCK"),
+ VNF_MOCK("MOCK"),
+ ;
+
+ String familyType;
+ String upperCaseName;
+ VnfType(String familyType) {
+ this.familyType = familyType;
+ this.upperCaseName = name().toUpperCase();
+ }
+
+ public VnfType getFamilyType() {
+ return VnfType.valueOf(familyType);
+ }
+
+ public String getUpperCaseName() {
+ return upperCaseName;
+ }
+
+ public static VnfType getVnfType(String inSensitiveCaseName){
+ String localUpperCaseName = inSensitiveCaseName.toUpperCase();
+ for(VnfType vnfType : VnfType.values()){
+ if(vnfType.getUpperCaseName().equals(localUpperCaseName)){
+ return vnfType;
+ }
+ }
+ throw new IllegalArgumentException(
+ "No enum with upperCaseName for this input value:" + inSensitiveCaseName );
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java
new file mode 100644
index 000000000..1f3b9d830
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.adapter.netconf.exception;
+
+
+public class DataAccessException extends RuntimeException {
+
+ private static final long serialVersionUID = -155423437162622414L;
+
+ public DataAccessException(){
+ }
+
+ public DataAccessException(String message){
+ super(message);
+ }
+
+ public DataAccessException(Throwable cause){
+ super(cause);
+ }
+
+ public DataAccessException(String message , Throwable cause){
+ super(message , cause);
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java
new file mode 100644
index 000000000..c8c692c2a
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.adapter.netconf.exception;
+
+public class NetconfDAOException extends RuntimeException {
+
+ private static final long serialVersionUID = -155423437162622414L;
+
+ public NetconfDAOException(){
+ }
+
+ public NetconfDAOException(String message){
+ super(message);
+ }
+
+ public NetconfDAOException(Throwable cause){
+ super(cause);
+ }
+
+ public NetconfDAOException(String message , Throwable cause){
+ super(message , cause);
+ }
+
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java
new file mode 100644
index 000000000..7740728f4
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java
@@ -0,0 +1,129 @@
+/*-
+ * ============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.adapter.netconf.internal;
+
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.*;
+
+/**
+ * Provides basic methods for exchanging netconf messages.
+ */
+public class NetconfAdapter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfAdapter.class);
+ private static final long MAX_WAITING_TIME = 1800000;
+ private static ExecutorService executor = Executors.newFixedThreadPool(5);
+
+ // device input stream
+ private InputStream in;
+ // device output stream
+ private OutputStream out;
+ private long maxWaitingTime = ConfigurationFactory.getConfiguration().getLongProperty("org.openecomp.appc.netconf.recv.timeout", MAX_WAITING_TIME);
+
+ /**
+ * Constructor.
+ *
+ * @param in InputStream this instance will read netconf messages from
+ * @param out OutputStream this instance will write netconf messages to
+ * @throws IOException
+ */
+ public NetconfAdapter(InputStream in, OutputStream out) throws IOException {
+ this.in = in;
+ this.out = out;
+ }
+
+ /**
+ * Receives netconf message from InputStream and return it's text (without netconf frame characters).
+ *
+ * @return text of message received from netconf device
+ * @throws IOException
+ */
+ public String receiveMessage() throws IOException {
+
+ final NetconfMessage message = new NetconfMessage();
+ final byte[] buf = new byte[1024];
+
+ //int readByte = 1;
+ // Read data with timeout
+ Callable<Boolean> readTask = new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ int c;
+ while ((c = in.read(buf)) > 0) {
+ if (c > 0) {
+ message.append(buf, 0, c);
+ if (message.isCompleted()) {
+ break;
+ }
+ }
+ }
+
+ if (c < 0) {
+ return false;
+ }
+ return true;
+ }
+ };
+
+ Future<Boolean> future = executor.submit(readTask);
+ Boolean status;
+ try {
+ status = future.get(maxWaitingTime, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+
+ if (status == false) {
+ throw new IOException("Failed to read netconf message");
+ }
+
+
+ String text = message.getText();
+ if (text != null) {
+ text = text.trim();
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Received message from netconf device:\n" + text);
+ }
+ return text;
+ }
+
+ /**
+ * Sends netconf message with provided text (adds netconf frame characters and sends the message).
+ *
+ * @param text text of message to be sent to netconf device
+ * @throws IOException
+ */
+ public void sendMessage(final String text) throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Sending message to netconf device:\n" + text);
+ }
+ out.write(new NetconfMessage(text).getFrame());
+ out.flush();
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java
new file mode 100644
index 000000000..e0f166483
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java
@@ -0,0 +1,103 @@
+/*-
+ * ============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.adapter.netconf.internal;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+
+/**
+ * Provides basic methods for exchanging netconf messages.
+ */
+public class NetconfAdapter2 {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfAdapter2.class);
+
+ // device input pipe
+ private final PipedOutputStream pipedOutIn = new PipedOutputStream();
+ private PipedInputStream in;
+ // device output pipe
+ private final PipedInputStream pipedInOut = new PipedInputStream();
+ private PipedOutputStream out;
+
+ /**
+ * Constructor.
+ *
+ * @throws IOException
+ */
+ public NetconfAdapter2() throws IOException {
+ in = new PipedInputStream(pipedOutIn);
+ out = new PipedOutputStream(pipedInOut);
+ }
+
+ /**
+ * @return InputStream this instance will read netconf messages from.
+ */
+ public InputStream getIn() {
+ return in;
+ }
+
+ /**
+ * @return OutputStream this instance will write netconf messages to.
+ */
+ public OutputStream getOut() {
+ return out;
+ }
+
+ /**
+ * Receives netconf message from InputStream and return it's text (without netconf frame characters).
+ *
+ * @return text of message received from netconf device
+ * @throws IOException
+ */
+ public String receiveMessage() throws IOException {
+ NetconfMessage message = new NetconfMessage();
+ byte[] buf = new byte[1024];
+ int c;
+ while((c = pipedInOut.read(buf)) > 0) {
+ message.append(buf, 0, c);
+ if (message.isCompleted()) {
+ break;
+ }
+ }
+ String text = message.getText();
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Received message from netconf device:\n" + text);
+ }
+ return text;
+ }
+
+ /**
+ * Sends netconf message with provided text (adds netconf frame characters and sends the message).
+ *
+ * @param text text of message to be sent to netconf device
+ * @throws IOException
+ */
+ public void sendMessage(final String text) throws IOException {
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Sending message to netconf device:\n" + text);
+ }
+ pipedOutIn.write(new NetconfMessage(text).getFrame());
+// pipedOutIn.flush();
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java
new file mode 100644
index 000000000..d68900802
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.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.adapter.netconf.internal;
+
+public class NetconfConstMessages {
+
+ public static final String CAPABILITIES_START =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <capabilities>\n";
+
+ public static final String CAPABILITIES_BASE =
+ " <capability>urn:ietf:params:netconf:base:1.0</capability>\n";
+
+ public static final String CAPABILITIES_END =
+ " </capabilities>\n" +
+ "</hello>";
+
+ public static final String GET_RUNNING_CONFIG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <get-config>\n" +
+ " <source>\n" +
+ " <running/>\n" +
+ " </source>\n" +
+ " </get-config>\n" +
+ "</rpc>";
+
+ public static final String CLOSE_SESSION =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc message-id=\"terminateConnection\" xmlns:netconf=\"urn:ietf:params:xml:ns:netconf:base:1.0\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <close-session/>\n" +
+ "</rpc>";
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
new file mode 100644
index 000000000..53eb5b520
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.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.adapter.netconf.internal;
+
+import javax.sql.rowset.CachedRowSet;
+
+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.adapter.netconf.util.Constants;
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+
+public class NetconfDataAccessServiceImpl implements NetconfDataAccessService {
+
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(NetconfDataAccessServiceImpl.class);
+
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
+
+ private String schema;
+
+ public void setDbLibService(DbLibService service) {dbLibService = service;}
+
+ private DbLibService dbLibService;
+
+ @Override
+ public String retrieveConfigFileName(String xmlID) throws DataAccessException {
+ String fileContent = "";
+
+ String queryString = "select " + Constants.FILE_CONTENT_TABLE_FIELD_NAME + " " +
+ "from " + Constants.CONFIGFILES_TABLE_NAME + " " +
+ "where " + Constants.FILE_NAME_TABLE_FIELD_NAME + " = ?";
+
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(xmlID);
+
+ try {
+
+ final CachedRowSet data = dbLibService.getData(queryString, argList, schema);
+ if (data.first()) {
+ fileContent = data.getString(Constants.FILE_CONTENT_TABLE_FIELD_NAME);
+ }
+
+ } catch (Throwable e) {
+ logger.error("Error Accessing Database " + e);
+ throw new DataAccessException(e);
+ }
+
+ return fileContent;
+ }
+
+ @Override
+ public boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws
+ DataAccessException {
+ boolean recordFound = false;
+
+ String queryString = "select " + Constants.USER_NAME_TABLE_FIELD_NAME + "," + Constants.PASSWORD_TABLE_FIELD_NAME + "," + Constants.PORT_NUMBER_TABLE_FIELD_NAME + " " +
+ "from " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME + " " +
+ "where " + Constants.VNF_TYPE_TABLE_FIELD_NAME + " = ?";
+
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(vnfType);
+
+ try {
+
+ final CachedRowSet data = dbLibService.getData(queryString, argList, schema);
+ if (data.first()) {
+ connectionDetails.setUsername(data.getString(Constants.USER_NAME_TABLE_FIELD_NAME));
+ connectionDetails.setPassword(data.getString(Constants.PASSWORD_TABLE_FIELD_NAME));
+ connectionDetails.setPort(data.getInt(Constants.PORT_NUMBER_TABLE_FIELD_NAME));
+ recordFound = true;
+ }
+
+ } catch (SQLException e) {
+ logger.error("Error Accessing Database " + e);
+ throw new DataAccessException(e);
+ }
+
+ return recordFound;
+ }
+
+ @Override
+ public boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) throws
+ DataAccessException
+ {
+ ConnectionDetails connDetails = new ConnectionDetails();
+ if(this.retrieveConnectionDetails(vnfType, connDetails))
+ {
+ connectionDetails.setHost(connDetails.getHost());
+ connectionDetails.setPort(connDetails.getPort());
+ connectionDetails.setUsername(connDetails.getUsername());
+ connectionDetails.setPassword(connDetails.getPassword());
+ }
+ return true;
+ }
+
+ @Override
+ public boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) throws
+ DataAccessException {
+
+ String queryString = "INSERT INTO "+ Constants.DEVICE_INTERFACE_LOG_TABLE_NAME+"("+
+ Constants.SERVICE_INSTANCE_ID_FIELD_NAME+","+
+ Constants.REQUEST_ID_FIELD_NAME+","+
+ Constants.CREATION_DATE_FIELD_NAME+","+
+ Constants.LOG_FIELD_NAME+") ";
+ queryString += "values(?,?,?,?)";
+
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(instanceId);
+ argList.add(requestId);
+ argList.add(creationDate);
+ argList.add(logText);
+
+ try {
+
+ dbLibService.writeData(queryString, argList, schema);
+
+ } catch (SQLException e) {
+ logger.error("Logging Device interaction failed - "+ queryString);
+ throw new DataAccessException(e);
+ }
+
+ return true;
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java
new file mode 100644
index 000000000..200145b0a
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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.adapter.netconf.internal;
+
+import java.io.ByteArrayOutputStream;
+
+class NetconfMessage {
+
+ private static final String EOM = "]]>]]>";
+
+ private String text;
+ private MessageBuffer buffer = new MessageBuffer();
+ private int eomNotch;
+
+ NetconfMessage() {
+ }
+
+ NetconfMessage(String text) {
+ if(text == null) {
+ throw new NullPointerException("Netconf message payload is null");
+ }
+ append(text.getBytes(), 0, text.length());
+ if(this.text == null) {
+ this.text = text;
+ }
+ }
+
+ void append(byte[] bytes, int start, int end) {
+ boolean eomFound = false;
+ for(int i = start; i < end; i++) {
+ if(bytes[i] == EOM.charAt(eomNotch)) {
+ // advance notch
+ eomNotch++;
+ } else {
+ // reset notch
+ eomNotch = 0;
+ }
+ if(eomNotch == EOM.length()) {
+ // end of message found
+ eomFound = true;
+ end = i + 1;
+ break;
+ }
+ }
+ buffer.write(bytes, start, end);
+ if(eomFound) {
+ text = new String(buffer.getBytes(), 0, buffer.size() - EOM.length());
+ buffer.reset();
+ }
+ }
+
+ String getText() {
+ return text;
+ }
+
+ boolean isCompleted() {
+ return (text != null);
+ }
+
+ byte[] getFrame() {
+ StringBuilder sb = new StringBuilder();
+ if(text != null) {
+ sb.append(text).append("\n");
+ }
+ sb.append(EOM);
+ return sb.toString().getBytes();
+ }
+
+ private class MessageBuffer extends ByteArrayOutputStream {
+
+ byte[] getBytes() {
+ return buf;
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java
new file mode 100644
index 000000000..e6b47db38
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.adapter.netconf.jsch;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * JSch logger implementation delegating to logback.
+ */
+public class JSchLogger implements com.jcraft.jsch.Logger {
+
+ private static final Logger LOG = LoggerFactory.getLogger(JSchLogger.class);
+
+ @Override
+ public boolean isEnabled(int level) {
+ return true;
+ }
+
+ @Override
+ public void log(int level, String message) {
+ switch(level) {
+ case com.jcraft.jsch.Logger.DEBUG:
+ LOG.debug(message);
+ break;
+
+ case com.jcraft.jsch.Logger.INFO:
+ LOG.info(message);
+ break;
+
+ case com.jcraft.jsch.Logger.WARN:
+ LOG.warn(message);
+ break;
+
+ case com.jcraft.jsch.Logger.ERROR:
+ case com.jcraft.jsch.Logger.FATAL:
+ LOG.error(message);
+ break;
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java
new file mode 100644
index 000000000..c743b2dd8
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java
@@ -0,0 +1,171 @@
+/*-
+ * ============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.adapter.netconf.jsch;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelSubsystem;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.Session;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+
+import org.openecomp.appc.adapter.netconf.NetconfClient;
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.internal.NetconfAdapter;
+import org.openecomp.appc.adapter.netconf.internal.NetconfConstMessages;
+import org.openecomp.appc.encryption.EncryptionTool;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.i18n.Msg;
+import com.att.eelf.i18n.EELFResourceManager;
+
+/**
+ * Implementation of NetconfClient interface based on JCraft jsch library.
+ */
+public class NetconfClientJsch implements NetconfClient {
+
+ private static final int SESSION_CONNECT_TIMEOUT = 30000;
+ private static final int CHANNEL_CONNECT_TIMEOUT = 10000;
+
+ private Session session;
+ private Channel channel;
+ private NetconfAdapter netconfAdapter;
+// private NetconfAdapter2 netconfAdapter;
+
+
+ @Override
+ public void connect(NetconfConnectionDetails connectionDetails) throws APPCException {
+ String host = connectionDetails.getHost();
+ int port = connectionDetails.getPort();
+ String username = connectionDetails.getUsername();
+ String password = connectionDetails.getPassword();
+ try {
+ JSch.setLogger(new JSchLogger());
+ JSch jsch = new JSch();
+ session = jsch.getSession(EncryptionTool.getInstance().decrypt(username), host, port);
+ session.setPassword(EncryptionTool.getInstance().decrypt(password));
+ session.setConfig("StrictHostKeyChecking", "no");
+
+ Properties additionalProps = connectionDetails.getAdditionalProperties();
+ if((additionalProps != null) && !additionalProps.isEmpty()) {
+ session.setConfig(additionalProps);
+ }
+
+ session.connect(SESSION_CONNECT_TIMEOUT);
+ session.setTimeout(10000);
+ try {
+// session.setServerAliveCountMax(0); // If this is not set to '0', then socket timeout on all reads will not work!!!!
+ channel = session.openChannel("subsystem");
+ ((ChannelSubsystem)channel).setSubsystem("netconf");
+ netconfAdapter = new NetconfAdapter(channel.getInputStream(), channel.getOutputStream());
+// netconfAdapter = new NetconfAdapter2();
+// channel.setInputStream(netconfAdapter.getIn());
+// channel.setOutputStream(netconfAdapter.getOut());
+ channel.connect(CHANNEL_CONNECT_TIMEOUT);
+ hello(connectionDetails.getCapabilities());
+ } catch(Exception e) {
+ disconnect();
+ throw e;
+ }
+ } catch(Exception e) {
+ String message = EELFResourceManager.format(Msg.CANNOT_ESTABLISH_CONNECTION, host, String.valueOf(port), username);
+ throw new APPCException(message, e);
+ }
+ }
+
+ @Override
+ public String exchangeMessage(String message) throws APPCException {
+ try {
+ netconfAdapter.sendMessage(message);
+ return netconfAdapter.receiveMessage();
+ } catch(IOException e) {
+ throw new APPCException(e);
+ }
+ }
+
+ @Override
+ public void configure(String configuration) throws APPCException {
+ try {
+ isOk(exchangeMessage(configuration));
+ } catch(IOException e) {
+ throw new APPCException(e);
+ }
+ }
+
+ @Override
+ public String getConfiguration() throws APPCException {
+ return exchangeMessage(NetconfConstMessages.GET_RUNNING_CONFIG);
+ }
+
+ @Override
+ public void disconnect() {
+ try {
+ if((channel != null) && !channel.isClosed()) {
+ netconfAdapter.sendMessage(NetconfConstMessages.CLOSE_SESSION);
+ isOk(netconfAdapter.receiveMessage());
+ }
+ } catch(IOException e) {
+ throw new RuntimeException("Error closing netconf device", e);
+ } finally {
+ netconfAdapter = null;
+ if(channel != null) {
+ channel.disconnect();
+ channel = null;
+ }
+ if(session != null) {
+ session.disconnect();
+ session = null;
+ }
+ }
+ }
+
+ private void hello(List<String> capabilities) throws IOException {
+ String helloIn = netconfAdapter.receiveMessage();
+ if(helloIn == null) {
+ throw new IOException("Expected hello message, but nothing received error from netconf device");
+ }
+ if(helloIn.contains("<rpc-error>")) {
+ throw new IOException("Expected hello message, but received error from netconf device:\n" + helloIn);
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append(NetconfConstMessages.CAPABILITIES_START);
+ sb.append(NetconfConstMessages.CAPABILITIES_BASE);
+ if(capabilities != null) {
+ for(String capability: capabilities) {
+ sb.append(" ").append(capability).append("\n");
+ }
+ }
+ sb.append(NetconfConstMessages.CAPABILITIES_END);
+ String helloOut = sb.toString();
+ netconfAdapter.sendMessage(helloOut);
+ }
+
+ private void isOk(String response) throws IOException {
+ if(response == null) {
+ throw new IOException("No response from netconf device");
+ }
+ if(!response.contains("<ok/>")) {
+ throw new IOException("Error response from netconf device: \n" + response);
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java
new file mode 100644
index 000000000..2c10cdedd
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java
@@ -0,0 +1,233 @@
+/*-
+ * ============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.adapter.netconf.odlconnector;
+
+import org.apache.http.HttpStatus;
+import org.openecomp.appc.adapter.netconf.NetconfClient;
+import org.openecomp.appc.adapter.netconf.NetconfClientRestconf;
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.util.Constants;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.util.httpClient;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.util.Properties;
+
+public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRestconf {
+
+ private EELFLogger logger = EELFManager.getInstance().getLogger(NetconfClientRestconfImpl.class);
+
+ private NetconfConnectionDetails connectionDetails;
+
+ //constructor
+ public NetconfClientRestconfImpl(){
+ }
+
+ //restconf client impl
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException {
+
+ logger.info("Configuring device "+deviceMountPointName+" with configuration "+configuration);
+
+ int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/json");
+
+ if (httpCode != HttpStatus.SC_OK) {
+ logger.error("Configuration request failed. throwing Exception !");
+ throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName);
+ }
+ }
+
+ @Override
+ public void connect(String deviceMountPointName, String payload) throws APPCException{
+
+ logger.info("Connecting device "+deviceMountPointName);
+
+ int httpCode = httpClient.postMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getConnectPath(),payload,"application/json");
+
+ if(httpCode != HttpStatus.SC_NO_CONTENT){
+ logger.error("Connect request failed with code "+httpCode+". throwing Exception !");
+ throw new APPCException("Error connecting device :" + deviceMountPointName);
+ }
+ }
+
+ @Override
+ public boolean checkConnection(String deviceMountPointName) throws APPCException {
+ logger.info("Checking device "+deviceMountPointName+" connectivity");
+
+ String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getCheckConnectivityPath(deviceMountPointName),"application/json");
+
+ return result != null;
+ }
+
+ @Override
+ public void disconnect(String deviceMountPointName) throws APPCException {
+ logger.info("Disconnecting "+deviceMountPointName);
+
+ int httpCode = httpClient.deleteMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getDisconnectPath(deviceMountPointName),"application/json");
+
+ if(httpCode != HttpStatus.SC_OK){
+ logger.error("Disconnection of device "+deviceMountPointName+" failed!");
+ throw new APPCException("Disconnection of device "+deviceMountPointName+" failed!");
+ }
+ }
+
+ @Override
+ public String getConfiguration(String deviceMountPointName, String moduleName, String nodeName) throws APPCException{
+ logger.info("Getting configuration of device "+deviceMountPointName);
+
+ String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),"application/json");
+
+ if (result == null) {
+ logger.error("Configuration request failed. throwing Exception !");
+ throw new APPCException("Error getting configuration of node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName);
+ }
+
+ return result;
+ }
+
+ //netconf client impl
+
+ @Override
+ public void connect(NetconfConnectionDetails connectionDetails) throws APPCException {
+ if(connectionDetails == null){
+ throw new APPCException("Invalid connection details - null value");
+ }
+ this.connectionDetails = connectionDetails;
+ this.connect(connectionDetails.getHost(),getPayload());
+ }
+
+ @Override
+ public String exchangeMessage(String message) throws APPCException {
+ // TODO implement
+ return null;
+ }
+
+ @Override
+ public void configure(String configuration) throws APPCException {
+ if(connectionDetails == null){
+ throw new APPCException("Invalid connection details - null value");
+ }
+
+ Properties props = connectionDetails.getAdditionalProperties();
+ if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){
+ throw new APPCException("Invalid properties!");
+ }
+
+ String moduleName = props.getProperty("module.name");
+ String nodeName = props.getProperty("node.name");
+ String deviceMountPointName = connectionDetails.getHost();
+
+ int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/xml");
+
+ if (httpCode != HttpStatus.SC_OK) {
+ logger.error("Configuration request failed. throwing Exception !");
+ throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName);
+ }
+ }
+
+ @Override
+ public String getConfiguration() throws APPCException {
+ if(connectionDetails == null){
+ throw new APPCException("Invalid connection details - null value");
+ }
+
+ Properties props = connectionDetails.getAdditionalProperties();
+ if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){
+ throw new APPCException("Invalid properties!");
+ }
+
+ return this.getConfiguration(connectionDetails.getHost(),props.getProperty("module.name"),props.getProperty("node.name"));
+ }
+
+ @Override
+ public void disconnect() throws APPCException {
+ if(connectionDetails == null){
+ throw new APPCException("Invalid connection details - null value");
+ }
+ this.disconnect(connectionDetails.getHost());
+ }
+
+ //private methods
+ private String getModuleConfigurePath(String deviceMountPointName, String moduleName, String nodeName){
+
+
+ String deviceSpecificPath = deviceMountPointName + "/yang-ext:mount/" + moduleName + ":" + nodeName;
+
+ return Constants.CONFIGURE_PATH + deviceSpecificPath;
+ }
+
+ private String getConnectPath(){
+
+ return Constants.CONNECT_PATH;
+ }
+
+ private String getCheckConnectivityPath(String deviceMountPointName) {
+ return Constants.CHECK_CONNECTION_PATH + deviceMountPointName;
+ }
+
+ private String getDisconnectPath(String deviceMountPointName) {
+ return Constants.DISCONNECT_PATH + deviceMountPointName;
+ }
+
+ private String getPayload() {
+ return "{\n" +
+ " \"config:module\":\n" +
+ " {\n" +
+ " \"type\":\"odl-sal-netconf-connector-cfg:sal-netconf-connector\",\n" +
+ " \"netconf-northbound-ssh\\odl-sal-netconf-connector-cfg:name\":"+connectionDetails.getHost()+",\n" +
+ " \"odl-sal-netconf-connector-cfg:address\":"+connectionDetails.getHost()+",\n" +
+ " \"odl-sal-netconf-connector-cfg:port\":"+connectionDetails.getPort()+",\n" +
+ " \"odl-sal-netconf-connector-cfg:username\":"+connectionDetails.getUsername()+",\n" +
+ " \"odl-sal-netconf-connector-cfg:password\":"+connectionDetails.getPassword()+",\n" +
+ " \"tcp-only\":\"false\",\n" +
+ " \"odl-sal-netconf-connector-cfg:event-executor\":\n" +
+ " {\n" +
+ " \"type\":\"netty:netty-event-executor\",\n" +
+ " \"name\":\"global-event-executor\"\n" +
+ " },\n" +
+ " \"odl-sal-netconf-connector-cfg:binding-registry\":\n" +
+ " {\n" +
+ " \"type\":\"opendaylight-md-sal-binding:binding-broker-osgi-registry\",\n" +
+ " \"name\":\"binding-osgi-broker\"\n" +
+ " },\n" +
+ " \"odl-sal-netconf-connector-cfg:dom-registry\":\n" +
+ " {\n" +
+ " \"type\":\"opendaylight-md-sal-dom:dom-broker-osgi-registry\",\n" +
+ " \"name\":\"dom-broker\"\n" +
+ " },\n" +
+ " \"odl-sal-netconf-connector-cfg:client-dispatcher\":\n" +
+ " {\n" +
+ " \"type\":\"odl-netconf-cfg:netconf-client-dispatcher\",\n" +
+ " \"name\":\"global-netconf-dispatcher\"\n" +
+ " },\n" +
+ " \"odl-sal-netconf-connector-cfg:processing-executor\":\n" +
+ " {\n" +
+ " \"type\":\"threadpool:threadpool\",\n" +
+ " \"name\":\"global-netconf-processing-executor\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java
new file mode 100644
index 000000000..92141e1b7
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java
@@ -0,0 +1,64 @@
+/*-
+ * ============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.adapter.netconf.util;
+
+public class Constants {
+
+ 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";
+
+ // tables and fields
+ public static final String NETCONF_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 VM_HOST_TABLE_FIELD_NAME = "VM_HOST";
+ public static final String VM_NAME_TABLE_FIELD_NAME = "VM_NAME";
+ 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";
+
+ // input fields names
+ public static final String VNF_TYPE_FIELD_NAME = "org.openecomp.appc.vftype";
+ 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 DG_ERROR_FIELD_NAME = "org.openecomp.appc.dg.error";
+ public static final String RESOURCEKEY = "resourceKey";
+ public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..fc741daf5
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,41 @@
+###
+# ============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.jdbc.driver=netconfctl
+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.netconf.recv.timeout=1800000
+
+### ###
+### Properties commented out below provided in appc.properties ###
+### ###
+#event.pool.members=<DMAAP_IP>:3904
+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-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java
new file mode 100644
index 000000000..d6d5ae278
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java
@@ -0,0 +1,197 @@
+/*-
+ * ============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=========================================================
+ */
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.junit.Test;
+import org.openecomp.appc.adapter.netconf.OperationalStateValidator;
+import org.openecomp.appc.adapter.netconf.OperationalStateValidatorFactory;
+import org.openecomp.appc.adapter.netconf.VnfType;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+
+public class OperationalStateValidatorTest {
+
+ @Test
+ public void testVNFValidResponse() {
+ String validResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
+ " <data>\n" +
+ " <ManagedElement xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <id>1</id>\n" +
+ " <ProcessorManagement>\n" +
+ " <id>1</id>\n" +
+ " <MatedPair>\n" +
+ " <id>1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_5</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_7</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " </MatedPair>\n" +
+ " <SystemController>\n" +
+ " <id>SC-1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </SystemController>\n" +
+ " <SystemController>\n" +
+ " <id>SC-2</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </SystemController>\n" +
+ " </ProcessorManagement>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </data>\n" +
+ "</rpc-reply>";
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(VnfType.VNF);
+ assertValidResponse(validResponse, operationalStateValidator);
+ }
+
+ void assertInvalidResponse(String response, OperationalStateValidator operationalStateValidator) {
+ try {
+ operationalStateValidator.validateResponse(response);
+ fail("invalid resposne passed without exception!!!");
+ } catch (APPCException e) {
+ assertNotNull(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testVNFInvalidResponses() {
+
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(VnfType.VNF);
+ assertInvalidResponse(null, operationalStateValidator);
+
+ assertInvalidResponse("", operationalStateValidator);
+
+ String response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ assertInvalidResponse(response, operationalStateValidator);
+
+ response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
+ "</rpc-reply>";
+ assertInvalidResponse(response, operationalStateValidator);
+
+ response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
+ " <data>\n" +
+ " <ManagedElement xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <id>1</id>\n" +
+ " <ProcessorManagement>\n" +
+ " <id>1</id>\n" +
+ " <MatedPair>\n" +
+ " <id>1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_5</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_7</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " </MatedPair>\n" +
+ " <SystemController>\n" +
+ " <id>SC-1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </SystemController>\n" +
+ " <SystemController>\n" +
+ " <id>SC-2</id>\n" +
+ " <operationalState></operationalState>\n" +
+ " </SystemController>\n" +
+ " </ProcessorManagement>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </data>\n" +
+ "</rpc-reply>";
+ assertInvalidResponse(response, operationalStateValidator);
+ }
+
+ void assertValidResponse(String response, OperationalStateValidator operationalStateValidator) {
+ try {
+ operationalStateValidator.validateResponse(response);
+ } catch (APPCException e) {
+ fail("Got unexpected exception. Validation failed. " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testMockValidResponse() {
+ String response = "valid";
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator("mock");
+ assertValidResponse(response, operationalStateValidator);
+
+ response = "";
+ assertValidResponse(response, operationalStateValidator);
+
+ response = null;
+ assertValidResponse(response, operationalStateValidator);
+ }
+
+ @Test
+ public void testMockInValidResponse() {
+ String response = "anything InValid anything.. ";
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(VnfType.MOCK);
+ assertInvalidResponse(response, operationalStateValidator);
+ }
+
+ @Test
+ public void testGetOperationalStateValidatorForInValidVnfType() {
+ try{
+ OperationalStateValidatorFactory.getOperationalStateValidator("wrongVnfType");
+ fail("invalid vnfType without exception!!!");
+ } catch (Exception e) {
+ assertNotNull(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testGetOperationalStateValidatorForValidVnfType() {
+ String vnfType = VnfType.VNF.name().toLowerCase();
+ assertGettingValidatorForValidVnf(vnfType);
+
+ vnfType = VnfType.VNF.name().toUpperCase();
+ assertGettingValidatorForValidVnf(vnfType);
+
+ vnfType = VnfType.MOCK.name().toLowerCase();
+ assertGettingValidatorForValidVnf(vnfType);
+
+ vnfType = VnfType.MOCK.name().toUpperCase();
+ assertGettingValidatorForValidVnf(vnfType);
+ }
+
+ void assertGettingValidatorForValidVnf(String vnfType) {
+ try{
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(vnfType);
+ assertNotNull(operationalStateValidator);
+ } catch (Exception e) {
+ fail("valid vnfType throw exception!!!");
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java
new file mode 100644
index 000000000..5e63d5010
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java
@@ -0,0 +1,88 @@
+/*-
+ * ============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.adapter.netconf.internal;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.appc.adapter.netconf.internal.NetconfAdapter;
+
+import java.io.IOException;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+
+public class TestNetconfAdapter {
+
+ private static final String EOM = "]]>]]>";
+
+ @Test
+ public void testReceiveMessage() throws IOException {
+ PipedOutputStream pos = new PipedOutputStream();
+ PipedInputStream is = new PipedInputStream(pos);
+
+ PipedInputStream pis = new PipedInputStream();
+ PipedOutputStream os = new PipedOutputStream(pis);
+
+ NetconfAdapter netconfAdapter = new NetconfAdapter(is, os);
+
+ String request = "Hello, netconf!";
+ pos.write(request.getBytes());
+ pos.write(EOM.getBytes());
+ String response = netconfAdapter.receiveMessage();
+ Assert.assertNotNull(response);
+ Assert.assertEquals(request, response.trim());
+ }
+
+ @Test
+ public void testSendMessage() throws IOException {
+ PipedOutputStream pos = new PipedOutputStream();
+ PipedInputStream is = new PipedInputStream(pos);
+
+ PipedInputStream pis = new PipedInputStream();
+ PipedOutputStream os = new PipedOutputStream(pis);
+
+ NetconfAdapter netconfAdapter = new NetconfAdapter(is, os);
+
+ String request = "Hello, netconf!";
+ netconfAdapter.sendMessage(request);
+ byte[] bytes = new byte[request.length()+EOM.length()+2];
+ int count = pis.read(bytes);
+ String response = new String(bytes, 0, count);
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.endsWith(EOM));
+ response = response.substring(0, response.length() - EOM.length()).trim();
+ Assert.assertEquals(request, response);
+ }
+
+ @Test
+ public void testSendReceive() throws IOException {
+ PipedOutputStream os = new PipedOutputStream();
+ PipedInputStream is = new PipedInputStream(os);
+
+ NetconfAdapter netconfAdapter = new NetconfAdapter(is, os);
+
+ String request = "Hello, netconf!";
+ netconfAdapter.sendMessage(request);
+ String response = netconfAdapter.receiveMessage();
+ Assert.assertNotNull(response);
+ Assert.assertEquals(request, response.trim());
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java
new file mode 100644
index 000000000..a26c6e9e9
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestGetRunningConfig {
+
+ private static final String HOST = "192.168.1.2";
+ private static final String USER = "test";
+ private static final String PSWD = "test123";
+ private static final int PORT = 830;
+ private static final List<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java
new file mode 100644
index 000000000..e4baecc89
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestModifyConfig {
+
+ private static final String HOST = "192.168.1.2";
+ private static final String USER = "test";
+ private static final String PSWD = "test123";
+ private static final int PORT = 830;
+ private static final List<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+ private static final String CONFIG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" +
+ " <edit-config>\n" +
+ " <target>\n" +
+ " <running />\n" +
+ " </target>\n" +
+ " <default-operation>merge</default-operation>\n" +
+ " <config xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <ManagedElement xmlns=\"urn:org.openecomp.appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:VnfFunction\">\n" +
+ " <id>1</id>\n" +
+ " <Interfaces>\n" +
+ " <id>1</id>\n" +
+ " <DiaRealmRf>\n" +
+ " <realm>example.com</realm>\n" +
+ " <reconnectTimer>60</reconnectTimer>\n" +
+ " </DiaRealmRf>\n" +
+ " </Interfaces>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </config>\n" +
+ " </edit-config>\n" +
+ "</rpc>";
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+
+ System.out.println("=> Reconfiguring device...");
+ String outMessage = netconfClientJsch.exchangeMessage(CONFIG);
+ System.out.println("=> Reconfiguration response:\n" + outMessage);
+
+ System.out.println("=> Running get configuration...");
+ configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java
new file mode 100644
index 000000000..1fe2e1093
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestModifyConfigMock {
+
+ private static final String HOST = "192.168.1.2";
+ private static final String USER = "test";
+ private static final String PSWD = "test123";
+ private static final int PORT = 830;
+ private static final List<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+ private static final String CONFIG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" +
+ " <edit-config>\n" +
+ " <target>\n" +
+ " <running />\n" +
+ " </target>\n" +
+ " <default-operation>merge</default-operation>\n" +
+ " <config xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <ManagedElement xmlns=\"urn:org.openecomp.appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:VnfFunction\">\n" +
+ " <id>1</id>\n" +
+ " <Interfaces>\n" +
+ " <id>1</id>\n" +
+ " <DiaRealmRf>\n" +
+ " <realm>example.com</realm>\n" +
+ " <reconnectTimer>60</reconnectTimer>\n" +
+ " </DiaRealmRf>\n" +
+ " </Interfaces>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </config>\n" +
+ " </edit-config>\n" +
+ "</rpc>";
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+
+ System.out.println("=> Reconfiguring device...");
+ String outMessage = netconfClientJsch.exchangeMessage(CONFIG);
+ System.out.println("=> Reconfiguration response:\n" + outMessage);
+
+ System.out.println("=> Running get configuration...");
+ configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java
new file mode 100644
index 000000000..256e8e8f5
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java
@@ -0,0 +1,91 @@
+/*-
+ * ============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.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestModifyConfigRouterMock {
+
+ private static final String HOST = "10.147.27.50"; // yuma netconf simulator
+ private static final int PORT = 830;
+ private static final String USER = "admin";
+ private static final String PSWD = "admin";
+ private static final List<String> CAPABILITIES = Collections.emptyList();
+ private static final String CONFIG =
+ "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <edit-config>\n" +
+ " <target>\n" +
+ " <candidate/>\n" +
+ " </target>\n" +
+ " <config xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <router xmlns=\"urn:sdnhub:odl:tutorial:router\">\n" +
+ " <ospf>\n" +
+ " <process-id>1</process-id>\n" +
+ " <networks>\n" +
+ " <subnet-ip>100.100.100.0/24</subnet-ip>\n" +
+ " <area-id>10</area-id>\n" +
+ " </networks>\n" +
+ " </ospf>\n" +
+ " <bgp>\n" +
+ " <as-number>1000</as-number>\n" +
+ " <router-id>10.10.1.1</router-id>\n" +
+ " <neighbors>\n" +
+ " <as-number>2000</as-number>\n" +
+ " <peer-ip>10.10.1.2</peer-ip>\n" +
+ " </neighbors>\n" +
+ " </bgp>\n" +
+ " </router>\n" +
+ " </config>\n" +
+ " </edit-config>\n" +
+ "</rpc>\n";
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+
+ System.out.println("=> Reconfiguring device...");
+ String outMessage = netconfClientJsch.exchangeMessage(CONFIG);
+ System.out.println("=> Reconfiguration response:\n" + outMessage);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java
new file mode 100644
index 000000000..39c1a871c
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java
@@ -0,0 +1,87 @@
+/*-
+ * ============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.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestOperationalStates {
+
+ private static final String HOST = "192.168.1.2";
+ private static final String USER = "test";
+ private static final String PSWD = "test123";
+ private static final int PORT = 830;
+ private static final List<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+ private static final String GET_OPERATIONAL_STATES =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<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:openecomp: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>";
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+
+ System.out.println("=> Running get operational states...");
+ String outMessage = netconfClientJsch.exchangeMessage(GET_OPERATIONAL_STATES);
+ System.out.println("=> Operational states:\n" + outMessage);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}