blob: a942845b9141d3c7bce85e8bb4cac8bd373e1132 [file] [log] [blame]
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -05001from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \
Brinda Santha0140de2019-07-18 16:59:19 -04002 CONFIG_DEFAULT_OPERATION_REPLACE
3from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import NetconfExecutorExtensionsKt
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -05004
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -05005
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -05006class NetconfClient:
7
Brinda Santha0140de2019-07-18 16:59:19 -04008 def __init__(self, log, component_function, requirement_name):
9 self.log = log
10 self.component_function = component_function
11 netconf_device = NetconfExecutorExtensionsKt.netconfDevice(component_function, requirement_name)
12 self.netconf_rpc_client = netconf_device.netconfRpcService
13 self.netconf_session = netconf_device.netconfSession
Muthuramalingam, Brinda Santhf7c65792019-02-12 15:26:19 -050014
Brinda Santha0140de2019-07-18 16:59:19 -040015 def disconnect(self):
16 self.netconf_session.disconnect()
17 return
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050018
Brinda Santha0140de2019-07-18 16:59:19 -040019 def connect(self):
20 self.netconf_session.connect()
21 return
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050022
Brinda Santha0140de2019-07-18 16:59:19 -040023 def lock(self, config_target=CONFIG_TARGET_CANDIDATE):
24 device_response = self.netconf_rpc_client.lock(config_target)
25 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050026
Brinda Santha0140de2019-07-18 16:59:19 -040027 def get_config(self, filter="", config_target=CONFIG_TARGET_RUNNING):
28 device_response = self.netconf_rpc_client.getConfig(filter, config_target)
29 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050030
Brinda Santha0140de2019-07-18 16:59:19 -040031 def edit_config(self, message_content, config_target=CONFIG_TARGET_CANDIDATE,
32 edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE):
33 device_response = self.netconf_rpc_client.editConfig(message_content,
34 config_target,
35 edit_default_peration)
36 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050037
Brinda Santha0140de2019-07-18 16:59:19 -040038 def commit(self, confirmed=False, confirm_timeout=60, persist="",
39 persist_id=""):
40 device_response = self.netconf_rpc_client.commit(confirmed, confirm_timeout,
41 persist, persist_id)
42 return device_response
Alexis de Talhouët18e18572019-02-19 10:02:00 -050043
Brinda Santha0140de2019-07-18 16:59:19 -040044 def invoke_rpc(self, rpc):
45 device_response = self.netconf_rpc_client.invokeRpc(rpc)
46 return device_response
Alexis de Talhouët1a19d332019-03-11 22:22:30 -040047
Brinda Santha0140de2019-07-18 16:59:19 -040048 def cancel_commit(self, persist_id=""):
49 device_response = self.netconf_rpc_client.cancelCommit(persist_id)
50 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050051
Brinda Santha0140de2019-07-18 16:59:19 -040052 def unlock(self, config_target=CONFIG_TARGET_CANDIDATE):
53 device_response = self.netconf_rpc_client.unLock(config_target)
54 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050055
Brinda Santha0140de2019-07-18 16:59:19 -040056 def validate(self, config_target=CONFIG_TARGET_CANDIDATE):
57 device_response = self.netconf_rpc_client.validate(config_target)
58 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050059
Brinda Santha0140de2019-07-18 16:59:19 -040060 def discard_change(self):
61 device_response = self.netconf_rpc_client.discardConfig()
62 return device_response