Skip to content

Commit

Permalink
Fix nxos and nxos_ssh hostname change handling (napalm-automation#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers authored and ExaneServerTeam committed Mar 4, 2020
1 parent c14dd5e commit ee137e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions napalm/nxos/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def commit_config(self, message=""):

if self.replace:
self._load_cfg_from_checkpoint()
# If hostname changes ensure Netmiko state is updated properly
self._netmiko_device.set_base_prompt()
else:
self._commit_merge()

Expand Down
10 changes: 7 additions & 3 deletions napalm/nxos_ssh/nxos_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,15 @@ def _send_command(self, command, raw_text=False):
"""
return self.device.send_command(command)

def _send_command_list(self, commands):
def _send_command_list(self, commands, expect_string=None):
"""Wrapper for Netmiko's send_command method (for list of commands."""
output = ""
for command in commands:
output += self.device.send_command(
command, strip_prompt=False, strip_command=False
command,
strip_prompt=False,
strip_command=False,
expect_string=expect_string,
)
return output

Expand Down Expand Up @@ -528,8 +531,9 @@ def _load_cfg_from_checkpoint(self):
"rollback running-config file {}".format(self.candidate_cfg),
"no terminal dont-ask",
]

try:
rollback_result = self._send_command_list(commands)
rollback_result = self._send_command_list(commands, expect_string=r"[#>]")
finally:
self.changed = True
msg = rollback_result
Expand Down

0 comments on commit ee137e3

Please sign in to comment.