aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorCherukuri, Venkatanaresh (vn166g) <vn166g@att.com>2019-01-08 11:51:22 -0500
committerSingal, Kapil (ks220y) <ks220y@att.com>2019-01-10 15:07:48 -0500
commit5624d7c1590faaa6fba5e3f5eefdfcc1774a9c03 (patch)
tree7f397f6dd5a033b5e6990744b54826c978b1c4b3 /ms
parentb78d581b9b9c661d39b510a233207f9b1e53ba08 (diff)
1 Controller Design Studio
Adding Netconf Executor Function module to support Netconf Transactions Change-Id: Idc2765f680819e2553a7a43d8b23dbecc2628f4a Issue-ID: CCSDK-790 Signed-off-by: Cherukuri, Venkatanaresh (vn166g) <vn166g@att.com>
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/pom.xml24
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt44
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt19
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionFactory.kt50
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt147
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfStreamThread.kt29
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfExecutionData.kt115
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/DeviceInfo.kt53
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfRpcClientService.kt109
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfSession.kt88
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConnectionUtils.kt32
11 files changed, 708 insertions, 2 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
index 131261d1..3128b641 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
+++ b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
@@ -31,7 +31,29 @@
<groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
<artifactId>python-executor</artifactId>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>${jettison.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <!-- <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15on</artifactId>
+ <version>${bouncycastle.version}</version>
+ </dependency> -->
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.54</version>
+ </dependency>
+
+ </dependencies>
</project>
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
index 267a49a7..562dd768 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
@@ -23,4 +23,46 @@ import org.springframework.context.annotation.Configuration
@Configuration
@ComponentScan
@EnableConfigurationProperties
-open class NetconfExecutorConfiguration \ No newline at end of file
+open class NetconfExecutorConfiguration
+
+
+class NetconfExecutorConstants {
+ companion object {
+ const val CONTEX_PARAM_MESSAGE = "message"
+ const val COMPONENT_SCRIPT_PATH = "component-scripts"
+
+ const val REQ_NETCONF_CONNECTION = "netconf-connection"
+ const val NETCONF_CONNECTION_SOURCE = "source"
+ const val NETCONF_CONNECTION_LOGIN_KEY = "login-key"
+ const val NETCONF_CONNECTION_LOGIN_ACCOUNT = "login-account"
+ const val NETCONF_CONNECTION_TARGET_IP = "target-ip-address"
+ const val NETCONF_CONNECTION_MESSAGE_PORT = "port-number"
+ const val NETCONF_CONNECTION_TIMEOUT = "connection-time-out"
+
+ const val INPUT_PARAM_REQUEST_ID = "request-id"
+ const val INPUT_PARAM_RESOURCE_ID = "resource-id"
+ const val INPUT_PARAM_RESERVATION_ID = "reservation-id"
+ const val INPUT_PARAM_RESOURCE_TYPE = "resource-type"
+ const val INPUT_PARAM_ACTION_NAME = "action-name"
+ const val INPUT_PARAM_TEMPLATE_NAME = "template-name"
+ const val INPUT_PARAM_ASSIGNMENT_ACTION_NAME = "assignment-action-name"
+
+ const val SCRIPT_OUTPUT_RESPONSE_DATA = "responseData"
+ const val SCRIPT_OUTPUT_ERROR_MESSAGE = "errorMessage"
+
+ const val OUTPUT_PARAM_RESPONSE_DATA = "response-data"
+ const val OUTPUT_PARAM_ERROR_MESSAGE = "error-message"
+ const val OUTPUT_PARAM_STATUS = "status"
+ const val OUTPUT_STATUS_SUCCESS = "success"
+ const val OUTPUT_STATUS_FAILURE = "failure"
+
+ const val CONFIG_DATA_TYPE_XML = "XML"
+ const val CONFIG_DATA_TYPE_JSON = "JSON"
+
+ const val CONFIG_TARGET_RUNNING = "running"
+ const val CONFIG_TARGET_CANDIDATE = "candidate"
+ const val CONFIG_DEFAULT_OPERATION_MERGE = "merge"
+ const val CONFIG_DEFAULT_OPERATION_REPLACE = "replace"
+ const val DEFAULT_NETCONF_SESSION_MANAGER_TYPE = "DEFAULT_NETCONF_SESSION"
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt
index f4818106..5f1b38da 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt
@@ -16,6 +16,9 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionFactory
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.NetconfSession
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -24,4 +27,20 @@ import org.springframework.stereotype.Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
class NetconfRpcService {
+ lateinit var deviceInfo: DeviceInfo
+ lateinit var netconfSession: NetconfSession
+
+ fun connect(netconfDeviceInfo: DeviceInfo) {
+ netconfSession = NetconfSessionFactory.instance("DEFAULT_NETCONF_SESSION", netconfDeviceInfo)
+ // TODO
+ }
+
+ fun disconnect() {
+ netconfSession.close()
+ }
+
+ fun reconnect() {
+ disconnect()
+ connect(deviceInfo)
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionFactory.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionFactory.kt
new file mode 100644
index 00000000..5299e5ac
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionFactory.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.data.NetconfException
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.NetconfSession
+import java.util.*
+
+object NetconfSessionFactory {
+
+ private fun NetconfSessionFactory() {}
+
+ val netConfSessionManagerMap = HashMap<String, NetconfSession>()
+
+ fun registerNetConfSessionManager(type: String, netconfSession: NetconfSession) {
+ netConfSessionManagerMap[type] = netconfSession
+ }
+
+ /**
+ * Creates a new NETCONF session for the specified device.
+ *
+ * @param type type of the session.
+ * @param netconfDeviceInfo information of the device to create the session for.
+ * @return Instance of NetconfSession.
+ * @throws NetconfException when problems arise establishing the connection.
+ */
+ @Throws(NetconfException::class)
+ fun instance(type: String, netconfDeviceInfo: DeviceInfo): NetconfSession {
+ return if (netConfSessionManagerMap.containsKey(type)) {
+ netConfSessionManagerMap[type]!!
+ } else {
+ return NetconfSessionImpl(netconfDeviceInfo)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
new file mode 100644
index 00000000..adcba131
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
@@ -0,0 +1,147 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core
+
+import com.google.common.collect.ImmutableList
+import com.google.common.collect.ImmutableSet
+import org.apache.sshd.client.SshClient
+import org.apache.sshd.client.channel.ClientChannel
+import org.apache.sshd.client.session.ClientSession
+import org.apache.sshd.common.FactoryManager
+import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.data.NetconfException
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.NetconfSession
+import org.slf4j.LoggerFactory
+import java.io.IOException
+import java.util.*
+import java.util.concurrent.CompletableFuture
+import java.util.concurrent.ConcurrentHashMap
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.atomic.AtomicInteger
+
+class NetconfSessionImpl(val deviceInfo: DeviceInfo): NetconfSession {
+ val log = LoggerFactory.getLogger(NetconfSessionImpl::class.java)
+ var connectTimeout: Long = 0
+ var replyTimeout: Int = 0
+ var idleTimeout: Int = 0
+ var sessionID: String? = null
+ var errorReplies: MutableList<String> = mutableListOf()
+ var netconfCapabilities = ImmutableList.of("urn:ietf:params:netconf:base:1.0", "urn:ietf:params:netconf:base:1.1")
+
+ // var replies: MutableMap<String, CompletableFuture<String>> = mutableListOf<String,CompletableFuture<String>()>()
+ var replies: Map<String, CompletableFuture<String>> = ConcurrentHashMap()
+ val deviceCapabilities = LinkedHashSet<String>()
+
+ lateinit var session: ClientSession
+ lateinit var client: SshClient
+ lateinit var channel: ClientChannel
+ //var streamHandler: NetconfStreamHandler? = null
+
+ val messageIdInteger = AtomicInteger(1)
+
+ init {
+ startConnection()
+ }
+
+ private fun startConnection() {
+ connectTimeout = deviceInfo.connectTimeoutSec
+ replyTimeout = deviceInfo.replyTimeout
+ idleTimeout = deviceInfo.idleTimeout
+ log.info("Connecting to NETCONF Device {} with timeouts C:{}, R:{}, I:{}", deviceInfo, connectTimeout,
+ replyTimeout, idleTimeout)
+ try {
+ startClient()
+ } catch (e: IOException) {
+ throw NetconfException("Failed to establish SSH with device $deviceInfo")
+ }
+
+ }
+
+ private fun startClient() {
+ //client = SshClient.setUpDefaultClient().toInt()
+ client = SshClient()
+ client.getProperties().putIfAbsent(FactoryManager.IDLE_TIMEOUT, TimeUnit.SECONDS.toMillis(idleTimeout.toLong()))
+ client.getProperties().putIfAbsent(FactoryManager.NIO2_READ_TIMEOUT,
+ TimeUnit.SECONDS.toMillis(idleTimeout + 15L))
+ client.start()
+ client.setKeyPairProvider(SimpleGeneratorHostKeyProvider())
+ startSession()
+ }
+
+ private fun startSession() {
+ val connectFuture = client.connect(deviceInfo.name, deviceInfo.ipAddress, deviceInfo.port)
+ .verify(connectTimeout, TimeUnit.SECONDS)
+
+ session = connectFuture.session
+
+ session.addPasswordIdentity(deviceInfo.pass)
+ session.auth().verify(connectTimeout, TimeUnit.SECONDS)
+
+ val event = session.waitFor(ImmutableSet.of(ClientSession.ClientSessionEvent.WAIT_AUTH,
+ ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.AUTHED), 0)
+
+ if (!event.contains(ClientSession.ClientSessionEvent.AUTHED)) {
+ log.debug("Session closed {} for event {}", session.isClosed(), event)
+ throw NetconfException(String
+ .format("Failed to authenticate session with device (%s) check the user/pwd or key", deviceInfo))
+ }
+ openChannel()
+ }
+
+ private fun openChannel() {
+ channel = session.createSubsystemChannel("netconf")
+ val channeuture = channel.open()
+
+ if (channeuture!!.await(connectTimeout, TimeUnit.SECONDS) && channeuture.isOpened) {
+ // streamHandler = NetconfStreamThread(channel.getInvertedOut(), channel.getInvertedIn(), deviceInfo,
+ // NetconfSessionDelegateImpl(), replies)
+ // sendHello()
+ } else {
+ throw NetconfException(String.format("Failed to open channel with device (%s)", deviceInfo))
+ }
+ }
+
+ private fun sendHello() {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+
+ override fun asyncRpc(request: String, msgId: String): CompletableFuture<String> {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun close(): Boolean {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun getSessionId(): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun getDeviceCapabilitiesSet(): Set<String> {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun checkAndReestablish() {
+ super.checkAndReestablish()
+ }
+
+ override fun setCapabilities(capabilities: List<String>) {
+ super.setCapabilities(capabilities)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfStreamThread.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfStreamThread.kt
new file mode 100644
index 00000000..c0fe37df
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfStreamThread.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core
+
+import org.slf4j.LoggerFactory
+
+
+class NetconfStreamThread : Thread() {
+
+ val log = LoggerFactory.getLogger(NetconfStreamThread::class.java)
+
+ override fun run() {
+
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfExecutionData.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfExecutionData.kt
new file mode 100644
index 00000000..312554ed
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/data/NetconfExecutionData.kt
@@ -0,0 +1,115 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.data
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
+import java.io.IOException
+import java.util.*
+
+class NetconfExecutionRequest {
+ lateinit var requestId: String
+ val action: String? = null
+ val source: String? = null
+ val loginKey: String? = null
+ val loginAccount: String? = null
+ val targetIP: String? = null
+ val port: Int = 0
+ val connectionTimeoutSec: Int = 0
+ val implementationScript: String? = null
+ val context: MutableMap<String, Any> = mutableMapOf()
+}
+
+class DeviceResponse {
+ lateinit var deviceInfo: DeviceInfo
+ lateinit var status: String
+ var errorMessage: String? = null
+ var responseMessage: String? = null
+ var requestMessage: String? = null
+ var subDeviceResponse: MutableMap<Any, Any>? = null
+
+ fun addSubDeviceResponse(key: String, subDeviceResponse: DeviceResponse) {
+ if (this.subDeviceResponse == null) {
+ this.subDeviceResponse = hashMapOf()
+ }
+ this.subDeviceResponse!![key] = subDeviceResponse
+ }
+}
+
+class NetconfExecutionResponse {
+ val status: String? = null
+ val errorMessage: String? = null
+ val responseData: Any = Any()
+}
+
+open class NetconfException(message: String) : IOException(message)
+
+class NetconfDeviceOutputEvent {
+ private var type: NetconfDeviceOutputEvent.Type
+ private var messagePayload: String? = null
+ private var messageID: String? = null
+ private var deviceInfo: DeviceInfo? = null
+ private var subject: Any? = null
+ private var time: Long = 0
+
+ /**
+ * Type of device related events.
+ */
+ enum class Type {
+ DEVICE_REPLY,
+ DEVICE_NOTIFICATION,
+ DEVICE_UNREGISTERED,
+ DEVICE_ERROR,
+ SESSION_CLOSED
+ }
+
+ /**
+ * Creates an event of a given type and for the specified subject and the current time.
+ *
+ * @param type event type
+ * @param subject event subject
+ * @param payload message from the device
+ * @param msgID id of the message related to the event
+ * @param netconfDeviceInfo device of event
+ */
+ constructor(type: Type, subject: String, payload: String, msgID: Optional<String>, netconfDeviceInfo: DeviceInfo) {
+ this.type = type
+ this.subject = subject
+ this.messagePayload = payload
+ this.deviceInfo = netconfDeviceInfo
+ this.messageID = msgID.get()
+ }
+
+ /**
+ * Creates an event of a given type and for the specified subject and time.
+ *
+ * @param type event type
+ * @param subject event subject
+ * @param payload message from the device
+ * @param msgID id of the message related to the event
+ * @param netconfDeviceInfo device of event
+ * @param time occurrence time
+ */
+ constructor(type: Type, subject: Any, payload: String, msgID: String, netconfDeviceInfo: DeviceInfo, time: Long) {
+ this.type = type
+ this.subject = subject
+ this.time = time
+ this.messagePayload = payload
+ this.deviceInfo = netconfDeviceInfo
+ this.messageID = msgID
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/DeviceInfo.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/DeviceInfo.kt
new file mode 100644
index 00000000..4b71770e
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/DeviceInfo.kt
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces
+
+
+data class DeviceInfo (
+ var name: String? = null,
+ var pass: String? = null,
+ var ipAddress: String? = null,
+ var port: Int = 0,
+ var key: String? = null,
+ // private var sshClientLib: NetconfSshClientLib = NetconfSshClientLib,
+
+ var connectTimeoutSec: Long = 30,
+ var replyTimeout: Int = 60,
+ var idleTimeout: Int = 45,
+ var deviceId: String? = null
+){
+ /**
+ * Information for contacting the controller.
+ *
+ * @param name the connection type
+ * @param pass the pass for the device
+ * @param ipAddress the ip address
+ * @param port the tcp port
+ */
+ fun DeviceInfo(name: String, pass: String, ipAddress: String, port: Int, connectTimeoutSec: Long){
+ //checkArgument(name != "", "Empty device username")
+ // checkArgument(port > 0, "Negative port")
+ //checkNotNull(ipAddress, "Null ip address")
+ this.name = name
+ this.pass = pass
+ this.ipAddress = ipAddress
+ this.port = port
+ //this.sshClientLib = Optional.ofNullable(NetconfSshClientLib)
+ this.connectTimeoutSec = connectTimeoutSec
+ this. deviceId = "$ipAddress:$port"
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfRpcClientService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfRpcClientService.kt
new file mode 100644
index 00000000..5d3c190c
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfRpcClientService.kt
@@ -0,0 +1,109 @@
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.data.DeviceResponse
+
+interface NetconfRpcClientService {
+
+ fun disconnect()
+
+
+ fun reconnect()
+
+ /**
+ * @param messageId message id of the request.
+ * @param configTarget config target ( running or candidate)
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun lock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+
+ /**
+ * @param messageId message id of the request.
+ * @param messageContent filter content.
+ * @param configTarget config target ( running or candidate)
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun getConfig(messageId: String, messageContent: String, configTarget: String, messageTimeout: Int): DeviceResponse
+
+ /**
+ * @param messageId message id of the request.
+ * @param configTarget config target ( running or candidate)
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun deleteConfig(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+
+ /**
+ * @param messageId message id of the request.
+ * @param messageContent edit config content.
+ * @param reConnect reconnect session
+ * @param wait waiting time to perform operation ( 0 indicates no wait )
+ * @param lock lock the device before performing edit.
+ * @param configTarget config target ( running or candidate)
+ * @param editDefaultOperation edit default operation (merge | replace | create | delete | remove or
+ * delete)
+ * @param clearCandidate commit after edit config
+ * @param commit clear candiate store before edit
+ * @param discardChanges Rollback on failure
+ * @param validate validate the config before commit
+ * @param unlock unlock device after edit
+ * @param preRestartWait
+ * @param postRestartWait
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun editConfig(messageId: String, messageContent: String, reConnect: Boolean, wait: Int, lock: Boolean,
+ configTarget: String, editDefaultOperation: String, clearCandidate: Boolean, validate: Boolean, commit: Boolean,
+ discardChanges: Boolean, unlock: Boolean, preRestartWait: Int, postRestartWait: Int, messageTimeout: Int): DeviceResponse
+
+ /**
+ * @param messageId message id of the request.
+ * @param configTarget config target ( running or candidate)
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun validate(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+
+ /**
+ * @param messageId message id of the request.
+ * @param message optional commit message
+ * @param discardChanges Rollback on failure
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun commit(messageId: String, message: String, discardChanges: Boolean, messageTimeout: Int): DeviceResponse
+
+ /**
+ * @param messageId message id of the request.
+ * @param configTarget config target ( running or candidate)
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun unLock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+
+ /**
+ * @param messageId message id of the request.
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun discardConfig(messageId: String, messageTimeout: Int): DeviceResponse
+
+ /**
+ * @param messageId message id of the request.
+ * @param force force close
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun close(messageId: String, force: Boolean, messageTimeout: Int): DeviceResponse
+
+ /**
+ * Executes an RPC request to the netconf server.
+ *
+ * @param request the XML containing the RPC request for the server.
+ * @param messageId message id of the request.
+ * @param messageTimeout message timeout of the request.
+ * @return Device response
+ */
+ fun asyncRpc(request: String, messageId: String, messageTimeout: Int): DeviceResponse
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfSession.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfSession.kt
new file mode 100644
index 00000000..84310ea5
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/interfaces/NetconfSession.kt
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces
+
+import org.slf4j.LoggerFactory
+import java.util.concurrent.CompletableFuture
+
+interface NetconfSession {
+
+ /**
+ * Executes an asynchronous RPC request to the server and obtains a future for it's response.
+ *
+ * @param request the XML containing the RPC request for the server.
+ * @param msgId message id of the request.
+ * @return Server response or ERROR
+ * @throws NetconfException when there is a problem in the communication process on the underlying
+ * connection
+ * @throws NetconfTransportException on secure transport-layer error
+ */
+ fun asyncRpc(request: String, msgId: String): CompletableFuture<String>
+
+ /**
+ * Closes the Netconf session with the device. the first time it tries gracefully, then kills it
+ * forcefully
+ *
+ * @return true if closed
+ * @throws NetconfException when there is a problem in the communication process on the underlying
+ * connection
+ */
+ fun close(): Boolean
+
+ /**
+ * Gets the session ID of the Netconf session.
+ *
+ * @return Session ID as a string.
+ */
+ fun getSessionId(): String
+
+ /**
+ * Gets the capabilities of the remote Netconf device associated to this session.
+ *
+ * @return Network capabilities as strings in a Set.
+ */
+ fun getDeviceCapabilitiesSet(): Set<String>
+
+ /**
+ * Checks the state of the underlying SSH session and connection and if necessary it reestablishes
+ * it. Should be implemented, providing a default here for retro compatibility.
+ *
+ * @throws NetconfException when there is a problem in reestablishing the connection or the session
+ * to the device.
+ */
+ fun checkAndReestablish() {
+ val log = LoggerFactory.getLogger(NetconfSession::class.java)
+ log.error("Not implemented/exposed by the underlying ({}) implementation", "NetconfSession")
+ }
+
+ /**
+ * Sets the ONOS side capabilities.
+ *
+ * @param capabilities list of capabilities has.
+ */
+ fun setCapabilities(capabilities: List<String>) {
+ // default implementation should be removed in the future
+ // no-op
+ }
+
+ /**
+ * Get the device information for initialised session.
+ *
+ * @return DeviceInfo as device information
+ */
+ //fun getDeviceInfo(): DeviceInfo
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConnectionUtils.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConnectionUtils.kt
new file mode 100644
index 00000000..5b4b0d41
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConnectionUtils.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+
+class NetconfConnectionUtils {
+ companion object {
+
+ fun getDeficeInfoForNodeRequirement(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ requirementName: String): DeviceInfo {
+ val deviceInfo = DeviceInfo()
+ //TODO
+ return deviceInfo
+ }
+ }
+} \ No newline at end of file