blob: dd7d2dc22772d6959209f5d734c31d0937d5fd5b [file] [log] [blame]
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -05001from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \
2 CONFIG_DEFAULT_OPERATION_REPLACE
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
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -05007 def __init__(self, log, component_function, requirement_name):
8 self.log = log
9 self.component_function = component_function
10 netconf_device = self.component_function.initializeNetconfConnection(
11 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
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050015 def disconnect(self):
16 self.netconf_session.disconnect()
17 return
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050018
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050019 def connect(self):
20 self.netconf_session.connect()
21 return
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050022
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -050023 def lock(self, config_target=CONFIG_TARGET_CANDIDATE):
24 device_response = self.netconf_rpc_client.lock(config_target)
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050025 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050026
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -050027 def get_config(self, filter="", config_target=CONFIG_TARGET_RUNNING):
28 device_response = self.netconf_rpc_client.getConfig(filter, config_target)
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050029 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050030
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -050031 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,
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050034 config_target,
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -050035 edit_default_peration)
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050036 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050037
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -050038 def commit(self):
39 device_response = self.netconf_rpc_client.commit()
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050040 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050041
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -050042 def unlock(self, config_target=CONFIG_TARGET_CANDIDATE):
43 device_response = self.netconf_rpc_client.unLock(config_target)
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050044 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050045
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -050046 def validate(self, config_target=CONFIG_TARGET_CANDIDATE):
47 device_response = self.netconf_rpc_client.validate(config_target)
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050048 return device_response
Cherukuri, Venkatanaresh (vn166g)8df56932019-02-05 09:47:55 -050049
Alexis de Talhouëta69b9f52019-02-18 08:08:24 -050050 def discard_change(self):
51 device_response = self.netconf_rpc_client.discardConfig()
Alexis de Talhouët3daf7d02019-02-12 23:05:01 -050052 return device_response