diff options
author | Jessica Wagantall <jwagantall@linuxfoundation.org> | 2019-03-22 10:35:38 -0700 |
---|---|---|
committer | Jessica Wagantall <jwagantall@linuxfoundation.org> | 2019-03-22 10:36:17 -0700 |
commit | 995a36660fc855447d69a41a9a25b6b27fa57bf0 (patch) | |
tree | d5f5cb3dfaac6e31f9f2d885a04c9e180a2a02c3 /components/scripts/python/ccsdk_netconf/netconfclient.py | |
parent | 9cee11e750a6ea570bf3580f5f20399bf898e694 (diff) | |
parent | 86233d8ea68bebb4e49cc8d1378917f2e1d3cee4 (diff) |
Migrate "components" from ccsdk/apps
Migrate code from ccsdk/apps components
subfolder into ccsdk/cds
Issue-ID: CIMAN-245
Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
Diffstat (limited to 'components/scripts/python/ccsdk_netconf/netconfclient.py')
-rw-r--r-- | components/scripts/python/ccsdk_netconf/netconfclient.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py new file mode 100644 index 000000000..e263ba8f7 --- /dev/null +++ b/components/scripts/python/ccsdk_netconf/netconfclient.py @@ -0,0 +1,62 @@ +from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \ + CONFIG_DEFAULT_OPERATION_REPLACE + + +class NetconfClient: + + def __init__(self, log, component_function, requirement_name): + self.log = log + self.component_function = component_function + netconf_device = self.component_function.initializeNetconfConnection( + requirement_name) + self.netconf_rpc_client = netconf_device.netconfRpcService + self.netconf_session = netconf_device.netconfSession + + def disconnect(self): + self.netconf_session.disconnect() + return + + def connect(self): + self.netconf_session.connect() + return + + def lock(self, config_target=CONFIG_TARGET_CANDIDATE): + device_response = self.netconf_rpc_client.lock(config_target) + return device_response + + def get_config(self, filter="", config_target=CONFIG_TARGET_RUNNING): + device_response = self.netconf_rpc_client.getConfig(filter, config_target) + return device_response + + def edit_config(self, message_content, config_target=CONFIG_TARGET_CANDIDATE, + edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE): + device_response = self.netconf_rpc_client.editConfig(message_content, + config_target, + edit_default_peration) + return device_response + + def commit(self, confirmed=False, confirm_timeout=60, persist="", + persist_id=""): + device_response = self.netconf_rpc_client.commit(confirmed, confirm_timeout, + persist, persist_id) + return device_response + + def invoke_rpc(self, rpc): + device_response = self.netconf_rpc_client.invokeRpc(rpc) + return device_response + + def cancel_commit(self, persist_id=""): + device_response = self.netconf_rpc_client.cancelCommit(persist_id) + return device_response + + def unlock(self, config_target=CONFIG_TARGET_CANDIDATE): + device_response = self.netconf_rpc_client.unLock(config_target) + return device_response + + def validate(self, config_target=CONFIG_TARGET_CANDIDATE): + device_response = self.netconf_rpc_client.validate(config_target) + return device_response + + def discard_change(self): + device_response = self.netconf_rpc_client.discardConfig() + return device_response |