1 import netconf_constant
2 from netconfclient import NetconfClient
3 from java.lang import Exception
4 from abstract_blueprint_function import AbstractPythonComponentFunction
5 from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfRpcService
6 from org.onap.ccsdk.apps.controllerblueprints.core.utils import JacksonUtils
7 from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces import DeviceInfo
8 from org.onap.ccsdk.apps.controllerblueprints.core.service import BluePrintRuntimeService
11 class DefaultGetNetConfig(AbstractPythonComponentFunction):
12 def process(self, execution_request):
14 log = globals()[netconf_constant.SERVICE_LOG]
16 #requestId = globals()[netconf_constant.PARAM_REQUEST_ID]
19 bluePrintRuntimeService = globals()['bluePrintRuntimeService']
21 capabilityProperty = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device","netconf")
23 log.info("capabilityProperty {}",capabilityProperty)
24 netconfService = NetconfRpcService()
25 nc = NetconfClient(log, netconfService)
27 nc.connect(netconfService.getNetconfDeviceInfo(capabilityProperty))
28 runningConfigTemplate = "runningconfig-template"
30 runningConfigMessageId = "get-config-" + requestId
32 deviceResponse = nc.getConfig(messageId=runningConfigMessageId,
33 filter=runningConfigTemplate)
35 log.info("Get Running Config Response {} ", deviceResponse.responseMessage)
36 if(deviceResponse !='null') :
37 status = deviceResponse.status
39 if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'):
40 errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage
42 except Exception, err:
43 log.info("Exception in the script {}",err.getMessage())
44 status = netconf_constant.STATUS_FAILURE
45 errorMessage = "Get Running Config Failure ::"+err.getMessage()
47 def recover(self, runtime_exception, execution_request):
48 print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH