Skip to content

Commit

Permalink
Merge pull request #3359 from AleksBelytskyi/huawei_vrp8_save_conf_fix
Browse files Browse the repository at this point in the history
fixing safe configuration for Huawei VRPv8
  • Loading branch information
ktbyers authored Jan 12, 2024
2 parents 8f4d3f0 + e7ea812 commit 1c75ca3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions netmiko/huawei/huawei.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,26 @@ def save_config(
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
######################################################################
or
######################################################################
Warning: The current configuration will be written to the device. Continue? [Y/N]:y
Now saving the current configuration to the slot 1 .
Info: Save the configuration successfully.
######################################################################
"""

# Huawei devices might break if you try to use send_command_timing() so use send_command()
# instead.
if confirm:
pattern = rf"(?:Are you sure|{self.prompt_pattern})"
pattern = rf"(?:[Cc]ontinue\?|{self.prompt_pattern})"
output = self._send_command_str(
command_string=cmd,
expect_string=pattern,
strip_prompt=False,
strip_command=False,
read_timeout=100.0,
)
if confirm_response and "Are you sure" in output:
if confirm_response and re.search(r"[Cc]ontinue\?", output):
output += self._send_command_str(
command_string=confirm_response,
expect_string=self.prompt_pattern,
Expand Down Expand Up @@ -266,7 +272,3 @@ def commit(
if error_marker in output:
raise ValueError(f"Commit failed with following errors:\n\n{output}")
return output

def save_config(self, *args: Any, **kwargs: Any) -> str:
"""Not Implemented"""
raise NotImplementedError

0 comments on commit 1c75ca3

Please sign in to comment.