repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.normalize_cmd
def normalize_cmd(self, command): """Normalize CLI commands to have a single trailing newline. :param command: Command that may require line feed to be normalized :type command: str """ command = command.rstrip() command += self.RETURN return command
python
def normalize_cmd(self, command): """Normalize CLI commands to have a single trailing newline. :param command: Command that may require line feed to be normalized :type command: str """ command = command.rstrip() command += self.RETURN return command
[ "def", "normalize_cmd", "(", "self", ",", "command", ")", ":", "command", "=", "command", ".", "rstrip", "(", ")", "command", "+=", "self", ".", "RETURN", "return", "command" ]
Normalize CLI commands to have a single trailing newline. :param command: Command that may require line feed to be normalized :type command: str
[ "Normalize", "CLI", "commands", "to", "have", "a", "single", "trailing", "newline", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1369-L1377
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.check_enable_mode
def check_enable_mode(self, check_string=""): """Check if in enable mode. Return boolean. :param check_string: Identification of privilege mode from device :type check_string: str """ self.write_channel(self.RETURN) output = self.read_until_prompt() return check_...
python
def check_enable_mode(self, check_string=""): """Check if in enable mode. Return boolean. :param check_string: Identification of privilege mode from device :type check_string: str """ self.write_channel(self.RETURN) output = self.read_until_prompt() return check_...
[ "def", "check_enable_mode", "(", "self", ",", "check_string", "=", "\"\"", ")", ":", "self", ".", "write_channel", "(", "self", ".", "RETURN", ")", "output", "=", "self", ".", "read_until_prompt", "(", ")", "return", "check_string", "in", "output" ]
Check if in enable mode. Return boolean. :param check_string: Identification of privilege mode from device :type check_string: str
[ "Check", "if", "in", "enable", "mode", ".", "Return", "boolean", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1379-L1387
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.enable
def enable(self, cmd="", pattern="ssword", re_flags=re.IGNORECASE): """Enter enable mode. :param cmd: Device command to enter enable mode :type cmd: str :param pattern: pattern to search for indicating device is waiting for password :type pattern: str :param re_flags: ...
python
def enable(self, cmd="", pattern="ssword", re_flags=re.IGNORECASE): """Enter enable mode. :param cmd: Device command to enter enable mode :type cmd: str :param pattern: pattern to search for indicating device is waiting for password :type pattern: str :param re_flags: ...
[ "def", "enable", "(", "self", ",", "cmd", "=", "\"\"", ",", "pattern", "=", "\"ssword\"", ",", "re_flags", "=", "re", ".", "IGNORECASE", ")", ":", "output", "=", "\"\"", "msg", "=", "(", "\"Failed to enter enable mode. Please ensure you pass \"", "\"the 'secret'...
Enter enable mode. :param cmd: Device command to enter enable mode :type cmd: str :param pattern: pattern to search for indicating device is waiting for password :type pattern: str :param re_flags: Regular expression flags used in conjunction with pattern :type re_flag...
[ "Enter", "enable", "mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1389-L1418
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.exit_enable_mode
def exit_enable_mode(self, exit_command=""): """Exit enable mode. :param exit_command: Command that exits the session from privileged mode :type exit_command: str """ output = "" if self.check_enable_mode(): self.write_channel(self.normalize_cmd(exit_command)...
python
def exit_enable_mode(self, exit_command=""): """Exit enable mode. :param exit_command: Command that exits the session from privileged mode :type exit_command: str """ output = "" if self.check_enable_mode(): self.write_channel(self.normalize_cmd(exit_command)...
[ "def", "exit_enable_mode", "(", "self", ",", "exit_command", "=", "\"\"", ")", ":", "output", "=", "\"\"", "if", "self", ".", "check_enable_mode", "(", ")", ":", "self", ".", "write_channel", "(", "self", ".", "normalize_cmd", "(", "exit_command", ")", ")"...
Exit enable mode. :param exit_command: Command that exits the session from privileged mode :type exit_command: str
[ "Exit", "enable", "mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1420-L1432
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.check_config_mode
def check_config_mode(self, check_string="", pattern=""): """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 pat...
python
def check_config_mode(self, check_string="", pattern=""): """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 pat...
[ "def", "check_config_mode", "(", "self", ",", "check_string", "=", "\"\"", ",", "pattern", "=", "\"\"", ")", ":", "self", ".", "write_channel", "(", "self", ".", "RETURN", ")", "# You can encounter an issue here (on router name changes) prefer delay-based solution", "if...
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
[ "Checks", "if", "the", "device", "is", "in", "configuration", "mode", "or", "not", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1434-L1449
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.config_mode
def config_mode(self, config_command="", pattern=""): """Enter into config_mode. :param config_command: Configuration command to send to the device :type config_command: str :param pattern: Pattern to terminate reading of channel :type pattern: str """ output = ...
python
def config_mode(self, config_command="", pattern=""): """Enter into config_mode. :param config_command: Configuration command to send to the device :type config_command: str :param pattern: Pattern to terminate reading of channel :type pattern: str """ output = ...
[ "def", "config_mode", "(", "self", ",", "config_command", "=", "\"\"", ",", "pattern", "=", "\"\"", ")", ":", "output", "=", "\"\"", "if", "not", "self", ".", "check_config_mode", "(", ")", ":", "self", ".", "write_channel", "(", "self", ".", "normalize_...
Enter into config_mode. :param config_command: Configuration command to send to the device :type config_command: str :param pattern: Pattern to terminate reading of channel :type pattern: str
[ "Enter", "into", "config_mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1451-L1466
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.exit_config_mode
def exit_config_mode(self, exit_config="", pattern=""): """Exit from configuration mode. :param exit_config: Command to exit configuration mode :type exit_config: str :param pattern: Pattern to terminate reading of channel :type pattern: str """ output = "" ...
python
def exit_config_mode(self, exit_config="", pattern=""): """Exit from configuration mode. :param exit_config: Command to exit configuration mode :type exit_config: str :param pattern: Pattern to terminate reading of channel :type pattern: str """ output = "" ...
[ "def", "exit_config_mode", "(", "self", ",", "exit_config", "=", "\"\"", ",", "pattern", "=", "\"\"", ")", ":", "output", "=", "\"\"", "if", "self", ".", "check_config_mode", "(", ")", ":", "self", ".", "write_channel", "(", "self", ".", "normalize_cmd", ...
Exit from configuration mode. :param exit_config: Command to exit configuration mode :type exit_config: str :param pattern: Pattern to terminate reading of channel :type pattern: str
[ "Exit", "from", "configuration", "mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1468-L1484
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.send_config_from_file
def send_config_from_file(self, config_file=None, **kwargs): """ Send configuration commands down the SSH channel from a file. The file is processed line-by-line and each command is sent down the SSH channel. **kwargs are passed to send_config_set method. :param config...
python
def send_config_from_file(self, config_file=None, **kwargs): """ Send configuration commands down the SSH channel from a file. The file is processed line-by-line and each command is sent down the SSH channel. **kwargs are passed to send_config_set method. :param config...
[ "def", "send_config_from_file", "(", "self", ",", "config_file", "=", "None", ",", "*", "*", "kwargs", ")", ":", "with", "io", ".", "open", "(", "config_file", ",", "\"rt\"", ",", "encoding", "=", "\"utf-8\"", ")", "as", "cfg_file", ":", "return", "self"...
Send configuration commands down the SSH channel from a file. The file is processed line-by-line and each command is sent down the SSH channel. **kwargs are passed to send_config_set method. :param config_file: Path to configuration file to be sent to the device :type config_f...
[ "Send", "configuration", "commands", "down", "the", "SSH", "channel", "from", "a", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1486-L1502
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.send_config_set
def send_config_set( self, config_commands=None, exit_config_mode=True, delay_factor=1, max_loops=150, strip_prompt=False, strip_command=False, config_mode_command=None, ): """ Send configuration commands down the SSH channel. ...
python
def send_config_set( self, config_commands=None, exit_config_mode=True, delay_factor=1, max_loops=150, strip_prompt=False, strip_command=False, config_mode_command=None, ): """ Send configuration commands down the SSH channel. ...
[ "def", "send_config_set", "(", "self", ",", "config_commands", "=", "None", ",", "exit_config_mode", "=", "True", ",", "delay_factor", "=", "1", ",", "max_loops", "=", "150", ",", "strip_prompt", "=", "False", ",", "strip_command", "=", "False", ",", "config...
Send configuration commands down the SSH channel. config_commands is an iterable containing all of the configuration commands. The commands will be executed one after the other. Automatically exits/enters configuration mode. :param config_commands: Multiple configuration commands to b...
[ "Send", "configuration", "commands", "down", "the", "SSH", "channel", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1504-L1570
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.strip_ansi_escape_codes
def strip_ansi_escape_codes(self, string_buffer): """ Remove any ANSI (VT100) ESC codes from the output http://en.wikipedia.org/wiki/ANSI_escape_code Note: this does not capture ALL possible ANSI Escape Codes only the ones I have encountered Current codes that are filt...
python
def strip_ansi_escape_codes(self, string_buffer): """ Remove any ANSI (VT100) ESC codes from the output http://en.wikipedia.org/wiki/ANSI_escape_code Note: this does not capture ALL possible ANSI Escape Codes only the ones I have encountered Current codes that are filt...
[ "def", "strip_ansi_escape_codes", "(", "self", ",", "string_buffer", ")", ":", "# noqa", "log", ".", "debug", "(", "\"In strip_ansi_escape_codes\"", ")", "log", ".", "debug", "(", "\"repr = {}\"", ".", "format", "(", "repr", "(", "string_buffer", ")", ")", ")"...
Remove any ANSI (VT100) ESC codes from the output http://en.wikipedia.org/wiki/ANSI_escape_code Note: this does not capture ALL possible ANSI Escape Codes only the ones I have encountered Current codes that are filtered: ESC = '\x1b' or chr(27) ESC = is the escape char...
[ "Remove", "any", "ANSI", "(", "VT100", ")", "ESC", "codes", "from", "the", "output" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1572-L1658
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.disconnect
def disconnect(self): """Try to gracefully close the SSH connection.""" try: self.cleanup() if self.protocol == "ssh": self.paramiko_cleanup() elif self.protocol == "telnet": self.remote_conn.close() elif self.protocol == "s...
python
def disconnect(self): """Try to gracefully close the SSH connection.""" try: self.cleanup() if self.protocol == "ssh": self.paramiko_cleanup() elif self.protocol == "telnet": self.remote_conn.close() elif self.protocol == "s...
[ "def", "disconnect", "(", "self", ")", ":", "try", ":", "self", ".", "cleanup", "(", ")", "if", "self", ".", "protocol", "==", "\"ssh\"", ":", "self", ".", "paramiko_cleanup", "(", ")", "elif", "self", ".", "protocol", "==", "\"telnet\"", ":", "self", ...
Try to gracefully close the SSH connection.
[ "Try", "to", "gracefully", "close", "the", "SSH", "connection", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1669-L1685
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.open_session_log
def open_session_log(self, filename, mode="write"): """Open the session_log file.""" if mode == "append": self.session_log = open(filename, mode="ab") else: self.session_log = open(filename, mode="wb") self._session_log_close = True
python
def open_session_log(self, filename, mode="write"): """Open the session_log file.""" if mode == "append": self.session_log = open(filename, mode="ab") else: self.session_log = open(filename, mode="wb") self._session_log_close = True
[ "def", "open_session_log", "(", "self", ",", "filename", ",", "mode", "=", "\"write\"", ")", ":", "if", "mode", "==", "\"append\"", ":", "self", ".", "session_log", "=", "open", "(", "filename", ",", "mode", "=", "\"ab\"", ")", "else", ":", "self", "."...
Open the session_log file.
[ "Open", "the", "session_log", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1695-L1701
train
ktbyers/netmiko
netmiko/base_connection.py
BaseConnection.close_session_log
def close_session_log(self): """Close the session_log file (if it is a file that we opened).""" if self.session_log is not None and self._session_log_close: self.session_log.close() self.session_log = None
python
def close_session_log(self): """Close the session_log file (if it is a file that we opened).""" if self.session_log is not None and self._session_log_close: self.session_log.close() self.session_log = None
[ "def", "close_session_log", "(", "self", ")", ":", "if", "self", ".", "session_log", "is", "not", "None", "and", "self", ".", "_session_log_close", ":", "self", ".", "session_log", ".", "close", "(", ")", "self", ".", "session_log", "=", "None" ]
Close the session_log file (if it is a file that we opened).
[ "Close", "the", "session_log", "file", "(", "if", "it", "is", "a", "file", "that", "we", "opened", ")", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1703-L1707
train
ktbyers/netmiko
netmiko/ipinfusion/ipinfusion_ocnos.py
IpInfusionOcNOSBase.save_config
def save_config(self, cmd="write", confirm=False, confirm_response=""): """Saves Config Using write command""" return super(IpInfusionOcNOSBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
python
def save_config(self, cmd="write", confirm=False, confirm_response=""): """Saves Config Using write command""" return super(IpInfusionOcNOSBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"write\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "IpInfusionOcNOSBase", ",", "self", ")", ".", "save_config", "(", "cmd", "=", "cmd", ",...
Saves Config Using write command
[ "Saves", "Config", "Using", "write", "command" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ipinfusion/ipinfusion_ocnos.py#L24-L28
train
ktbyers/netmiko
netmiko/ipinfusion/ipinfusion_ocnos.py
IpInfusionOcNOSTelnet._process_option
def _process_option(self, tsocket, command, option): """ For all telnet options, re-implement the default telnetlib behaviour and refuse to handle any options. If the server expresses interest in 'terminal type' option, then reply back with 'xterm' terminal type. """ if c...
python
def _process_option(self, tsocket, command, option): """ For all telnet options, re-implement the default telnetlib behaviour and refuse to handle any options. If the server expresses interest in 'terminal type' option, then reply back with 'xterm' terminal type. """ if c...
[ "def", "_process_option", "(", "self", ",", "tsocket", ",", "command", ",", "option", ")", ":", "if", "command", "==", "DO", "and", "option", "==", "TTYPE", ":", "tsocket", ".", "sendall", "(", "IAC", "+", "WILL", "+", "TTYPE", ")", "tsocket", ".", "...
For all telnet options, re-implement the default telnetlib behaviour and refuse to handle any options. If the server expresses interest in 'terminal type' option, then reply back with 'xterm' terminal type.
[ "For", "all", "telnet", "options", "re", "-", "implement", "the", "default", "telnetlib", "behaviour", "and", "refuse", "to", "handle", "any", "options", ".", "If", "the", "server", "expresses", "interest", "in", "terminal", "type", "option", "then", "reply", ...
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ipinfusion/ipinfusion_ocnos.py#L40-L52
train
ktbyers/netmiko
netmiko/fortinet/fortinet_ssh.py
FortinetSSH.disable_paging
def disable_paging(self, delay_factor=1): """Disable paging is only available with specific roles so it may fail.""" check_command = "get system status | grep Virtual" output = self.send_command_timing(check_command) self.allow_disable_global = True self.vdoms = False sel...
python
def disable_paging(self, delay_factor=1): """Disable paging is only available with specific roles so it may fail.""" check_command = "get system status | grep Virtual" output = self.send_command_timing(check_command) self.allow_disable_global = True self.vdoms = False sel...
[ "def", "disable_paging", "(", "self", ",", "delay_factor", "=", "1", ")", ":", "check_command", "=", "\"get system status | grep Virtual\"", "output", "=", "self", ".", "send_command_timing", "(", "check_command", ")", "self", ".", "allow_disable_global", "=", "True...
Disable paging is only available with specific roles so it may fail.
[ "Disable", "paging", "is", "only", "available", "with", "specific", "roles", "so", "it", "may", "fail", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/fortinet/fortinet_ssh.py#L27-L62
train
ktbyers/netmiko
netmiko/fortinet/fortinet_ssh.py
FortinetSSH._retrieve_output_mode
def _retrieve_output_mode(self): """Save the state of the output mode so it can be reset at the end of the session.""" reg_mode = re.compile(r"output\s+:\s+(?P<mode>.*)\s+\n") output = self.send_command("get system console") result_mode_re = reg_mode.search(output) if result_mode...
python
def _retrieve_output_mode(self): """Save the state of the output mode so it can be reset at the end of the session.""" reg_mode = re.compile(r"output\s+:\s+(?P<mode>.*)\s+\n") output = self.send_command("get system console") result_mode_re = reg_mode.search(output) if result_mode...
[ "def", "_retrieve_output_mode", "(", "self", ")", ":", "reg_mode", "=", "re", ".", "compile", "(", "r\"output\\s+:\\s+(?P<mode>.*)\\s+\\n\"", ")", "output", "=", "self", ".", "send_command", "(", "\"get system console\"", ")", "result_mode_re", "=", "reg_mode", ".",...
Save the state of the output mode so it can be reset at the end of the session.
[ "Save", "the", "state", "of", "the", "output", "mode", "so", "it", "can", "be", "reset", "at", "the", "end", "of", "the", "session", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/fortinet/fortinet_ssh.py#L64-L72
train
ktbyers/netmiko
netmiko/fortinet/fortinet_ssh.py
FortinetSSH.cleanup
def cleanup(self): """Re-enable paging globally.""" if self.allow_disable_global: # Return paging state output_mode_cmd = "set output {}".format(self._output_mode) enable_paging_commands = ["config system console", output_mode_cmd, "end"] if self.vdoms: ...
python
def cleanup(self): """Re-enable paging globally.""" if self.allow_disable_global: # Return paging state output_mode_cmd = "set output {}".format(self._output_mode) enable_paging_commands = ["config system console", output_mode_cmd, "end"] if self.vdoms: ...
[ "def", "cleanup", "(", "self", ")", ":", "if", "self", ".", "allow_disable_global", ":", "# Return paging state", "output_mode_cmd", "=", "\"set output {}\"", ".", "format", "(", "self", ".", "_output_mode", ")", "enable_paging_commands", "=", "[", "\"config system ...
Re-enable paging globally.
[ "Re", "-", "enable", "paging", "globally", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/fortinet/fortinet_ssh.py#L74-L84
train
ktbyers/netmiko
netmiko/accedian/accedian_ssh.py
AccedianSSH.set_base_prompt
def set_base_prompt( self, pri_prompt_terminator=":", alt_prompt_terminator="#", delay_factor=2 ): """Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output.""" super(AccedianSSH, self).set_base_prompt( pri_prompt_terminator=pri_prompt_terminator, ...
python
def set_base_prompt( self, pri_prompt_terminator=":", alt_prompt_terminator="#", delay_factor=2 ): """Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output.""" super(AccedianSSH, self).set_base_prompt( pri_prompt_terminator=pri_prompt_terminator, ...
[ "def", "set_base_prompt", "(", "self", ",", "pri_prompt_terminator", "=", "\":\"", ",", "alt_prompt_terminator", "=", "\"#\"", ",", "delay_factor", "=", "2", ")", ":", "super", "(", "AccedianSSH", ",", "self", ")", ".", "set_base_prompt", "(", "pri_prompt_termin...
Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output.
[ "Sets", "self", ".", "base_prompt", ":", "used", "as", "delimiter", "for", "stripping", "of", "trailing", "prompt", "in", "output", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/accedian/accedian_ssh.py#L35-L44
train
ktbyers/netmiko
netmiko/hp/hp_procurve.py
HPProcurveBase.session_preparation
def session_preparation(self): """ Prepare the session after the connection has been established. Procurve uses - 'Press any key to continue' """ delay_factor = self.select_delay_factor(delay_factor=0) output = "" count = 1 while count <= 30: o...
python
def session_preparation(self): """ Prepare the session after the connection has been established. Procurve uses - 'Press any key to continue' """ delay_factor = self.select_delay_factor(delay_factor=0) output = "" count = 1 while count <= 30: o...
[ "def", "session_preparation", "(", "self", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", "=", "0", ")", "output", "=", "\"\"", "count", "=", "1", "while", "count", "<=", "30", ":", "output", "+=", "self", ".", "r...
Prepare the session after the connection has been established. Procurve uses - 'Press any key to continue'
[ "Prepare", "the", "session", "after", "the", "connection", "has", "been", "established", ".", "Procurve", "uses", "-", "Press", "any", "key", "to", "continue" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L11-L41
train
ktbyers/netmiko
netmiko/hp/hp_procurve.py
HPProcurveBase.enable
def enable( self, cmd="enable", pattern="password", re_flags=re.IGNORECASE, default_username="manager", ): """Enter enable mode""" if self.check_enable_mode(): return "" output = self.send_command_timing(cmd) if ( "usern...
python
def enable( self, cmd="enable", pattern="password", re_flags=re.IGNORECASE, default_username="manager", ): """Enter enable mode""" if self.check_enable_mode(): return "" output = self.send_command_timing(cmd) if ( "usern...
[ "def", "enable", "(", "self", ",", "cmd", "=", "\"enable\"", ",", "pattern", "=", "\"password\"", ",", "re_flags", "=", "re", ".", "IGNORECASE", ",", "default_username", "=", "\"manager\"", ",", ")", ":", "if", "self", ".", "check_enable_mode", "(", ")", ...
Enter enable mode
[ "Enter", "enable", "mode" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L43-L64
train
ktbyers/netmiko
netmiko/hp/hp_procurve.py
HPProcurveBase.cleanup
def cleanup(self): """Gracefully exit the SSH session.""" self.exit_config_mode() self.write_channel("logout" + self.RETURN) count = 0 while count <= 5: time.sleep(0.5) output = self.read_channel() if "Do you want to log out" in output: ...
python
def cleanup(self): """Gracefully exit the SSH session.""" self.exit_config_mode() self.write_channel("logout" + self.RETURN) count = 0 while count <= 5: time.sleep(0.5) output = self.read_channel() if "Do you want to log out" in output: ...
[ "def", "cleanup", "(", "self", ")", ":", "self", ".", "exit_config_mode", "(", ")", "self", ".", "write_channel", "(", "\"logout\"", "+", "self", ".", "RETURN", ")", "count", "=", "0", "while", "count", "<=", "5", ":", "time", ".", "sleep", "(", "0.5...
Gracefully exit the SSH session.
[ "Gracefully", "exit", "the", "SSH", "session", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L66-L86
train
ktbyers/netmiko
netmiko/hp/hp_procurve.py
HPProcurveBase.save_config
def save_config(self, cmd="write memory", confirm=False, confirm_response=""): """Save Config.""" return super(HPProcurveBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
python
def save_config(self, cmd="write memory", confirm=False, confirm_response=""): """Save Config.""" return super(HPProcurveBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"write memory\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "HPProcurveBase", ",", "self", ")", ".", "save_config", "(", "cmd", "=", "cmd", ...
Save Config.
[ "Save", "Config", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L88-L92
train
ktbyers/netmiko
netmiko/hp/hp_procurve.py
HPProcurveTelnet.telnet_login
def telnet_login( self, pri_prompt_terminator="#", alt_prompt_terminator=">", username_pattern=r"Login Name:", pwd_pattern=r"assword", delay_factor=1, max_loops=60, ): """Telnet login: can be username/password or just password.""" super(HPProcu...
python
def telnet_login( self, pri_prompt_terminator="#", alt_prompt_terminator=">", username_pattern=r"Login Name:", pwd_pattern=r"assword", delay_factor=1, max_loops=60, ): """Telnet login: can be username/password or just password.""" super(HPProcu...
[ "def", "telnet_login", "(", "self", ",", "pri_prompt_terminator", "=", "\"#\"", ",", "alt_prompt_terminator", "=", "\">\"", ",", "username_pattern", "=", "r\"Login Name:\"", ",", "pwd_pattern", "=", "r\"assword\"", ",", "delay_factor", "=", "1", ",", "max_loops", ...
Telnet login: can be username/password or just password.
[ "Telnet", "login", ":", "can", "be", "username", "/", "password", "or", "just", "password", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L100-L117
train
ktbyers/netmiko
netmiko/f5/f5_tmsh_ssh.py
F5TmshSSH.session_preparation
def session_preparation(self): """Prepare the session after the connection has been established.""" self._test_channel_read() self.set_base_prompt() self.tmsh_mode() self.set_base_prompt() self.disable_paging( command="modify cli preference pager disabled disp...
python
def session_preparation(self): """Prepare the session after the connection has been established.""" self._test_channel_read() self.set_base_prompt() self.tmsh_mode() self.set_base_prompt() self.disable_paging( command="modify cli preference pager disabled disp...
[ "def", "session_preparation", "(", "self", ")", ":", "self", ".", "_test_channel_read", "(", ")", "self", ".", "set_base_prompt", "(", ")", "self", ".", "tmsh_mode", "(", ")", "self", ".", "set_base_prompt", "(", ")", "self", ".", "disable_paging", "(", "c...
Prepare the session after the connection has been established.
[ "Prepare", "the", "session", "after", "the", "connection", "has", "been", "established", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/f5/f5_tmsh_ssh.py#L7-L18
train
ktbyers/netmiko
netmiko/f5/f5_tmsh_ssh.py
F5TmshSSH.tmsh_mode
def tmsh_mode(self, delay_factor=1): """tmsh command is equivalent to config command on F5.""" delay_factor = self.select_delay_factor(delay_factor) self.clear_buffer() command = "{}tmsh{}".format(self.RETURN, self.RETURN) self.write_channel(command) time.sleep(1 * delay_...
python
def tmsh_mode(self, delay_factor=1): """tmsh command is equivalent to config command on F5.""" delay_factor = self.select_delay_factor(delay_factor) self.clear_buffer() command = "{}tmsh{}".format(self.RETURN, self.RETURN) self.write_channel(command) time.sleep(1 * delay_...
[ "def", "tmsh_mode", "(", "self", ",", "delay_factor", "=", "1", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", ")", "self", ".", "clear_buffer", "(", ")", "command", "=", "\"{}tmsh{}\"", ".", "format", "(", "self", ...
tmsh command is equivalent to config command on F5.
[ "tmsh", "command", "is", "equivalent", "to", "config", "command", "on", "F5", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/f5/f5_tmsh_ssh.py#L20-L28
train
ktbyers/netmiko
netmiko/linux/linux_ssh.py
LinuxSSH.set_base_prompt
def set_base_prompt( self, pri_prompt_terminator="$", alt_prompt_terminator="#", delay_factor=1 ): """Determine base prompt.""" return super(LinuxSSH, self).set_base_prompt( pri_prompt_terminator=pri_prompt_terminator, alt_prompt_terminator=alt_prompt_terminator, ...
python
def set_base_prompt( self, pri_prompt_terminator="$", alt_prompt_terminator="#", delay_factor=1 ): """Determine base prompt.""" return super(LinuxSSH, self).set_base_prompt( pri_prompt_terminator=pri_prompt_terminator, alt_prompt_terminator=alt_prompt_terminator, ...
[ "def", "set_base_prompt", "(", "self", ",", "pri_prompt_terminator", "=", "\"$\"", ",", "alt_prompt_terminator", "=", "\"#\"", ",", "delay_factor", "=", "1", ")", ":", "return", "super", "(", "LinuxSSH", ",", "self", ")", ".", "set_base_prompt", "(", "pri_prom...
Determine base prompt.
[ "Determine", "base", "prompt", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L30-L38
train
ktbyers/netmiko
netmiko/linux/linux_ssh.py
LinuxSSH.send_config_set
def send_config_set(self, config_commands=None, exit_config_mode=True, **kwargs): """Can't exit from root (if root)""" if self.username == "root": exit_config_mode = False return super(LinuxSSH, self).send_config_set( config_commands=config_commands, exit_config_mode=exit...
python
def send_config_set(self, config_commands=None, exit_config_mode=True, **kwargs): """Can't exit from root (if root)""" if self.username == "root": exit_config_mode = False return super(LinuxSSH, self).send_config_set( config_commands=config_commands, exit_config_mode=exit...
[ "def", "send_config_set", "(", "self", ",", "config_commands", "=", "None", ",", "exit_config_mode", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "username", "==", "\"root\"", ":", "exit_config_mode", "=", "False", "return", "super", ...
Can't exit from root (if root)
[ "Can", "t", "exit", "from", "root", "(", "if", "root", ")" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L40-L46
train
ktbyers/netmiko
netmiko/linux/linux_ssh.py
LinuxSSH.exit_enable_mode
def exit_enable_mode(self, exit_command="exit"): """Exit enable mode.""" delay_factor = self.select_delay_factor(delay_factor=0) output = "" if self.check_enable_mode(): self.write_channel(self.normalize_cmd(exit_command)) time.sleep(0.3 * delay_factor) ...
python
def exit_enable_mode(self, exit_command="exit"): """Exit enable mode.""" delay_factor = self.select_delay_factor(delay_factor=0) output = "" if self.check_enable_mode(): self.write_channel(self.normalize_cmd(exit_command)) time.sleep(0.3 * delay_factor) ...
[ "def", "exit_enable_mode", "(", "self", ",", "exit_command", "=", "\"exit\"", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", "=", "0", ")", "output", "=", "\"\"", "if", "self", ".", "check_enable_mode", "(", ")", ":",...
Exit enable mode.
[ "Exit", "enable", "mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L63-L73
train
ktbyers/netmiko
netmiko/linux/linux_ssh.py
LinuxSSH.enable
def enable(self, cmd="sudo su", pattern="ssword", re_flags=re.IGNORECASE): """Attempt to become root.""" delay_factor = self.select_delay_factor(delay_factor=0) output = "" if not self.check_enable_mode(): self.write_channel(self.normalize_cmd(cmd)) time.sleep(0.3...
python
def enable(self, cmd="sudo su", pattern="ssword", re_flags=re.IGNORECASE): """Attempt to become root.""" delay_factor = self.select_delay_factor(delay_factor=0) output = "" if not self.check_enable_mode(): self.write_channel(self.normalize_cmd(cmd)) time.sleep(0.3...
[ "def", "enable", "(", "self", ",", "cmd", "=", "\"sudo su\"", ",", "pattern", "=", "\"ssword\"", ",", "re_flags", "=", "re", ".", "IGNORECASE", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", "=", "0", ")", "output",...
Attempt to become root.
[ "Attempt", "to", "become", "root", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L75-L97
train
ktbyers/netmiko
netmiko/linux/linux_ssh.py
LinuxFileTransfer.remote_file_size
def remote_file_size(self, remote_cmd="", remote_file=None): """Get the file size of the remote file.""" return self._remote_file_size_unix( remote_cmd=remote_cmd, remote_file=remote_file )
python
def remote_file_size(self, remote_cmd="", remote_file=None): """Get the file size of the remote file.""" return self._remote_file_size_unix( remote_cmd=remote_cmd, remote_file=remote_file )
[ "def", "remote_file_size", "(", "self", ",", "remote_cmd", "=", "\"\"", ",", "remote_file", "=", "None", ")", ":", "return", "self", ".", "_remote_file_size_unix", "(", "remote_cmd", "=", "remote_cmd", ",", "remote_file", "=", "remote_file", ")" ]
Get the file size of the remote file.
[ "Get", "the", "file", "size", "of", "the", "remote", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L135-L139
train
ktbyers/netmiko
netmiko/scp_functions.py
file_transfer
def file_transfer( ssh_conn, source_file, dest_file, file_system=None, direction="put", disable_md5=False, inline_transfer=False, overwrite_file=False, ): """Use Secure Copy or Inline (IOS-only) to transfer files to/from network devices. inline_transfer ONLY SUPPORTS TEXT FILES ...
python
def file_transfer( ssh_conn, source_file, dest_file, file_system=None, direction="put", disable_md5=False, inline_transfer=False, overwrite_file=False, ): """Use Secure Copy or Inline (IOS-only) to transfer files to/from network devices. inline_transfer ONLY SUPPORTS TEXT FILES ...
[ "def", "file_transfer", "(", "ssh_conn", ",", "source_file", ",", "dest_file", ",", "file_system", "=", "None", ",", "direction", "=", "\"put\"", ",", "disable_md5", "=", "False", ",", "inline_transfer", "=", "False", ",", "overwrite_file", "=", "False", ",", ...
Use Secure Copy or Inline (IOS-only) to transfer files to/from network devices. inline_transfer ONLY SUPPORTS TEXT FILES and will not support binary file transfers. return { 'file_exists': boolean, 'file_transferred': boolean, 'file_verified': boolean, }
[ "Use", "Secure", "Copy", "or", "Inline", "(", "IOS", "-", "only", ")", "to", "transfer", "files", "to", "/", "from", "network", "devices", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_functions.py#L23-L112
train
ktbyers/netmiko
netmiko/alcatel/alcatel_sros_ssh.py
AlcatelSrosSSH.set_base_prompt
def set_base_prompt(self, *args, **kwargs): """Remove the > when navigating into the different config level.""" cur_base_prompt = super(AlcatelSrosSSH, self).set_base_prompt(*args, **kwargs) match = re.search(r"(.*)(>.*)*#", cur_base_prompt) if match: # strip off >... from ba...
python
def set_base_prompt(self, *args, **kwargs): """Remove the > when navigating into the different config level.""" cur_base_prompt = super(AlcatelSrosSSH, self).set_base_prompt(*args, **kwargs) match = re.search(r"(.*)(>.*)*#", cur_base_prompt) if match: # strip off >... from ba...
[ "def", "set_base_prompt", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cur_base_prompt", "=", "super", "(", "AlcatelSrosSSH", ",", "self", ")", ".", "set_base_prompt", "(", "*", "args", ",", "*", "*", "kwargs", ")", "match", "=", ...
Remove the > when navigating into the different config level.
[ "Remove", "the", ">", "when", "navigating", "into", "the", "different", "config", "level", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L20-L27
train
ktbyers/netmiko
netmiko/alcatel/alcatel_sros_ssh.py
AlcatelSrosSSH.enable
def enable(self, cmd="enable-admin", pattern="ssword", re_flags=re.IGNORECASE): """Enter enable mode.""" return super(AlcatelSrosSSH, self).enable( cmd=cmd, pattern=pattern, re_flags=re_flags )
python
def enable(self, cmd="enable-admin", pattern="ssword", re_flags=re.IGNORECASE): """Enter enable mode.""" return super(AlcatelSrosSSH, self).enable( cmd=cmd, pattern=pattern, re_flags=re_flags )
[ "def", "enable", "(", "self", ",", "cmd", "=", "\"enable-admin\"", ",", "pattern", "=", "\"ssword\"", ",", "re_flags", "=", "re", ".", "IGNORECASE", ")", ":", "return", "super", "(", "AlcatelSrosSSH", ",", "self", ")", ".", "enable", "(", "cmd", "=", "...
Enter enable mode.
[ "Enter", "enable", "mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L29-L33
train
ktbyers/netmiko
netmiko/alcatel/alcatel_sros_ssh.py
AlcatelSrosSSH.check_enable_mode
def check_enable_mode(self, check_string="CLI Already in admin mode"): """Check whether we are in enable-admin mode. SROS requires us to do this: *A:HOSTNAME# enable-admin MINOR: CLI Already in admin mode. *A:HOSTNAME# *A:HOSTNAME# enable-admin Password: ...
python
def check_enable_mode(self, check_string="CLI Already in admin mode"): """Check whether we are in enable-admin mode. SROS requires us to do this: *A:HOSTNAME# enable-admin MINOR: CLI Already in admin mode. *A:HOSTNAME# *A:HOSTNAME# enable-admin Password: ...
[ "def", "check_enable_mode", "(", "self", ",", "check_string", "=", "\"CLI Already in admin mode\"", ")", ":", "output", "=", "self", ".", "send_command_timing", "(", "\"enable-admin\"", ")", "if", "re", ".", "search", "(", "r\"ssword\"", ",", "output", ")", ":",...
Check whether we are in enable-admin mode. SROS requires us to do this: *A:HOSTNAME# enable-admin MINOR: CLI Already in admin mode. *A:HOSTNAME# *A:HOSTNAME# enable-admin Password: MINOR: CLI Invalid password. *A:HOSTNAME#
[ "Check", "whether", "we", "are", "in", "enable", "-", "admin", "mode", ".", "SROS", "requires", "us", "to", "do", "this", ":", "*", "A", ":", "HOSTNAME#", "enable", "-", "admin", "MINOR", ":", "CLI", "Already", "in", "admin", "mode", ".", "*", "A", ...
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L35-L54
train
ktbyers/netmiko
netmiko/alcatel/alcatel_sros_ssh.py
AlcatelSrosSSH.config_mode
def config_mode(self, config_command="configure", pattern="#"): """ Enter into configuration mode on SROS device.""" return super(AlcatelSrosSSH, self).config_mode( config_command=config_command, pattern=pattern )
python
def config_mode(self, config_command="configure", pattern="#"): """ Enter into configuration mode on SROS device.""" return super(AlcatelSrosSSH, self).config_mode( config_command=config_command, pattern=pattern )
[ "def", "config_mode", "(", "self", ",", "config_command", "=", "\"configure\"", ",", "pattern", "=", "\"#\"", ")", ":", "return", "super", "(", "AlcatelSrosSSH", ",", "self", ")", ".", "config_mode", "(", "config_command", "=", "config_command", ",", "pattern"...
Enter into configuration mode on SROS device.
[ "Enter", "into", "configuration", "mode", "on", "SROS", "device", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L60-L64
train
ktbyers/netmiko
netmiko/alcatel/alcatel_sros_ssh.py
AlcatelSrosSSH.exit_config_mode
def exit_config_mode(self, exit_config="exit all", pattern="#"): """ Exit from configuration mode.""" return super(AlcatelSrosSSH, self).exit_config_mode( exit_config=exit_config, pattern=pattern )
python
def exit_config_mode(self, exit_config="exit all", pattern="#"): """ Exit from configuration mode.""" return super(AlcatelSrosSSH, self).exit_config_mode( exit_config=exit_config, pattern=pattern )
[ "def", "exit_config_mode", "(", "self", ",", "exit_config", "=", "\"exit all\"", ",", "pattern", "=", "\"#\"", ")", ":", "return", "super", "(", "AlcatelSrosSSH", ",", "self", ")", ".", "exit_config_mode", "(", "exit_config", "=", "exit_config", ",", "pattern"...
Exit from configuration mode.
[ "Exit", "from", "configuration", "mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L66-L70
train
ktbyers/netmiko
netmiko/alcatel/alcatel_sros_ssh.py
AlcatelSrosSSH.check_config_mode
def check_config_mode(self, check_string="config", pattern="#"): """ Checks if the device is in configuration mode or not. """ return super(AlcatelSrosSSH, self).check_config_mode( check_string=check_string, pattern=pattern )
python
def check_config_mode(self, check_string="config", pattern="#"): """ Checks if the device is in configuration mode or not. """ return super(AlcatelSrosSSH, self).check_config_mode( check_string=check_string, pattern=pattern )
[ "def", "check_config_mode", "(", "self", ",", "check_string", "=", "\"config\"", ",", "pattern", "=", "\"#\"", ")", ":", "return", "super", "(", "AlcatelSrosSSH", ",", "self", ")", ".", "check_config_mode", "(", "check_string", "=", "check_string", ",", "patte...
Checks if the device is in configuration mode or not.
[ "Checks", "if", "the", "device", "is", "in", "configuration", "mode", "or", "not", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L72-L76
train
ktbyers/netmiko
netmiko/dell/dell_dnos6.py
DellDNOS6Base.save_config
def save_config( self, cmd="copy running-configuration startup-configuration", confirm=False, confirm_response="", ): """Saves Config""" return super(DellDNOS6Base, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
python
def save_config( self, cmd="copy running-configuration startup-configuration", confirm=False, confirm_response="", ): """Saves Config""" return super(DellDNOS6Base, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"copy running-configuration startup-configuration\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ",", ")", ":", "return", "super", "(", "DellDNOS6Base", ",", "self", ")", ".", "save_c...
Saves Config
[ "Saves", "Config" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_dnos6.py#L20-L29
train
ktbyers/netmiko
netmiko/extreme/extreme_exos.py
ExtremeExosBase.set_base_prompt
def set_base_prompt(self, *args, **kwargs): """ Extreme attaches an id to the prompt. The id increases with every command. It needs to br stripped off to match the prompt. Eg. testhost.1 # testhost.2 # testhost.3 # If new config is loaded and not sav...
python
def set_base_prompt(self, *args, **kwargs): """ Extreme attaches an id to the prompt. The id increases with every command. It needs to br stripped off to match the prompt. Eg. testhost.1 # testhost.2 # testhost.3 # If new config is loaded and not sav...
[ "def", "set_base_prompt", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cur_base_prompt", "=", "super", "(", "ExtremeExosBase", ",", "self", ")", ".", "set_base_prompt", "(", "*", "args", ",", "*", "*", "kwargs", ")", "# Strip off an...
Extreme attaches an id to the prompt. The id increases with every command. It needs to br stripped off to match the prompt. Eg. testhost.1 # testhost.2 # testhost.3 # If new config is loaded and not saved yet, a '* ' prefix appears before the prompt, eg. ...
[ "Extreme", "attaches", "an", "id", "to", "the", "prompt", ".", "The", "id", "increases", "with", "every", "command", ".", "It", "needs", "to", "br", "stripped", "off", "to", "match", "the", "prompt", ".", "Eg", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_exos.py#L23-L45
train
ktbyers/netmiko
netmiko/extreme/extreme_exos.py
ExtremeExosBase.send_command
def send_command(self, *args, **kwargs): """Extreme needs special handler here due to the prompt changes.""" # Change send_command behavior to use self.base_prompt kwargs.setdefault("auto_find_prompt", False) # refresh self.base_prompt self.set_base_prompt() return supe...
python
def send_command(self, *args, **kwargs): """Extreme needs special handler here due to the prompt changes.""" # Change send_command behavior to use self.base_prompt kwargs.setdefault("auto_find_prompt", False) # refresh self.base_prompt self.set_base_prompt() return supe...
[ "def", "send_command", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Change send_command behavior to use self.base_prompt", "kwargs", ".", "setdefault", "(", "\"auto_find_prompt\"", ",", "False", ")", "# refresh self.base_prompt", "self", ".", ...
Extreme needs special handler here due to the prompt changes.
[ "Extreme", "needs", "special", "handler", "here", "due", "to", "the", "prompt", "changes", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_exos.py#L47-L55
train
ktbyers/netmiko
netmiko/extreme/extreme_exos.py
ExtremeExosBase.save_config
def save_config( self, cmd="save configuration primary", confirm=False, confirm_response="" ): """Saves configuration.""" return super(ExtremeExosBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
python
def save_config( self, cmd="save configuration primary", confirm=False, confirm_response="" ): """Saves configuration.""" return super(ExtremeExosBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"save configuration primary\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "ExtremeExosBase", ",", "self", ")", ".", "save_config", "(", "cmd", "...
Saves configuration.
[ "Saves", "configuration", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_exos.py#L69-L75
train
ktbyers/netmiko
netmiko/juniper/juniper.py
JuniperBase.enter_cli_mode
def enter_cli_mode(self): """Check if at shell prompt root@ and go into CLI.""" delay_factor = self.select_delay_factor(delay_factor=0) count = 0 cur_prompt = "" while count < 50: self.write_channel(self.RETURN) time.sleep(0.1 * delay_factor) c...
python
def enter_cli_mode(self): """Check if at shell prompt root@ and go into CLI.""" delay_factor = self.select_delay_factor(delay_factor=0) count = 0 cur_prompt = "" while count < 50: self.write_channel(self.RETURN) time.sleep(0.1 * delay_factor) c...
[ "def", "enter_cli_mode", "(", "self", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", "=", "0", ")", "count", "=", "0", "cur_prompt", "=", "\"\"", "while", "count", "<", "50", ":", "self", ".", "write_channel", "(", ...
Check if at shell prompt root@ and go into CLI.
[ "Check", "if", "at", "shell", "prompt", "root" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/juniper/juniper.py#L43-L59
train
ktbyers/netmiko
netmiko/juniper/juniper.py
JuniperBase.strip_prompt
def strip_prompt(self, *args, **kwargs): """Strip the trailing router prompt from the output.""" a_string = super(JuniperBase, self).strip_prompt(*args, **kwargs) return self.strip_context_items(a_string)
python
def strip_prompt(self, *args, **kwargs): """Strip the trailing router prompt from the output.""" a_string = super(JuniperBase, self).strip_prompt(*args, **kwargs) return self.strip_context_items(a_string)
[ "def", "strip_prompt", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "a_string", "=", "super", "(", "JuniperBase", ",", "self", ")", ".", "strip_prompt", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self", ".", "st...
Strip the trailing router prompt from the output.
[ "Strip", "the", "trailing", "router", "prompt", "from", "the", "output", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/juniper/juniper.py#L187-L190
train
ktbyers/netmiko
netmiko/juniper/juniper.py
JuniperBase.strip_context_items
def strip_context_items(self, a_string): """Strip Juniper-specific output. Juniper will also put a configuration context: [edit] and various chassis contexts: {master:0}, {backup:1} This method removes those lines. """ strings_to_strip = [ r...
python
def strip_context_items(self, a_string): """Strip Juniper-specific output. Juniper will also put a configuration context: [edit] and various chassis contexts: {master:0}, {backup:1} This method removes those lines. """ strings_to_strip = [ r...
[ "def", "strip_context_items", "(", "self", ",", "a_string", ")", ":", "strings_to_strip", "=", "[", "r\"\\[edit.*\\]\"", ",", "r\"\\{master:.*\\}\"", ",", "r\"\\{backup:.*\\}\"", ",", "r\"\\{line.*\\}\"", ",", "r\"\\{primary.*\\}\"", ",", "r\"\\{secondary.*\\}\"", ",", ...
Strip Juniper-specific output. Juniper will also put a configuration context: [edit] and various chassis contexts: {master:0}, {backup:1} This method removes those lines.
[ "Strip", "Juniper", "-", "specific", "output", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/juniper/juniper.py#L192-L218
train
ktbyers/netmiko
netmiko/arista/arista.py
AristaBase.check_config_mode
def check_config_mode(self, check_string=")#", pattern=""): """ Checks if the device is in configuration mode or not. Arista, unfortunately, does this: loc1-core01(s1)# Can also be (s2) """ log.debug("pattern: {0}".format(pattern)) self.write_channel(sel...
python
def check_config_mode(self, check_string=")#", pattern=""): """ Checks if the device is in configuration mode or not. Arista, unfortunately, does this: loc1-core01(s1)# Can also be (s2) """ log.debug("pattern: {0}".format(pattern)) self.write_channel(sel...
[ "def", "check_config_mode", "(", "self", ",", "check_string", "=", "\")#\"", ",", "pattern", "=", "\"\"", ")", ":", "log", ".", "debug", "(", "\"pattern: {0}\"", ".", "format", "(", "pattern", ")", ")", "self", ".", "write_channel", "(", "self", ".", "RE...
Checks if the device is in configuration mode or not. Arista, unfortunately, does this: loc1-core01(s1)# Can also be (s2)
[ "Checks", "if", "the", "device", "is", "in", "configuration", "mode", "or", "not", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/arista/arista.py#L19-L35
train
ktbyers/netmiko
netmiko/cisco/cisco_nxos_ssh.py
CiscoNxosSSH.session_preparation
def session_preparation(self): """Prepare the session after the connection has been established.""" self._test_channel_read(pattern=r"[>#]") self.ansi_escape_codes = True self.set_base_prompt() self.disable_paging() # Clear the read buffer time.sleep(0.3 * self.gl...
python
def session_preparation(self): """Prepare the session after the connection has been established.""" self._test_channel_read(pattern=r"[>#]") self.ansi_escape_codes = True self.set_base_prompt() self.disable_paging() # Clear the read buffer time.sleep(0.3 * self.gl...
[ "def", "session_preparation", "(", "self", ")", ":", "self", ".", "_test_channel_read", "(", "pattern", "=", "r\"[>#]\"", ")", "self", ".", "ansi_escape_codes", "=", "True", "self", ".", "set_base_prompt", "(", ")", "self", ".", "disable_paging", "(", ")", "...
Prepare the session after the connection has been established.
[ "Prepare", "the", "session", "after", "the", "connection", "has", "been", "established", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_nxos_ssh.py#L11-L19
train
ktbyers/netmiko
netmiko/cisco/cisco_nxos_ssh.py
CiscoNxosSSH.normalize_linefeeds
def normalize_linefeeds(self, a_string): """Convert '\r\n' or '\r\r\n' to '\n, and remove extra '\r's in the text.""" newline = re.compile(r"(\r\r\n|\r\n)") # NX-OS fix for incorrect MD5 on 9K (due to strange <enter> patterns on NX-OS) return newline.sub(self.RESPONSE_RETURN, a_string).r...
python
def normalize_linefeeds(self, a_string): """Convert '\r\n' or '\r\r\n' to '\n, and remove extra '\r's in the text.""" newline = re.compile(r"(\r\r\n|\r\n)") # NX-OS fix for incorrect MD5 on 9K (due to strange <enter> patterns on NX-OS) return newline.sub(self.RESPONSE_RETURN, a_string).r...
[ "def", "normalize_linefeeds", "(", "self", ",", "a_string", ")", ":", "newline", "=", "re", ".", "compile", "(", "r\"(\\r\\r\\n|\\r\\n)\"", ")", "# NX-OS fix for incorrect MD5 on 9K (due to strange <enter> patterns on NX-OS)", "return", "newline", ".", "sub", "(", "self",...
Convert '\r\n' or '\r\r\n' to '\n, and remove extra '\r's in the text.
[ "Convert", "\\", "r", "\\", "n", "or", "\\", "r", "\\", "r", "\\", "n", "to", "\\", "n", "and", "remove", "extra", "\\", "r", "s", "in", "the", "text", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_nxos_ssh.py#L21-L25
train
ktbyers/netmiko
netmiko/cisco/cisco_nxos_ssh.py
CiscoNxosSSH.check_config_mode
def check_config_mode(self, check_string=")#", pattern="#"): """Checks if the device is in configuration mode or not.""" return super(CiscoNxosSSH, self).check_config_mode( check_string=check_string, pattern=pattern )
python
def check_config_mode(self, check_string=")#", pattern="#"): """Checks if the device is in configuration mode or not.""" return super(CiscoNxosSSH, self).check_config_mode( check_string=check_string, pattern=pattern )
[ "def", "check_config_mode", "(", "self", ",", "check_string", "=", "\")#\"", ",", "pattern", "=", "\"#\"", ")", ":", "return", "super", "(", "CiscoNxosSSH", ",", "self", ")", ".", "check_config_mode", "(", "check_string", "=", "check_string", ",", "pattern", ...
Checks if the device is in configuration mode or not.
[ "Checks", "if", "the", "device", "is", "in", "configuration", "mode", "or", "not", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_nxos_ssh.py#L27-L31
train
ktbyers/netmiko
netmiko/cisco/cisco_nxos_ssh.py
CiscoNxosFileTransfer.check_file_exists
def check_file_exists(self, remote_cmd=""): """Check if the dest_file already exists on the file system (return boolean).""" if self.direction == "put": if not remote_cmd: remote_cmd = "dir {}{}".format(self.file_system, self.dest_file) remote_out = self.ssh_ctl_c...
python
def check_file_exists(self, remote_cmd=""): """Check if the dest_file already exists on the file system (return boolean).""" if self.direction == "put": if not remote_cmd: remote_cmd = "dir {}{}".format(self.file_system, self.dest_file) remote_out = self.ssh_ctl_c...
[ "def", "check_file_exists", "(", "self", ",", "remote_cmd", "=", "\"\"", ")", ":", "if", "self", ".", "direction", "==", "\"put\"", ":", "if", "not", "remote_cmd", ":", "remote_cmd", "=", "\"dir {}{}\"", ".", "format", "(", "self", ".", "file_system", ",",...
Check if the dest_file already exists on the file system (return boolean).
[ "Check", "if", "the", "dest_file", "already", "exists", "on", "the", "file", "system", "(", "return", "boolean", ")", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_nxos_ssh.py#L64-L78
train
ktbyers/netmiko
netmiko/cisco/cisco_tp_tcce.py
CiscoTpTcCeSSH.strip_prompt
def strip_prompt(self, a_string): """Strip the trailing router prompt from the output.""" expect_string = r"^(OK|ERROR|Command not recognized\.)$" response_list = a_string.split(self.RESPONSE_RETURN) last_line = response_list[-1] if re.search(expect_string, last_line): ...
python
def strip_prompt(self, a_string): """Strip the trailing router prompt from the output.""" expect_string = r"^(OK|ERROR|Command not recognized\.)$" response_list = a_string.split(self.RESPONSE_RETURN) last_line = response_list[-1] if re.search(expect_string, last_line): ...
[ "def", "strip_prompt", "(", "self", ",", "a_string", ")", ":", "expect_string", "=", "r\"^(OK|ERROR|Command not recognized\\.)$\"", "response_list", "=", "a_string", ".", "split", "(", "self", ".", "RESPONSE_RETURN", ")", "last_line", "=", "response_list", "[", "-",...
Strip the trailing router prompt from the output.
[ "Strip", "the", "trailing", "router", "prompt", "from", "the", "output", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_tp_tcce.py#L53-L61
train
ktbyers/netmiko
netmiko/cisco/cisco_tp_tcce.py
CiscoTpTcCeSSH.send_command
def send_command(self, *args, **kwargs): """ Send command to network device retrieve output until router_prompt or expect_string By default this method will keep waiting to receive data until the network device prompt is detected. The current network device prompt will be determined aut...
python
def send_command(self, *args, **kwargs): """ Send command to network device retrieve output until router_prompt or expect_string By default this method will keep waiting to receive data until the network device prompt is detected. The current network device prompt will be determined aut...
[ "def", "send_command", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">=", "2", ":", "expect_string", "=", "args", "[", "1", "]", "else", ":", "expect_string", "=", "kwargs", ".", "get", "(", "\"...
Send command to network device retrieve output until router_prompt or expect_string By default this method will keep waiting to receive data until the network device prompt is detected. The current network device prompt will be determined automatically. command_string = command to execute ...
[ "Send", "command", "to", "network", "device", "retrieve", "output", "until", "router_prompt", "or", "expect_string" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_tp_tcce.py#L63-L87
train
ktbyers/netmiko
netmiko/extreme/extreme_nos_ssh.py
ExtremeNosSSH.save_config
def save_config( self, cmd="copy running-config startup-config", confirm=True, confirm_response="y", ): """Save Config for Extreme VDX.""" return super(ExtremeNosSSH, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
python
def save_config( self, cmd="copy running-config startup-config", confirm=True, confirm_response="y", ): """Save Config for Extreme VDX.""" return super(ExtremeNosSSH, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"copy running-config startup-config\"", ",", "confirm", "=", "True", ",", "confirm_response", "=", "\"y\"", ",", ")", ":", "return", "super", "(", "ExtremeNosSSH", ",", "self", ")", ".", "save_config", "(",...
Save Config for Extreme VDX.
[ "Save", "Config", "for", "Extreme", "VDX", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_nos_ssh.py#L24-L33
train
ktbyers/netmiko
netmiko/huawei/huawei.py
HuaweiBase.exit_config_mode
def exit_config_mode(self, exit_config="return", pattern=r">"): """Exit configuration mode.""" return super(HuaweiBase, self).exit_config_mode( exit_config=exit_config, pattern=pattern )
python
def exit_config_mode(self, exit_config="return", pattern=r">"): """Exit configuration mode.""" return super(HuaweiBase, self).exit_config_mode( exit_config=exit_config, pattern=pattern )
[ "def", "exit_config_mode", "(", "self", ",", "exit_config", "=", "\"return\"", ",", "pattern", "=", "r\">\"", ")", ":", "return", "super", "(", "HuaweiBase", ",", "self", ")", ".", "exit_config_mode", "(", "exit_config", "=", "exit_config", ",", "pattern", "...
Exit configuration mode.
[ "Exit", "configuration", "mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L24-L28
train
ktbyers/netmiko
netmiko/huawei/huawei.py
HuaweiBase.set_base_prompt
def set_base_prompt( self, pri_prompt_terminator=">", alt_prompt_terminator="]", delay_factor=1 ): """ Sets self.base_prompt Used as delimiter for stripping of trailing prompt in output. Should be set to something that is general and applies in multiple contexts. For Comwar...
python
def set_base_prompt( self, pri_prompt_terminator=">", alt_prompt_terminator="]", delay_factor=1 ): """ Sets self.base_prompt Used as delimiter for stripping of trailing prompt in output. Should be set to something that is general and applies in multiple contexts. For Comwar...
[ "def", "set_base_prompt", "(", "self", ",", "pri_prompt_terminator", "=", "\">\"", ",", "alt_prompt_terminator", "=", "\"]\"", ",", "delay_factor", "=", "1", ")", ":", "log", ".", "debug", "(", "\"In set_base_prompt\"", ")", "delay_factor", "=", "self", ".", "...
Sets self.base_prompt Used as delimiter for stripping of trailing prompt in output. Should be set to something that is general and applies in multiple contexts. For Comware this will be the router prompt with < > or [ ] stripped off. This will be set on logging in, but not when enteri...
[ "Sets", "self", ".", "base_prompt" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L46-L85
train
ktbyers/netmiko
netmiko/huawei/huawei.py
HuaweiBase.save_config
def save_config(self, cmd="save", confirm=False, confirm_response=""): """ Save Config for HuaweiSSH""" return super(HuaweiBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
python
def save_config(self, cmd="save", confirm=False, confirm_response=""): """ Save Config for HuaweiSSH""" return super(HuaweiBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"save\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "HuaweiBase", ",", "self", ")", ".", "save_config", "(", "cmd", "=", "cmd", ",", "conf...
Save Config for HuaweiSSH
[ "Save", "Config", "for", "HuaweiSSH" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L87-L91
train
ktbyers/netmiko
netmiko/huawei/huawei.py
HuaweiTelnet.telnet_login
def telnet_login( self, pri_prompt_terminator=r"]\s*$", alt_prompt_terminator=r">\s*$", username_pattern=r"(?:user:|username|login|user name)", pwd_pattern=r"assword", delay_factor=1, max_loops=20, ): """Telnet login for Huawei Devices""" dela...
python
def telnet_login( self, pri_prompt_terminator=r"]\s*$", alt_prompt_terminator=r">\s*$", username_pattern=r"(?:user:|username|login|user name)", pwd_pattern=r"assword", delay_factor=1, max_loops=20, ): """Telnet login for Huawei Devices""" dela...
[ "def", "telnet_login", "(", "self", ",", "pri_prompt_terminator", "=", "r\"]\\s*$\"", ",", "alt_prompt_terminator", "=", "r\">\\s*$\"", ",", "username_pattern", "=", "r\"(?:user:|username|login|user name)\"", ",", "pwd_pattern", "=", "r\"assword\"", ",", "delay_factor", "...
Telnet login for Huawei Devices
[ "Telnet", "login", "for", "Huawei", "Devices" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L103-L164
train
ktbyers/netmiko
netmiko/huawei/huawei.py
HuaweiVrpv8SSH.commit
def commit(self, comment="", delay_factor=1): """ Commit the candidate configuration. Commit the entered configuration. Raise an error and return the failure if the commit fails. default: command_string = commit comment: command_string = commit com...
python
def commit(self, comment="", delay_factor=1): """ Commit the candidate configuration. Commit the entered configuration. Raise an error and return the failure if the commit fails. default: command_string = commit comment: command_string = commit com...
[ "def", "commit", "(", "self", ",", "comment", "=", "\"\"", ",", "delay_factor", "=", "1", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", ")", "error_marker", "=", "\"Failed to generate committed config\"", "command_string", ...
Commit the candidate configuration. Commit the entered configuration. Raise an error and return the failure if the commit fails. default: command_string = commit comment: command_string = commit comment <comment>
[ "Commit", "the", "candidate", "configuration", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L168-L202
train
ktbyers/netmiko
examples/asa_upgrade.py
asa_scp_handler
def asa_scp_handler(ssh_conn, cmd="ssh scopy enable", mode="enable"): """Enable/disable SCP on Cisco ASA.""" if mode == "disable": cmd = "no " + cmd return ssh_conn.send_config_set([cmd])
python
def asa_scp_handler(ssh_conn, cmd="ssh scopy enable", mode="enable"): """Enable/disable SCP on Cisco ASA.""" if mode == "disable": cmd = "no " + cmd return ssh_conn.send_config_set([cmd])
[ "def", "asa_scp_handler", "(", "ssh_conn", ",", "cmd", "=", "\"ssh scopy enable\"", ",", "mode", "=", "\"enable\"", ")", ":", "if", "mode", "==", "\"disable\"", ":", "cmd", "=", "\"no \"", "+", "cmd", "return", "ssh_conn", ".", "send_config_set", "(", "[", ...
Enable/disable SCP on Cisco ASA.
[ "Enable", "/", "disable", "SCP", "on", "Cisco", "ASA", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/asa_upgrade.py#L9-L13
train
ktbyers/netmiko
examples/asa_upgrade.py
main
def main(): """Script to upgrade a Cisco ASA.""" try: ip_addr = raw_input("Enter ASA IP address: ") except NameError: ip_addr = input("Enter ASA IP address: ") my_pass = getpass() start_time = datetime.now() print(">>>> {}".format(start_time)) net_device = { "device_...
python
def main(): """Script to upgrade a Cisco ASA.""" try: ip_addr = raw_input("Enter ASA IP address: ") except NameError: ip_addr = input("Enter ASA IP address: ") my_pass = getpass() start_time = datetime.now() print(">>>> {}".format(start_time)) net_device = { "device_...
[ "def", "main", "(", ")", ":", "try", ":", "ip_addr", "=", "raw_input", "(", "\"Enter ASA IP address: \"", ")", "except", "NameError", ":", "ip_addr", "=", "input", "(", "\"Enter ASA IP address: \"", ")", "my_pass", "=", "getpass", "(", ")", "start_time", "=", ...
Script to upgrade a Cisco ASA.
[ "Script", "to", "upgrade", "a", "Cisco", "ASA", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/asa_upgrade.py#L16-L91
train
ktbyers/netmiko
examples/use_cases/case16_concurrency/processes_netmiko.py
show_version
def show_version(a_device): """Execute show version command using Netmiko.""" remote_conn = ConnectHandler(**a_device) print() print("#" * 80) print(remote_conn.send_command("show version")) print("#" * 80) print()
python
def show_version(a_device): """Execute show version command using Netmiko.""" remote_conn = ConnectHandler(**a_device) print() print("#" * 80) print(remote_conn.send_command("show version")) print("#" * 80) print()
[ "def", "show_version", "(", "a_device", ")", ":", "remote_conn", "=", "ConnectHandler", "(", "*", "*", "a_device", ")", "print", "(", ")", "print", "(", "\"#\"", "*", "80", ")", "print", "(", "remote_conn", ".", "send_command", "(", "\"show version\"", ")"...
Execute show version command using Netmiko.
[ "Execute", "show", "version", "command", "using", "Netmiko", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/use_cases/case16_concurrency/processes_netmiko.py#L14-L21
train
ktbyers/netmiko
examples/use_cases/case16_concurrency/processes_netmiko.py
main
def main(): """ Use processes and Netmiko to connect to each of the devices. Execute 'show version' on each device. Record the amount of time required to do this. """ start_time = datetime.now() procs = [] for a_device in devices: my_proc = Process(target=show_version, args=(a_devic...
python
def main(): """ Use processes and Netmiko to connect to each of the devices. Execute 'show version' on each device. Record the amount of time required to do this. """ start_time = datetime.now() procs = [] for a_device in devices: my_proc = Process(target=show_version, args=(a_devic...
[ "def", "main", "(", ")", ":", "start_time", "=", "datetime", ".", "now", "(", ")", "procs", "=", "[", "]", "for", "a_device", "in", "devices", ":", "my_proc", "=", "Process", "(", "target", "=", "show_version", ",", "args", "=", "(", "a_device", ",",...
Use processes and Netmiko to connect to each of the devices. Execute 'show version' on each device. Record the amount of time required to do this.
[ "Use", "processes", "and", "Netmiko", "to", "connect", "to", "each", "of", "the", "devices", ".", "Execute", "show", "version", "on", "each", "device", ".", "Record", "the", "amount", "of", "time", "required", "to", "do", "this", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/use_cases/case16_concurrency/processes_netmiko.py#L24-L41
train
ktbyers/netmiko
netmiko/cisco/cisco_wlc_ssh.py
CiscoWlcSSH.special_login_handler
def special_login_handler(self, delay_factor=1): """WLC presents with the following on login (in certain OS versions) login as: user (Cisco Controller) User: user Password:**** """ delay_factor = self.select_delay_factor(delay_factor) i = 0 tim...
python
def special_login_handler(self, delay_factor=1): """WLC presents with the following on login (in certain OS versions) login as: user (Cisco Controller) User: user Password:**** """ delay_factor = self.select_delay_factor(delay_factor) i = 0 tim...
[ "def", "special_login_handler", "(", "self", ",", "delay_factor", "=", "1", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", ")", "i", "=", "0", "time", ".", "sleep", "(", "delay_factor", "*", "0.5", ")", "output", "=...
WLC presents with the following on login (in certain OS versions) login as: user (Cisco Controller) User: user Password:****
[ "WLC", "presents", "with", "the", "following", "on", "login", "(", "in", "certain", "OS", "versions", ")" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L15-L42
train
ktbyers/netmiko
netmiko/cisco/cisco_wlc_ssh.py
CiscoWlcSSH.send_command_w_enter
def send_command_w_enter(self, *args, **kwargs): """ 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 s...
python
def send_command_w_enter(self, *args, **kwargs): """ 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 s...
[ "def", "send_command_w_enter", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">", "1", ":", "raise", "ValueError", "(", "\"Must pass in delay_factor as keyword argument\"", ")", "# If no delay_factor use 1 for def...
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
[ "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", "outp...
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L44-L94
train
ktbyers/netmiko
netmiko/cisco/cisco_wlc_ssh.py
CiscoWlcSSH.check_config_mode
def check_config_mode(self, check_string="config", pattern=""): """Checks if the device is in configuration mode or not.""" if not pattern: pattern = re.escape(self.base_prompt) return super(CiscoWlcSSH, self).check_config_mode(check_string, pattern)
python
def check_config_mode(self, check_string="config", pattern=""): """Checks if the device is in configuration mode or not.""" if not pattern: pattern = re.escape(self.base_prompt) return super(CiscoWlcSSH, self).check_config_mode(check_string, pattern)
[ "def", "check_config_mode", "(", "self", ",", "check_string", "=", "\"config\"", ",", "pattern", "=", "\"\"", ")", ":", "if", "not", "pattern", ":", "pattern", "=", "re", ".", "escape", "(", "self", ".", "base_prompt", ")", "return", "super", "(", "Cisco...
Checks if the device is in configuration mode or not.
[ "Checks", "if", "the", "device", "is", "in", "configuration", "mode", "or", "not", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L118-L122
train
ktbyers/netmiko
netmiko/cisco/cisco_wlc_ssh.py
CiscoWlcSSH.exit_config_mode
def exit_config_mode(self, exit_config="exit", pattern=""): """Exit config_mode.""" if not pattern: pattern = re.escape(self.base_prompt) return super(CiscoWlcSSH, self).exit_config_mode(exit_config, pattern)
python
def exit_config_mode(self, exit_config="exit", pattern=""): """Exit config_mode.""" if not pattern: pattern = re.escape(self.base_prompt) return super(CiscoWlcSSH, self).exit_config_mode(exit_config, pattern)
[ "def", "exit_config_mode", "(", "self", ",", "exit_config", "=", "\"exit\"", ",", "pattern", "=", "\"\"", ")", ":", "if", "not", "pattern", ":", "pattern", "=", "re", ".", "escape", "(", "self", ".", "base_prompt", ")", "return", "super", "(", "CiscoWlcS...
Exit config_mode.
[ "Exit", "config_mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L130-L134
train
ktbyers/netmiko
netmiko/cisco/cisco_wlc_ssh.py
CiscoWlcSSH.save_config
def save_config(self, cmd="save config", confirm=True, confirm_response="y"): """Saves Config.""" self.enable() if confirm: output = self.send_command_timing(command_string=cmd) if confirm_response: output += self.send_command_timing(confirm_response) ...
python
def save_config(self, cmd="save config", confirm=True, confirm_response="y"): """Saves Config.""" self.enable() if confirm: output = self.send_command_timing(command_string=cmd) if confirm_response: output += self.send_command_timing(confirm_response) ...
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"save config\"", ",", "confirm", "=", "True", ",", "confirm_response", "=", "\"y\"", ")", ":", "self", ".", "enable", "(", ")", "if", "confirm", ":", "output", "=", "self", ".", "send_command_timing", ...
Saves Config.
[ "Saves", "Config", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L176-L189
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
Row._BuildIndex
def _BuildIndex(self): """Recreate the key index.""" self._index = {} for i, k in enumerate(self._keys): self._index[k] = i
python
def _BuildIndex(self): """Recreate the key index.""" self._index = {} for i, k in enumerate(self._keys): self._index[k] = i
[ "def", "_BuildIndex", "(", "self", ")", ":", "self", ".", "_index", "=", "{", "}", "for", "i", ",", "k", "in", "enumerate", "(", "self", ".", "_keys", ")", ":", "self", ".", "_index", "[", "k", "]", "=", "i" ]
Recreate the key index.
[ "Recreate", "the", "key", "index", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L78-L82
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
Row.get
def get(self, column, default_value=None): """Get an item from the Row by column name. Args: column: Tuple of column names, or a (str) column name, or positional column number, 0-indexed. default_value: The value to use if the key is not found. Returns: A list or string with ...
python
def get(self, column, default_value=None): """Get an item from the Row by column name. Args: column: Tuple of column names, or a (str) column name, or positional column number, 0-indexed. default_value: The value to use if the key is not found. Returns: A list or string with ...
[ "def", "get", "(", "self", ",", "column", ",", "default_value", "=", "None", ")", ":", "if", "isinstance", "(", "column", ",", "(", "list", ",", "tuple", ")", ")", ":", "ret", "=", "[", "]", "for", "col", "in", "column", ":", "ret", ".", "append"...
Get an item from the Row by column name. Args: column: Tuple of column names, or a (str) column name, or positional column number, 0-indexed. default_value: The value to use if the key is not found. Returns: A list or string with column value(s) or default_value if not found.
[ "Get", "an", "item", "from", "the", "Row", "by", "column", "name", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L145-L169
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
Row.index
def index(self, column): # pylint: disable=C6409 """Fetches the column number (0 indexed). Args: column: A string, column to fetch the index of. Returns: An int, the row index number. Raises: ValueError: The specified column was not found. """ for i, key in enumerat...
python
def index(self, column): # pylint: disable=C6409 """Fetches the column number (0 indexed). Args: column: A string, column to fetch the index of. Returns: An int, the row index number. Raises: ValueError: The specified column was not found. """ for i, key in enumerat...
[ "def", "index", "(", "self", ",", "column", ")", ":", "# pylint: disable=C6409", "for", "i", ",", "key", "in", "enumerate", "(", "self", ".", "_keys", ")", ":", "if", "key", "==", "column", ":", "return", "i", "raise", "ValueError", "(", "'Column \"%s\" ...
Fetches the column number (0 indexed). Args: column: A string, column to fetch the index of. Returns: An int, the row index number. Raises: ValueError: The specified column was not found.
[ "Fetches", "the", "column", "number", "(", "0", "indexed", ")", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L171-L186
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
Row._SetColour
def _SetColour(self, value_list): """Sets row's colour attributes to a list of values in terminal.SGR.""" if value_list is None: self._color = None return colors = [] for color in value_list: if color in terminal.SGR: colors.append(colo...
python
def _SetColour(self, value_list): """Sets row's colour attributes to a list of values in terminal.SGR.""" if value_list is None: self._color = None return colors = [] for color in value_list: if color in terminal.SGR: colors.append(colo...
[ "def", "_SetColour", "(", "self", ",", "value_list", ")", ":", "if", "value_list", "is", "None", ":", "self", ".", "_color", "=", "None", "return", "colors", "=", "[", "]", "for", "color", "in", "value_list", ":", "if", "color", "in", "terminal", ".", ...
Sets row's colour attributes to a list of values in terminal.SGR.
[ "Sets", "row", "s", "colour", "attributes", "to", "a", "list", "of", "values", "in", "terminal", ".", "SGR", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L213-L228
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
Row.Insert
def Insert(self, key, value, row_index): """Inserts new values at a specified offset. Args: key: string for header value. value: string for a data value. row_index: Offset into row for data. Raises: IndexError: If the offset is out of bands. """ if row_index < 0: ...
python
def Insert(self, key, value, row_index): """Inserts new values at a specified offset. Args: key: string for header value. value: string for a data value. row_index: Offset into row for data. Raises: IndexError: If the offset is out of bands. """ if row_index < 0: ...
[ "def", "Insert", "(", "self", ",", "key", ",", "value", ",", "row_index", ")", ":", "if", "row_index", "<", "0", ":", "row_index", "+=", "len", "(", "self", ")", "if", "not", "0", "<=", "row_index", "<", "len", "(", "self", ")", ":", "raise", "In...
Inserts new values at a specified offset. Args: key: string for header value. value: string for a data value. row_index: Offset into row for data. Raises: IndexError: If the offset is out of bands.
[ "Inserts", "new", "values", "at", "a", "specified", "offset", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L280-L305
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable.Map
def Map(self, function): """Applies the function to every row in the table. Args: function: A function applied to each row. Returns: A new TextTable() Raises: TableError: When transform is not invalid row entry. The transform must be compatible with Append(). ...
python
def Map(self, function): """Applies the function to every row in the table. Args: function: A function applied to each row. Returns: A new TextTable() Raises: TableError: When transform is not invalid row entry. The transform must be compatible with Append(). ...
[ "def", "Map", "(", "self", ",", "function", ")", ":", "new_table", "=", "self", ".", "__class__", "(", ")", "# pylint: disable=protected-access", "new_table", ".", "_table", "=", "[", "self", ".", "header", "]", "for", "row", "in", "self", ":", "filtered_r...
Applies the function to every row in the table. Args: function: A function applied to each row. Returns: A new TextTable() Raises: TableError: When transform is not invalid row entry. The transform must be compatible with Append().
[ "Applies", "the", "function", "to", "every", "row", "in", "the", "table", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L420-L440
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable.sort
def sort(self, cmp=None, key=None, reverse=False): """Sorts rows in the texttable. Args: cmp: func, non default sort algorithm to use. key: func, applied to each element before sorting. reverse: bool, reverse order of sort. """ def _DefaultKey(value): """Default k...
python
def sort(self, cmp=None, key=None, reverse=False): """Sorts rows in the texttable. Args: cmp: func, non default sort algorithm to use. key: func, applied to each element before sorting. reverse: bool, reverse order of sort. """ def _DefaultKey(value): """Default k...
[ "def", "sort", "(", "self", ",", "cmp", "=", "None", ",", "key", "=", "None", ",", "reverse", "=", "False", ")", ":", "def", "_DefaultKey", "(", "value", ")", ":", "\"\"\"Default key func is to create a list of all fields.\"\"\"", "result", "=", "[", "]", "f...
Sorts rows in the texttable. Args: cmp: func, non default sort algorithm to use. key: func, applied to each element before sorting. reverse: bool, reverse order of sort.
[ "Sorts", "rows", "in", "the", "texttable", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L444-L478
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable.extend
def extend(self, table, keys=None): """Extends all rows in the texttable. The rows are extended with the new columns from the table. Args: table: A texttable, the table to extend this table by. keys: A set, the set of columns to use as the key. If None, the row index is used. ...
python
def extend(self, table, keys=None): """Extends all rows in the texttable. The rows are extended with the new columns from the table. Args: table: A texttable, the table to extend this table by. keys: A set, the set of columns to use as the key. If None, the row index is used. ...
[ "def", "extend", "(", "self", ",", "table", ",", "keys", "=", "None", ")", ":", "if", "keys", ":", "for", "k", "in", "keys", ":", "if", "k", "not", "in", "self", ".", "_Header", "(", ")", ":", "raise", "IndexError", "(", "\"Unknown key: '%s'\"", ",...
Extends all rows in the texttable. The rows are extended with the new columns from the table. Args: table: A texttable, the table to extend this table by. keys: A set, the set of columns to use as the key. If None, the row index is used. Raises: IndexError: If key is not a valid...
[ "Extends", "all", "rows", "in", "the", "texttable", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L482-L525
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable.Remove
def Remove(self, row): """Removes a row from the table. Args: row: int, the row number to delete. Must be >= 1, as the header cannot be removed. Raises: TableError: Attempt to remove nonexistent or header row. """ if row == 0 or row > self.size: raise TableE...
python
def Remove(self, row): """Removes a row from the table. Args: row: int, the row number to delete. Must be >= 1, as the header cannot be removed. Raises: TableError: Attempt to remove nonexistent or header row. """ if row == 0 or row > self.size: raise TableE...
[ "def", "Remove", "(", "self", ",", "row", ")", ":", "if", "row", "==", "0", "or", "row", ">", "self", ".", "size", ":", "raise", "TableError", "(", "\"Attempt to remove header row\"", ")", "new_table", "=", "[", "]", "# pylint: disable=E1103", "for", "t_ro...
Removes a row from the table. Args: row: int, the row number to delete. Must be >= 1, as the header cannot be removed. Raises: TableError: Attempt to remove nonexistent or header row.
[ "Removes", "a", "row", "from", "the", "table", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L528-L547
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable._GetRow
def _GetRow(self, columns=None): """Returns the current row as a tuple.""" row = self._table[self._row_index] if columns: result = [] for col in columns: if col not in self.header: raise TableError("Column header %s not known in table....
python
def _GetRow(self, columns=None): """Returns the current row as a tuple.""" row = self._table[self._row_index] if columns: result = [] for col in columns: if col not in self.header: raise TableError("Column header %s not known in table....
[ "def", "_GetRow", "(", "self", ",", "columns", "=", "None", ")", ":", "row", "=", "self", ".", "_table", "[", "self", ".", "_row_index", "]", "if", "columns", ":", "result", "=", "[", "]", "for", "col", "in", "columns", ":", "if", "col", "not", "...
Returns the current row as a tuple.
[ "Returns", "the", "current", "row", "as", "a", "tuple", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L553-L564
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable._SetRow
def _SetRow(self, new_values, row=0): """Sets the current row to new list. Args: new_values: List|dict of new values to insert into row. row: int, Row to insert values into. Raises: TableError: If number of new values is not equal to row size. """ if not row: ...
python
def _SetRow(self, new_values, row=0): """Sets the current row to new list. Args: new_values: List|dict of new values to insert into row. row: int, Row to insert values into. Raises: TableError: If number of new values is not equal to row size. """ if not row: ...
[ "def", "_SetRow", "(", "self", ",", "new_values", ",", "row", "=", "0", ")", ":", "if", "not", "row", ":", "row", "=", "self", ".", "_row_index", "if", "row", ">", "self", ".", "size", ":", "raise", "TableError", "(", "\"Entry %s beyond table size %s.\""...
Sets the current row to new list. Args: new_values: List|dict of new values to insert into row. row: int, Row to insert values into. Raises: TableError: If number of new values is not equal to row size.
[ "Sets", "the", "current", "row", "to", "new", "list", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L566-L583
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable._SetHeader
def _SetHeader(self, new_values): """Sets header of table to the given tuple. Args: new_values: Tuple of new header values. """ row = self.row_class() row.row = 0 for v in new_values: row[v] = v self._table[0] = row
python
def _SetHeader(self, new_values): """Sets header of table to the given tuple. Args: new_values: Tuple of new header values. """ row = self.row_class() row.row = 0 for v in new_values: row[v] = v self._table[0] = row
[ "def", "_SetHeader", "(", "self", ",", "new_values", ")", ":", "row", "=", "self", ".", "row_class", "(", ")", "row", ".", "row", "=", "0", "for", "v", "in", "new_values", ":", "row", "[", "v", "]", "=", "v", "self", ".", "_table", "[", "0", "]...
Sets header of table to the given tuple. Args: new_values: Tuple of new header values.
[ "Sets", "header", "of", "table", "to", "the", "given", "tuple", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L585-L595
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable._SmallestColSize
def _SmallestColSize(self, text): """Finds the largest indivisible word of a string. ...and thus the smallest possible column width that can contain that word unsplit over rows. Args: text: A string of text potentially consisting of words. Returns: Integer size of the largest sing...
python
def _SmallestColSize(self, text): """Finds the largest indivisible word of a string. ...and thus the smallest possible column width that can contain that word unsplit over rows. Args: text: A string of text potentially consisting of words. Returns: Integer size of the largest sing...
[ "def", "_SmallestColSize", "(", "self", ",", "text", ")", ":", "if", "not", "text", ":", "return", "0", "stripped", "=", "terminal", ".", "StripAnsiText", "(", "text", ")", "return", "max", "(", "len", "(", "word", ")", "for", "word", "in", "stripped",...
Finds the largest indivisible word of a string. ...and thus the smallest possible column width that can contain that word unsplit over rows. Args: text: A string of text potentially consisting of words. Returns: Integer size of the largest single word in the text.
[ "Finds", "the", "largest", "indivisible", "word", "of", "a", "string", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L637-L652
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable.RowWith
def RowWith(self, column, value): """Retrieves the first non header row with the column of the given value. Args: column: str, the name of the column to check. value: str, The value of the column to check. Returns: A Row() of the first row found, None otherwise. Raises: In...
python
def RowWith(self, column, value): """Retrieves the first non header row with the column of the given value. Args: column: str, the name of the column to check. value: str, The value of the column to check. Returns: A Row() of the first row found, None otherwise. Raises: In...
[ "def", "RowWith", "(", "self", ",", "column", ",", "value", ")", ":", "for", "row", "in", "self", ".", "_table", "[", "1", ":", "]", ":", "if", "row", "[", "column", "]", "==", "value", ":", "return", "row", "return", "None" ]
Retrieves the first non header row with the column of the given value. Args: column: str, the name of the column to check. value: str, The value of the column to check. Returns: A Row() of the first row found, None otherwise. Raises: IndexError: The specified column does not exist...
[ "Retrieves", "the", "first", "non", "header", "row", "with", "the", "column", "of", "the", "given", "value", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L965-L981
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable.AddColumn
def AddColumn(self, column, default="", col_index=-1): """Appends a new column to the table. Args: column: A string, name of the column to add. default: Default value for entries. Defaults to ''. col_index: Integer index for where to insert new column. Raises: TableError: Colum...
python
def AddColumn(self, column, default="", col_index=-1): """Appends a new column to the table. Args: column: A string, name of the column to add. default: Default value for entries. Defaults to ''. col_index: Integer index for where to insert new column. Raises: TableError: Colum...
[ "def", "AddColumn", "(", "self", ",", "column", ",", "default", "=", "\"\"", ",", "col_index", "=", "-", "1", ")", ":", "if", "column", "in", "self", ".", "table", ":", "raise", "TableError", "(", "\"Column %r already in table.\"", "%", "column", ")", "i...
Appends a new column to the table. Args: column: A string, name of the column to add. default: Default value for entries. Defaults to ''. col_index: Integer index for where to insert new column. Raises: TableError: Column name already exists.
[ "Appends", "a", "new", "column", "to", "the", "table", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L983-L1004
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable.Append
def Append(self, new_values): """Adds a new row (list) to the table. Args: new_values: Tuple, dict, or Row() of new values to append as a row. Raises: TableError: Supplied tuple not equal to table width. """ newrow = self.NewRow() newrow.values = new_values self...
python
def Append(self, new_values): """Adds a new row (list) to the table. Args: new_values: Tuple, dict, or Row() of new values to append as a row. Raises: TableError: Supplied tuple not equal to table width. """ newrow = self.NewRow() newrow.values = new_values self...
[ "def", "Append", "(", "self", ",", "new_values", ")", ":", "newrow", "=", "self", ".", "NewRow", "(", ")", "newrow", ".", "values", "=", "new_values", "self", ".", "_table", ".", "append", "(", "newrow", ")" ]
Adds a new row (list) to the table. Args: new_values: Tuple, dict, or Row() of new values to append as a row. Raises: TableError: Supplied tuple not equal to table width.
[ "Adds", "a", "new", "row", "(", "list", ")", "to", "the", "table", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L1006-L1017
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable.NewRow
def NewRow(self, value=""): """Fetches a new, empty row, with headers populated. Args: value: Initial value to set each row entry to. Returns: A Row() object. """ newrow = self.row_class() newrow.row = self.size + 1 newrow.table = self headers = self._He...
python
def NewRow(self, value=""): """Fetches a new, empty row, with headers populated. Args: value: Initial value to set each row entry to. Returns: A Row() object. """ newrow = self.row_class() newrow.row = self.size + 1 newrow.table = self headers = self._He...
[ "def", "NewRow", "(", "self", ",", "value", "=", "\"\"", ")", ":", "newrow", "=", "self", ".", "row_class", "(", ")", "newrow", ".", "row", "=", "self", ".", "size", "+", "1", "newrow", ".", "table", "=", "self", "headers", "=", "self", ".", "_He...
Fetches a new, empty row, with headers populated. Args: value: Initial value to set each row entry to. Returns: A Row() object.
[ "Fetches", "a", "new", "empty", "row", "with", "headers", "populated", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L1019-L1034
train
ktbyers/netmiko
netmiko/_textfsm/_texttable.py
TextTable.CsvToTable
def CsvToTable(self, buf, header=True, separator=","): """Parses buffer into tabular format. Strips off comments (preceded by '#'). Optionally parses and indexes by first line (header). Args: buf: String file buffer containing CSV data. header: Is the first line of buffer a header. ...
python
def CsvToTable(self, buf, header=True, separator=","): """Parses buffer into tabular format. Strips off comments (preceded by '#'). Optionally parses and indexes by first line (header). Args: buf: String file buffer containing CSV data. header: Is the first line of buffer a header. ...
[ "def", "CsvToTable", "(", "self", ",", "buf", ",", "header", "=", "True", ",", "separator", "=", "\",\"", ")", ":", "self", ".", "Reset", "(", ")", "header_row", "=", "self", ".", "row_class", "(", ")", "if", "header", ":", "line", "=", "buf", ".",...
Parses buffer into tabular format. Strips off comments (preceded by '#'). Optionally parses and indexes by first line (header). Args: buf: String file buffer containing CSV data. header: Is the first line of buffer a header. separator: String that CSV is separated by. Returns: ...
[ "Parses", "buffer", "into", "tabular", "format", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L1036-L1103
train
ktbyers/netmiko
netmiko/extreme/extreme_vsp_ssh.py
ExtremeVspSSH.save_config
def save_config(self, cmd="save config", confirm=False, confirm_response=""): """Save Config""" return super(ExtremeVspSSH, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
python
def save_config(self, cmd="save config", confirm=False, confirm_response=""): """Save Config""" return super(ExtremeVspSSH, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"save config\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "ExtremeVspSSH", ",", "self", ")", ".", "save_config", "(", "cmd", "=", "cmd", ",...
Save Config
[ "Save", "Config" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_vsp_ssh.py#L20-L24
train
ktbyers/netmiko
netmiko/pluribus/pluribus_ssh.py
PluribusSSH.disable_paging
def disable_paging(self, command="pager off", delay_factor=1): """Make sure paging is disabled.""" return super(PluribusSSH, self).disable_paging( command=command, delay_factor=delay_factor )
python
def disable_paging(self, command="pager off", delay_factor=1): """Make sure paging is disabled.""" return super(PluribusSSH, self).disable_paging( command=command, delay_factor=delay_factor )
[ "def", "disable_paging", "(", "self", ",", "command", "=", "\"pager off\"", ",", "delay_factor", "=", "1", ")", ":", "return", "super", "(", "PluribusSSH", ",", "self", ")", ".", "disable_paging", "(", "command", "=", "command", ",", "delay_factor", "=", "...
Make sure paging is disabled.
[ "Make", "sure", "paging", "is", "disabled", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/pluribus/pluribus_ssh.py#L13-L17
train
ktbyers/netmiko
netmiko/utilities.py
load_yaml_file
def load_yaml_file(yaml_file): """Read YAML file.""" try: import yaml except ImportError: sys.exit("Unable to import yaml module.") try: with io.open(yaml_file, "rt", encoding="utf-8") as fname: return yaml.safe_load(fname) except IOError: sys.exit("Unable...
python
def load_yaml_file(yaml_file): """Read YAML file.""" try: import yaml except ImportError: sys.exit("Unable to import yaml module.") try: with io.open(yaml_file, "rt", encoding="utf-8") as fname: return yaml.safe_load(fname) except IOError: sys.exit("Unable...
[ "def", "load_yaml_file", "(", "yaml_file", ")", ":", "try", ":", "import", "yaml", "except", "ImportError", ":", "sys", ".", "exit", "(", "\"Unable to import yaml module.\"", ")", "try", ":", "with", "io", ".", "open", "(", "yaml_file", ",", "\"rt\"", ",", ...
Read YAML file.
[ "Read", "YAML", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L55-L65
train
ktbyers/netmiko
netmiko/utilities.py
find_cfg_file
def find_cfg_file(file_name=None): """Look for .netmiko.yml in current dir, then ~/.netmiko.yml.""" base_file = ".netmiko.yml" check_files = [base_file, os.path.expanduser("~") + "/" + base_file] if file_name: check_files.insert(0, file_name) for test_file in check_files: if os.path....
python
def find_cfg_file(file_name=None): """Look for .netmiko.yml in current dir, then ~/.netmiko.yml.""" base_file = ".netmiko.yml" check_files = [base_file, os.path.expanduser("~") + "/" + base_file] if file_name: check_files.insert(0, file_name) for test_file in check_files: if os.path....
[ "def", "find_cfg_file", "(", "file_name", "=", "None", ")", ":", "base_file", "=", "\".netmiko.yml\"", "check_files", "=", "[", "base_file", ",", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "+", "\"/\"", "+", "base_file", "]", "if", "file_name...
Look for .netmiko.yml in current dir, then ~/.netmiko.yml.
[ "Look", "for", ".", "netmiko", ".", "yml", "in", "current", "dir", "then", "~", "/", ".", "netmiko", ".", "yml", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L74-L83
train
ktbyers/netmiko
netmiko/utilities.py
display_inventory
def display_inventory(my_devices): """Print out inventory devices and groups.""" inventory_groups = ["all"] inventory_devices = [] for k, v in my_devices.items(): if isinstance(v, list): inventory_groups.append(k) elif isinstance(v, dict): inventory_devices.append...
python
def display_inventory(my_devices): """Print out inventory devices and groups.""" inventory_groups = ["all"] inventory_devices = [] for k, v in my_devices.items(): if isinstance(v, list): inventory_groups.append(k) elif isinstance(v, dict): inventory_devices.append...
[ "def", "display_inventory", "(", "my_devices", ")", ":", "inventory_groups", "=", "[", "\"all\"", "]", "inventory_devices", "=", "[", "]", "for", "k", ",", "v", "in", "my_devices", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "list", ...
Print out inventory devices and groups.
[ "Print", "out", "inventory", "devices", "and", "groups", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L86-L107
train
ktbyers/netmiko
netmiko/utilities.py
obtain_all_devices
def obtain_all_devices(my_devices): """Dynamically create 'all' group.""" new_devices = {} for device_name, device_or_group in my_devices.items(): # Skip any groups if not isinstance(device_or_group, list): new_devices[device_name] = device_or_group return new_devices
python
def obtain_all_devices(my_devices): """Dynamically create 'all' group.""" new_devices = {} for device_name, device_or_group in my_devices.items(): # Skip any groups if not isinstance(device_or_group, list): new_devices[device_name] = device_or_group return new_devices
[ "def", "obtain_all_devices", "(", "my_devices", ")", ":", "new_devices", "=", "{", "}", "for", "device_name", ",", "device_or_group", "in", "my_devices", ".", "items", "(", ")", ":", "# Skip any groups", "if", "not", "isinstance", "(", "device_or_group", ",", ...
Dynamically create 'all' group.
[ "Dynamically", "create", "all", "group", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L110-L117
train
ktbyers/netmiko
netmiko/utilities.py
ensure_dir_exists
def ensure_dir_exists(verify_dir): """Ensure directory exists. Create if necessary.""" if not os.path.exists(verify_dir): # Doesn't exist create dir os.makedirs(verify_dir) else: # Exists if not os.path.isdir(verify_dir): # Not a dir, raise an exception ...
python
def ensure_dir_exists(verify_dir): """Ensure directory exists. Create if necessary.""" if not os.path.exists(verify_dir): # Doesn't exist create dir os.makedirs(verify_dir) else: # Exists if not os.path.isdir(verify_dir): # Not a dir, raise an exception ...
[ "def", "ensure_dir_exists", "(", "verify_dir", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "verify_dir", ")", ":", "# Doesn't exist create dir", "os", ".", "makedirs", "(", "verify_dir", ")", "else", ":", "# Exists", "if", "not", "os", "....
Ensure directory exists. Create if necessary.
[ "Ensure", "directory", "exists", ".", "Create", "if", "necessary", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L133-L142
train
ktbyers/netmiko
netmiko/utilities.py
find_netmiko_dir
def find_netmiko_dir(): """Check environment first, then default dir""" try: netmiko_base_dir = os.environ["NETMIKO_DIR"] except KeyError: netmiko_base_dir = NETMIKO_BASE_DIR netmiko_base_dir = os.path.expanduser(netmiko_base_dir) if netmiko_base_dir == "/": raise ValueError(...
python
def find_netmiko_dir(): """Check environment first, then default dir""" try: netmiko_base_dir = os.environ["NETMIKO_DIR"] except KeyError: netmiko_base_dir = NETMIKO_BASE_DIR netmiko_base_dir = os.path.expanduser(netmiko_base_dir) if netmiko_base_dir == "/": raise ValueError(...
[ "def", "find_netmiko_dir", "(", ")", ":", "try", ":", "netmiko_base_dir", "=", "os", ".", "environ", "[", "\"NETMIKO_DIR\"", "]", "except", "KeyError", ":", "netmiko_base_dir", "=", "NETMIKO_BASE_DIR", "netmiko_base_dir", "=", "os", ".", "path", ".", "expanduser...
Check environment first, then default dir
[ "Check", "environment", "first", "then", "default", "dir" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L145-L155
train
ktbyers/netmiko
netmiko/utilities.py
write_bytes
def write_bytes(out_data, encoding="ascii"): """Write Python2 and Python3 compatible byte stream.""" if sys.version_info[0] >= 3: if isinstance(out_data, type("")): if encoding == "utf-8": return out_data.encode("utf-8") else: return out_data.encod...
python
def write_bytes(out_data, encoding="ascii"): """Write Python2 and Python3 compatible byte stream.""" if sys.version_info[0] >= 3: if isinstance(out_data, type("")): if encoding == "utf-8": return out_data.encode("utf-8") else: return out_data.encod...
[ "def", "write_bytes", "(", "out_data", ",", "encoding", "=", "\"ascii\"", ")", ":", "if", "sys", ".", "version_info", "[", "0", "]", ">=", "3", ":", "if", "isinstance", "(", "out_data", ",", "type", "(", "\"\"", ")", ")", ":", "if", "encoding", "==",...
Write Python2 and Python3 compatible byte stream.
[ "Write", "Python2", "and", "Python3", "compatible", "byte", "stream", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L158-L179
train
ktbyers/netmiko
netmiko/utilities.py
check_serial_port
def check_serial_port(name): """returns valid COM Port.""" try: cdc = next(serial.tools.list_ports.grep(name)) return cdc[0] except StopIteration: msg = "device {} not found. ".format(name) msg += "available devices are: " ports = list(serial.tools.list_ports.comports...
python
def check_serial_port(name): """returns valid COM Port.""" try: cdc = next(serial.tools.list_ports.grep(name)) return cdc[0] except StopIteration: msg = "device {} not found. ".format(name) msg += "available devices are: " ports = list(serial.tools.list_ports.comports...
[ "def", "check_serial_port", "(", "name", ")", ":", "try", ":", "cdc", "=", "next", "(", "serial", ".", "tools", ".", "list_ports", ".", "grep", "(", "name", ")", ")", "return", "cdc", "[", "0", "]", "except", "StopIteration", ":", "msg", "=", "\"devi...
returns valid COM Port.
[ "returns", "valid", "COM", "Port", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L182-L193
train
ktbyers/netmiko
netmiko/utilities.py
get_template_dir
def get_template_dir(): """Find and return the ntc-templates/templates dir.""" try: template_dir = os.path.expanduser(os.environ["NET_TEXTFSM"]) index = os.path.join(template_dir, "index") if not os.path.isfile(index): # Assume only base ./ntc-templates specified ...
python
def get_template_dir(): """Find and return the ntc-templates/templates dir.""" try: template_dir = os.path.expanduser(os.environ["NET_TEXTFSM"]) index = os.path.join(template_dir, "index") if not os.path.isfile(index): # Assume only base ./ntc-templates specified ...
[ "def", "get_template_dir", "(", ")", ":", "try", ":", "template_dir", "=", "os", ".", "path", ".", "expanduser", "(", "os", ".", "environ", "[", "\"NET_TEXTFSM\"", "]", ")", "index", "=", "os", ".", "path", ".", "join", "(", "template_dir", ",", "\"ind...
Find and return the ntc-templates/templates dir.
[ "Find", "and", "return", "the", "ntc", "-", "templates", "/", "templates", "dir", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L196-L216
train
ktbyers/netmiko
netmiko/utilities.py
clitable_to_dict
def clitable_to_dict(cli_table): """Converts TextFSM cli_table object to list of dictionaries.""" objs = [] for row in cli_table: temp_dict = {} for index, element in enumerate(row): temp_dict[cli_table.header[index].lower()] = element objs.append(temp_dict) return ob...
python
def clitable_to_dict(cli_table): """Converts TextFSM cli_table object to list of dictionaries.""" objs = [] for row in cli_table: temp_dict = {} for index, element in enumerate(row): temp_dict[cli_table.header[index].lower()] = element objs.append(temp_dict) return ob...
[ "def", "clitable_to_dict", "(", "cli_table", ")", ":", "objs", "=", "[", "]", "for", "row", "in", "cli_table", ":", "temp_dict", "=", "{", "}", "for", "index", ",", "element", "in", "enumerate", "(", "row", ")", ":", "temp_dict", "[", "cli_table", ".",...
Converts TextFSM cli_table object to list of dictionaries.
[ "Converts", "TextFSM", "cli_table", "object", "to", "list", "of", "dictionaries", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L219-L227
train
ktbyers/netmiko
netmiko/utilities.py
get_structured_data
def get_structured_data(raw_output, platform, command): """Convert raw CLI output to structured data using TextFSM template.""" template_dir = get_template_dir() index_file = os.path.join(template_dir, "index") textfsm_obj = clitable.CliTable(index_file, template_dir) attrs = {"Command": command, "P...
python
def get_structured_data(raw_output, platform, command): """Convert raw CLI output to structured data using TextFSM template.""" template_dir = get_template_dir() index_file = os.path.join(template_dir, "index") textfsm_obj = clitable.CliTable(index_file, template_dir) attrs = {"Command": command, "P...
[ "def", "get_structured_data", "(", "raw_output", ",", "platform", ",", "command", ")", ":", "template_dir", "=", "get_template_dir", "(", ")", "index_file", "=", "os", ".", "path", ".", "join", "(", "template_dir", ",", "\"index\"", ")", "textfsm_obj", "=", ...
Convert raw CLI output to structured data using TextFSM template.
[ "Convert", "raw", "CLI", "output", "to", "structured", "data", "using", "TextFSM", "template", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L230-L243
train
ktbyers/netmiko
netmiko/extreme/extreme_netiron.py
ExtremeNetironBase.save_config
def save_config(self, cmd="write memory", confirm=False, confirm_response=""): """Save Config""" return super(ExtremeNetironBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
python
def save_config(self, cmd="write memory", confirm=False, confirm_response=""): """Save Config""" return super(ExtremeNetironBase, self).save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"write memory\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "ExtremeNetironBase", ",", "self", ")", ".", "save_config", "(", "cmd", "=", "cmd"...
Save Config
[ "Save", "Config" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_netiron.py#L6-L10
train
cloudtools/troposphere
examples/ElastiCacheRedis.py
main
def main(): """ Create a ElastiCache Redis Node and EC2 Instance """ template = Template() # Description template.add_description( 'AWS CloudFormation Sample Template ElastiCache_Redis:' 'Sample template showing how to create an Amazon' 'ElastiCache Redis Cluster. **WAR...
python
def main(): """ Create a ElastiCache Redis Node and EC2 Instance """ template = Template() # Description template.add_description( 'AWS CloudFormation Sample Template ElastiCache_Redis:' 'Sample template showing how to create an Amazon' 'ElastiCache Redis Cluster. **WAR...
[ "def", "main", "(", ")", ":", "template", "=", "Template", "(", ")", "# Description", "template", ".", "add_description", "(", "'AWS CloudFormation Sample Template ElastiCache_Redis:'", "'Sample template showing how to create an Amazon'", "'ElastiCache Redis Cluster. **WARNING** Th...
Create a ElastiCache Redis Node and EC2 Instance
[ "Create", "a", "ElastiCache", "Redis", "Node", "and", "EC2", "Instance" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/examples/ElastiCacheRedis.py#L36-L523
train