MCPcopy
hub / github.com/ktbyers/netmiko / check_config_mode

Method check_config_mode

netmiko/base_connection.py:2095–2120  ·  view source on GitHub ↗

Checks if the device is in configuration mode or not. :param check_string: Identification of configuration mode from the device :type check_string: str :param pattern: Pattern to terminate reading of channel :type pattern: str :param force_regex: Use regula

(
        self, check_string: str = "", pattern: str = "", force_regex: bool = False
    )

Source from the content-addressed store, hash-verified

2093 return output
2094
2095 def check_config_mode(
2096 self, check_string: str = "", pattern: str = "", force_regex: bool = False
2097 ) -> bool:
2098 """Checks if the device is in configuration mode or not.
2099
2100 :param check_string: Identification of configuration mode from the device
2101 :type check_string: str
2102
2103 :param pattern: Pattern to terminate reading of channel
2104 :type pattern: str
2105
2106 :param force_regex: Use regular expression pattern to find check_string in output
2107 :type force_regex: bool
2108
2109 """
2110 self.write_channel(self.RETURN)
2111 # You can encounter an issue here (on router name changes) prefer delay-based solution
2112 if not pattern:
2113 output = self.read_channel_timing(read_timeout=10.0)
2114 else:
2115 output = self.read_until_pattern(pattern=pattern)
2116
2117 if force_regex:
2118 return bool(re.search(check_string, output))
2119 else:
2120 return check_string in output
2121
2122 def config_mode(self, config_command: str = "", pattern: str = "", re_flags: int = 0) -> str:
2123 """Enter into config_mode.

Callers 2

config_modeMethod · 0.95
exit_config_modeMethod · 0.95

Calls 3

write_channelMethod · 0.95
read_channel_timingMethod · 0.95
read_until_patternMethod · 0.95

Tested by

no test coverage detected