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.cds.blueprintsprocessor.functions.netconf.executor import NetconfRpcService
9 class DefaultGetNetConfig(AbstractPythonComponentFunction):
10 def process(self, execution_request):
12 log = globals()[netconf_constant.SERVICE_LOG]
14 #requestId = globals()[netconf_constant.PARAM_REQUEST_ID]
17 bluePrintRuntimeService = globals()['bluePrintRuntimeService']
19 capabilityProperty = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device","netconf")
21 log.info("capabilityProperty {}",capabilityProperty)
22 netconfService = NetconfRpcService()
23 nc = NetconfClient(log, netconfService)
25 nc.connect(netconfService.getNetconfDeviceInfo(capabilityProperty))
26 runningConfigTemplate = "runningconfig-template"
28 runningConfigMessageId = "get-config-" + requestId
30 deviceResponse = nc.getConfig(messageId=runningConfigMessageId,
31 filter=runningConfigTemplate)
33 log.info("Get Running Config Response {} ", deviceResponse.responseMessage)
34 if(deviceResponse !='null') :
35 status = deviceResponse.status
37 if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'):
38 errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage
40 except Exception, err:
41 log.info("Exception in the script {}",err.getMessage())
42 status = netconf_constant.STATUS_FAILURE
43 errorMessage = "Get Running Config Failure ::"+err.getMessage()
45 def recover(self, runtime_exception, execution_request):
46 print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH