From 7804a3a0a14b894dff7c351c6bbf10b169cc3d4d Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 25 Mar 2024 18:58:47 -0700 Subject: [PATCH 1/2] Remove changed attribute from nxos driver --- napalm/nxos/nxos.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/napalm/nxos/nxos.py b/napalm/nxos/nxos.py index fbbffc44d..5559c9646 100644 --- a/napalm/nxos/nxos.py +++ b/napalm/nxos/nxos.py @@ -120,7 +120,6 @@ def __init__( self.timeout = timeout self.replace = True self.loaded = False - self.changed = False self.merge_candidate = "" self.candidate_cfg = "candidate_config.txt" self.rollback_cfg = "rollback_config.txt" @@ -220,13 +219,11 @@ def _commit_merge(self) -> None: if output and "Invalid command" in output: raise MergeConfigException("Error while applying config!") except Exception as e: - self.changed = True self.rollback() err_header = "Configuration merge failed; automatic rollback attempted" merge_error = "{0}:\n{1}".format(err_header, repr(str(e))) raise MergeConfigException(merge_error) - self.changed = True # clear the merge buffer self.merge_candidate = "" @@ -920,8 +917,6 @@ def _load_cfg_from_checkpoint(self) -> None: except ConnectionError: # requests will raise an error with verbose warning output (don't fail on this). return - finally: - self.changed = True # For nx-api a list is returned so extract the result associated with the # 'rollback' command. @@ -946,7 +941,6 @@ def rollback(self) -> None: raise ReplaceConfigException(msg) self.device.rollback(self.rollback_cfg) self._copy_run_start() - self.changed = False def get_facts(self) -> models.FactsDict: facts: models.FactsDict = {} # type: ignore From 41b40814edbab6095569491cbaddeae0573454d5 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Mon, 25 Mar 2024 19:00:56 -0700 Subject: [PATCH 2/2] Adding nxos_ssh driver, changed attribute removal --- napalm/nxos_ssh/nxos_ssh.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/napalm/nxos_ssh/nxos_ssh.py b/napalm/nxos_ssh/nxos_ssh.py index 3bfa46ec9..fcec00c28 100644 --- a/napalm/nxos_ssh/nxos_ssh.py +++ b/napalm/nxos_ssh/nxos_ssh.py @@ -542,12 +542,9 @@ def _load_cfg_from_checkpoint(self): "no terminal dont-ask", ] - try: - rollback_result = self._send_command_list( - commands, expect_string=r"[#>]", read_timeout=90 - ) - finally: - self.changed = True + rollback_result = self._send_command_list( + commands, expect_string=r"[#>]", read_timeout=90 + ) msg = rollback_result if "Rollback failed." in msg: raise ReplaceConfigException(msg) @@ -570,7 +567,6 @@ def rollback(self): # If hostname changes ensure Netmiko state is updated properly self._netmiko_device.set_base_prompt() self._copy_run_start() - self.changed = False def _apply_key_map(self, key_map, table): new_dict = {}