blob: 2d4829363bd01894143d0706b8dd95d23df7c737 [file] [log] [blame]
Steve Siani19dfd632019-08-15 21:42:50 -04001from netconf_constant import *
Brinda Santha0140de2019-07-18 16:59:19 -04002from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import NetconfExecutorExtensionsKt
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -05003
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -05004
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -05005class NetconfClient:
6
Brinda Santha0140de2019-07-18 16:59:19 -04007 def __init__(self, log, component_function, requirement_name):
8 self.log = log
9 self.component_function = component_function
10 netconf_device = NetconfExecutorExtensionsKt.netconfDevice(component_function, requirement_name)
11 self.netconf_rpc_client = netconf_device.netconfRpcService
12 self.netconf_session = netconf_device.netconfSession
Muthuramalingam, Brinda Santhf7c65792019-02-12 15:26:19 -050013
Brinda Santha0140de2019-07-18 16:59:19 -040014 def disconnect(self):
15 self.netconf_session.disconnect()
16 return
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050017
Brinda Santha0140de2019-07-18 16:59:19 -040018 def connect(self):
19 self.netconf_session.connect()
20 return
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050021
Brinda Santha0140de2019-07-18 16:59:19 -040022 def lock(self, config_target=CONFIG_TARGET_CANDIDATE):
23 device_response = self.netconf_rpc_client.lock(config_target)
24 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050025
Brinda Santha0140de2019-07-18 16:59:19 -040026 def get_config(self, filter="", config_target=CONFIG_TARGET_RUNNING):
27 device_response = self.netconf_rpc_client.getConfig(filter, config_target)
28 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050029
Brinda Santha0140de2019-07-18 16:59:19 -040030 def edit_config(self, message_content, config_target=CONFIG_TARGET_CANDIDATE,
31 edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE):
32 device_response = self.netconf_rpc_client.editConfig(message_content,
33 config_target,
34 edit_default_peration)
35 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050036
Brinda Santha0140de2019-07-18 16:59:19 -040037 def commit(self, confirmed=False, confirm_timeout=60, persist="",
38 persist_id=""):
39 device_response = self.netconf_rpc_client.commit(confirmed, confirm_timeout,
40 persist, persist_id)
41 return device_response
Alexis de Talhouët18e18572019-02-19 10:02:00 -050042
Brinda Santha0140de2019-07-18 16:59:19 -040043 def invoke_rpc(self, rpc):
44 device_response = self.netconf_rpc_client.invokeRpc(rpc)
45 return device_response
Alexis de Talhouët1a19d332019-03-11 22:22:30 -040046
Brinda Santha0140de2019-07-18 16:59:19 -040047 def cancel_commit(self, persist_id=""):
48 device_response = self.netconf_rpc_client.cancelCommit(persist_id)
49 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050050
Brinda Santha0140de2019-07-18 16:59:19 -040051 def unlock(self, config_target=CONFIG_TARGET_CANDIDATE):
52 device_response = self.netconf_rpc_client.unLock(config_target)
53 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050054
Brinda Santha0140de2019-07-18 16:59:19 -040055 def validate(self, config_target=CONFIG_TARGET_CANDIDATE):
56 device_response = self.netconf_rpc_client.validate(config_target)
57 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050058
Brinda Santha0140de2019-07-18 16:59:19 -040059 def discard_change(self):
60 device_response = self.netconf_rpc_client.discardConfig()
61 return device_response
Steve Siani19dfd632019-08-15 21:42:50 -040062
Steve Siani6dec3fb2019-08-27 14:58:30 -040063 def get(self, filter_content):
64 device_response = self.netconf_rpc_client.get(filter_content)
65 return device_response