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/snmp_autodetect.py | SNMPDetect._get_snmpv2c | def _get_snmpv2c(self, oid):
"""
Try to send an SNMP GET operation using SNMPv2 for the specified OID.
Parameters
----------
oid : str
The SNMP OID that you want to get.
Returns
-------
string : str
The string as part of the value... | python | def _get_snmpv2c(self, oid):
"""
Try to send an SNMP GET operation using SNMPv2 for the specified OID.
Parameters
----------
oid : str
The SNMP OID that you want to get.
Returns
-------
string : str
The string as part of the value... | [
"def",
"_get_snmpv2c",
"(",
"self",
",",
"oid",
")",
":",
"snmp_target",
"=",
"(",
"self",
".",
"hostname",
",",
"self",
".",
"snmp_port",
")",
"cmd_gen",
"=",
"cmdgen",
".",
"CommandGenerator",
"(",
")",
"(",
"error_detected",
",",
"error_status",
",",
... | Try to send an SNMP GET operation using SNMPv2 for the specified OID.
Parameters
----------
oid : str
The SNMP OID that you want to get.
Returns
-------
string : str
The string as part of the value from the OID you are trying to retrieve. | [
"Try",
"to",
"send",
"an",
"SNMP",
"GET",
"operation",
"using",
"SNMPv2",
"for",
"the",
"specified",
"OID",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/snmp_autodetect.py#L268-L295 | train |
ktbyers/netmiko | netmiko/snmp_autodetect.py | SNMPDetect._get_snmp | def _get_snmp(self, oid):
"""Wrapper for generic SNMP call."""
if self.snmp_version in ["v1", "v2c"]:
return self._get_snmpv2c(oid)
else:
return self._get_snmpv3(oid) | python | def _get_snmp(self, oid):
"""Wrapper for generic SNMP call."""
if self.snmp_version in ["v1", "v2c"]:
return self._get_snmpv2c(oid)
else:
return self._get_snmpv3(oid) | [
"def",
"_get_snmp",
"(",
"self",
",",
"oid",
")",
":",
"if",
"self",
".",
"snmp_version",
"in",
"[",
"\"v1\"",
",",
"\"v2c\"",
"]",
":",
"return",
"self",
".",
"_get_snmpv2c",
"(",
"oid",
")",
"else",
":",
"return",
"self",
".",
"_get_snmpv3",
"(",
"... | Wrapper for generic SNMP call. | [
"Wrapper",
"for",
"generic",
"SNMP",
"call",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/snmp_autodetect.py#L297-L302 | train |
ktbyers/netmiko | netmiko/snmp_autodetect.py | SNMPDetect.autodetect | def autodetect(self):
"""
Try to guess the device_type using SNMP GET based on the SNMP_MAPPER dict. The type which
is returned is directly matching the name in *netmiko.ssh_dispatcher.CLASS_MAPPER_BASE*
dict.
Thus you can use this name to retrieve automatically the right Connec... | python | def autodetect(self):
"""
Try to guess the device_type using SNMP GET based on the SNMP_MAPPER dict. The type which
is returned is directly matching the name in *netmiko.ssh_dispatcher.CLASS_MAPPER_BASE*
dict.
Thus you can use this name to retrieve automatically the right Connec... | [
"def",
"autodetect",
"(",
"self",
")",
":",
"# Convert SNMP_MAPPER to a list and sort by priority",
"snmp_mapper_list",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"SNMP_MAPPER",
".",
"items",
"(",
")",
":",
"snmp_mapper_list",
".",
"append",
"(",
"{",
"k",
":"... | Try to guess the device_type using SNMP GET based on the SNMP_MAPPER dict. The type which
is returned is directly matching the name in *netmiko.ssh_dispatcher.CLASS_MAPPER_BASE*
dict.
Thus you can use this name to retrieve automatically the right ConnectionClass
Returns
-------... | [
"Try",
"to",
"guess",
"the",
"device_type",
"using",
"SNMP",
"GET",
"based",
"on",
"the",
"SNMP_MAPPER",
"dict",
".",
"The",
"type",
"which",
"is",
"returned",
"is",
"directly",
"matching",
"the",
"name",
"in",
"*",
"netmiko",
".",
"ssh_dispatcher",
".",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/snmp_autodetect.py#L304-L342 | train |
ktbyers/netmiko | netmiko/flexvnf/flexvnf_ssh.py | FlexvnfSSH.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/flexvnf/flexvnf_ssh.py#L26-L44 | train |
ktbyers/netmiko | netmiko/flexvnf/flexvnf_ssh.py | FlexvnfSSH.exit_config_mode | def exit_config_mode(self, exit_config="exit configuration-mode"):
"""Exit configuration mode."""
output = ""
if self.check_config_mode():
output = self.send_command_timing(
exit_config, strip_prompt=False, strip_command=False
)
# if 'Exit with... | python | def exit_config_mode(self, exit_config="exit configuration-mode"):
"""Exit configuration mode."""
output = ""
if self.check_config_mode():
output = self.send_command_timing(
exit_config, strip_prompt=False, strip_command=False
)
# if 'Exit with... | [
"def",
"exit_config_mode",
"(",
"self",
",",
"exit_config",
"=",
"\"exit configuration-mode\"",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"check_config_mode",
"(",
")",
":",
"output",
"=",
"self",
".",
"send_command_timing",
"(",
"exit_config",
",",
... | Exit configuration mode. | [
"Exit",
"configuration",
"mode",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/flexvnf/flexvnf_ssh.py#L66-L80 | train |
ktbyers/netmiko | netmiko/flexvnf/flexvnf_ssh.py | FlexvnfSSH.commit | def commit(
self,
confirm=False,
confirm_delay=None,
check=False,
comment="",
and_quit=False,
delay_factor=1,
):
"""
Commit the candidate configuration.
Commit the entered configuration. Raise an error and return the failure
if... | python | def commit(
self,
confirm=False,
confirm_delay=None,
check=False,
comment="",
and_quit=False,
delay_factor=1,
):
"""
Commit the candidate configuration.
Commit the entered configuration. Raise an error and return the failure
if... | [
"def",
"commit",
"(",
"self",
",",
"confirm",
"=",
"False",
",",
"confirm_delay",
"=",
"None",
",",
"check",
"=",
"False",
",",
"comment",
"=",
"\"\"",
",",
"and_quit",
"=",
"False",
",",
"delay_factor",
"=",
"1",
",",
")",
":",
"delay_factor",
"=",
... | Commit the candidate configuration.
Commit the entered configuration. Raise an error and return the failure
if the commit fails.
Automatically enters configuration mode
default:
command_string = commit
check and (confirm or confirm_dely or comment):
Exc... | [
"Commit",
"the",
"candidate",
"configuration",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/flexvnf/flexvnf_ssh.py#L82-L171 | train |
ktbyers/netmiko | netmiko/flexvnf/flexvnf_ssh.py | FlexvnfSSH.strip_prompt | def strip_prompt(self, *args, **kwargs):
"""Strip the trailing router prompt from the output."""
a_string = super(FlexvnfSSH, 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(FlexvnfSSH, self).strip_prompt(*args, **kwargs)
return self.strip_context_items(a_string) | [
"def",
"strip_prompt",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"a_string",
"=",
"super",
"(",
"FlexvnfSSH",
",",
"self",
")",
".",
"strip_prompt",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"str... | 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/flexvnf/flexvnf_ssh.py#L173-L176 | train |
ktbyers/netmiko | netmiko/ruckus/ruckus_fastiron.py | RuckusFastironBase.enable | def enable(
self, cmd="enable", pattern=r"(ssword|User Name)", re_flags=re.IGNORECASE
):
"""Enter enable mode.
With RADIUS can prompt for User Name
SSH@Lab-ICX7250>en
User Name:service_netmiko
Password:
SSH@Lab-ICX7250#
"""
output = ""
... | python | def enable(
self, cmd="enable", pattern=r"(ssword|User Name)", re_flags=re.IGNORECASE
):
"""Enter enable mode.
With RADIUS can prompt for User Name
SSH@Lab-ICX7250>en
User Name:service_netmiko
Password:
SSH@Lab-ICX7250#
"""
output = ""
... | [
"def",
"enable",
"(",
"self",
",",
"cmd",
"=",
"\"enable\"",
",",
"pattern",
"=",
"r\"(ssword|User Name)\"",
",",
"re_flags",
"=",
"re",
".",
"IGNORECASE",
")",
":",
"output",
"=",
"\"\"",
"if",
"not",
"self",
".",
"check_enable_mode",
"(",
")",
":",
"co... | Enter enable mode.
With RADIUS can prompt for User Name
SSH@Lab-ICX7250>en
User Name:service_netmiko
Password:
SSH@Lab-ICX7250# | [
"Enter",
"enable",
"mode",
".",
"With",
"RADIUS",
"can",
"prompt",
"for",
"User",
"Name",
"SSH"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ruckus/ruckus_fastiron.py#L21-L59 | train |
ktbyers/netmiko | netmiko/ruckus/ruckus_fastiron.py | RuckusFastironBase.save_config | def save_config(self, cmd="write mem", confirm=False, confirm_response=""):
"""Saves configuration."""
return super(RuckusFastironBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | python | def save_config(self, cmd="write mem", confirm=False, confirm_response=""):
"""Saves configuration."""
return super(RuckusFastironBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"write mem\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"RuckusFastironBase",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"cmd",
... | Saves configuration. | [
"Saves",
"configuration",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ruckus/ruckus_fastiron.py#L61-L65 | train |
ktbyers/netmiko | netmiko/ruckus/ruckus_fastiron.py | RuckusFastironTelnet._process_option | def _process_option(self, tsocket, command, option):
"""
Ruckus FastIron/ICX does not always echo commands to output by default.
If server expresses interest in 'ECHO' option, then reply back with 'DO
ECHO'
"""
if option == ECHO:
tsocket.sendall(IAC + DO + ECH... | python | def _process_option(self, tsocket, command, option):
"""
Ruckus FastIron/ICX does not always echo commands to output by default.
If server expresses interest in 'ECHO' option, then reply back with 'DO
ECHO'
"""
if option == ECHO:
tsocket.sendall(IAC + DO + ECH... | [
"def",
"_process_option",
"(",
"self",
",",
"tsocket",
",",
"command",
",",
"option",
")",
":",
"if",
"option",
"==",
"ECHO",
":",
"tsocket",
".",
"sendall",
"(",
"IAC",
"+",
"DO",
"+",
"ECHO",
")",
"elif",
"command",
"in",
"(",
"DO",
",",
"DONT",
... | Ruckus FastIron/ICX does not always echo commands to output by default.
If server expresses interest in 'ECHO' option, then reply back with 'DO
ECHO' | [
"Ruckus",
"FastIron",
"/",
"ICX",
"does",
"not",
"always",
"echo",
"commands",
"to",
"output",
"by",
"default",
".",
"If",
"server",
"expresses",
"interest",
"in",
"ECHO",
"option",
"then",
"reply",
"back",
"with",
"DO",
"ECHO"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ruckus/ruckus_fastiron.py#L74-L85 | train |
ktbyers/netmiko | examples/use_cases/case16_concurrency/processes_netmiko_queue.py | show_version_queue | def show_version_queue(a_device, output_q):
"""
Use Netmiko to execute show version. Use a queue to pass the data back to
the main process.
"""
output_dict = {}
remote_conn = ConnectHandler(**a_device)
hostname = remote_conn.base_prompt
output = ("#" * 80) + "\n"
output += remote_con... | python | def show_version_queue(a_device, output_q):
"""
Use Netmiko to execute show version. Use a queue to pass the data back to
the main process.
"""
output_dict = {}
remote_conn = ConnectHandler(**a_device)
hostname = remote_conn.base_prompt
output = ("#" * 80) + "\n"
output += remote_con... | [
"def",
"show_version_queue",
"(",
"a_device",
",",
"output_q",
")",
":",
"output_dict",
"=",
"{",
"}",
"remote_conn",
"=",
"ConnectHandler",
"(",
"*",
"*",
"a_device",
")",
"hostname",
"=",
"remote_conn",
".",
"base_prompt",
"output",
"=",
"(",
"\"#\"",
"*",... | Use Netmiko to execute show version. Use a queue to pass the data back to
the main process. | [
"Use",
"Netmiko",
"to",
"execute",
"show",
"version",
".",
"Use",
"a",
"queue",
"to",
"pass",
"the",
"data",
"back",
"to",
"the",
"main",
"process",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/use_cases/case16_concurrency/processes_netmiko_queue.py#L15-L27 | train |
ktbyers/netmiko | examples/use_cases/case16_concurrency/processes_netmiko_queue.py | main | def main():
"""
Use processes and Netmiko to connect to each of the devices. Execute
'show version' on each device. Use a queue to pass the output back to the parent process.
Record the amount of time required to do this.
"""
start_time = datetime.now()
output_q = Queue(maxsize=20)
proc... | python | def main():
"""
Use processes and Netmiko to connect to each of the devices. Execute
'show version' on each device. Use a queue to pass the output back to the parent process.
Record the amount of time required to do this.
"""
start_time = datetime.now()
output_q = Queue(maxsize=20)
proc... | [
"def",
"main",
"(",
")",
":",
"start_time",
"=",
"datetime",
".",
"now",
"(",
")",
"output_q",
"=",
"Queue",
"(",
"maxsize",
"=",
"20",
")",
"procs",
"=",
"[",
"]",
"for",
"a_device",
"in",
"devices",
":",
"my_proc",
"=",
"Process",
"(",
"target",
... | Use processes and Netmiko to connect to each of the devices. Execute
'show version' on each device. Use a queue to pass the output back to the parent process.
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",
".",
"Use",
"a",
"queue",
"to",
"pass",
"the",
"output",
"back",
"to",
"the",
"parent",
"process",
"."... | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/use_cases/case16_concurrency/processes_netmiko_queue.py#L30-L55 | train |
ktbyers/netmiko | netmiko/cisco/cisco_asa_ssh.py | CiscoAsaSSH.session_preparation | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self._test_channel_read()
self.set_base_prompt()
if self.secret:
self.enable()
else:
self.asa_login()
self.disable_paging(command="terminal pager 0"... | python | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self._test_channel_read()
self.set_base_prompt()
if self.secret:
self.enable()
else:
self.asa_login()
self.disable_paging(command="terminal pager 0"... | [
"def",
"session_preparation",
"(",
"self",
")",
":",
"self",
".",
"_test_channel_read",
"(",
")",
"self",
".",
"set_base_prompt",
"(",
")",
"if",
"self",
".",
"secret",
":",
"self",
".",
"enable",
"(",
")",
"else",
":",
"self",
".",
"asa_login",
"(",
"... | 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_asa_ssh.py#L12-L30 | train |
ktbyers/netmiko | netmiko/cisco/cisco_asa_ssh.py | CiscoAsaSSH.send_command_timing | def send_command_timing(self, *args, **kwargs):
"""
If the ASA is in multi-context mode, then the base_prompt needs to be
updated after each context change.
"""
output = super(CiscoAsaSSH, self).send_command_timing(*args, **kwargs)
if len(args) >= 1:
command_s... | python | def send_command_timing(self, *args, **kwargs):
"""
If the ASA is in multi-context mode, then the base_prompt needs to be
updated after each context change.
"""
output = super(CiscoAsaSSH, self).send_command_timing(*args, **kwargs)
if len(args) >= 1:
command_s... | [
"def",
"send_command_timing",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"output",
"=",
"super",
"(",
"CiscoAsaSSH",
",",
"self",
")",
".",
"send_command_timing",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"len",
"("... | If the ASA is in multi-context mode, then the base_prompt needs to be
updated after each context change. | [
"If",
"the",
"ASA",
"is",
"in",
"multi",
"-",
"context",
"mode",
"then",
"the",
"base_prompt",
"needs",
"to",
"be",
"updated",
"after",
"each",
"context",
"change",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_asa_ssh.py#L32-L44 | train |
ktbyers/netmiko | netmiko/cisco/cisco_asa_ssh.py | CiscoAsaSSH.send_command | def send_command(self, *args, **kwargs):
"""
If the ASA is in multi-context mode, then the base_prompt needs to be
updated after each context change.
"""
if len(args) >= 1:
command_string = args[0]
else:
command_string = kwargs["command_string"]
... | python | def send_command(self, *args, **kwargs):
"""
If the ASA is in multi-context mode, then the base_prompt needs to be
updated after each context change.
"""
if len(args) >= 1:
command_string = args[0]
else:
command_string = kwargs["command_string"]
... | [
"def",
"send_command",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">=",
"1",
":",
"command_string",
"=",
"args",
"[",
"0",
"]",
"else",
":",
"command_string",
"=",
"kwargs",
"[",
"\"command_string... | If the ASA is in multi-context mode, then the base_prompt needs to be
updated after each context change. | [
"If",
"the",
"ASA",
"is",
"in",
"multi",
"-",
"context",
"mode",
"then",
"the",
"base_prompt",
"needs",
"to",
"be",
"updated",
"after",
"each",
"context",
"change",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_asa_ssh.py#L46-L66 | train |
ktbyers/netmiko | netmiko/cisco/cisco_asa_ssh.py | CiscoAsaSSH.set_base_prompt | def set_base_prompt(self, *args, **kwargs):
"""
Cisco ASA in multi-context mode needs to have the base prompt updated
(if you switch contexts i.e. 'changeto')
This switch of ASA contexts can occur in configuration mode. If this
happens the trailing '(config*' needs stripped off.... | python | def set_base_prompt(self, *args, **kwargs):
"""
Cisco ASA in multi-context mode needs to have the base prompt updated
(if you switch contexts i.e. 'changeto')
This switch of ASA contexts can occur in configuration mode. If this
happens the trailing '(config*' needs stripped off.... | [
"def",
"set_base_prompt",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cur_base_prompt",
"=",
"super",
"(",
"CiscoAsaSSH",
",",
"self",
")",
".",
"set_base_prompt",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"match",
"=",
"... | Cisco ASA in multi-context mode needs to have the base prompt updated
(if you switch contexts i.e. 'changeto')
This switch of ASA contexts can occur in configuration mode. If this
happens the trailing '(config*' needs stripped off. | [
"Cisco",
"ASA",
"in",
"multi",
"-",
"context",
"mode",
"needs",
"to",
"have",
"the",
"base",
"prompt",
"updated",
"(",
"if",
"you",
"switch",
"contexts",
"i",
".",
"e",
".",
"changeto",
")"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_asa_ssh.py#L72-L85 | train |
ktbyers/netmiko | netmiko/cisco/cisco_asa_ssh.py | CiscoAsaSSH.asa_login | def asa_login(self):
"""
Handle ASA reaching privilege level 15 using login
twb-dc-fw1> login
Username: admin
Password: ************
"""
delay_factor = self.select_delay_factor(0)
i = 1
max_attempts = 50
self.write_channel("login" + self.... | python | def asa_login(self):
"""
Handle ASA reaching privilege level 15 using login
twb-dc-fw1> login
Username: admin
Password: ************
"""
delay_factor = self.select_delay_factor(0)
i = 1
max_attempts = 50
self.write_channel("login" + self.... | [
"def",
"asa_login",
"(",
"self",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"0",
")",
"i",
"=",
"1",
"max_attempts",
"=",
"50",
"self",
".",
"write_channel",
"(",
"\"login\"",
"+",
"self",
".",
"RETURN",
")",
"while",
"i",
... | Handle ASA reaching privilege level 15 using login
twb-dc-fw1> login
Username: admin
Password: ************ | [
"Handle",
"ASA",
"reaching",
"privilege",
"level",
"15",
"using",
"login"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_asa_ssh.py#L87-L111 | train |
ktbyers/netmiko | netmiko/cisco/cisco_asa_ssh.py | CiscoAsaSSH.save_config | def save_config(self, cmd="write mem", confirm=False, confirm_response=""):
"""Saves Config"""
return super(CiscoAsaSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | python | def save_config(self, cmd="write mem", confirm=False, confirm_response=""):
"""Saves Config"""
return super(CiscoAsaSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"write mem\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"CiscoAsaSSH",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"cmd",
",",
... | Saves Config | [
"Saves",
"Config"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_asa_ssh.py#L113-L117 | train |
ktbyers/netmiko | netmiko/cisco/cisco_xr_ssh.py | CiscoXrSSH.send_config_set | def send_config_set(self, config_commands=None, exit_config_mode=True, **kwargs):
"""IOS-XR requires you not exit from configuration mode."""
return super(CiscoXrSSH, self).send_config_set(
config_commands=config_commands, exit_config_mode=False, **kwargs
) | python | def send_config_set(self, config_commands=None, exit_config_mode=True, **kwargs):
"""IOS-XR requires you not exit from configuration mode."""
return super(CiscoXrSSH, self).send_config_set(
config_commands=config_commands, exit_config_mode=False, **kwargs
) | [
"def",
"send_config_set",
"(",
"self",
",",
"config_commands",
"=",
"None",
",",
"exit_config_mode",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"CiscoXrSSH",
",",
"self",
")",
".",
"send_config_set",
"(",
"config_commands",
"=",
... | IOS-XR requires you not exit from configuration mode. | [
"IOS",
"-",
"XR",
"requires",
"you",
"not",
"exit",
"from",
"configuration",
"mode",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_xr_ssh.py#L20-L24 | train |
ktbyers/netmiko | netmiko/cisco/cisco_xr_ssh.py | CiscoXrSSH.commit | def commit(
self, confirm=False, confirm_delay=None, comment="", label="", delay_factor=1
):
"""
Commit the candidate configuration.
default (no options):
command_string = commit
confirm and confirm_delay:
command_string = commit confirmed <confirm_de... | python | def commit(
self, confirm=False, confirm_delay=None, comment="", label="", delay_factor=1
):
"""
Commit the candidate configuration.
default (no options):
command_string = commit
confirm and confirm_delay:
command_string = commit confirmed <confirm_de... | [
"def",
"commit",
"(",
"self",
",",
"confirm",
"=",
"False",
",",
"confirm_delay",
"=",
"None",
",",
"comment",
"=",
"\"\"",
",",
"label",
"=",
"\"\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
... | Commit the candidate configuration.
default (no options):
command_string = commit
confirm and confirm_delay:
command_string = commit confirmed <confirm_delay>
label (which is a label name):
command_string = commit label <label>
comment:
co... | [
"Commit",
"the",
"candidate",
"configuration",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_xr_ssh.py#L26-L118 | train |
ktbyers/netmiko | netmiko/cisco/cisco_xr_ssh.py | CiscoXrSSH.check_config_mode | def check_config_mode(self, check_string=")#", pattern=r"[#\$]"):
"""Checks if the device is in configuration mode or not.
IOS-XR, unfortunately, does this:
RP/0/RSP0/CPU0:BNG(admin)#
"""
self.write_channel(self.RETURN)
output = self.read_until_pattern(pattern=pattern)
... | python | def check_config_mode(self, check_string=")#", pattern=r"[#\$]"):
"""Checks if the device is in configuration mode or not.
IOS-XR, unfortunately, does this:
RP/0/RSP0/CPU0:BNG(admin)#
"""
self.write_channel(self.RETURN)
output = self.read_until_pattern(pattern=pattern)
... | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\")#\"",
",",
"pattern",
"=",
"r\"[#\\$]\"",
")",
":",
"self",
".",
"write_channel",
"(",
"self",
".",
"RETURN",
")",
"output",
"=",
"self",
".",
"read_until_pattern",
"(",
"pattern",
"=",
... | Checks if the device is in configuration mode or not.
IOS-XR, unfortunately, does this:
RP/0/RSP0/CPU0:BNG(admin)# | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_xr_ssh.py#L120-L131 | train |
ktbyers/netmiko | netmiko/cisco/cisco_xr_ssh.py | CiscoXrFileTransfer.process_md5 | def process_md5(self, md5_output, pattern=r"^([a-fA-F0-9]+)$"):
"""
IOS-XR defaults with timestamps enabled
# show md5 file /bootflash:/boot/grub/grub.cfg
Sat Mar 3 17:49:03.596 UTC
c84843f0030efd44b01343fdb8c2e801
"""
match = re.search(pattern, md5_output, flag... | python | def process_md5(self, md5_output, pattern=r"^([a-fA-F0-9]+)$"):
"""
IOS-XR defaults with timestamps enabled
# show md5 file /bootflash:/boot/grub/grub.cfg
Sat Mar 3 17:49:03.596 UTC
c84843f0030efd44b01343fdb8c2e801
"""
match = re.search(pattern, md5_output, flag... | [
"def",
"process_md5",
"(",
"self",
",",
"md5_output",
",",
"pattern",
"=",
"r\"^([a-fA-F0-9]+)$\"",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"pattern",
",",
"md5_output",
",",
"flags",
"=",
"re",
".",
"M",
")",
"if",
"match",
":",
"return",
"m... | IOS-XR defaults with timestamps enabled
# show md5 file /bootflash:/boot/grub/grub.cfg
Sat Mar 3 17:49:03.596 UTC
c84843f0030efd44b01343fdb8c2e801 | [
"IOS",
"-",
"XR",
"defaults",
"with",
"timestamps",
"enabled"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_xr_ssh.py#L156-L168 | train |
ktbyers/netmiko | netmiko/dell/dell_os10_ssh.py | DellOS10SSH.save_config | def save_config(
self,
cmd="copy running-configuration startup-configuration",
confirm=False,
confirm_response="",
):
"""Saves Config"""
return super(DellOS10SSH, 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(DellOS10SSH, 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",
"(",
"DellOS10SSH",
",",
"self",
")",
".",
"save_con... | Saves Config | [
"Saves",
"Config"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_os10_ssh.py#L12-L21 | train |
ktbyers/netmiko | netmiko/dell/dell_os10_ssh.py | DellOS10FileTransfer.remote_file_size | def remote_file_size(self, remote_cmd="", remote_file=None):
"""Get the file size of the remote file."""
if remote_file is None:
if self.direction == "put":
remote_file = self.dest_file
elif self.direction == "get":
remote_file = self.source_file
... | python | def remote_file_size(self, remote_cmd="", remote_file=None):
"""Get the file size of the remote file."""
if remote_file is None:
if self.direction == "put":
remote_file = self.dest_file
elif self.direction == "get":
remote_file = self.source_file
... | [
"def",
"remote_file_size",
"(",
"self",
",",
"remote_cmd",
"=",
"\"\"",
",",
"remote_file",
"=",
"None",
")",
":",
"if",
"remote_file",
"is",
"None",
":",
"if",
"self",
".",
"direction",
"==",
"\"put\"",
":",
"remote_file",
"=",
"self",
".",
"dest_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/dell/dell_os10_ssh.py#L41-L57 | train |
ktbyers/netmiko | netmiko/dell/dell_os10_ssh.py | DellOS10FileTransfer.remote_space_available | def remote_space_available(self, search_pattern=r"(\d+) bytes free"):
"""Return space available on remote device."""
remote_cmd = 'system "df {}"'.format(self.folder_name)
remote_output = self.ssh_ctl_chan.send_command_expect(remote_cmd)
for line in remote_output.splitlines():
... | python | def remote_space_available(self, search_pattern=r"(\d+) bytes free"):
"""Return space available on remote device."""
remote_cmd = 'system "df {}"'.format(self.folder_name)
remote_output = self.ssh_ctl_chan.send_command_expect(remote_cmd)
for line in remote_output.splitlines():
... | [
"def",
"remote_space_available",
"(",
"self",
",",
"search_pattern",
"=",
"r\"(\\d+) bytes free\"",
")",
":",
"remote_cmd",
"=",
"'system \"df {}\"'",
".",
"format",
"(",
"self",
".",
"folder_name",
")",
"remote_output",
"=",
"self",
".",
"ssh_ctl_chan",
".",
"sen... | Return space available on remote device. | [
"Return",
"space",
"available",
"on",
"remote",
"device",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_os10_ssh.py#L59-L67 | train |
ktbyers/netmiko | netmiko/dell/dell_os10_ssh.py | DellOS10FileTransfer.check_file_exists | def check_file_exists(self, remote_cmd="dir home"):
"""Check if the dest_file already exists on the file system (return boolean)."""
if self.direction == "put":
remote_out = self.ssh_ctl_chan.send_command_expect(remote_cmd)
search_string = r"Directory contents .*{}".format(self.d... | python | def check_file_exists(self, remote_cmd="dir home"):
"""Check if the dest_file already exists on the file system (return boolean)."""
if self.direction == "put":
remote_out = self.ssh_ctl_chan.send_command_expect(remote_cmd)
search_string = r"Directory contents .*{}".format(self.d... | [
"def",
"check_file_exists",
"(",
"self",
",",
"remote_cmd",
"=",
"\"dir home\"",
")",
":",
"if",
"self",
".",
"direction",
"==",
"\"put\"",
":",
"remote_out",
"=",
"self",
".",
"ssh_ctl_chan",
".",
"send_command_expect",
"(",
"remote_cmd",
")",
"search_string",
... | 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/dell/dell_os10_ssh.py#L87-L94 | train |
ktbyers/netmiko | netmiko/dell/dell_os10_ssh.py | DellOS10FileTransfer.get_file | def get_file(self):
"""SCP copy the file from the remote device to local system."""
source_file = "{}".format(self.source_file)
self.scp_conn.scp_get_file(source_file, self.dest_file)
self.scp_conn.close() | python | def get_file(self):
"""SCP copy the file from the remote device to local system."""
source_file = "{}".format(self.source_file)
self.scp_conn.scp_get_file(source_file, self.dest_file)
self.scp_conn.close() | [
"def",
"get_file",
"(",
"self",
")",
":",
"source_file",
"=",
"\"{}\"",
".",
"format",
"(",
"self",
".",
"source_file",
")",
"self",
".",
"scp_conn",
".",
"scp_get_file",
"(",
"source_file",
",",
"self",
".",
"dest_file",
")",
"self",
".",
"scp_conn",
".... | SCP copy the file from the remote device to local system. | [
"SCP",
"copy",
"the",
"file",
"from",
"the",
"remote",
"device",
"to",
"local",
"system",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_os10_ssh.py#L103-L107 | train |
ktbyers/netmiko | netmiko/oneaccess/oneaccess_oneos.py | OneaccessOneOSBase.save_config | def save_config(self, cmd="write mem", confirm=False, confirm_response=""):
"""Save config: write mem"""
return super(OneaccessOneOSBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | python | def save_config(self, cmd="write mem", confirm=False, confirm_response=""):
"""Save config: write mem"""
return super(OneaccessOneOSBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"write mem\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"OneaccessOneOSBase",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"cmd",
... | Save config: write mem | [
"Save",
"config",
":",
"write",
"mem"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/oneaccess/oneaccess_oneos.py#L27-L31 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | IndexTable._ParseIndex | def _ParseIndex(self, preread, precompile):
"""Reads index file and stores entries in TextTable.
For optimisation reasons, a second table is created with compiled entries.
Args:
preread: func, Pre-processing, applied to each field as it is read.
precompile: func, Pre-compilation, applied to ... | python | def _ParseIndex(self, preread, precompile):
"""Reads index file and stores entries in TextTable.
For optimisation reasons, a second table is created with compiled entries.
Args:
preread: func, Pre-processing, applied to each field as it is read.
precompile: func, Pre-compilation, applied to ... | [
"def",
"_ParseIndex",
"(",
"self",
",",
"preread",
",",
"precompile",
")",
":",
"self",
".",
"index",
"=",
"texttable",
".",
"TextTable",
"(",
")",
"self",
".",
"index",
".",
"CsvToTable",
"(",
"self",
".",
"_index_handle",
")",
"if",
"preread",
":",
"... | Reads index file and stores entries in TextTable.
For optimisation reasons, a second table is created with compiled entries.
Args:
preread: func, Pre-processing, applied to each field as it is read.
precompile: func, Pre-compilation, applied to each field before compiling.
Raises:
IndexTab... | [
"Reads",
"index",
"file",
"and",
"stores",
"entries",
"in",
"TextTable",
".",
"For",
"optimisation",
"reasons",
"a",
"second",
"table",
"is",
"created",
"with",
"compiled",
"entries",
".",
"Args",
":",
"preread",
":",
"func",
"Pre",
"-",
"processing",
"appli... | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L107-L131 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | IndexTable.GetRowMatch | def GetRowMatch(self, attributes):
"""Returns the row number that matches the supplied attributes."""
for row in self.compiled:
try:
for key in attributes:
# Silently skip attributes not present in the index file.
# pylint: disable=E110... | python | def GetRowMatch(self, attributes):
"""Returns the row number that matches the supplied attributes."""
for row in self.compiled:
try:
for key in attributes:
# Silently skip attributes not present in the index file.
# pylint: disable=E110... | [
"def",
"GetRowMatch",
"(",
"self",
",",
"attributes",
")",
":",
"for",
"row",
"in",
"self",
".",
"compiled",
":",
"try",
":",
"for",
"key",
"in",
"attributes",
":",
"# Silently skip attributes not present in the index file.",
"# pylint: disable=E1103",
"if",
"(",
... | Returns the row number that matches the supplied attributes. | [
"Returns",
"the",
"row",
"number",
"that",
"matches",
"the",
"supplied",
"attributes",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L133-L150 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable.synchronised | def synchronised(func):
"""Synchronisation decorator."""
# pylint: disable=E0213
def Wrapper(main_obj, *args, **kwargs):
main_obj._lock.acquire() # pylint: disable=W0212
try:
return func(main_obj, *args, **kwargs) # pylint: disable=E1102
fin... | python | def synchronised(func):
"""Synchronisation decorator."""
# pylint: disable=E0213
def Wrapper(main_obj, *args, **kwargs):
main_obj._lock.acquire() # pylint: disable=W0212
try:
return func(main_obj, *args, **kwargs) # pylint: disable=E1102
fin... | [
"def",
"synchronised",
"(",
"func",
")",
":",
"# pylint: disable=E0213",
"def",
"Wrapper",
"(",
"main_obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"main_obj",
".",
"_lock",
".",
"acquire",
"(",
")",
"# pylint: disable=W0212",
"try",
":",
"ret... | Synchronisation decorator. | [
"Synchronisation",
"decorator",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L172-L183 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable.ReadIndex | def ReadIndex(self, index_file=None):
"""Reads the IndexTable index file of commands and templates.
Args:
index_file: String, file where template/command mappings reside.
Raises:
CliTableError: A template column was not found in the table.
"""
self.index_file = index_file or sel... | python | def ReadIndex(self, index_file=None):
"""Reads the IndexTable index file of commands and templates.
Args:
index_file: String, file where template/command mappings reside.
Raises:
CliTableError: A template column was not found in the table.
"""
self.index_file = index_file or sel... | [
"def",
"ReadIndex",
"(",
"self",
",",
"index_file",
"=",
"None",
")",
":",
"self",
".",
"index_file",
"=",
"index_file",
"or",
"self",
".",
"index_file",
"fullpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"template_dir",
",",
"self",
".... | Reads the IndexTable index file of commands and templates.
Args:
index_file: String, file where template/command mappings reside.
Raises:
CliTableError: A template column was not found in the table. | [
"Reads",
"the",
"IndexTable",
"index",
"file",
"of",
"commands",
"and",
"templates",
".",
"Args",
":",
"index_file",
":",
"String",
"file",
"where",
"template",
"/",
"command",
"mappings",
"reside",
".",
"Raises",
":",
"CliTableError",
":",
"A",
"template",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L202-L220 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable._TemplateNamesToFiles | def _TemplateNamesToFiles(self, template_str):
"""Parses a string of templates into a list of file handles."""
template_list = template_str.split(":")
template_files = []
try:
for tmplt in template_list:
template_files.append(open(os.path.join(self.template_di... | python | def _TemplateNamesToFiles(self, template_str):
"""Parses a string of templates into a list of file handles."""
template_list = template_str.split(":")
template_files = []
try:
for tmplt in template_list:
template_files.append(open(os.path.join(self.template_di... | [
"def",
"_TemplateNamesToFiles",
"(",
"self",
",",
"template_str",
")",
":",
"template_list",
"=",
"template_str",
".",
"split",
"(",
"\":\"",
")",
"template_files",
"=",
"[",
"]",
"try",
":",
"for",
"tmplt",
"in",
"template_list",
":",
"template_files",
".",
... | Parses a string of templates into a list of file handles. | [
"Parses",
"a",
"string",
"of",
"templates",
"into",
"a",
"list",
"of",
"file",
"handles",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L222-L234 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable.ParseCmd | def ParseCmd(self, cmd_input, attributes=None, templates=None):
"""Creates a TextTable table of values from cmd_input string.
Parses command output with template/s. If more than one template is found
subsequent tables are merged if keys match (dropped otherwise).
Args:
cmd_input: String, Devic... | python | def ParseCmd(self, cmd_input, attributes=None, templates=None):
"""Creates a TextTable table of values from cmd_input string.
Parses command output with template/s. If more than one template is found
subsequent tables are merged if keys match (dropped otherwise).
Args:
cmd_input: String, Devic... | [
"def",
"ParseCmd",
"(",
"self",
",",
"cmd_input",
",",
"attributes",
"=",
"None",
",",
"templates",
"=",
"None",
")",
":",
"# Store raw command data within the object.",
"self",
".",
"raw",
"=",
"cmd_input",
"if",
"not",
"templates",
":",
"# Find template in templ... | Creates a TextTable table of values from cmd_input string.
Parses command output with template/s. If more than one template is found
subsequent tables are merged if keys match (dropped otherwise).
Args:
cmd_input: String, Device/command response.
attributes: Dict, attribute that further refine m... | [
"Creates",
"a",
"TextTable",
"table",
"of",
"values",
"from",
"cmd_input",
"string",
".",
"Parses",
"command",
"output",
"with",
"template",
"/",
"s",
".",
"If",
"more",
"than",
"one",
"template",
"is",
"found",
"subsequent",
"tables",
"are",
"merged",
"if",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L236-L275 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable._PreParse | def _PreParse(self, key, value):
"""Executed against each field of each row read from index table."""
if key == "Command":
return re.sub(r"(\[\[.+?\]\])", self._Completion, value)
else:
return value | python | def _PreParse(self, key, value):
"""Executed against each field of each row read from index table."""
if key == "Command":
return re.sub(r"(\[\[.+?\]\])", self._Completion, value)
else:
return value | [
"def",
"_PreParse",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"==",
"\"Command\"",
":",
"return",
"re",
".",
"sub",
"(",
"r\"(\\[\\[.+?\\]\\])\"",
",",
"self",
".",
"_Completion",
",",
"value",
")",
"else",
":",
"return",
"value"
] | Executed against each field of each row read from index table. | [
"Executed",
"against",
"each",
"field",
"of",
"each",
"row",
"read",
"from",
"index",
"table",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L301-L306 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable.LabelValueTable | def LabelValueTable(self, keys=None):
"""Return LabelValue with FSM derived keys."""
keys = keys or self.superkey
# pylint: disable=E1002
return super(CliTable, self).LabelValueTable(keys) | python | def LabelValueTable(self, keys=None):
"""Return LabelValue with FSM derived keys."""
keys = keys or self.superkey
# pylint: disable=E1002
return super(CliTable, self).LabelValueTable(keys) | [
"def",
"LabelValueTable",
"(",
"self",
",",
"keys",
"=",
"None",
")",
":",
"keys",
"=",
"keys",
"or",
"self",
".",
"superkey",
"# pylint: disable=E1002",
"return",
"super",
"(",
"CliTable",
",",
"self",
")",
".",
"LabelValueTable",
"(",
"keys",
")"
] | Return LabelValue with FSM derived keys. | [
"Return",
"LabelValue",
"with",
"FSM",
"derived",
"keys",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L329-L333 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable.sort | def sort(self, cmp=None, key=None, reverse=False):
"""Overrides sort func to use the KeyValue for the key."""
if not key and self._keys:
key = self.KeyValue
super(CliTable, self).sort(cmp=cmp, key=key, reverse=reverse) | python | def sort(self, cmp=None, key=None, reverse=False):
"""Overrides sort func to use the KeyValue for the key."""
if not key and self._keys:
key = self.KeyValue
super(CliTable, self).sort(cmp=cmp, key=key, reverse=reverse) | [
"def",
"sort",
"(",
"self",
",",
"cmp",
"=",
"None",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"not",
"key",
"and",
"self",
".",
"_keys",
":",
"key",
"=",
"self",
".",
"KeyValue",
"super",
"(",
"CliTable",
",",
"self"... | Overrides sort func to use the KeyValue for the key. | [
"Overrides",
"sort",
"func",
"to",
"use",
"the",
"KeyValue",
"for",
"the",
"key",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L336-L340 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable.AddKeys | def AddKeys(self, key_list):
"""Mark additional columns as being part of the superkey.
Supplements the Keys already extracted from the FSM template.
Useful when adding new columns to existing tables.
Note: This will impact attempts to further 'extend' the table as the
superkey must be common bet... | python | def AddKeys(self, key_list):
"""Mark additional columns as being part of the superkey.
Supplements the Keys already extracted from the FSM template.
Useful when adding new columns to existing tables.
Note: This will impact attempts to further 'extend' the table as the
superkey must be common bet... | [
"def",
"AddKeys",
"(",
"self",
",",
"key_list",
")",
":",
"for",
"keyname",
"in",
"key_list",
":",
"if",
"keyname",
"not",
"in",
"self",
".",
"header",
":",
"raise",
"KeyError",
"(",
"\"'%s'\"",
"%",
"keyname",
")",
"self",
".",
"_keys",
"=",
"self",
... | Mark additional columns as being part of the superkey.
Supplements the Keys already extracted from the FSM template.
Useful when adding new columns to existing tables.
Note: This will impact attempts to further 'extend' the table as the
superkey must be common between tables for successful extension.
... | [
"Mark",
"additional",
"columns",
"as",
"being",
"part",
"of",
"the",
"superkey",
".",
"Supplements",
"the",
"Keys",
"already",
"extracted",
"from",
"the",
"FSM",
"template",
".",
"Useful",
"when",
"adding",
"new",
"columns",
"to",
"existing",
"tables",
".",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L344-L360 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable.superkey | def superkey(self):
"""Returns a set of column names that together constitute the superkey."""
sorted_list = []
for header in self.header:
if header in self._keys:
sorted_list.append(header)
return sorted_list | python | def superkey(self):
"""Returns a set of column names that together constitute the superkey."""
sorted_list = []
for header in self.header:
if header in self._keys:
sorted_list.append(header)
return sorted_list | [
"def",
"superkey",
"(",
"self",
")",
":",
"sorted_list",
"=",
"[",
"]",
"for",
"header",
"in",
"self",
".",
"header",
":",
"if",
"header",
"in",
"self",
".",
"_keys",
":",
"sorted_list",
".",
"append",
"(",
"header",
")",
"return",
"sorted_list"
] | Returns a set of column names that together constitute the superkey. | [
"Returns",
"a",
"set",
"of",
"column",
"names",
"that",
"together",
"constitute",
"the",
"superkey",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L363-L369 | train |
ktbyers/netmiko | netmiko/_textfsm/_clitable.py | CliTable.KeyValue | def KeyValue(self, row=None):
"""Returns the super key value for the row."""
if not row:
if self._iterator:
# If we are inside an iterator use current row iteration.
row = self[self._iterator]
else:
row = self.row
# If no su... | python | def KeyValue(self, row=None):
"""Returns the super key value for the row."""
if not row:
if self._iterator:
# If we are inside an iterator use current row iteration.
row = self[self._iterator]
else:
row = self.row
# If no su... | [
"def",
"KeyValue",
"(",
"self",
",",
"row",
"=",
"None",
")",
":",
"if",
"not",
"row",
":",
"if",
"self",
".",
"_iterator",
":",
"# If we are inside an iterator use current row iteration.",
"row",
"=",
"self",
"[",
"self",
".",
"_iterator",
"]",
"else",
":",... | Returns the super key value for the row. | [
"Returns",
"the",
"super",
"key",
"value",
"for",
"the",
"row",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L371-L387 | train |
ktbyers/netmiko | netmiko/dell/dell_isilon_ssh.py | DellIsilonSSH.set_base_prompt | def set_base_prompt(
self, pri_prompt_terminator="$", alt_prompt_terminator="#", delay_factor=1
):
"""Determine base prompt."""
return super(DellIsilonSSH, 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(DellIsilonSSH, 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",
"(",
"DellIsilonSSH",
",",
"self",
")",
".",
"set_base_prompt",
"(",
"pri... | Determine base prompt. | [
"Determine",
"base",
"prompt",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_isilon_ssh.py#L10-L18 | train |
ktbyers/netmiko | netmiko/dell/dell_isilon_ssh.py | DellIsilonSSH.strip_ansi_escape_codes | def strip_ansi_escape_codes(self, string_buffer):
"""Remove Null code"""
output = re.sub(r"\x00", "", string_buffer)
return super(DellIsilonSSH, self).strip_ansi_escape_codes(output) | python | def strip_ansi_escape_codes(self, string_buffer):
"""Remove Null code"""
output = re.sub(r"\x00", "", string_buffer)
return super(DellIsilonSSH, self).strip_ansi_escape_codes(output) | [
"def",
"strip_ansi_escape_codes",
"(",
"self",
",",
"string_buffer",
")",
":",
"output",
"=",
"re",
".",
"sub",
"(",
"r\"\\x00\"",
",",
"\"\"",
",",
"string_buffer",
")",
"return",
"super",
"(",
"DellIsilonSSH",
",",
"self",
")",
".",
"strip_ansi_escape_codes"... | Remove Null code | [
"Remove",
"Null",
"code"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_isilon_ssh.py#L20-L23 | train |
ktbyers/netmiko | netmiko/dell/dell_isilon_ssh.py | DellIsilonSSH.session_preparation | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self.ansi_escape_codes = True
self.zsh_mode()
self.find_prompt(delay_factor=1)
self.set_base_prompt()
# Clear the read buffer
time.sleep(0.3 * self.global_delay_fac... | python | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self.ansi_escape_codes = True
self.zsh_mode()
self.find_prompt(delay_factor=1)
self.set_base_prompt()
# Clear the read buffer
time.sleep(0.3 * self.global_delay_fac... | [
"def",
"session_preparation",
"(",
"self",
")",
":",
"self",
".",
"ansi_escape_codes",
"=",
"True",
"self",
".",
"zsh_mode",
"(",
")",
"self",
".",
"find_prompt",
"(",
"delay_factor",
"=",
"1",
")",
"self",
".",
"set_base_prompt",
"(",
")",
"# Clear the read... | 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/dell/dell_isilon_ssh.py#L25-L33 | train |
ktbyers/netmiko | netmiko/dell/dell_isilon_ssh.py | DellIsilonSSH.zsh_mode | def zsh_mode(self, delay_factor=1, prompt_terminator="$"):
"""Run zsh command to unify the environment"""
delay_factor = self.select_delay_factor(delay_factor)
self.clear_buffer()
command = self.RETURN + "zsh" + self.RETURN
self.write_channel(command)
time.sleep(1 * delay... | python | def zsh_mode(self, delay_factor=1, prompt_terminator="$"):
"""Run zsh command to unify the environment"""
delay_factor = self.select_delay_factor(delay_factor)
self.clear_buffer()
command = self.RETURN + "zsh" + self.RETURN
self.write_channel(command)
time.sleep(1 * delay... | [
"def",
"zsh_mode",
"(",
"self",
",",
"delay_factor",
"=",
"1",
",",
"prompt_terminator",
"=",
"\"$\"",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"self",
".",
"clear_buffer",
"(",
")",
"command",
"=",
"self",... | Run zsh command to unify the environment | [
"Run",
"zsh",
"command",
"to",
"unify",
"the",
"environment"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_isilon_ssh.py#L35-L43 | train |
ktbyers/netmiko | netmiko/dell/dell_isilon_ssh.py | DellIsilonSSH.config_mode | def config_mode(self, config_command="sudo su"):
"""Attempt to become root."""
delay_factor = self.select_delay_factor(delay_factor=1)
output = ""
if not self.check_config_mode():
output += self.send_command_timing(
config_command, strip_prompt=False, strip_co... | python | def config_mode(self, config_command="sudo su"):
"""Attempt to become root."""
delay_factor = self.select_delay_factor(delay_factor=1)
output = ""
if not self.check_config_mode():
output += self.send_command_timing(
config_command, strip_prompt=False, strip_co... | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"sudo su\"",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
"=",
"1",
")",
"output",
"=",
"\"\"",
"if",
"not",
"self",
".",
"check_config_mode",
"(",
")... | Attempt to become root. | [
"Attempt",
"to",
"become",
"root",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_isilon_ssh.py#L69-L84 | train |
ktbyers/netmiko | netmiko/quanta/quanta_mesh_ssh.py | QuantaMeshSSH.disable_paging | def disable_paging(self, command="no pager", delay_factor=1):
"""Disable paging"""
return super(QuantaMeshSSH, self).disable_paging(command=command) | python | def disable_paging(self, command="no pager", delay_factor=1):
"""Disable paging"""
return super(QuantaMeshSSH, self).disable_paging(command=command) | [
"def",
"disable_paging",
"(",
"self",
",",
"command",
"=",
"\"no pager\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"return",
"super",
"(",
"QuantaMeshSSH",
",",
"self",
")",
".",
"disable_paging",
"(",
"command",
"=",
"command",
")"
] | Disable paging | [
"Disable",
"paging"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/quanta/quanta_mesh_ssh.py#L6-L8 | train |
ktbyers/netmiko | netmiko/quanta/quanta_mesh_ssh.py | QuantaMeshSSH.save_config | def save_config(
self,
cmd="copy running-config startup-config",
confirm=False,
confirm_response="",
):
"""Saves Config"""
return super(QuantaMeshSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | python | def save_config(
self,
cmd="copy running-config startup-config",
confirm=False,
confirm_response="",
):
"""Saves Config"""
return super(QuantaMeshSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"copy running-config startup-config\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
",",
")",
":",
"return",
"super",
"(",
"QuantaMeshSSH",
",",
"self",
")",
".",
"save_config",
"(",... | Saves Config | [
"Saves",
"Config"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/quanta/quanta_mesh_ssh.py#L14-L23 | train |
ktbyers/netmiko | netmiko/ssh_autodetect.py | SSHDetect.autodetect | def autodetect(self):
"""
Try to guess the best 'device_type' based on patterns defined in SSH_MAPPER_BASE
Returns
-------
best_match : str or None
The device type that is currently the best to use to interact with the device
"""
for device_type, auto... | python | def autodetect(self):
"""
Try to guess the best 'device_type' based on patterns defined in SSH_MAPPER_BASE
Returns
-------
best_match : str or None
The device type that is currently the best to use to interact with the device
"""
for device_type, auto... | [
"def",
"autodetect",
"(",
"self",
")",
":",
"for",
"device_type",
",",
"autodetect_dict",
"in",
"SSH_MAPPER_BASE",
".",
"items",
"(",
")",
":",
"tmp_dict",
"=",
"autodetect_dict",
".",
"copy",
"(",
")",
"call_method",
"=",
"tmp_dict",
".",
"pop",
"(",
"\"d... | Try to guess the best 'device_type' based on patterns defined in SSH_MAPPER_BASE
Returns
-------
best_match : str or None
The device type that is currently the best to use to interact with the device | [
"Try",
"to",
"guess",
"the",
"best",
"device_type",
"based",
"on",
"patterns",
"defined",
"in",
"SSH_MAPPER_BASE"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_autodetect.py#L215-L246 | train |
ktbyers/netmiko | netmiko/ssh_autodetect.py | SSHDetect._send_command | def _send_command(self, cmd=""):
"""
Handle reading/writing channel directly. It is also sanitizing the output received.
Parameters
----------
cmd : str, optional
The command to send to the remote device (default : "", just send a new line)
Returns
-... | python | def _send_command(self, cmd=""):
"""
Handle reading/writing channel directly. It is also sanitizing the output received.
Parameters
----------
cmd : str, optional
The command to send to the remote device (default : "", just send a new line)
Returns
-... | [
"def",
"_send_command",
"(",
"self",
",",
"cmd",
"=",
"\"\"",
")",
":",
"self",
".",
"connection",
".",
"write_channel",
"(",
"cmd",
"+",
"\"\\n\"",
")",
"time",
".",
"sleep",
"(",
"1",
")",
"output",
"=",
"self",
".",
"connection",
".",
"_read_channel... | Handle reading/writing channel directly. It is also sanitizing the output received.
Parameters
----------
cmd : str, optional
The command to send to the remote device (default : "", just send a new line)
Returns
-------
output : str
The output fr... | [
"Handle",
"reading",
"/",
"writing",
"channel",
"directly",
".",
"It",
"is",
"also",
"sanitizing",
"the",
"output",
"received",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_autodetect.py#L248-L267 | train |
ktbyers/netmiko | netmiko/ssh_autodetect.py | SSHDetect._send_command_wrapper | def _send_command_wrapper(self, cmd):
"""
Send command to the remote device with a caching feature to avoid sending the same command
twice based on the SSH_MAPPER_BASE dict cmd key.
Parameters
----------
cmd : str
The command to send to the remote device afte... | python | def _send_command_wrapper(self, cmd):
"""
Send command to the remote device with a caching feature to avoid sending the same command
twice based on the SSH_MAPPER_BASE dict cmd key.
Parameters
----------
cmd : str
The command to send to the remote device afte... | [
"def",
"_send_command_wrapper",
"(",
"self",
",",
"cmd",
")",
":",
"cached_results",
"=",
"self",
".",
"_results_cache",
".",
"get",
"(",
"cmd",
")",
"if",
"not",
"cached_results",
":",
"response",
"=",
"self",
".",
"_send_command",
"(",
"cmd",
")",
"self"... | Send command to the remote device with a caching feature to avoid sending the same command
twice based on the SSH_MAPPER_BASE dict cmd key.
Parameters
----------
cmd : str
The command to send to the remote device after checking cache.
Returns
-------
... | [
"Send",
"command",
"to",
"the",
"remote",
"device",
"with",
"a",
"caching",
"feature",
"to",
"avoid",
"sending",
"the",
"same",
"command",
"twice",
"based",
"on",
"the",
"SSH_MAPPER_BASE",
"dict",
"cmd",
"key",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_autodetect.py#L269-L290 | train |
ktbyers/netmiko | netmiko/ssh_autodetect.py | SSHDetect._autodetect_std | def _autodetect_std(self, cmd="", search_patterns=None, re_flags=re.I, priority=99):
"""
Standard method to try to auto-detect the device type. This method will be called for each
device_type present in SSH_MAPPER_BASE dict ('dispatch' key). It will attempt to send a
command and match so... | python | def _autodetect_std(self, cmd="", search_patterns=None, re_flags=re.I, priority=99):
"""
Standard method to try to auto-detect the device type. This method will be called for each
device_type present in SSH_MAPPER_BASE dict ('dispatch' key). It will attempt to send a
command and match so... | [
"def",
"_autodetect_std",
"(",
"self",
",",
"cmd",
"=",
"\"\"",
",",
"search_patterns",
"=",
"None",
",",
"re_flags",
"=",
"re",
".",
"I",
",",
"priority",
"=",
"99",
")",
":",
"invalid_responses",
"=",
"[",
"r\"% Invalid input detected\"",
",",
"r\"syntax e... | Standard method to try to auto-detect the device type. This method will be called for each
device_type present in SSH_MAPPER_BASE dict ('dispatch' key). It will attempt to send a
command and match some regular expression from the ouput for each entry in SSH_MAPPER_BASE
('cmd' and 'search_pattern... | [
"Standard",
"method",
"to",
"try",
"to",
"auto",
"-",
"detect",
"the",
"device",
"type",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"each",
"device_type",
"present",
"in",
"SSH_MAPPER_BASE",
"dict",
"(",
"dispatch",
"key",
")",
".",
"It",
"will"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_autodetect.py#L292-L334 | train |
ktbyers/netmiko | netmiko/alcatel/alcatel_aos_ssh.py | AlcatelAosSSH.save_config | def save_config(
self, cmd="write memory flash-synchro", confirm=False, confirm_response=""
):
"""Save Config"""
return super(AlcatelAosSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | python | def save_config(
self, cmd="write memory flash-synchro", confirm=False, confirm_response=""
):
"""Save Config"""
return super(AlcatelAosSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"write memory flash-synchro\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"AlcatelAosSSH",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"="... | Save Config | [
"Save",
"Config"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_aos_ssh.py#L43-L49 | train |
ktbyers/netmiko | netmiko/ssh_dispatcher.py | ConnectHandler | def ConnectHandler(*args, **kwargs):
"""Factory function selects the proper class and creates object based on device_type."""
if kwargs["device_type"] not in platforms:
raise ValueError(
"Unsupported device_type: "
"currently supported platforms are: {}".format(platforms_str)
... | python | def ConnectHandler(*args, **kwargs):
"""Factory function selects the proper class and creates object based on device_type."""
if kwargs["device_type"] not in platforms:
raise ValueError(
"Unsupported device_type: "
"currently supported platforms are: {}".format(platforms_str)
... | [
"def",
"ConnectHandler",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"[",
"\"device_type\"",
"]",
"not",
"in",
"platforms",
":",
"raise",
"ValueError",
"(",
"\"Unsupported device_type: \"",
"\"currently supported platforms are: {}\"",
".",
... | Factory function selects the proper class and creates object based on device_type. | [
"Factory",
"function",
"selects",
"the",
"proper",
"class",
"and",
"creates",
"object",
"based",
"on",
"device_type",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_dispatcher.py#L223-L231 | train |
ktbyers/netmiko | netmiko/ssh_dispatcher.py | redispatch | def redispatch(obj, device_type, session_prep=True):
"""Dynamically change Netmiko object's class to proper class.
Generally used with terminal_server device_type when you need to redispatch after interacting
with terminal server.
"""
new_class = ssh_dispatcher(device_type)
obj.device_type = de... | python | def redispatch(obj, device_type, session_prep=True):
"""Dynamically change Netmiko object's class to proper class.
Generally used with terminal_server device_type when you need to redispatch after interacting
with terminal server.
"""
new_class = ssh_dispatcher(device_type)
obj.device_type = de... | [
"def",
"redispatch",
"(",
"obj",
",",
"device_type",
",",
"session_prep",
"=",
"True",
")",
":",
"new_class",
"=",
"ssh_dispatcher",
"(",
"device_type",
")",
"obj",
".",
"device_type",
"=",
"device_type",
"obj",
".",
"__class__",
"=",
"new_class",
"if",
"ses... | Dynamically change Netmiko object's class to proper class.
Generally used with terminal_server device_type when you need to redispatch after interacting
with terminal server. | [
"Dynamically",
"change",
"Netmiko",
"object",
"s",
"class",
"to",
"proper",
"class",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_dispatcher.py#L239-L249 | train |
ktbyers/netmiko | netmiko/ssh_dispatcher.py | FileTransfer | def FileTransfer(*args, **kwargs):
"""Factory function selects the proper SCP class and creates object based on device_type."""
if len(args) >= 1:
device_type = args[0].device_type
else:
device_type = kwargs["ssh_conn"].device_type
if device_type not in scp_platforms:
raise Value... | python | def FileTransfer(*args, **kwargs):
"""Factory function selects the proper SCP class and creates object based on device_type."""
if len(args) >= 1:
device_type = args[0].device_type
else:
device_type = kwargs["ssh_conn"].device_type
if device_type not in scp_platforms:
raise Value... | [
"def",
"FileTransfer",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">=",
"1",
":",
"device_type",
"=",
"args",
"[",
"0",
"]",
".",
"device_type",
"else",
":",
"device_type",
"=",
"kwargs",
"[",
"\"ssh_conn\"",
... | Factory function selects the proper SCP class and creates object based on device_type. | [
"Factory",
"function",
"selects",
"the",
"proper",
"SCP",
"class",
"and",
"creates",
"object",
"based",
"on",
"device_type",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_dispatcher.py#L252-L264 | train |
ktbyers/netmiko | setup.py | find_version | def find_version(*file_paths):
"""
This pattern was modeled on a method from the Python Packaging User Guide:
https://packaging.python.org/en/latest/single_source_version.html
We read instead of importing so we don't get import errors if our code
imports from dependencies listed in install_requ... | python | def find_version(*file_paths):
"""
This pattern was modeled on a method from the Python Packaging User Guide:
https://packaging.python.org/en/latest/single_source_version.html
We read instead of importing so we don't get import errors if our code
imports from dependencies listed in install_requ... | [
"def",
"find_version",
"(",
"*",
"file_paths",
")",
":",
"base_module_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"*",
"file_paths",
")",
"with",
"open",
"(",
"base_module_file",
")",
"as",
"f",
":",
"base_module_data",
"=",
"f",
".",
"read",
"(",
... | This pattern was modeled on a method from the Python Packaging User Guide:
https://packaging.python.org/en/latest/single_source_version.html
We read instead of importing so we don't get import errors if our code
imports from dependencies listed in install_requires. | [
"This",
"pattern",
"was",
"modeled",
"on",
"a",
"method",
"from",
"the",
"Python",
"Packaging",
"User",
"Guide",
":",
"https",
":",
"//",
"packaging",
".",
"python",
".",
"org",
"/",
"en",
"/",
"latest",
"/",
"single_source_version",
".",
"html"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/setup.py#L11-L27 | train |
ktbyers/netmiko | netmiko/calix/calix_b6.py | CalixB6Base.session_preparation | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self.ansi_escape_codes = True
self._test_channel_read()
self.set_base_prompt()
self.disable_paging()
self.set_terminal_width(command="terminal width 511")
# Clear t... | python | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self.ansi_escape_codes = True
self._test_channel_read()
self.set_base_prompt()
self.disable_paging()
self.set_terminal_width(command="terminal width 511")
# Clear t... | [
"def",
"session_preparation",
"(",
"self",
")",
":",
"self",
".",
"ansi_escape_codes",
"=",
"True",
"self",
".",
"_test_channel_read",
"(",
")",
"self",
".",
"set_base_prompt",
"(",
")",
"self",
".",
"disable_paging",
"(",
")",
"self",
".",
"set_terminal_width... | 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/calix/calix_b6.py#L28-L37 | train |
ktbyers/netmiko | netmiko/calix/calix_b6.py | CalixB6Base.check_config_mode | def check_config_mode(self, check_string=")#", pattern=""):
"""Checks if the device is in configuration mode"""
return super(CalixB6Base, self).check_config_mode(check_string=check_string) | python | def check_config_mode(self, check_string=")#", pattern=""):
"""Checks if the device is in configuration mode"""
return super(CalixB6Base, self).check_config_mode(check_string=check_string) | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\")#\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"CalixB6Base",
",",
"self",
")",
".",
"check_config_mode",
"(",
"check_string",
"=",
"check_string",
")"
] | Checks if the device is in configuration mode | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/calix/calix_b6.py#L64-L66 | train |
ktbyers/netmiko | netmiko/mellanox/mellanox_ssh.py | MellanoxSSH.disable_paging | def disable_paging(self, command="terminal length 999", delay_factor=1):
"""Disable paging default to a Cisco CLI method."""
delay_factor = self.select_delay_factor(delay_factor)
time.sleep(delay_factor * 0.1)
self.clear_buffer()
command = self.normalize_cmd(command)
log.... | python | def disable_paging(self, command="terminal length 999", delay_factor=1):
"""Disable paging default to a Cisco CLI method."""
delay_factor = self.select_delay_factor(delay_factor)
time.sleep(delay_factor * 0.1)
self.clear_buffer()
command = self.normalize_cmd(command)
log.... | [
"def",
"disable_paging",
"(",
"self",
",",
"command",
"=",
"\"terminal length 999\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"time",
".",
"sleep",
"(",
"delay_factor",
"*",
"0... | Disable paging default to a Cisco CLI method. | [
"Disable",
"paging",
"default",
"to",
"a",
"Cisco",
"CLI",
"method",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/mellanox/mellanox_ssh.py#L23-L37 | train |
ktbyers/netmiko | netmiko/mellanox/mellanox_ssh.py | MellanoxSSH.save_config | def save_config(
self, cmd="configuration write", confirm=False, confirm_response=""
):
"""Save Config on Mellanox devices Enters and Leaves Config Mode"""
output = self.enable()
output += self.config_mode()
output += self.send_command(cmd)
output += self.exit_config_... | python | def save_config(
self, cmd="configuration write", confirm=False, confirm_response=""
):
"""Save Config on Mellanox devices Enters and Leaves Config Mode"""
output = self.enable()
output += self.config_mode()
output += self.send_command(cmd)
output += self.exit_config_... | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"configuration write\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"output",
"=",
"self",
".",
"enable",
"(",
")",
"output",
"+=",
"self",
".",
"config_mode",
"(",
... | Save Config on Mellanox devices Enters and Leaves Config Mode | [
"Save",
"Config",
"on",
"Mellanox",
"devices",
"Enters",
"and",
"Leaves",
"Config",
"Mode"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/mellanox/mellanox_ssh.py#L50-L58 | train |
ktbyers/netmiko | netmiko/rad/rad_etx.py | RadETXBase.config_mode | def config_mode(self, config_command="config", pattern=">config"):
"""Enter into configuration mode on remote device."""
return super(RadETXBase, self).config_mode(
config_command=config_command, pattern=pattern
) | python | def config_mode(self, config_command="config", pattern=">config"):
"""Enter into configuration mode on remote device."""
return super(RadETXBase, self).config_mode(
config_command=config_command, pattern=pattern
) | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"config\"",
",",
"pattern",
"=",
"\">config\"",
")",
":",
"return",
"super",
"(",
"RadETXBase",
",",
"self",
")",
".",
"config_mode",
"(",
"config_command",
"=",
"config_command",
",",
"pattern",... | Enter into configuration mode on remote device. | [
"Enter",
"into",
"configuration",
"mode",
"on",
"remote",
"device",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/rad/rad_etx.py#L44-L48 | train |
ktbyers/netmiko | netmiko/rad/rad_etx.py | RadETXBase.check_config_mode | def check_config_mode(self, check_string=">config", pattern=""):
"""
Checks if the device is in configuration mode or not.
Rad config starts with baseprompt>config.
"""
return super(RadETXBase, 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.
Rad config starts with baseprompt>config.
"""
return super(RadETXBase, self).check_config_mode(
check_string=check_string, pattern=pattern
... | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\">config\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"RadETXBase",
",",
"self",
")",
".",
"check_config_mode",
"(",
"check_string",
"=",
"check_string",
",",
"pattern",... | Checks if the device is in configuration mode or not.
Rad config starts with baseprompt>config. | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/rad/rad_etx.py#L50-L58 | train |
ktbyers/netmiko | netmiko/rad/rad_etx.py | RadETXBase.exit_config_mode | def exit_config_mode(self, exit_config="exit all", pattern="#"):
"""Exit from configuration mode."""
return super(RadETXBase, 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(RadETXBase, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) | [
"def",
"exit_config_mode",
"(",
"self",
",",
"exit_config",
"=",
"\"exit all\"",
",",
"pattern",
"=",
"\"#\"",
")",
":",
"return",
"super",
"(",
"RadETXBase",
",",
"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/rad/rad_etx.py#L60-L64 | train |
ktbyers/netmiko | netmiko/rad/rad_etx.py | RadETXTelnet.telnet_login | def telnet_login(
self, username_pattern=r"(?:user>)", alt_prompt_term=r"#\s*$", **kwargs
):
"""
RAD presents with the following on login
user>
password> ****
"""
self.TELNET_RETURN = self.RETURN
return super(RadETXTelnet, self).telnet_login(
... | python | def telnet_login(
self, username_pattern=r"(?:user>)", alt_prompt_term=r"#\s*$", **kwargs
):
"""
RAD presents with the following on login
user>
password> ****
"""
self.TELNET_RETURN = self.RETURN
return super(RadETXTelnet, self).telnet_login(
... | [
"def",
"telnet_login",
"(",
"self",
",",
"username_pattern",
"=",
"r\"(?:user>)\"",
",",
"alt_prompt_term",
"=",
"r\"#\\s*$\"",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"TELNET_RETURN",
"=",
"self",
".",
"RETURN",
"return",
"super",
"(",
"RadETXTelnet",... | RAD presents with the following on login
user>
password> **** | [
"RAD",
"presents",
"with",
"the",
"following",
"on",
"login"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/rad/rad_etx.py#L79-L94 | train |
ktbyers/netmiko | netmiko/vyos/vyos_ssh.py | VyOSSSH.config_mode | def config_mode(self, config_command="configure", pattern=r"[edit]"):
"""Enter configuration mode."""
return super(VyOSSSH, self).config_mode(
config_command=config_command, pattern=pattern
) | python | def config_mode(self, config_command="configure", pattern=r"[edit]"):
"""Enter configuration mode."""
return super(VyOSSSH, self).config_mode(
config_command=config_command, pattern=pattern
) | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"configure\"",
",",
"pattern",
"=",
"r\"[edit]\"",
")",
":",
"return",
"super",
"(",
"VyOSSSH",
",",
"self",
")",
".",
"config_mode",
"(",
"config_command",
"=",
"config_command",
",",
"pattern",... | Enter configuration mode. | [
"Enter",
"configuration",
"mode",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/vyos/vyos_ssh.py#L35-L39 | train |
ktbyers/netmiko | netmiko/vyos/vyos_ssh.py | VyOSSSH.commit | def commit(self, comment="", delay_factor=0.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 c... | python | def commit(self, comment="", delay_factor=0.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 c... | [
"def",
"commit",
"(",
"self",
",",
"comment",
"=",
"\"\"",
",",
"delay_factor",
"=",
"0.1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"error_marker",
"=",
"[",
"\"Failed to generate committed config\"",
",",
"\"... | 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/vyos/vyos_ssh.py#L56-L88 | train |
ktbyers/netmiko | netmiko/vyos/vyos_ssh.py | VyOSSSH.send_config_set | def send_config_set(
self,
config_commands=None,
exit_config_mode=False,
delay_factor=1,
max_loops=150,
strip_prompt=False,
strip_command=False,
config_mode_command=None,
):
"""Remain in configuration mode."""
return super(VyOSSSH, self... | python | def send_config_set(
self,
config_commands=None,
exit_config_mode=False,
delay_factor=1,
max_loops=150,
strip_prompt=False,
strip_command=False,
config_mode_command=None,
):
"""Remain in configuration mode."""
return super(VyOSSSH, self... | [
"def",
"send_config_set",
"(",
"self",
",",
"config_commands",
"=",
"None",
",",
"exit_config_mode",
"=",
"False",
",",
"delay_factor",
"=",
"1",
",",
"max_loops",
"=",
"150",
",",
"strip_prompt",
"=",
"False",
",",
"strip_command",
"=",
"False",
",",
"confi... | Remain in configuration mode. | [
"Remain",
"in",
"configuration",
"mode",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/vyos/vyos_ssh.py#L103-L122 | train |
ktbyers/netmiko | netmiko/cisco_base_connection.py | CiscoBaseConnection.check_config_mode | def check_config_mode(self, check_string=")#", pattern=""):
"""
Checks if the device is in configuration mode or not.
Cisco IOS devices abbreviate the prompt at 20 chars in config mode
"""
return super(CiscoBaseConnection, self).check_config_mode(
check_string=check_... | python | def check_config_mode(self, check_string=")#", pattern=""):
"""
Checks if the device is in configuration mode or not.
Cisco IOS devices abbreviate the prompt at 20 chars in config mode
"""
return super(CiscoBaseConnection, self).check_config_mode(
check_string=check_... | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\")#\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"CiscoBaseConnection",
",",
"self",
")",
".",
"check_config_mode",
"(",
"check_string",
"=",
"check_string",
",",
"patte... | Checks if the device is in configuration mode or not.
Cisco IOS devices abbreviate the prompt at 20 chars in config mode | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco_base_connection.py#L31-L39 | train |
ktbyers/netmiko | netmiko/cisco_base_connection.py | CiscoBaseConnection.config_mode | def config_mode(self, config_command="config term", pattern=""):
"""
Enter into configuration mode on remote device.
Cisco IOS devices abbreviate the prompt at 20 chars in config mode
"""
if not pattern:
pattern = re.escape(self.base_prompt[:16])
return super... | python | def config_mode(self, config_command="config term", pattern=""):
"""
Enter into configuration mode on remote device.
Cisco IOS devices abbreviate the prompt at 20 chars in config mode
"""
if not pattern:
pattern = re.escape(self.base_prompt[:16])
return super... | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"config term\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"if",
"not",
"pattern",
":",
"pattern",
"=",
"re",
".",
"escape",
"(",
"self",
".",
"base_prompt",
"[",
":",
"16",
"]",
")",
"retur... | Enter into configuration mode on remote device.
Cisco IOS devices abbreviate the prompt at 20 chars in config mode | [
"Enter",
"into",
"configuration",
"mode",
"on",
"remote",
"device",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco_base_connection.py#L41-L51 | train |
ktbyers/netmiko | netmiko/cisco_base_connection.py | CiscoBaseConnection.exit_config_mode | def exit_config_mode(self, exit_config="end", pattern="#"):
"""Exit from configuration mode."""
return super(CiscoBaseConnection, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) | python | def exit_config_mode(self, exit_config="end", pattern="#"):
"""Exit from configuration mode."""
return super(CiscoBaseConnection, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) | [
"def",
"exit_config_mode",
"(",
"self",
",",
"exit_config",
"=",
"\"end\"",
",",
"pattern",
"=",
"\"#\"",
")",
":",
"return",
"super",
"(",
"CiscoBaseConnection",
",",
"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/cisco_base_connection.py#L53-L57 | train |
ktbyers/netmiko | netmiko/cisco_base_connection.py | CiscoBaseConnection._autodetect_fs | def _autodetect_fs(self, cmd="dir", pattern=r"Directory of (.*)/"):
"""Autodetect the file system on the remote device. Used by SCP operations."""
if not self.check_enable_mode():
raise ValueError("Must be in enable mode to auto-detect the file-system.")
output = self.send_command_ex... | python | def _autodetect_fs(self, cmd="dir", pattern=r"Directory of (.*)/"):
"""Autodetect the file system on the remote device. Used by SCP operations."""
if not self.check_enable_mode():
raise ValueError("Must be in enable mode to auto-detect the file-system.")
output = self.send_command_ex... | [
"def",
"_autodetect_fs",
"(",
"self",
",",
"cmd",
"=",
"\"dir\"",
",",
"pattern",
"=",
"r\"Directory of (.*)/\"",
")",
":",
"if",
"not",
"self",
".",
"check_enable_mode",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"Must be in enable mode to auto-detect the file-sy... | Autodetect the file system on the remote device. Used by SCP operations. | [
"Autodetect",
"the",
"file",
"system",
"on",
"the",
"remote",
"device",
".",
"Used",
"by",
"SCP",
"operations",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco_base_connection.py#L183-L205 | train |
ktbyers/netmiko | netmiko/mrv/mrv_ssh.py | MrvOptiswitchSSH.enable | def enable(self, cmd="enable", pattern=r"#", re_flags=re.IGNORECASE):
"""Enable mode on MRV uses no password."""
output = ""
if not self.check_enable_mode():
self.write_channel(self.normalize_cmd(cmd))
output += self.read_until_prompt_or_pattern(
pattern=p... | python | def enable(self, cmd="enable", pattern=r"#", re_flags=re.IGNORECASE):
"""Enable mode on MRV uses no password."""
output = ""
if not self.check_enable_mode():
self.write_channel(self.normalize_cmd(cmd))
output += self.read_until_prompt_or_pattern(
pattern=p... | [
"def",
"enable",
"(",
"self",
",",
"cmd",
"=",
"\"enable\"",
",",
"pattern",
"=",
"r\"#\"",
",",
"re_flags",
"=",
"re",
".",
"IGNORECASE",
")",
":",
"output",
"=",
"\"\"",
"if",
"not",
"self",
".",
"check_enable_mode",
"(",
")",
":",
"self",
".",
"wr... | Enable mode on MRV uses no password. | [
"Enable",
"mode",
"on",
"MRV",
"uses",
"no",
"password",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/mrv/mrv_ssh.py#L23-L37 | train |
ktbyers/netmiko | netmiko/mrv/mrv_ssh.py | MrvOptiswitchSSH.save_config | def save_config(self, cmd="save config flash", confirm=False, confirm_response=""):
"""Saves configuration."""
return super(MrvOptiswitchSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | python | def save_config(self, cmd="save config flash", confirm=False, confirm_response=""):
"""Saves configuration."""
return super(MrvOptiswitchSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"save config flash\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"MrvOptiswitchSSH",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"c... | Saves configuration. | [
"Saves",
"configuration",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/mrv/mrv_ssh.py#L39-L43 | train |
ktbyers/netmiko | netmiko/netapp/netapp_cdot_ssh.py | NetAppcDotSSH.session_preparation | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self.set_base_prompt()
cmd = self.RETURN + "rows 0" + self.RETURN
self.disable_paging(command=cmd) | python | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self.set_base_prompt()
cmd = self.RETURN + "rows 0" + self.RETURN
self.disable_paging(command=cmd) | [
"def",
"session_preparation",
"(",
"self",
")",
":",
"self",
".",
"set_base_prompt",
"(",
")",
"cmd",
"=",
"self",
".",
"RETURN",
"+",
"\"rows 0\"",
"+",
"self",
".",
"RETURN",
"self",
".",
"disable_paging",
"(",
"command",
"=",
"cmd",
")"
] | 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/netapp/netapp_cdot_ssh.py#L7-L11 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._timeout_exceeded | def _timeout_exceeded(self, start, msg="Timeout exceeded!"):
"""Raise NetMikoTimeoutException if waiting too much in the serving queue.
:param start: Initial start time to see if session lock timeout has been exceeded
:type start: float (from time.time() call i.e. epoch time)
:param ms... | python | def _timeout_exceeded(self, start, msg="Timeout exceeded!"):
"""Raise NetMikoTimeoutException if waiting too much in the serving queue.
:param start: Initial start time to see if session lock timeout has been exceeded
:type start: float (from time.time() call i.e. epoch time)
:param ms... | [
"def",
"_timeout_exceeded",
"(",
"self",
",",
"start",
",",
"msg",
"=",
"\"Timeout exceeded!\"",
")",
":",
"if",
"not",
"start",
":",
"# Must provide a comparison time",
"return",
"False",
"if",
"time",
".",
"time",
"(",
")",
"-",
"start",
">",
"self",
".",
... | Raise NetMikoTimeoutException if waiting too much in the serving queue.
:param start: Initial start time to see if session lock timeout has been exceeded
:type start: float (from time.time() call i.e. epoch time)
:param msg: Exception message if timeout was exceeded
:type msg: str | [
"Raise",
"NetMikoTimeoutException",
"if",
"waiting",
"too",
"much",
"in",
"the",
"serving",
"queue",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L327-L342 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._lock_netmiko_session | def _lock_netmiko_session(self, start=None):
"""Try to acquire the Netmiko session lock. If not available, wait in the queue until
the channel is available again.
:param start: Initial start time to measure the session timeout
:type start: float (from time.time() call i.e. epoch time)
... | python | def _lock_netmiko_session(self, start=None):
"""Try to acquire the Netmiko session lock. If not available, wait in the queue until
the channel is available again.
:param start: Initial start time to measure the session timeout
:type start: float (from time.time() call i.e. epoch time)
... | [
"def",
"_lock_netmiko_session",
"(",
"self",
",",
"start",
"=",
"None",
")",
":",
"if",
"not",
"start",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"# Wait here until the SSH channel lock is acquired or until session_timeout exceeded",
"while",
"not",
"self",
... | Try to acquire the Netmiko session lock. If not available, wait in the queue until
the channel is available again.
:param start: Initial start time to measure the session timeout
:type start: float (from time.time() call i.e. epoch time) | [
"Try",
"to",
"acquire",
"the",
"Netmiko",
"session",
"lock",
".",
"If",
"not",
"available",
"wait",
"in",
"the",
"queue",
"until",
"the",
"channel",
"is",
"available",
"again",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L344-L358 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._write_channel | def _write_channel(self, out_data):
"""Generic handler that will write to both SSH and telnet channel.
:param out_data: data to be written to the channel
:type out_data: str (can be either unicode/byte string)
"""
if self.protocol == "ssh":
self.remote_conn.sendall(w... | python | def _write_channel(self, out_data):
"""Generic handler that will write to both SSH and telnet channel.
:param out_data: data to be written to the channel
:type out_data: str (can be either unicode/byte string)
"""
if self.protocol == "ssh":
self.remote_conn.sendall(w... | [
"def",
"_write_channel",
"(",
"self",
",",
"out_data",
")",
":",
"if",
"self",
".",
"protocol",
"==",
"\"ssh\"",
":",
"self",
".",
"remote_conn",
".",
"sendall",
"(",
"write_bytes",
"(",
"out_data",
",",
"encoding",
"=",
"self",
".",
"encoding",
")",
")"... | Generic handler that will write to both SSH and telnet channel.
:param out_data: data to be written to the channel
:type out_data: str (can be either unicode/byte string) | [
"Generic",
"handler",
"that",
"will",
"write",
"to",
"both",
"SSH",
"and",
"telnet",
"channel",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L367-L392 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.write_channel | def write_channel(self, out_data):
"""Generic handler that will write to both SSH and telnet channel.
:param out_data: data to be written to the channel
:type out_data: str (can be either unicode/byte string)
"""
self._lock_netmiko_session()
try:
self._write_... | python | def write_channel(self, out_data):
"""Generic handler that will write to both SSH and telnet channel.
:param out_data: data to be written to the channel
:type out_data: str (can be either unicode/byte string)
"""
self._lock_netmiko_session()
try:
self._write_... | [
"def",
"write_channel",
"(",
"self",
",",
"out_data",
")",
":",
"self",
".",
"_lock_netmiko_session",
"(",
")",
"try",
":",
"self",
".",
"_write_channel",
"(",
"out_data",
")",
"finally",
":",
"# Always unlock the SSH channel, even on exception.",
"self",
".",
"_u... | Generic handler that will write to both SSH and telnet channel.
:param out_data: data to be written to the channel
:type out_data: str (can be either unicode/byte string) | [
"Generic",
"handler",
"that",
"will",
"write",
"to",
"both",
"SSH",
"and",
"telnet",
"channel",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L399-L410 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.is_alive | def is_alive(self):
"""Returns a boolean flag with the state of the connection."""
null = chr(0)
if self.remote_conn is None:
log.error("Connection is not initialised, is_alive returns False")
return False
if self.protocol == "telnet":
try:
... | python | def is_alive(self):
"""Returns a boolean flag with the state of the connection."""
null = chr(0)
if self.remote_conn is None:
log.error("Connection is not initialised, is_alive returns False")
return False
if self.protocol == "telnet":
try:
... | [
"def",
"is_alive",
"(",
"self",
")",
":",
"null",
"=",
"chr",
"(",
"0",
")",
"if",
"self",
".",
"remote_conn",
"is",
"None",
":",
"log",
".",
"error",
"(",
"\"Connection is not initialised, is_alive returns False\"",
")",
"return",
"False",
"if",
"self",
"."... | Returns a boolean flag with the state of the connection. | [
"Returns",
"a",
"boolean",
"flag",
"with",
"the",
"state",
"of",
"the",
"connection",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L412-L441 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._read_channel | def _read_channel(self):
"""Generic handler that will read all the data from an SSH or telnet channel."""
if self.protocol == "ssh":
output = ""
while True:
if self.remote_conn.recv_ready():
outbuf = self.remote_conn.recv(MAX_BUFFER)
... | python | def _read_channel(self):
"""Generic handler that will read all the data from an SSH or telnet channel."""
if self.protocol == "ssh":
output = ""
while True:
if self.remote_conn.recv_ready():
outbuf = self.remote_conn.recv(MAX_BUFFER)
... | [
"def",
"_read_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"protocol",
"==",
"\"ssh\"",
":",
"output",
"=",
"\"\"",
"while",
"True",
":",
"if",
"self",
".",
"remote_conn",
".",
"recv_ready",
"(",
")",
":",
"outbuf",
"=",
"self",
".",
"remote_con... | Generic handler that will read all the data from an SSH or telnet channel. | [
"Generic",
"handler",
"that",
"will",
"read",
"all",
"the",
"data",
"from",
"an",
"SSH",
"or",
"telnet",
"channel",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L443-L465 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.read_channel | def read_channel(self):
"""Generic handler that will read all the data from an SSH or telnet channel."""
output = ""
self._lock_netmiko_session()
try:
output = self._read_channel()
finally:
# Always unlock the SSH channel, even on exception.
se... | python | def read_channel(self):
"""Generic handler that will read all the data from an SSH or telnet channel."""
output = ""
self._lock_netmiko_session()
try:
output = self._read_channel()
finally:
# Always unlock the SSH channel, even on exception.
se... | [
"def",
"read_channel",
"(",
"self",
")",
":",
"output",
"=",
"\"\"",
"self",
".",
"_lock_netmiko_session",
"(",
")",
"try",
":",
"output",
"=",
"self",
".",
"_read_channel",
"(",
")",
"finally",
":",
"# Always unlock the SSH channel, even on exception.",
"self",
... | Generic handler that will read all the data from an SSH or telnet channel. | [
"Generic",
"handler",
"that",
"will",
"read",
"all",
"the",
"data",
"from",
"an",
"SSH",
"or",
"telnet",
"channel",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L467-L476 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._read_channel_expect | def _read_channel_expect(self, pattern="", re_flags=0, max_loops=150):
"""Function that reads channel until pattern is detected.
pattern takes a regular expression.
By default pattern will be self.base_prompt
Note: this currently reads beyond pattern. In the case of SSH it reads MAX_B... | python | def _read_channel_expect(self, pattern="", re_flags=0, max_loops=150):
"""Function that reads channel until pattern is detected.
pattern takes a regular expression.
By default pattern will be self.base_prompt
Note: this currently reads beyond pattern. In the case of SSH it reads MAX_B... | [
"def",
"_read_channel_expect",
"(",
"self",
",",
"pattern",
"=",
"\"\"",
",",
"re_flags",
"=",
"0",
",",
"max_loops",
"=",
"150",
")",
":",
"output",
"=",
"\"\"",
"if",
"not",
"pattern",
":",
"pattern",
"=",
"re",
".",
"escape",
"(",
"self",
".",
"ba... | Function that reads channel until pattern is detected.
pattern takes a regular expression.
By default pattern will be self.base_prompt
Note: this currently reads beyond pattern. In the case of SSH it reads MAX_BUFFER.
In the case of telnet it reads all non-blocking data.
Ther... | [
"Function",
"that",
"reads",
"channel",
"until",
"pattern",
"is",
"detected",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L478-L541 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._read_channel_timing | def _read_channel_timing(self, delay_factor=1, max_loops=150):
"""Read data on the channel based on timing delays.
Attempt to read channel max_loops number of times. If no data this will cause a 15 second
delay.
Once data is encountered read channel for another two seconds (2 * delay_f... | python | def _read_channel_timing(self, delay_factor=1, max_loops=150):
"""Read data on the channel based on timing delays.
Attempt to read channel max_loops number of times. If no data this will cause a 15 second
delay.
Once data is encountered read channel for another two seconds (2 * delay_f... | [
"def",
"_read_channel_timing",
"(",
"self",
",",
"delay_factor",
"=",
"1",
",",
"max_loops",
"=",
"150",
")",
":",
"# Time to delay in each read loop",
"loop_delay",
"=",
"0.1",
"final_delay",
"=",
"2",
"# Default to making loop time be roughly equivalent to self.timeout (s... | Read data on the channel based on timing delays.
Attempt to read channel max_loops number of times. If no data this will cause a 15 second
delay.
Once data is encountered read channel for another two seconds (2 * delay_factor) to make
sure reading of channel is complete.
:para... | [
"Read",
"data",
"on",
"the",
"channel",
"based",
"on",
"timing",
"delays",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L543-L586 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.read_until_prompt_or_pattern | def read_until_prompt_or_pattern(self, pattern="", re_flags=0):
"""Read until either self.base_prompt or pattern is detected.
:param pattern: the pattern used to identify that the output is complete (i.e. stop \
reading when pattern is detected). pattern will be combined with self.base_prompt t... | python | def read_until_prompt_or_pattern(self, pattern="", re_flags=0):
"""Read until either self.base_prompt or pattern is detected.
:param pattern: the pattern used to identify that the output is complete (i.e. stop \
reading when pattern is detected). pattern will be combined with self.base_prompt t... | [
"def",
"read_until_prompt_or_pattern",
"(",
"self",
",",
"pattern",
"=",
"\"\"",
",",
"re_flags",
"=",
"0",
")",
":",
"combined_pattern",
"=",
"re",
".",
"escape",
"(",
"self",
".",
"base_prompt",
")",
"if",
"pattern",
":",
"combined_pattern",
"=",
"r\"({}|{... | Read until either self.base_prompt or pattern is detected.
:param pattern: the pattern used to identify that the output is complete (i.e. stop \
reading when pattern is detected). pattern will be combined with self.base_prompt to \
terminate output reading when the first of self.base_prompt or ... | [
"Read",
"until",
"either",
"self",
".",
"base_prompt",
"or",
"pattern",
"is",
"detected",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L596-L612 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.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. Can be username/password or just p... | 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. Can be username/password or just p... | [
"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. Can be username/password or just password.
:param pri_prompt_terminator: Primary trailing delimiter for identifying a device prompt
:type pri_prompt_terminator: str
:param alt_prompt_terminator: Alternate trailing delimiter for identifying a device prompt
:type alt_prompt... | [
"Telnet",
"login",
".",
"Can",
"be",
"username",
"/",
"password",
"or",
"just",
"password",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L632-L713 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._use_ssh_config | def _use_ssh_config(self, dict_arg):
"""Update SSH connection parameters based on contents of SSH 'config' file.
:param dict_arg: Dictionary of SSH connection parameters
:type dict_arg: dict
"""
connect_dict = dict_arg.copy()
# Use SSHConfig to generate source content.
... | python | def _use_ssh_config(self, dict_arg):
"""Update SSH connection parameters based on contents of SSH 'config' file.
:param dict_arg: Dictionary of SSH connection parameters
:type dict_arg: dict
"""
connect_dict = dict_arg.copy()
# Use SSHConfig to generate source content.
... | [
"def",
"_use_ssh_config",
"(",
"self",
",",
"dict_arg",
")",
":",
"connect_dict",
"=",
"dict_arg",
".",
"copy",
"(",
")",
"# Use SSHConfig to generate source content.",
"full_path",
"=",
"path",
".",
"abspath",
"(",
"path",
".",
"expanduser",
"(",
"self",
".",
... | Update SSH connection parameters based on contents of SSH 'config' file.
:param dict_arg: Dictionary of SSH connection parameters
:type dict_arg: dict | [
"Update",
"SSH",
"connection",
"parameters",
"based",
"on",
"contents",
"of",
"SSH",
"config",
"file",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L751-L786 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._connect_params_dict | def _connect_params_dict(self):
"""Generate dictionary of Paramiko connection parameters."""
conn_dict = {
"hostname": self.host,
"port": self.port,
"username": self.username,
"password": self.password,
"look_for_keys": self.use_keys,
... | python | def _connect_params_dict(self):
"""Generate dictionary of Paramiko connection parameters."""
conn_dict = {
"hostname": self.host,
"port": self.port,
"username": self.username,
"password": self.password,
"look_for_keys": self.use_keys,
... | [
"def",
"_connect_params_dict",
"(",
"self",
")",
":",
"conn_dict",
"=",
"{",
"\"hostname\"",
":",
"self",
".",
"host",
",",
"\"port\"",
":",
"self",
".",
"port",
",",
"\"username\"",
":",
"self",
".",
"username",
",",
"\"password\"",
":",
"self",
".",
"p... | Generate dictionary of Paramiko connection parameters. | [
"Generate",
"dictionary",
"of",
"Paramiko",
"connection",
"parameters",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L788-L807 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._sanitize_output | def _sanitize_output(
self, output, strip_command=False, command_string=None, strip_prompt=False
):
"""Strip out command echo, trailing router prompt and ANSI escape codes.
:param output: Output from a remote network device
:type output: unicode string
:param strip_command:... | python | def _sanitize_output(
self, output, strip_command=False, command_string=None, strip_prompt=False
):
"""Strip out command echo, trailing router prompt and ANSI escape codes.
:param output: Output from a remote network device
:type output: unicode string
:param strip_command:... | [
"def",
"_sanitize_output",
"(",
"self",
",",
"output",
",",
"strip_command",
"=",
"False",
",",
"command_string",
"=",
"None",
",",
"strip_prompt",
"=",
"False",
")",
":",
"if",
"self",
".",
"ansi_escape_codes",
":",
"output",
"=",
"self",
".",
"strip_ansi_e... | Strip out command echo, trailing router prompt and ANSI escape codes.
:param output: Output from a remote network device
:type output: unicode string
:param strip_command:
:type strip_command: | [
"Strip",
"out",
"command",
"echo",
"trailing",
"router",
"prompt",
"and",
"ANSI",
"escape",
"codes",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L809-L828 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.establish_connection | def establish_connection(self, width=None, height=None):
"""Establish SSH connection to the network device
Timeout will generate a NetMikoTimeoutException
Authentication failure will generate a NetMikoAuthenticationException
width and height are needed for Fortinet paging setting.
... | python | def establish_connection(self, width=None, height=None):
"""Establish SSH connection to the network device
Timeout will generate a NetMikoTimeoutException
Authentication failure will generate a NetMikoAuthenticationException
width and height are needed for Fortinet paging setting.
... | [
"def",
"establish_connection",
"(",
"self",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
")",
":",
"if",
"self",
".",
"protocol",
"==",
"\"telnet\"",
":",
"self",
".",
"remote_conn",
"=",
"telnetlib",
".",
"Telnet",
"(",
"self",
".",
"host",
... | Establish SSH connection to the network device
Timeout will generate a NetMikoTimeoutException
Authentication failure will generate a NetMikoAuthenticationException
width and height are needed for Fortinet paging setting.
:param width: Specified width of the VT100 terminal window
... | [
"Establish",
"SSH",
"connection",
"to",
"the",
"network",
"device"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L830-L892 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._build_ssh_client | def _build_ssh_client(self):
"""Prepare for Paramiko SSH connection."""
# Create instance of SSHClient object
remote_conn_pre = paramiko.SSHClient()
# Load host_keys for better SSH security
if self.system_host_keys:
remote_conn_pre.load_system_host_keys()
if ... | python | def _build_ssh_client(self):
"""Prepare for Paramiko SSH connection."""
# Create instance of SSHClient object
remote_conn_pre = paramiko.SSHClient()
# Load host_keys for better SSH security
if self.system_host_keys:
remote_conn_pre.load_system_host_keys()
if ... | [
"def",
"_build_ssh_client",
"(",
"self",
")",
":",
"# Create instance of SSHClient object",
"remote_conn_pre",
"=",
"paramiko",
".",
"SSHClient",
"(",
")",
"# Load host_keys for better SSH security",
"if",
"self",
".",
"system_host_keys",
":",
"remote_conn_pre",
".",
"loa... | Prepare for Paramiko SSH connection. | [
"Prepare",
"for",
"Paramiko",
"SSH",
"connection",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L935-L948 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.select_delay_factor | def select_delay_factor(self, delay_factor):
"""
Choose the greater of delay_factor or self.global_delay_factor (default).
In fast_cli choose the lesser of delay_factor of self.global_delay_factor.
:param delay_factor: See __init__: global_delay_factor
:type delay_factor: int
... | python | def select_delay_factor(self, delay_factor):
"""
Choose the greater of delay_factor or self.global_delay_factor (default).
In fast_cli choose the lesser of delay_factor of self.global_delay_factor.
:param delay_factor: See __init__: global_delay_factor
:type delay_factor: int
... | [
"def",
"select_delay_factor",
"(",
"self",
",",
"delay_factor",
")",
":",
"if",
"self",
".",
"fast_cli",
":",
"if",
"delay_factor",
"<=",
"self",
".",
"global_delay_factor",
":",
"return",
"delay_factor",
"else",
":",
"return",
"self",
".",
"global_delay_factor"... | Choose the greater of delay_factor or self.global_delay_factor (default).
In fast_cli choose the lesser of delay_factor of self.global_delay_factor.
:param delay_factor: See __init__: global_delay_factor
:type delay_factor: int | [
"Choose",
"the",
"greater",
"of",
"delay_factor",
"or",
"self",
".",
"global_delay_factor",
"(",
"default",
")",
".",
"In",
"fast_cli",
"choose",
"the",
"lesser",
"of",
"delay_factor",
"of",
"self",
".",
"global_delay_factor",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L950-L967 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.set_terminal_width | def set_terminal_width(self, command="", delay_factor=1):
"""CLI terminals try to automatically adjust the line based on the width of the terminal.
This causes the output to get distorted when accessed programmatically.
Set terminal width to 511 which works on a broad set of devices.
:... | python | def set_terminal_width(self, command="", delay_factor=1):
"""CLI terminals try to automatically adjust the line based on the width of the terminal.
This causes the output to get distorted when accessed programmatically.
Set terminal width to 511 which works on a broad set of devices.
:... | [
"def",
"set_terminal_width",
"(",
"self",
",",
"command",
"=",
"\"\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"if",
"not",
"command",
":",
"return",
"\"\"",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"command",
"=",
... | CLI terminals try to automatically adjust the line based on the width of the terminal.
This causes the output to get distorted when accessed programmatically.
Set terminal width to 511 which works on a broad set of devices.
:param command: Command string to send to the device
:type com... | [
"CLI",
"terminals",
"try",
"to",
"automatically",
"adjust",
"the",
"line",
"based",
"on",
"the",
"width",
"of",
"the",
"terminal",
".",
"This",
"causes",
"the",
"output",
"to",
"get",
"distorted",
"when",
"accessed",
"programmatically",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L996-L1016 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.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 Cisco
d... | 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 Cisco
d... | [
"def",
"set_base_prompt",
"(",
"self",
",",
"pri_prompt_terminator",
"=",
"\"#\"",
",",
"alt_prompt_terminator",
"=",
"\">\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"prompt",
"=",
"self",
".",
"find_prompt",
"(",
"delay_factor",
"=",
"delay_factor",
")",
"i... | 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 Cisco
devices this will be set to router hostname (i.e. prompt without '>' or '#').
This will be set on entering user ex... | [
"Sets",
"self",
".",
"base_prompt"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1018-L1045 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.find_prompt | def find_prompt(self, delay_factor=1):
"""Finds the current network device prompt, last line only.
:param delay_factor: See __init__: global_delay_factor
:type delay_factor: int
"""
delay_factor = self.select_delay_factor(delay_factor)
self.clear_buffer()
self.wr... | python | def find_prompt(self, delay_factor=1):
"""Finds the current network device prompt, last line only.
:param delay_factor: See __init__: global_delay_factor
:type delay_factor: int
"""
delay_factor = self.select_delay_factor(delay_factor)
self.clear_buffer()
self.wr... | [
"def",
"find_prompt",
"(",
"self",
",",
"delay_factor",
"=",
"1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"self",
".",
"clear_buffer",
"(",
")",
"self",
".",
"write_channel",
"(",
"self",
".",
"RETURN",
... | Finds the current network device prompt, last line only.
:param delay_factor: See __init__: global_delay_factor
:type delay_factor: int | [
"Finds",
"the",
"current",
"network",
"device",
"prompt",
"last",
"line",
"only",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1047-L1084 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.send_command_timing | def send_command_timing(
self,
command_string,
delay_factor=1,
max_loops=150,
strip_prompt=True,
strip_command=True,
normalize=True,
use_textfsm=False,
):
"""Execute command_string on the SSH channel using a delay-based mechanism. Generally
... | python | def send_command_timing(
self,
command_string,
delay_factor=1,
max_loops=150,
strip_prompt=True,
strip_command=True,
normalize=True,
use_textfsm=False,
):
"""Execute command_string on the SSH channel using a delay-based mechanism. Generally
... | [
"def",
"send_command_timing",
"(",
"self",
",",
"command_string",
",",
"delay_factor",
"=",
"1",
",",
"max_loops",
"=",
"150",
",",
"strip_prompt",
"=",
"True",
",",
"strip_command",
"=",
"True",
",",
"normalize",
"=",
"True",
",",
"use_textfsm",
"=",
"False... | Execute command_string on the SSH channel using a delay-based mechanism. Generally
used for show commands.
:param command_string: The command to be executed on the remote device.
:type command_string: str
:param delay_factor: Multiplying factor used to adjust delays (default: 1).
... | [
"Execute",
"command_string",
"on",
"the",
"SSH",
"channel",
"using",
"a",
"delay",
"-",
"based",
"mechanism",
".",
"Generally",
"used",
"for",
"show",
"commands",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1090-L1145 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.strip_prompt | def strip_prompt(self, a_string):
"""Strip the trailing router prompt from the output.
:param a_string: Returned string from device
:type a_string: str
"""
response_list = a_string.split(self.RESPONSE_RETURN)
last_line = response_list[-1]
if self.base_prompt in l... | python | def strip_prompt(self, a_string):
"""Strip the trailing router prompt from the output.
:param a_string: Returned string from device
:type a_string: str
"""
response_list = a_string.split(self.RESPONSE_RETURN)
last_line = response_list[-1]
if self.base_prompt in l... | [
"def",
"strip_prompt",
"(",
"self",
",",
"a_string",
")",
":",
"response_list",
"=",
"a_string",
".",
"split",
"(",
"self",
".",
"RESPONSE_RETURN",
")",
"last_line",
"=",
"response_list",
"[",
"-",
"1",
"]",
"if",
"self",
".",
"base_prompt",
"in",
"last_li... | Strip the trailing router prompt from the output.
:param a_string: Returned string from device
:type a_string: str | [
"Strip",
"the",
"trailing",
"router",
"prompt",
"from",
"the",
"output",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1147-L1158 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection._first_line_handler | def _first_line_handler(self, data, search_pattern):
"""
In certain situations the first line will get repainted which causes a false
match on the terminating pattern.
Filter this out.
returns a tuple of (data, first_line_processed)
Where data is the original data pote... | python | def _first_line_handler(self, data, search_pattern):
"""
In certain situations the first line will get repainted which causes a false
match on the terminating pattern.
Filter this out.
returns a tuple of (data, first_line_processed)
Where data is the original data pote... | [
"def",
"_first_line_handler",
"(",
"self",
",",
"data",
",",
"search_pattern",
")",
":",
"try",
":",
"# First line is the echo line containing the command. In certain situations",
"# it gets repainted and needs filtered",
"lines",
"=",
"data",
".",
"split",
"(",
"self",
"."... | In certain situations the first line will get repainted which causes a false
match on the terminating pattern.
Filter this out.
returns a tuple of (data, first_line_processed)
Where data is the original data potentially with the first line modified
and the first_line_processed... | [
"In",
"certain",
"situations",
"the",
"first",
"line",
"will",
"get",
"repainted",
"which",
"causes",
"a",
"false",
"match",
"on",
"the",
"terminating",
"pattern",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1160-L1185 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.send_command | def send_command(
self,
command_string,
expect_string=None,
delay_factor=1,
max_loops=500,
auto_find_prompt=True,
strip_prompt=True,
strip_command=True,
normalize=True,
use_textfsm=False,
):
"""Execute command_string on the SSH ... | python | def send_command(
self,
command_string,
expect_string=None,
delay_factor=1,
max_loops=500,
auto_find_prompt=True,
strip_prompt=True,
strip_command=True,
normalize=True,
use_textfsm=False,
):
"""Execute command_string on the SSH ... | [
"def",
"send_command",
"(",
"self",
",",
"command_string",
",",
"expect_string",
"=",
"None",
",",
"delay_factor",
"=",
"1",
",",
"max_loops",
"=",
"500",
",",
"auto_find_prompt",
"=",
"True",
",",
"strip_prompt",
"=",
"True",
",",
"strip_command",
"=",
"Tru... | Execute command_string on the SSH channel using a pattern-based mechanism. Generally
used for show commands. 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.
:param c... | [
"Execute",
"command_string",
"on",
"the",
"SSH",
"channel",
"using",
"a",
"pattern",
"-",
"based",
"mechanism",
".",
"Generally",
"used",
"for",
"show",
"commands",
".",
"By",
"default",
"this",
"method",
"will",
"keep",
"waiting",
"to",
"receive",
"data",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1187-L1309 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.strip_command | def strip_command(self, command_string, output):
"""
Strip command_string from output string
Cisco IOS adds backspaces into output for long commands (i.e. for commands that line wrap)
:param command_string: The command string sent to the device
:type command_string: str
... | python | def strip_command(self, command_string, output):
"""
Strip command_string from output string
Cisco IOS adds backspaces into output for long commands (i.e. for commands that line wrap)
:param command_string: The command string sent to the device
:type command_string: str
... | [
"def",
"strip_command",
"(",
"self",
",",
"command_string",
",",
"output",
")",
":",
"backspace_char",
"=",
"\"\\x08\"",
"# Check for line wrap (remove backspaces)",
"if",
"backspace_char",
"in",
"output",
":",
"output",
"=",
"output",
".",
"replace",
"(",
"backspac... | Strip command_string from output string
Cisco IOS adds backspaces into output for long commands (i.e. for commands that line wrap)
:param command_string: The command string sent to the device
:type command_string: str
:param output: The returned output as a result of the command strin... | [
"Strip",
"command_string",
"from",
"output",
"string"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1332-L1354 | train |
ktbyers/netmiko | netmiko/base_connection.py | BaseConnection.normalize_linefeeds | def normalize_linefeeds(self, a_string):
"""Convert `\r\r\n`,`\r\n`, `\n\r` to `\n.`
:param a_string: A string that may have non-normalized line feeds
i.e. output returned from device, or a device prompt
:type a_string: str
"""
newline = re.compile("(\r\r\r\n|\r\r\n|... | python | def normalize_linefeeds(self, a_string):
"""Convert `\r\r\n`,`\r\n`, `\n\r` to `\n.`
:param a_string: A string that may have non-normalized line feeds
i.e. output returned from device, or a device prompt
:type a_string: str
"""
newline = re.compile("(\r\r\r\n|\r\r\n|... | [
"def",
"normalize_linefeeds",
"(",
"self",
",",
"a_string",
")",
":",
"newline",
"=",
"re",
".",
"compile",
"(",
"\"(\\r\\r\\r\\n|\\r\\r\\n|\\r\\n|\\n\\r)\"",
")",
"a_string",
"=",
"newline",
".",
"sub",
"(",
"self",
".",
"RESPONSE_RETURN",
",",
"a_string",
")",... | Convert `\r\r\n`,`\r\n`, `\n\r` to `\n.`
:param a_string: A string that may have non-normalized line feeds
i.e. output returned from device, or a device prompt
:type a_string: str | [
"Convert",
"\\",
"r",
"\\",
"r",
"\\",
"n",
"\\",
"r",
"\\",
"n",
"\\",
"n",
"\\",
"r",
"to",
"\\",
"n",
"."
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1356-L1367 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.