summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-03-11 22:22:30 -0400
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-03-11 22:34:11 -0400
commit6c56cf0348b574138722b2a4f67718d48709e4c2 (patch)
treed8f3471483c713976175a2824fcda8639d924347 /ms
parent512e8952527276f8103d8fc1ea92d55c3cf45298 (diff)
Add support to invoke device specific RPC
Change-Id: Ia003ed669cc88a4c24a495e79db620b5034bc3ca Issue-ID: CCSDK-790 Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms')
-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
2 files changed, 31 insertions, 0 deletions
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 550852165..02c0a3426 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 8d8e0ea46..15fb3122c 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()