aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-03-13 00:24:11 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-13 00:24:11 +0000
commit4057d047848f6a2891e39d183e90215f91d990db (patch)
treea5fd89c0495f11f7e8157c277014d2468d8f4e2e
parente67ccb367e2cc3618ce4a9526a77c923373d13da (diff)
parent4a2c6a244ca8f0640922fdc98c0990998011f5cf (diff)
Merge "Add support to invoke device specific RPC"
-rw-r--r--components/scripts/python/ccsdk_netconf/netconfclient.py4
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt18
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt13
3 files changed, 35 insertions, 0 deletions
diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py
index d898ec00..e263ba8f 100644
--- a/components/scripts/python/ccsdk_netconf/netconfclient.py
+++ b/components/scripts/python/ccsdk_netconf/netconfclient.py
@@ -41,6 +41,10 @@ class NetconfClient:
persist, persist_id)
return device_response
+ def invoke_rpc(self, rpc):
+ device_response = self.netconf_rpc_client.invokeRpc(rpc)
+ return device_response
+
def cancel_commit(self, persist_id=""):
device_response = self.netconf_rpc_client.cancelCommit(persist_id)
return device_response
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
index 55085216..02c0a342 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
@@ -57,6 +57,24 @@ interface NetconfRpcService {
editDefaultOperation: String = ModifyAction.NONE.action): DeviceResponse
/**
+ * Invoke custom RPC as provided as input.
+ *
+ * Some use cases might required one to directly invoke a device
+ * specific RPC. The RPC must be correctly formatted.
+ *
+ * Ex: in order to rollback last submitted configuration
+ * for JUNOS devices, such RPC can be use:
+ * <code>
+ * &lt;rpc>
+ * &lt;load-configuration rollback="1"/>
+ * &lt;/rpc>
+ * </code>
+ *
+ * @param rpc the rpc content.
+ */
+ fun invokeRpc(rpc: String): DeviceResponse
+
+ /**
* Validate
*
* @param configTarget running or candidate, default candidate
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
index 8d8e0ea4..15fb3122 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
@@ -41,6 +41,19 @@ class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcServ
this.netconfSession = netconfSession
}
+ override fun invokeRpc(rpc: String): DeviceResponse {
+ var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
+ log.info("$deviceInfo: invokeRpc: messageId($messageId)")
+ try {
+ output = asyncRpc(rpc, messageId)
+ } catch (e: Exception) {
+ output.status = RpcStatus.FAILURE
+ output.errorMessage = "$deviceInfo: failed in invokeRpc command $e.message"
+ }
+ return output
+ }
+
override fun getConfig(filter: String, configTarget: String): DeviceResponse {
var output = DeviceResponse()
val messageId = messageIdInteger.getAndIncrement().toString()