diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml index df351a5b8..3ec16bfbd 100644 --- a/.github/workflows/commit.yaml +++ b/.github/workflows/commit.yaml @@ -1,13 +1,15 @@ --- name: build on: [push, pull_request] +env: + environment: gh_actions jobs: std_tests: runs-on: ubuntu-latest strategy: max-parallel: 4 matrix: - python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0] + python-version: [3.7, 3.8, 3.9, 3.10.0] steps: - name: Checkout repository diff --git a/docs/netmiko/aruba/aruba_ssh.html b/docs/netmiko/aruba/aruba_ssh.html index 68912a967..f6d8f5dd9 100644 --- a/docs/netmiko/aruba/aruba_ssh.html +++ b/docs/netmiko/aruba/aruba_ssh.html @@ -52,7 +52,7 @@

Module netmiko.aruba.aruba_ssh

self._test_channel_read(pattern=r"[>#]") self.set_base_prompt() self.enable() - self.disable_paging(command="no page") + self.disable_paging(command="no paging") def check_config_mode( self, check_string: str = "(config) #", pattern: str = r"[>#]" @@ -214,7 +214,7 @@

Classes

self._test_channel_read(pattern=r"[>#]") self.set_base_prompt() self.enable() - self.disable_paging(command="no page") + self.disable_paging(command="no paging") def check_config_mode( self, check_string: str = "(config) #", pattern: str = r"[>#]" @@ -297,7 +297,7 @@

Methods

self._test_channel_read(pattern=r"[>#]") self.set_base_prompt() self.enable() - self.disable_paging(command="no page") + self.disable_paging(command="no paging") diff --git a/docs/netmiko/aruba/index.html b/docs/netmiko/aruba/index.html index 7419d6574..6e4b9a538 100644 --- a/docs/netmiko/aruba/index.html +++ b/docs/netmiko/aruba/index.html @@ -172,7 +172,7 @@

Classes

self._test_channel_read(pattern=r"[>#]") self.set_base_prompt() self.enable() - self.disable_paging(command="no page") + self.disable_paging(command="no paging") def check_config_mode( self, check_string: str = "(config) #", pattern: str = r"[>#]" @@ -255,7 +255,7 @@

Methods

self._test_channel_read(pattern=r"[>#]") self.set_base_prompt() self.enable() - self.disable_paging(command="no page") + self.disable_paging(command="no paging") diff --git a/docs/netmiko/base_connection.html b/docs/netmiko/base_connection.html index 85508950e..cafaa1d19 100644 --- a/docs/netmiko/base_connection.html +++ b/docs/netmiko/base_connection.html @@ -643,7 +643,7 @@

Module netmiko.base_connection

results = re.split(pattern, output, maxsplit=1, flags=re_flags) # The string matched by pattern must be retained in the output string. - # re.split will do this if capturing parentesis are used. + # re.split will do this if capturing parenthesis are used. if len(results) == 2: # no capturing parenthesis, convert and try again. pattern = f"({pattern})" @@ -1150,7 +1150,7 @@

Module netmiko.base_connection

time.sleep(main_delay * 10) new_data = "" while i <= count: - new_data += self.read_channel_timing() + new_data += self.read_channel_timing(read_timeout=20) if new_data: return new_data @@ -1971,7 +1971,7 @@

Module netmiko.base_connection

self.write_channel(self.RETURN) # You can encounter an issue here (on router name changes) prefer delay-based solution if not pattern: - output = self.read_channel_timing() + output = self.read_channel_timing(read_timeout=10.0) else: output = self.read_until_pattern(pattern=pattern) return check_string in output @@ -3068,7 +3068,7 @@

Classes

results = re.split(pattern, output, maxsplit=1, flags=re_flags) # The string matched by pattern must be retained in the output string. - # re.split will do this if capturing parentesis are used. + # re.split will do this if capturing parenthesis are used. if len(results) == 2: # no capturing parenthesis, convert and try again. pattern = f"({pattern})" @@ -3575,7 +3575,7 @@

Classes

time.sleep(main_delay * 10) new_data = "" while i <= count: - new_data += self.read_channel_timing() + new_data += self.read_channel_timing(read_timeout=20) if new_data: return new_data @@ -4396,7 +4396,7 @@

Classes

self.write_channel(self.RETURN) # You can encounter an issue here (on router name changes) prefer delay-based solution if not pattern: - output = self.read_channel_timing() + output = self.read_channel_timing(read_timeout=10.0) else: output = self.read_until_pattern(pattern=pattern) return check_string in output @@ -4892,7 +4892,7 @@

Methods

self.write_channel(self.RETURN) # You can encounter an issue here (on router name changes) prefer delay-based solution if not pattern: - output = self.read_channel_timing() + output = self.read_channel_timing(read_timeout=10.0) else: output = self.read_until_pattern(pattern=pattern) return check_string in output @@ -5120,7 +5120,7 @@

Methods

-def enable(self, cmd='', pattern='ssword', enable_pattern=None, re_flags=) +def enable(self, cmd='', pattern='ssword', enable_pattern=None, re_flags=re.IGNORECASE)

Enter enable mode.

@@ -5711,7 +5711,7 @@

Methods

results = re.split(pattern, output, maxsplit=1, flags=re_flags) # The string matched by pattern must be retained in the output string. - # re.split will do this if capturing parentesis are used. + # re.split will do this if capturing parenthesis are used. if len(results) == 2: # no capturing parenthesis, convert and try again. pattern = f"({pattern})" diff --git a/docs/netmiko/cisco/cisco_ios.html b/docs/netmiko/cisco/cisco_ios.html index 1e6f961ec..415a0da32 100644 --- a/docs/netmiko/cisco/cisco_ios.html +++ b/docs/netmiko/cisco/cisco_ios.html @@ -44,7 +44,30 @@

Module netmiko.cisco.cisco_ios

self.disable_paging() self.set_base_prompt() - def check_config_mode(self, check_string: str = ")#", pattern: str = r"#") -> bool: + def set_base_prompt( + self, + pri_prompt_terminator: str = "#", + alt_prompt_terminator: str = ">", + delay_factor: float = 1.0, + pattern: Optional[str] = None, + ) -> str: + """ + Cisco IOS/IOS-XE abbreviates the prompt at 20-chars in config mode. + + Consequently, abbreviate the base_prompt + """ + base_prompt = super().set_base_prompt( + pri_prompt_terminator=pri_prompt_terminator, + alt_prompt_terminator=alt_prompt_terminator, + delay_factor=delay_factor, + pattern=pattern, + ) + self.base_prompt = base_prompt[:16] + return self.base_prompt + + def check_config_mode( + self, check_string: str = ")#", pattern: str = r"[>#]" + ) -> bool: """ Checks if the device is in configuration mode or not. @@ -419,7 +442,30 @@

Classes

self.disable_paging() self.set_base_prompt() - def check_config_mode(self, check_string: str = ")#", pattern: str = r"#") -> bool: + def set_base_prompt( + self, + pri_prompt_terminator: str = "#", + alt_prompt_terminator: str = ">", + delay_factor: float = 1.0, + pattern: Optional[str] = None, + ) -> str: + """ + Cisco IOS/IOS-XE abbreviates the prompt at 20-chars in config mode. + + Consequently, abbreviate the base_prompt + """ + base_prompt = super().set_base_prompt( + pri_prompt_terminator=pri_prompt_terminator, + alt_prompt_terminator=alt_prompt_terminator, + delay_factor=delay_factor, + pattern=pattern, + ) + self.base_prompt = base_prompt[:16] + return self.base_prompt + + def check_config_mode( + self, check_string: str = ")#", pattern: str = r"[>#]" + ) -> bool: """ Checks if the device is in configuration mode or not. @@ -481,6 +527,36 @@

Methods

self.set_base_prompt()
+
+def set_base_prompt(self, pri_prompt_terminator='#', alt_prompt_terminator='>', delay_factor=1.0, pattern=None) +
+
+

Cisco IOS/IOS-XE abbreviates the prompt at 20-chars in config mode.

+

Consequently, abbreviate the base_prompt

+
+Source code +
def set_base_prompt(
+    self,
+    pri_prompt_terminator: str = "#",
+    alt_prompt_terminator: str = ">",
+    delay_factor: float = 1.0,
+    pattern: Optional[str] = None,
+) -> str:
+    """
+    Cisco IOS/IOS-XE abbreviates the prompt at 20-chars in config mode.
+
+    Consequently, abbreviate the base_prompt
+    """
+    base_prompt = super().set_base_prompt(
+        pri_prompt_terminator=pri_prompt_terminator,
+        alt_prompt_terminator=alt_prompt_terminator,
+        delay_factor=delay_factor,
+        pattern=pattern,
+    )
+    self.base_prompt = base_prompt[:16]
+    return self.base_prompt
+
+

Inherited members

  • diff --git a/docs/netmiko/cisco/cisco_nxos_ssh.html b/docs/netmiko/cisco/cisco_nxos_ssh.html index 72011f5e0..e2e6992c9 100644 --- a/docs/netmiko/cisco/cisco_nxos_ssh.html +++ b/docs/netmiko/cisco/cisco_nxos_ssh.html @@ -48,7 +48,9 @@

    Module netmiko.cisco.cisco_nxos_ssh

    # NX-OS fix for incorrect MD5 on 9K (due to strange <enter> patterns on NX-OS) return newline.sub(self.RESPONSE_RETURN, a_string).replace("\r", "\n") - def check_config_mode(self, check_string: str = ")#", pattern: str = "#") -> bool: + def check_config_mode( + self, check_string: str = ")#", pattern: str = r"[>#]" + ) -> bool: """Checks if the device is in configuration mode or not.""" return super().check_config_mode(check_string=check_string, pattern=pattern) @@ -501,7 +503,9 @@

    Inherited members

    # NX-OS fix for incorrect MD5 on 9K (due to strange <enter> patterns on NX-OS) return newline.sub(self.RESPONSE_RETURN, a_string).replace("\r", "\n") - def check_config_mode(self, check_string: str = ")#", pattern: str = "#") -> bool: + def check_config_mode( + self, check_string: str = ")#", pattern: str = r"[>#]" + ) -> bool: """Checks if the device is in configuration mode or not.""" return super().check_config_mode(check_string=check_string, pattern=pattern) @@ -546,13 +550,15 @@

    Ancestors

    Methods

    -def check_config_mode(self, check_string=')#', pattern='#') +def check_config_mode(self, check_string=')#', pattern='[>#]')

    Checks if the device is in configuration mode or not.

    Source code -
    def check_config_mode(self, check_string: str = ")#", pattern: str = "#") -> bool:
    +
    def check_config_mode(
    +    self, check_string: str = ")#", pattern: str = r"[>#]"
    +) -> bool:
         """Checks if the device is in configuration mode or not."""
         return super().check_config_mode(check_string=check_string, pattern=pattern)
    diff --git a/docs/netmiko/cisco/cisco_wlc_ssh.html b/docs/netmiko/cisco/cisco_wlc_ssh.html index 8016ec807..6aeb6e6c0 100644 --- a/docs/netmiko/cisco/cisco_wlc_ssh.html +++ b/docs/netmiko/cisco/cisco_wlc_ssh.html @@ -76,10 +76,12 @@

    Module netmiko.cisco.cisco_wlc_ssh

    def send_command_w_enter(self, *args: Any, **kwargs: Any) -> str: """ For 'show run-config' Cisco WLC adds a 'Press Enter to continue...' message - Even though pagination is disabled + Even though pagination is disabled. + show run-config also has excessive delays in the output which requires special handling. - Arguments are the same as send_command_timing() method + + Arguments are the same as send_command_timing() method. """ if len(args) > 1: raise ValueError("Must pass in delay_factor as keyword argument") @@ -89,17 +91,18 @@

    Module netmiko.cisco.cisco_wlc_ssh

    kwargs["delay_factor"] = self.select_delay_factor(delay_factor) output = self._send_command_timing_str(*args, **kwargs) + second_args = list(args) + if len(args) == 1: + second_args[0] = self.RETURN + else: + kwargs["command_string"] = self.RETURN + if not kwargs.get("max_loops"): + kwargs["max_loops"] = 150 + if "Press any key" in output or "Press Enter to" in output: - new_args = list(args) - if len(args) == 1: - new_args[0] = self.RETURN - else: - kwargs["command_string"] = self.RETURN - if not kwargs.get("max_loops"): - kwargs["max_loops"] = 150 # Send an 'enter' - output += self._send_command_timing_str(*new_args, **kwargs) + output += self._send_command_timing_str(*second_args, **kwargs) # WLC has excessive delay after this appears on screen if "802.11b Advanced Configuration" in output: @@ -125,17 +128,42 @@

    Module netmiko.cisco.cisco_wlc_ssh

    output = self.strip_prompt(output) return output - def send_command_w_yes(self, *args: Any, **kwargs: Any) -> str: + def _send_command_w_yes(self, *args: Any, **kwargs: Any) -> str: """ For 'show interface summary' Cisco WLC adds a - 'Would you like to display the next 15 entries?' message + 'Would you like to display the next 15 entries?' message. + Even though pagination is disabled - Arguments are the same as send_command_timing() method + Arguments are the same as send_command_timing() method. """ - output = self._send_command_timing_str(*args, **kwargs) - if "(y/n)" in output: - output += self._send_command_timing_str("y") + if len(args) > 1: + raise ValueError("Must pass in delay_factor as keyword argument") + + # If no delay_factor use 1 for default value + delay_factor = kwargs.get("delay_factor", 1) + kwargs["delay_factor"] = self.select_delay_factor(delay_factor) + + output = "" + new_output = self._send_command_timing_str(*args, **kwargs) + + second_args = list(args) + if len(args) == 1: + second_args[0] = "y" + else: + kwargs["command_string"] = "y" strip_prompt = kwargs.get("strip_prompt", True) + + while True: + output += new_output + if "display the next" in new_output.lower(): + new_output = self._send_command_timing_str(*second_args, **kwargs) + else: + break + + # Remove from output 'Would you like to display the next 15 entries? (y/n)' + pattern = r"^.*display the next.*\n$" + output = re.sub(pattern, "", output, flags=re.M) + if strip_prompt: # Had to strip trailing prompt twice. output = self.strip_prompt(output) @@ -412,10 +440,12 @@

    Classes

    def send_command_w_enter(self, *args: Any, **kwargs: Any) -> str: """ For 'show run-config' Cisco WLC adds a 'Press Enter to continue...' message - Even though pagination is disabled + Even though pagination is disabled. + show run-config also has excessive delays in the output which requires special handling. - Arguments are the same as send_command_timing() method + + Arguments are the same as send_command_timing() method. """ if len(args) > 1: raise ValueError("Must pass in delay_factor as keyword argument") @@ -425,17 +455,18 @@

    Classes

    kwargs["delay_factor"] = self.select_delay_factor(delay_factor) output = self._send_command_timing_str(*args, **kwargs) + second_args = list(args) + if len(args) == 1: + second_args[0] = self.RETURN + else: + kwargs["command_string"] = self.RETURN + if not kwargs.get("max_loops"): + kwargs["max_loops"] = 150 + if "Press any key" in output or "Press Enter to" in output: - new_args = list(args) - if len(args) == 1: - new_args[0] = self.RETURN - else: - kwargs["command_string"] = self.RETURN - if not kwargs.get("max_loops"): - kwargs["max_loops"] = 150 # Send an 'enter' - output += self._send_command_timing_str(*new_args, **kwargs) + output += self._send_command_timing_str(*second_args, **kwargs) # WLC has excessive delay after this appears on screen if "802.11b Advanced Configuration" in output: @@ -461,17 +492,42 @@

    Classes

    output = self.strip_prompt(output) return output - def send_command_w_yes(self, *args: Any, **kwargs: Any) -> str: + def _send_command_w_yes(self, *args: Any, **kwargs: Any) -> str: """ For 'show interface summary' Cisco WLC adds a - 'Would you like to display the next 15 entries?' message + 'Would you like to display the next 15 entries?' message. + Even though pagination is disabled - Arguments are the same as send_command_timing() method + Arguments are the same as send_command_timing() method. """ - output = self._send_command_timing_str(*args, **kwargs) - if "(y/n)" in output: - output += self._send_command_timing_str("y") + if len(args) > 1: + raise ValueError("Must pass in delay_factor as keyword argument") + + # If no delay_factor use 1 for default value + delay_factor = kwargs.get("delay_factor", 1) + kwargs["delay_factor"] = self.select_delay_factor(delay_factor) + + output = "" + new_output = self._send_command_timing_str(*args, **kwargs) + + second_args = list(args) + if len(args) == 1: + second_args[0] = "y" + else: + kwargs["command_string"] = "y" strip_prompt = kwargs.get("strip_prompt", True) + + while True: + output += new_output + if "display the next" in new_output.lower(): + new_output = self._send_command_timing_str(*second_args, **kwargs) + else: + break + + # Remove from output 'Would you like to display the next 15 entries? (y/n)' + pattern = r"^.*display the next.*\n$" + output = re.sub(pattern, "", output, flags=re.M) + if strip_prompt: # Had to strip trailing prompt twice. output = self.strip_prompt(output) @@ -711,19 +767,21 @@

    Methods

    For 'show run-config' Cisco WLC adds a 'Press Enter to continue…' message -Even though pagination is disabled -show run-config also has excessive delays in the output which requires special -handling. -Arguments are the same as send_command_timing() method

    +Even though pagination is disabled.

    +

    show run-config also has excessive delays in the output which requires special +handling.

    +

    Arguments are the same as send_command_timing() method.

    Source code
    def send_command_w_enter(self, *args: Any, **kwargs: Any) -> str:
         """
         For 'show run-config' Cisco WLC adds a 'Press Enter to continue...' message
    -    Even though pagination is disabled
    +    Even though pagination is disabled.
    +
         show run-config also has excessive delays in the output which requires special
         handling.
    -    Arguments are the same as send_command_timing() method
    +
    +    Arguments are the same as send_command_timing() method.
         """
         if len(args) > 1:
             raise ValueError("Must pass in delay_factor as keyword argument")
    @@ -733,17 +791,18 @@ 

    Methods

    kwargs["delay_factor"] = self.select_delay_factor(delay_factor) output = self._send_command_timing_str(*args, **kwargs) + second_args = list(args) + if len(args) == 1: + second_args[0] = self.RETURN + else: + kwargs["command_string"] = self.RETURN + if not kwargs.get("max_loops"): + kwargs["max_loops"] = 150 + if "Press any key" in output or "Press Enter to" in output: - new_args = list(args) - if len(args) == 1: - new_args[0] = self.RETURN - else: - kwargs["command_string"] = self.RETURN - if not kwargs.get("max_loops"): - kwargs["max_loops"] = 150 # Send an 'enter' - output += self._send_command_timing_str(*new_args, **kwargs) + output += self._send_command_timing_str(*second_args, **kwargs) # WLC has excessive delay after this appears on screen if "802.11b Advanced Configuration" in output: @@ -770,34 +829,6 @@

    Methods

    return output
    -
    -def send_command_w_yes(self, *args, **kwargs) -
    -
    -

    For 'show interface summary' Cisco WLC adds a -'Would you like to display the next 15 entries?' message -Even though pagination is disabled -Arguments are the same as send_command_timing() method

    -
    -Source code -
    def send_command_w_yes(self, *args: Any, **kwargs: Any) -> str:
    -    """
    -    For 'show interface summary' Cisco WLC adds a
    -    'Would you like to display the next 15 entries?' message
    -    Even though pagination is disabled
    -    Arguments are the same as send_command_timing() method
    -    """
    -    output = self._send_command_timing_str(*args, **kwargs)
    -    if "(y/n)" in output:
    -        output += self._send_command_timing_str("y")
    -    strip_prompt = kwargs.get("strip_prompt", True)
    -    if strip_prompt:
    -        # Had to strip trailing prompt twice.
    -        output = self.strip_prompt(output)
    -        output = self.strip_prompt(output)
    -    return output
    -
    -
    def session_preparation(self)
    @@ -934,7 +965,6 @@

    exit_config_mode

  • save_config
  • send_command_w_enter
  • -
  • send_command_w_yes
  • session_preparation
  • special_login_handler
  • diff --git a/docs/netmiko/cisco/cisco_xr.html b/docs/netmiko/cisco/cisco_xr.html index d93a0dee1..e59c9a1c5 100644 --- a/docs/netmiko/cisco/cisco_xr.html +++ b/docs/netmiko/cisco/cisco_xr.html @@ -44,6 +44,27 @@

    Module netmiko.cisco.cisco_xr

    self._test_channel_read(pattern=r"[>#]") self.set_base_prompt() + def set_base_prompt( + self, + pri_prompt_terminator: str = "#", + alt_prompt_terminator: str = ">", + delay_factor: float = 1.0, + pattern: Optional[str] = None, + ) -> str: + """ + Cisco IOS-XR abbreviates the prompt at 31-chars in config mode. + + Consequently, abbreviate the base_prompt + """ + base_prompt = super().set_base_prompt( + pri_prompt_terminator=pri_prompt_terminator, + alt_prompt_terminator=alt_prompt_terminator, + delay_factor=delay_factor, + pattern=pattern, + ) + self.base_prompt = base_prompt[:31] + return self.base_prompt + def send_config_set( self, config_commands: Union[str, Sequence[str], TextIO, None] = None, @@ -395,6 +416,27 @@

    Classes

    self._test_channel_read(pattern=r"[>#]") self.set_base_prompt() + def set_base_prompt( + self, + pri_prompt_terminator: str = "#", + alt_prompt_terminator: str = ">", + delay_factor: float = 1.0, + pattern: Optional[str] = None, + ) -> str: + """ + Cisco IOS-XR abbreviates the prompt at 31-chars in config mode. + + Consequently, abbreviate the base_prompt + """ + base_prompt = super().set_base_prompt( + pri_prompt_terminator=pri_prompt_terminator, + alt_prompt_terminator=alt_prompt_terminator, + delay_factor=delay_factor, + pattern=pattern, + ) + self.base_prompt = base_prompt[:31] + return self.base_prompt + def send_config_set( self, config_commands: Union[str, Sequence[str], TextIO, None] = None, @@ -822,6 +864,36 @@

    Methods

    self.set_base_prompt()
    +
    +def set_base_prompt(self, pri_prompt_terminator='#', alt_prompt_terminator='>', delay_factor=1.0, pattern=None) +
    +
    +

    Cisco IOS-XR abbreviates the prompt at 31-chars in config mode.

    +

    Consequently, abbreviate the base_prompt

    +
    +Source code +
    def set_base_prompt(
    +    self,
    +    pri_prompt_terminator: str = "#",
    +    alt_prompt_terminator: str = ">",
    +    delay_factor: float = 1.0,
    +    pattern: Optional[str] = None,
    +) -> str:
    +    """
    +    Cisco IOS-XR abbreviates the prompt at 31-chars in config mode.
    +
    +    Consequently, abbreviate the base_prompt
    +    """
    +    base_prompt = super().set_base_prompt(
    +        pri_prompt_terminator=pri_prompt_terminator,
    +        alt_prompt_terminator=alt_prompt_terminator,
    +        delay_factor=delay_factor,
    +        pattern=pattern,
    +    )
    +    self.base_prompt = base_prompt[:31]
    +    return self.base_prompt
    +
    +

    Inherited members

  • diff --git a/docs/netmiko/cisco/index.html b/docs/netmiko/cisco/index.html index 5b928666c..c1a3f6040 100644 --- a/docs/netmiko/cisco/index.html +++ b/docs/netmiko/cisco/index.html @@ -1023,7 +1023,30 @@

    Inherited members

    self.disable_paging() self.set_base_prompt() - def check_config_mode(self, check_string: str = ")#", pattern: str = r"#") -> bool: + def set_base_prompt( + self, + pri_prompt_terminator: str = "#", + alt_prompt_terminator: str = ">", + delay_factor: float = 1.0, + pattern: Optional[str] = None, + ) -> str: + """ + Cisco IOS/IOS-XE abbreviates the prompt at 20-chars in config mode. + + Consequently, abbreviate the base_prompt + """ + base_prompt = super().set_base_prompt( + pri_prompt_terminator=pri_prompt_terminator, + alt_prompt_terminator=alt_prompt_terminator, + delay_factor=delay_factor, + pattern=pattern, + ) + self.base_prompt = base_prompt[:16] + return self.base_prompt + + def check_config_mode( + self, check_string: str = ")#", pattern: str = r"[>#]" + ) -> bool: """ Checks if the device is in configuration mode or not. @@ -1085,6 +1108,36 @@

    Methods

    self.set_base_prompt() +
    +def set_base_prompt(self, pri_prompt_terminator='#', alt_prompt_terminator='>', delay_factor=1.0, pattern=None) +
    +
    +

    Cisco IOS/IOS-XE abbreviates the prompt at 20-chars in config mode.

    +

    Consequently, abbreviate the base_prompt

    +
    +Source code +
    def set_base_prompt(
    +    self,
    +    pri_prompt_terminator: str = "#",
    +    alt_prompt_terminator: str = ">",
    +    delay_factor: float = 1.0,
    +    pattern: Optional[str] = None,
    +) -> str:
    +    """
    +    Cisco IOS/IOS-XE abbreviates the prompt at 20-chars in config mode.
    +
    +    Consequently, abbreviate the base_prompt
    +    """
    +    base_prompt = super().set_base_prompt(
    +        pri_prompt_terminator=pri_prompt_terminator,
    +        alt_prompt_terminator=alt_prompt_terminator,
    +        delay_factor=delay_factor,
    +        pattern=pattern,
    +    )
    +    self.base_prompt = base_prompt[:16]
    +    return self.base_prompt
    +
    +

    Inherited members

  • @@ -4697,7 +4757,6 @@

    exit_config_mode

  • save_config
  • send_command_w_enter
  • -
  • send_command_w_yes
  • session_preparation
  • special_login_handler
  • diff --git a/docs/netmiko/cisco_base_connection.html b/docs/netmiko/cisco_base_connection.html index c16efae55..01aa04af5 100644 --- a/docs/netmiko/cisco_base_connection.html +++ b/docs/netmiko/cisco_base_connection.html @@ -216,8 +216,7 @@

    Module netmiko.cisco_base_connection

    def cleanup(self, command: str = "exit") -> None: """Gracefully exit the SSH session.""" try: - # The pattern="" forces use of send_command_timing - if self.check_config_mode(pattern=""): + if self.check_config_mode(): self.exit_config_mode() except Exception: pass @@ -593,8 +592,7 @@

    Classes

    def cleanup(self, command: str = "exit") -> None: """Gracefully exit the SSH session.""" try: - # The pattern="" forces use of send_command_timing - if self.check_config_mode(pattern=""): + if self.check_config_mode(): self.exit_config_mode() except Exception: pass @@ -722,8 +720,7 @@

    Methods

    def cleanup(self, command: str = "exit") -> None:
         """Gracefully exit the SSH session."""
         try:
    -        # The pattern="" forces use of send_command_timing
    -        if self.check_config_mode(pattern=""):
    +        if self.check_config_mode():
                 self.exit_config_mode()
         except Exception:
             pass
    @@ -734,7 +731,7 @@ 

    Methods

    -def enable(self, cmd='enable', pattern='ssword', enable_pattern=None, re_flags=) +def enable(self, cmd='enable', pattern='ssword', enable_pattern=None, re_flags=re.IGNORECASE)

    Enter enable mode.

    diff --git a/docs/netmiko/dell/dell_isilon_ssh.html b/docs/netmiko/dell/dell_isilon_ssh.html index 97f892aa0..27a5881f9 100644 --- a/docs/netmiko/dell/dell_isilon_ssh.html +++ b/docs/netmiko/dell/dell_isilon_ssh.html @@ -362,7 +362,7 @@

    Methods

    -def config_mode(self, config_command='sudo su', pattern='ssword', re_flags=) +def config_mode(self, config_command='sudo su', pattern='ssword', re_flags=re.IGNORECASE)

    Use equivalent enable method.

    diff --git a/docs/netmiko/dell/index.html b/docs/netmiko/dell/index.html index fb4385e7d..59e1a7d1d 100644 --- a/docs/netmiko/dell/index.html +++ b/docs/netmiko/dell/index.html @@ -849,7 +849,7 @@

    Methods

    -def config_mode(self, config_command='sudo su', pattern='ssword', re_flags=) +def config_mode(self, config_command='sudo su', pattern='ssword', re_flags=re.IGNORECASE)

    Use equivalent enable method.

    diff --git a/docs/netmiko/extreme/extreme_exos.html b/docs/netmiko/extreme/extreme_exos.html index 17a149b9a..c8295b8dc 100644 --- a/docs/netmiko/extreme/extreme_exos.html +++ b/docs/netmiko/extreme/extreme_exos.html @@ -40,7 +40,7 @@

    Module netmiko.extreme.extreme_exos

    """ def session_preparation(self) -> None: - self._test_channel_read(pattern=r"#") + self._test_channel_read(pattern=r"[>\#]") self.set_base_prompt() self.disable_paging(command="disable clipaging") self.send_command_timing("disable cli prompting") @@ -371,7 +371,7 @@

    Classes

    """ def session_preparation(self) -> None: - self._test_channel_read(pattern=r"#") + self._test_channel_read(pattern=r"[>\#]") self.set_base_prompt() self.disable_paging(command="disable clipaging") self.send_command_timing("disable cli prompting") diff --git a/docs/netmiko/hp/hp_comware.html b/docs/netmiko/hp/hp_comware.html index 8d615db8d..1b393cd8a 100644 --- a/docs/netmiko/hp/hp_comware.html +++ b/docs/netmiko/hp/hp_comware.html @@ -446,7 +446,7 @@

    Methods

    -def enable(self, cmd='system-view', pattern='ssword', enable_pattern=None, re_flags=) +def enable(self, cmd='system-view', pattern='ssword', enable_pattern=None, re_flags=re.IGNORECASE)

    enable mode on Comware is system-view.

    diff --git a/docs/netmiko/hp/hp_procurve.html b/docs/netmiko/hp/hp_procurve.html index 3b7d835fb..6dc186452 100644 --- a/docs/netmiko/hp/hp_procurve.html +++ b/docs/netmiko/hp/hp_procurve.html @@ -43,13 +43,30 @@

    Module netmiko.hp.hp_procurve

    # HP output contains VT100 escape codes self.ansi_escape_codes = True - # Procurve over SSH uses 'Press any key to continue' - data = self._test_channel_read(pattern=r"(any key to continue|[>#])") - if "any key to continue" in data: - self.write_channel(self.RETURN) - self._test_channel_read(pattern=r"[>#]") + # ProCurve has an odd behavior where the router prompt can show up + # before the 'Press any key to continue' message. Read up until the + # Copyright banner to get past this. + try: + self.read_until_pattern(pattern=r".*opyright", read_timeout=1.3) + except ReadTimeout: + pass + + # Procurve uses 'Press any key to continue' + try: + data = self.read_until_pattern( + pattern=r"(any key to continue|[>#])", read_timeout=3.0 + ) + if "any key to continue" in data: + self.write_channel(self.RETURN) + self.read_until_pattern(pattern=r"[>#]", read_timeout=3.0) + except ReadTimeout: + pass self.set_base_prompt() + # If prompt still looks odd, try one more time + if len(self.base_prompt) >= 25: + self.set_base_prompt() + self.set_terminal_width(command="terminal width 511", pattern="terminal") command = self.RETURN + "no page" self.disable_paging(command=command) @@ -342,13 +359,30 @@

    Classes

    # HP output contains VT100 escape codes self.ansi_escape_codes = True - # Procurve over SSH uses 'Press any key to continue' - data = self._test_channel_read(pattern=r"(any key to continue|[>#])") - if "any key to continue" in data: - self.write_channel(self.RETURN) - self._test_channel_read(pattern=r"[>#]") + # ProCurve has an odd behavior where the router prompt can show up + # before the 'Press any key to continue' message. Read up until the + # Copyright banner to get past this. + try: + self.read_until_pattern(pattern=r".*opyright", read_timeout=1.3) + except ReadTimeout: + pass + + # Procurve uses 'Press any key to continue' + try: + data = self.read_until_pattern( + pattern=r"(any key to continue|[>#])", read_timeout=3.0 + ) + if "any key to continue" in data: + self.write_channel(self.RETURN) + self.read_until_pattern(pattern=r"[>#]", read_timeout=3.0) + except ReadTimeout: + pass self.set_base_prompt() + # If prompt still looks odd, try one more time + if len(self.base_prompt) >= 25: + self.set_base_prompt() + self.set_terminal_width(command="terminal width 511", pattern="terminal") command = self.RETURN + "no page" self.disable_paging(command=command) @@ -502,7 +536,7 @@

    Methods

    -def enable(self, cmd='enable', pattern='password', enable_pattern=None, re_flags=, default_username='manager') +def enable(self, cmd='enable', pattern='password', enable_pattern=None, re_flags=re.IGNORECASE, default_username='manager')

    Enter enable mode

    @@ -595,13 +629,30 @@

    Methods

    # HP output contains VT100 escape codes self.ansi_escape_codes = True - # Procurve over SSH uses 'Press any key to continue' - data = self._test_channel_read(pattern=r"(any key to continue|[>#])") - if "any key to continue" in data: - self.write_channel(self.RETURN) - self._test_channel_read(pattern=r"[>#]") + # ProCurve has an odd behavior where the router prompt can show up + # before the 'Press any key to continue' message. Read up until the + # Copyright banner to get past this. + try: + self.read_until_pattern(pattern=r".*opyright", read_timeout=1.3) + except ReadTimeout: + pass + + # Procurve uses 'Press any key to continue' + try: + data = self.read_until_pattern( + pattern=r"(any key to continue|[>#])", read_timeout=3.0 + ) + if "any key to continue" in data: + self.write_channel(self.RETURN) + self.read_until_pattern(pattern=r"[>#]", read_timeout=3.0) + except ReadTimeout: + pass self.set_base_prompt() + # If prompt still looks odd, try one more time + if len(self.base_prompt) >= 25: + self.set_base_prompt() + self.set_terminal_width(command="terminal width 511", pattern="terminal") command = self.RETURN + "no page" self.disable_paging(command=command)
    diff --git a/docs/netmiko/huawei/huawei.html b/docs/netmiko/huawei/huawei.html index cbbc81653..24cbd3df7 100644 --- a/docs/netmiko/huawei/huawei.html +++ b/docs/netmiko/huawei/huawei.html @@ -38,7 +38,7 @@

    Module netmiko.huawei.huawei

    def session_preparation(self) -> None: """Prepare the session after the connection has been established.""" self.ansi_escape_codes = True - self._test_channel_read(pattern=r"[>\]]") + # The _test_channel_read happens in special_login_handler() self.set_base_prompt() self.disable_paging(command="screen-length 0 temporary") @@ -122,15 +122,14 @@

    Module netmiko.huawei.huawei

    """Huawei SSH driver.""" def special_login_handler(self, delay_factor: float = 1.0) -> None: - """Handle password change request by ignoring it""" - - # Huawei can prompt for password change. Search for that or for normal prompt - password_change_prompt = r"((Change now|Please choose))|([\]>]\s*$)" - output = self.read_until_pattern(password_change_prompt) - if re.search(password_change_prompt, output): - self.write_channel("N\n") - self.clear_buffer() - return None + # Huawei prompts for password change before displaying the initial base prompt. + # Search for that password change prompt or for base prompt. + password_change_prompt = r"(Change now|Please choose)" + prompt_or_password_change = r"(?:Change now|Please choose|[>\]])" + data = self.read_until_pattern(pattern=prompt_or_password_change) + if re.search(password_change_prompt, data): + self.write_channel("N" + self.RETURN) + self.read_until_pattern(pattern=r"[>\]]") class HuaweiTelnet(HuaweiBase): @@ -393,7 +392,7 @@

    Classes

    def session_preparation(self) -> None: """Prepare the session after the connection has been established.""" self.ansi_escape_codes = True - self._test_channel_read(pattern=r"[>\]]") + # The _test_channel_read happens in special_login_handler() self.set_base_prompt() self.disable_paging(command="screen-length 0 temporary") @@ -535,7 +534,7 @@

    Methods

    def session_preparation(self) -> None:
         """Prepare the session after the connection has been established."""
         self.ansi_escape_codes = True
    -    self._test_channel_read(pattern=r"[>\]]")
    +    # The _test_channel_read happens in special_login_handler()
         self.set_base_prompt()
         self.disable_paging(command="screen-length 0 temporary")
    @@ -770,15 +769,14 @@

    Inherited members

    """Huawei SSH driver.""" def special_login_handler(self, delay_factor: float = 1.0) -> None: - """Handle password change request by ignoring it""" - - # Huawei can prompt for password change. Search for that or for normal prompt - password_change_prompt = r"((Change now|Please choose))|([\]>]\s*$)" - output = self.read_until_pattern(password_change_prompt) - if re.search(password_change_prompt, output): - self.write_channel("N\n") - self.clear_buffer() - return None
    + # Huawei prompts for password change before displaying the initial base prompt. + # Search for that password change prompt or for base prompt. + password_change_prompt = r"(Change now|Please choose)" + prompt_or_password_change = r"(?:Change now|Please choose|[>\]])" + data = self.read_until_pattern(pattern=prompt_or_password_change) + if re.search(password_change_prompt, data): + self.write_channel("N" + self.RETURN) + self.read_until_pattern(pattern=r"[>\]]")

    Ancestors