Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'changed' attribute from nxos driver #2055

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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