From a0140dea9c608d745767574ac621ca0060a2bddc Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Thu, 18 Jul 2019 16:59:19 -0400 Subject: Refactor Netconf script component parent. Change-Id: Ibbec8cd5785372a89e14a86d4e6ff7f9fed4aad2 Issue-ID: CCSDK-1499 Signed-off-by: Brinda Santh Signed-off-by: Steve Siani --- .../Scripts/python/NetconfRpcExample.py | 70 +++++++++++----------- 1 file changed, 34 insertions(+), 36 deletions(-) (limited to 'components/model-catalog') diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py index f146e8123..2fd6c6659 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py @@ -16,39 +16,37 @@ import netconf_constant from common import ResolutionHelper from java.lang import Exception as JavaException from netconfclient import NetconfClient -from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import \ - NetconfComponentFunction - - -class NetconfRpcExample(NetconfComponentFunction): - - def process(self, execution_request): - try: - log = globals()[netconf_constant.SERVICE_LOG] - print(globals()) - nc = NetconfClient(log, self, "netconf-connection") - rr = ResolutionHelper(self) - - payload = rr.resolve_and_generate_message_from_template_prefix("hostname") - - nc.connect() - response = nc.lock() - if not response.isSuccess(): - log.error(response.errorMessage) - - nc.edit_config(message_content=payload, edit_default_peration="none") - nc.validate() - nc.discard_change() - nc.validate() - nc.commit() - nc.unlock() - nc.disconnect() - - except JavaException, err: - log.error("Java Exception in the script {}", err) - except Exception, err: - log.error("Python Exception in the script {}", err) - - def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH - return None +from org.onap.ccsdk.cds.blueprintsprocessor.services.execution import AbstractScriptComponentFunction + +class NetconfRpcExample(AbstractScriptComponentFunction): + + def process(self, execution_request): + try: + log = globals()[netconf_constant.SERVICE_LOG] + print(globals()) + nc = NetconfClient(log, self, "netconf-connection") + rr = ResolutionHelper(self) + + payload = rr.resolve_and_generate_message_from_template_prefix("hostname") + + nc.connect() + response = nc.lock() + if not response.isSuccess(): + log.error(response.errorMessage) + + nc.edit_config(message_content=payload, edit_default_peration="none") + nc.validate() + nc.discard_change() + nc.validate() + nc.commit() + nc.unlock() + nc.disconnect() + + except JavaException, err: + log.error("Java Exception in the script {}", err) + except Exception, err: + log.error("Python Exception in the script {}", err) + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None -- cgit 1.2.3-korg