Skip to content

Commit

Permalink
Merge pull request #2055 from napalm-automation/nxos_changed_remove
Browse files Browse the repository at this point in the history
Remove 'changed' attribute from nxos driver
  • Loading branch information
mirceaulinic authored Mar 26, 2024
2 parents 800e8d7 + 41b4081 commit cde303b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
6 changes: 0 additions & 6 deletions napalm/nxos/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = ""

Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
10 changes: 3 additions & 7 deletions napalm/nxos_ssh/nxos_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 = {}
Expand Down

0 comments on commit cde303b

Please sign in to comment.