From 4a2c6a244ca8f0640922fdc98c0990998011f5cf Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 11 Mar 2019 22:22:30 -0400 Subject: Add support to invoke device specific RPC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia003ed669cc88a4c24a495e79db620b5034bc3ca Issue-ID: CCSDK-790 Signed-off-by: Alexis de Talhouët --- .../netconf/executor/api/NetconfRpcService.kt | 18 ++++++++++++++++++ .../netconf/executor/core/NetconfRpcServiceImpl.kt | 13 +++++++++++++ 2 files changed, 31 insertions(+) (limited to 'ms') 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 @@ -56,6 +56,24 @@ interface NetconfRpcService { fun editConfig(messageContent: String, configTarget: String = NetconfDatastore.CANDIDATE.datastore, 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: + * + * <rpc> + * <load-configuration rollback="1"/> + * </rpc> + * + * + * @param rpc the rpc content. + */ + fun invokeRpc(rpc: String): DeviceResponse + /** * Validate * 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() -- cgit 1.2.3-korg