c966b1a4b8e03012fd0ca8a2e3db42ce29a20cd5
[ccsdk/cds.git] /
1 import  netconf_constant
2 from netconfclient import NetconfClient
3 from java.lang import Exception
4 from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfComponentFunction
5
6 class DefaultGetNetConfig(NetconfComponentFunction):
7
8     def process(self, execution_request):
9         try:
10             log = globals()[netconf_constant.SERVICE_LOG]
11             print(globals())
12             #requestId = globals()[netconf_constant.PARAM_REQUEST_ID]
13             requestId = '1234'
14             nc = NetconfClient(log, self)
15
16             # Create RPC Serivice
17             nc.createRPCServiceFromRequirement("netconf-connection")
18
19             runningConfigTemplate = "runningconfig-template"
20
21             runningConfigMessageId = "get-config-" + requestId
22
23             deviceResponse = nc.getConfig(messageId=runningConfigMessageId,
24                                           filter=runningConfigTemplate)
25
26             log.info("Get Running Config Response {} ", deviceResponse.responseMessage)
27             if(deviceResponse !='null') :
28                 status = deviceResponse.status
29                 responseData = "{}"
30                 if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'):
31                     errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage
32
33         except Exception, err:
34             log.error("Exception in the script {}",err.getMessage())
35             status = netconf_constant.STATUS_FAILURE
36             errorMessage = "Get Running Config Failure ::"+err.getMessage()
37
38     def  recover(self, runtime_exception, execution_request):
39         print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
40         return None
41