partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | DellOS10FileTransfer.remote_space_available | Return space available on remote device. | netmiko/dell/dell_os10_ssh.py | 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"):
"""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():
... | [
"Return",
"space",
"available",
"on",
"remote",
"device",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_os10_ssh.py#L59-L67 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | DellOS10FileTransfer.check_file_exists | Check if the dest_file already exists on the file system (return boolean). | netmiko/dell/dell_os10_ssh.py | 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"):
"""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... | [
"Check",
"if",
"the",
"dest_file",
"already",
"exists",
"on",
"the",
"file",
"system",
"(",
"return",
"boolean",
")",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_os10_ssh.py#L87-L94 | [
"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",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | DellOS10FileTransfer.get_file | SCP copy the file from the remote device to local system. | netmiko/dell/dell_os10_ssh.py | 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):
"""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() | [
"SCP",
"copy",
"the",
"file",
"from",
"the",
"remote",
"device",
"to",
"local",
"system",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_os10_ssh.py#L103-L107 | [
"def",
"get_file",
"(",
"self",
")",
":",
"source_file",
"=",
"\"{}\"",
".",
"format",
"(",
"self",
".",
"source_file",
")",
"self",
".",
"scp_conn",
".",
"scp_get_file",
"(",
"source_file",
",",
"self",
".",
"dest_file",
")",
"self",
".",
"scp_conn",
".... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | OneaccessOneOSBase.save_config | Save config: write mem | netmiko/oneaccess/oneaccess_oneos.py | 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=""):
"""Save config: write mem"""
return super(OneaccessOneOSBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Save",
"config",
":",
"write",
"mem"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/oneaccess/oneaccess_oneos.py#L27-L31 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"write mem\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"OneaccessOneOSBase",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"cmd",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | IndexTable._ParseIndex | 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... | netmiko/_textfsm/_clitable.py | 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):
"""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 ... | [
"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... | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L107-L131 | [
"def",
"_ParseIndex",
"(",
"self",
",",
"preread",
",",
"precompile",
")",
":",
"self",
".",
"index",
"=",
"texttable",
".",
"TextTable",
"(",
")",
"self",
".",
"index",
".",
"CsvToTable",
"(",
"self",
".",
"_index_handle",
")",
"if",
"preread",
":",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | IndexTable.GetRowMatch | Returns the row number that matches the supplied attributes. | netmiko/_textfsm/_clitable.py | 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):
"""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... | [
"Returns",
"the",
"row",
"number",
"that",
"matches",
"the",
"supplied",
"attributes",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L133-L150 | [
"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",
"(",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable.synchronised | Synchronisation decorator. | netmiko/_textfsm/_clitable.py | 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):
"""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... | [
"Synchronisation",
"decorator",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L172-L183 | [
"def",
"synchronised",
"(",
"func",
")",
":",
"# pylint: disable=E0213",
"def",
"Wrapper",
"(",
"main_obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"main_obj",
".",
"_lock",
".",
"acquire",
"(",
")",
"# pylint: disable=W0212",
"try",
":",
"ret... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable.ReadIndex | 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. | netmiko/_textfsm/_clitable.py | 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):
"""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... | [
"Reads",
"the",
"IndexTable",
"index",
"file",
"of",
"commands",
"and",
"templates",
".",
"Args",
":",
"index_file",
":",
"String",
"file",
"where",
"template",
"/",
"command",
"mappings",
"reside",
".",
"Raises",
":",
"CliTableError",
":",
"A",
"template",
... | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L202-L220 | [
"def",
"ReadIndex",
"(",
"self",
",",
"index_file",
"=",
"None",
")",
":",
"self",
".",
"index_file",
"=",
"index_file",
"or",
"self",
".",
"index_file",
"fullpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"template_dir",
",",
"self",
".... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable._TemplateNamesToFiles | Parses a string of templates into a list of file handles. | netmiko/_textfsm/_clitable.py | 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):
"""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... | [
"Parses",
"a",
"string",
"of",
"templates",
"into",
"a",
"list",
"of",
"file",
"handles",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L222-L234 | [
"def",
"_TemplateNamesToFiles",
"(",
"self",
",",
"template_str",
")",
":",
"template_list",
"=",
"template_str",
".",
"split",
"(",
"\":\"",
")",
"template_files",
"=",
"[",
"]",
"try",
":",
"for",
"tmplt",
"in",
"template_list",
":",
"template_files",
".",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable.ParseCmd | 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... | netmiko/_textfsm/_clitable.py | 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):
"""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... | [
"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",... | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L236-L275 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable._PreParse | Executed against each field of each row read from index table. | netmiko/_textfsm/_clitable.py | 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):
"""Executed against each field of each row read from index table."""
if key == "Command":
return re.sub(r"(\[\[.+?\]\])", self._Completion, value)
else:
return value | [
"Executed",
"against",
"each",
"field",
"of",
"each",
"row",
"read",
"from",
"index",
"table",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L301-L306 | [
"def",
"_PreParse",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"==",
"\"Command\"",
":",
"return",
"re",
".",
"sub",
"(",
"r\"(\\[\\[.+?\\]\\])\"",
",",
"self",
".",
"_Completion",
",",
"value",
")",
"else",
":",
"return",
"value"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable.LabelValueTable | Return LabelValue with FSM derived keys. | netmiko/_textfsm/_clitable.py | 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):
"""Return LabelValue with FSM derived keys."""
keys = keys or self.superkey
# pylint: disable=E1002
return super(CliTable, self).LabelValueTable(keys) | [
"Return",
"LabelValue",
"with",
"FSM",
"derived",
"keys",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L329-L333 | [
"def",
"LabelValueTable",
"(",
"self",
",",
"keys",
"=",
"None",
")",
":",
"keys",
"=",
"keys",
"or",
"self",
".",
"superkey",
"# pylint: disable=E1002",
"return",
"super",
"(",
"CliTable",
",",
"self",
")",
".",
"LabelValueTable",
"(",
"keys",
")"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable.sort | Overrides sort func to use the KeyValue for the key. | netmiko/_textfsm/_clitable.py | 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):
"""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) | [
"Overrides",
"sort",
"func",
"to",
"use",
"the",
"KeyValue",
"for",
"the",
"key",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L336-L340 | [
"def",
"sort",
"(",
"self",
",",
"cmp",
"=",
"None",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"not",
"key",
"and",
"self",
".",
"_keys",
":",
"key",
"=",
"self",
".",
"KeyValue",
"super",
"(",
"CliTable",
",",
"self"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable.AddKeys | 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.
... | netmiko/_textfsm/_clitable.py | 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):
"""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... | [
"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",
".",
... | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L344-L360 | [
"def",
"AddKeys",
"(",
"self",
",",
"key_list",
")",
":",
"for",
"keyname",
"in",
"key_list",
":",
"if",
"keyname",
"not",
"in",
"self",
".",
"header",
":",
"raise",
"KeyError",
"(",
"\"'%s'\"",
"%",
"keyname",
")",
"self",
".",
"_keys",
"=",
"self",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable.superkey | Returns a set of column names that together constitute the superkey. | netmiko/_textfsm/_clitable.py | 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):
"""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 | [
"Returns",
"a",
"set",
"of",
"column",
"names",
"that",
"together",
"constitute",
"the",
"superkey",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L363-L369 | [
"def",
"superkey",
"(",
"self",
")",
":",
"sorted_list",
"=",
"[",
"]",
"for",
"header",
"in",
"self",
".",
"header",
":",
"if",
"header",
"in",
"self",
".",
"_keys",
":",
"sorted_list",
".",
"append",
"(",
"header",
")",
"return",
"sorted_list"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CliTable.KeyValue | Returns the super key value for the row. | netmiko/_textfsm/_clitable.py | 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):
"""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... | [
"Returns",
"the",
"super",
"key",
"value",
"for",
"the",
"row",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_clitable.py#L371-L387 | [
"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",
":",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | DellIsilonSSH.set_base_prompt | Determine base prompt. | netmiko/dell/dell_isilon_ssh.py | 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
):
"""Determine base prompt."""
return super(DellIsilonSSH, self).set_base_prompt(
pri_prompt_terminator=pri_prompt_terminator,
alt_prompt_terminator=alt_prompt_terminator,... | [
"Determine",
"base",
"prompt",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_isilon_ssh.py#L10-L18 | [
"def",
"set_base_prompt",
"(",
"self",
",",
"pri_prompt_terminator",
"=",
"\"$\"",
",",
"alt_prompt_terminator",
"=",
"\"#\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"return",
"super",
"(",
"DellIsilonSSH",
",",
"self",
")",
".",
"set_base_prompt",
"(",
"pri... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | DellIsilonSSH.strip_ansi_escape_codes | Remove Null code | netmiko/dell/dell_isilon_ssh.py | 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):
"""Remove Null code"""
output = re.sub(r"\x00", "", string_buffer)
return super(DellIsilonSSH, self).strip_ansi_escape_codes(output) | [
"Remove",
"Null",
"code"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_isilon_ssh.py#L20-L23 | [
"def",
"strip_ansi_escape_codes",
"(",
"self",
",",
"string_buffer",
")",
":",
"output",
"=",
"re",
".",
"sub",
"(",
"r\"\\x00\"",
",",
"\"\"",
",",
"string_buffer",
")",
"return",
"super",
"(",
"DellIsilonSSH",
",",
"self",
")",
".",
"strip_ansi_escape_codes"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | DellIsilonSSH.session_preparation | Prepare the session after the connection has been established. | netmiko/dell/dell_isilon_ssh.py | 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):
"""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... | [
"Prepare",
"the",
"session",
"after",
"the",
"connection",
"has",
"been",
"established",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_isilon_ssh.py#L25-L33 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | DellIsilonSSH.zsh_mode | Run zsh command to unify the environment | netmiko/dell/dell_isilon_ssh.py | 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="$"):
"""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... | [
"Run",
"zsh",
"command",
"to",
"unify",
"the",
"environment"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_isilon_ssh.py#L35-L43 | [
"def",
"zsh_mode",
"(",
"self",
",",
"delay_factor",
"=",
"1",
",",
"prompt_terminator",
"=",
"\"$\"",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"self",
".",
"clear_buffer",
"(",
")",
"command",
"=",
"self",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | DellIsilonSSH.config_mode | Attempt to become root. | netmiko/dell/dell_isilon_ssh.py | 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"):
"""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... | [
"Attempt",
"to",
"become",
"root",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_isilon_ssh.py#L69-L84 | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"sudo su\"",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
"=",
"1",
")",
"output",
"=",
"\"\"",
"if",
"not",
"self",
".",
"check_config_mode",
"(",
")... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | QuantaMeshSSH.disable_paging | Disable paging | netmiko/quanta/quanta_mesh_ssh.py | 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):
"""Disable paging"""
return super(QuantaMeshSSH, self).disable_paging(command=command) | [
"Disable",
"paging"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/quanta/quanta_mesh_ssh.py#L6-L8 | [
"def",
"disable_paging",
"(",
"self",
",",
"command",
"=",
"\"no pager\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"return",
"super",
"(",
"QuantaMeshSSH",
",",
"self",
")",
".",
"disable_paging",
"(",
"command",
"=",
"command",
")"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | QuantaMeshSSH.save_config | Saves Config | netmiko/quanta/quanta_mesh_ssh.py | 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="",
):
"""Saves Config"""
return super(QuantaMeshSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Saves",
"Config"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/quanta/quanta_mesh_ssh.py#L14-L23 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"copy running-config startup-config\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
",",
")",
":",
"return",
"super",
"(",
"QuantaMeshSSH",
",",
"self",
")",
".",
"save_config",
"(",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | SSHDetect.autodetect | 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 | netmiko/ssh_autodetect.py | 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):
"""
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... | [
"Try",
"to",
"guess",
"the",
"best",
"device_type",
"based",
"on",
"patterns",
"defined",
"in",
"SSH_MAPPER_BASE"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_autodetect.py#L215-L246 | [
"def",
"autodetect",
"(",
"self",
")",
":",
"for",
"device_type",
",",
"autodetect_dict",
"in",
"SSH_MAPPER_BASE",
".",
"items",
"(",
")",
":",
"tmp_dict",
"=",
"autodetect_dict",
".",
"copy",
"(",
")",
"call_method",
"=",
"tmp_dict",
".",
"pop",
"(",
"\"d... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | SSHDetect._send_command | 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... | netmiko/ssh_autodetect.py | 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=""):
"""
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
-... | [
"Handle",
"reading",
"/",
"writing",
"channel",
"directly",
".",
"It",
"is",
"also",
"sanitizing",
"the",
"output",
"received",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_autodetect.py#L248-L267 | [
"def",
"_send_command",
"(",
"self",
",",
"cmd",
"=",
"\"\"",
")",
":",
"self",
".",
"connection",
".",
"write_channel",
"(",
"cmd",
"+",
"\"\\n\"",
")",
"time",
".",
"sleep",
"(",
"1",
")",
"output",
"=",
"self",
".",
"connection",
".",
"_read_channel... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | SSHDetect._send_command_wrapper | 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
-------
... | netmiko/ssh_autodetect.py | 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):
"""
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... | [
"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",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_autodetect.py#L269-L290 | [
"def",
"_send_command_wrapper",
"(",
"self",
",",
"cmd",
")",
":",
"cached_results",
"=",
"self",
".",
"_results_cache",
".",
"get",
"(",
"cmd",
")",
"if",
"not",
"cached_results",
":",
"response",
"=",
"self",
".",
"_send_command",
"(",
"cmd",
")",
"self"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | SSHDetect._autodetect_std | 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... | netmiko/ssh_autodetect.py | 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):
"""
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... | [
"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"... | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_autodetect.py#L292-L334 | [
"def",
"_autodetect_std",
"(",
"self",
",",
"cmd",
"=",
"\"\"",
",",
"search_patterns",
"=",
"None",
",",
"re_flags",
"=",
"re",
".",
"I",
",",
"priority",
"=",
"99",
")",
":",
"invalid_responses",
"=",
"[",
"r\"% Invalid input detected\"",
",",
"r\"syntax e... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | AlcatelAosSSH.save_config | Save Config | netmiko/alcatel/alcatel_aos_ssh.py | 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=""
):
"""Save Config"""
return super(AlcatelAosSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Save",
"Config"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_aos_ssh.py#L43-L49 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"write memory flash-synchro\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"AlcatelAosSSH",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"="... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | ConnectHandler | Factory function selects the proper class and creates object based on device_type. | netmiko/ssh_dispatcher.py | 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):
"""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)
... | [
"Factory",
"function",
"selects",
"the",
"proper",
"class",
"and",
"creates",
"object",
"based",
"on",
"device_type",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_dispatcher.py#L223-L231 | [
"def",
"ConnectHandler",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"[",
"\"device_type\"",
"]",
"not",
"in",
"platforms",
":",
"raise",
"ValueError",
"(",
"\"Unsupported device_type: \"",
"\"currently supported platforms are: {}\"",
".",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | redispatch | 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. | netmiko/ssh_dispatcher.py | 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):
"""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... | [
"Dynamically",
"change",
"Netmiko",
"object",
"s",
"class",
"to",
"proper",
"class",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_dispatcher.py#L239-L249 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | FileTransfer | Factory function selects the proper SCP class and creates object based on device_type. | netmiko/ssh_dispatcher.py | 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):
"""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... | [
"Factory",
"function",
"selects",
"the",
"proper",
"SCP",
"class",
"and",
"creates",
"object",
"based",
"on",
"device_type",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ssh_dispatcher.py#L252-L264 | [
"def",
"FileTransfer",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">=",
"1",
":",
"device_type",
"=",
"args",
"[",
"0",
"]",
".",
"device_type",
"else",
":",
"device_type",
"=",
"kwargs",
"[",
"\"ssh_conn\"",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | find_version | 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. | setup.py | 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):
"""
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... | [
"This",
"pattern",
"was",
"modeled",
"on",
"a",
"method",
"from",
"the",
"Python",
"Packaging",
"User",
"Guide",
":",
"https",
":",
"//",
"packaging",
".",
"python",
".",
"org",
"/",
"en",
"/",
"latest",
"/",
"single_source_version",
".",
"html"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/setup.py#L11-L27 | [
"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",
"(",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CalixB6Base.session_preparation | Prepare the session after the connection has been established. | netmiko/calix/calix_b6.py | 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):
"""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... | [
"Prepare",
"the",
"session",
"after",
"the",
"connection",
"has",
"been",
"established",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/calix/calix_b6.py#L28-L37 | [
"def",
"session_preparation",
"(",
"self",
")",
":",
"self",
".",
"ansi_escape_codes",
"=",
"True",
"self",
".",
"_test_channel_read",
"(",
")",
"self",
".",
"set_base_prompt",
"(",
")",
"self",
".",
"disable_paging",
"(",
")",
"self",
".",
"set_terminal_width... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CalixB6Base.check_config_mode | Checks if the device is in configuration mode | netmiko/calix/calix_b6.py | 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=""):
"""Checks if the device is in configuration mode"""
return super(CalixB6Base, self).check_config_mode(check_string=check_string) | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/calix/calix_b6.py#L64-L66 | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\")#\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"CalixB6Base",
",",
"self",
")",
".",
"check_config_mode",
"(",
"check_string",
"=",
"check_string",
")"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | MellanoxSSH.disable_paging | Disable paging default to a Cisco CLI method. | netmiko/mellanox/mellanox_ssh.py | 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):
"""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.... | [
"Disable",
"paging",
"default",
"to",
"a",
"Cisco",
"CLI",
"method",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/mellanox/mellanox_ssh.py#L23-L37 | [
"def",
"disable_paging",
"(",
"self",
",",
"command",
"=",
"\"terminal length 999\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"time",
".",
"sleep",
"(",
"delay_factor",
"*",
"0... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | MellanoxSSH.save_config | Save Config on Mellanox devices Enters and Leaves Config Mode | netmiko/mellanox/mellanox_ssh.py | 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=""
):
"""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_... | [
"Save",
"Config",
"on",
"Mellanox",
"devices",
"Enters",
"and",
"Leaves",
"Config",
"Mode"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/mellanox/mellanox_ssh.py#L50-L58 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"configuration write\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"output",
"=",
"self",
".",
"enable",
"(",
")",
"output",
"+=",
"self",
".",
"config_mode",
"(",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | RadETXBase.config_mode | Enter into configuration mode on remote device. | netmiko/rad/rad_etx.py | 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"):
"""Enter into configuration mode on remote device."""
return super(RadETXBase, self).config_mode(
config_command=config_command, pattern=pattern
) | [
"Enter",
"into",
"configuration",
"mode",
"on",
"remote",
"device",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/rad/rad_etx.py#L44-L48 | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"config\"",
",",
"pattern",
"=",
"\">config\"",
")",
":",
"return",
"super",
"(",
"RadETXBase",
",",
"self",
")",
".",
"config_mode",
"(",
"config_command",
"=",
"config_command",
",",
"pattern",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | RadETXBase.check_config_mode | Checks if the device is in configuration mode or not.
Rad config starts with baseprompt>config. | netmiko/rad/rad_etx.py | 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=""):
"""
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
... | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/rad/rad_etx.py#L50-L58 | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\">config\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"RadETXBase",
",",
"self",
")",
".",
"check_config_mode",
"(",
"check_string",
"=",
"check_string",
",",
"pattern",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | RadETXBase.exit_config_mode | Exit from configuration mode. | netmiko/rad/rad_etx.py | 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="#"):
"""Exit from configuration mode."""
return super(RadETXBase, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) | [
"Exit",
"from",
"configuration",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/rad/rad_etx.py#L60-L64 | [
"def",
"exit_config_mode",
"(",
"self",
",",
"exit_config",
"=",
"\"exit all\"",
",",
"pattern",
"=",
"\"#\"",
")",
":",
"return",
"super",
"(",
"RadETXBase",
",",
"self",
")",
".",
"exit_config_mode",
"(",
"exit_config",
"=",
"exit_config",
",",
"pattern",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | RadETXTelnet.telnet_login | RAD presents with the following on login
user>
password> **** | netmiko/rad/rad_etx.py | 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
):
"""
RAD presents with the following on login
user>
password> ****
"""
self.TELNET_RETURN = self.RETURN
return super(RadETXTelnet, self).telnet_login(
... | [
"RAD",
"presents",
"with",
"the",
"following",
"on",
"login"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/rad/rad_etx.py#L79-L94 | [
"def",
"telnet_login",
"(",
"self",
",",
"username_pattern",
"=",
"r\"(?:user>)\"",
",",
"alt_prompt_term",
"=",
"r\"#\\s*$\"",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"TELNET_RETURN",
"=",
"self",
".",
"RETURN",
"return",
"super",
"(",
"RadETXTelnet",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | VyOSSSH.config_mode | Enter configuration mode. | netmiko/vyos/vyos_ssh.py | 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]"):
"""Enter configuration mode."""
return super(VyOSSSH, self).config_mode(
config_command=config_command, pattern=pattern
) | [
"Enter",
"configuration",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/vyos/vyos_ssh.py#L35-L39 | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"configure\"",
",",
"pattern",
"=",
"r\"[edit]\"",
")",
":",
"return",
"super",
"(",
"VyOSSSH",
",",
"self",
")",
".",
"config_mode",
"(",
"config_command",
"=",
"config_command",
",",
"pattern",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | VyOSSSH.commit | 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> | netmiko/vyos/vyos_ssh.py | 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):
"""
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... | [
"Commit",
"the",
"candidate",
"configuration",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/vyos/vyos_ssh.py#L56-L88 | [
"def",
"commit",
"(",
"self",
",",
"comment",
"=",
"\"\"",
",",
"delay_factor",
"=",
"0.1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"error_marker",
"=",
"[",
"\"Failed to generate committed config\"",
",",
"\"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | VyOSSSH.send_config_set | Remain in configuration mode. | netmiko/vyos/vyos_ssh.py | 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,
config_mode_command=None,
):
"""Remain in configuration mode."""
return super(VyOSSSH, self... | [
"Remain",
"in",
"configuration",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/vyos/vyos_ssh.py#L103-L122 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoBaseConnection.check_config_mode | Checks if the device is in configuration mode or not.
Cisco IOS devices abbreviate the prompt at 20 chars in config mode | netmiko/cisco_base_connection.py | 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=""):
"""
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_... | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco_base_connection.py#L31-L39 | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\")#\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"CiscoBaseConnection",
",",
"self",
")",
".",
"check_config_mode",
"(",
"check_string",
"=",
"check_string",
",",
"patte... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoBaseConnection.config_mode | Enter into configuration mode on remote device.
Cisco IOS devices abbreviate the prompt at 20 chars in config mode | netmiko/cisco_base_connection.py | 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=""):
"""
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... | [
"Enter",
"into",
"configuration",
"mode",
"on",
"remote",
"device",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco_base_connection.py#L41-L51 | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"config term\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"if",
"not",
"pattern",
":",
"pattern",
"=",
"re",
".",
"escape",
"(",
"self",
".",
"base_prompt",
"[",
":",
"16",
"]",
")",
"retur... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoBaseConnection.exit_config_mode | Exit from configuration mode. | netmiko/cisco_base_connection.py | 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="#"):
"""Exit from configuration mode."""
return super(CiscoBaseConnection, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) | [
"Exit",
"from",
"configuration",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco_base_connection.py#L53-L57 | [
"def",
"exit_config_mode",
"(",
"self",
",",
"exit_config",
"=",
"\"end\"",
",",
"pattern",
"=",
"\"#\"",
")",
":",
"return",
"super",
"(",
"CiscoBaseConnection",
",",
"self",
")",
".",
"exit_config_mode",
"(",
"exit_config",
"=",
"exit_config",
",",
"pattern"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoBaseConnection._autodetect_fs | Autodetect the file system on the remote device. Used by SCP operations. | netmiko/cisco_base_connection.py | 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 (.*)/"):
"""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... | [
"Autodetect",
"the",
"file",
"system",
"on",
"the",
"remote",
"device",
".",
"Used",
"by",
"SCP",
"operations",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco_base_connection.py#L183-L205 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | MrvOptiswitchSSH.enable | Enable mode on MRV uses no password. | netmiko/mrv/mrv_ssh.py | 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):
"""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... | [
"Enable",
"mode",
"on",
"MRV",
"uses",
"no",
"password",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/mrv/mrv_ssh.py#L23-L37 | [
"def",
"enable",
"(",
"self",
",",
"cmd",
"=",
"\"enable\"",
",",
"pattern",
"=",
"r\"#\"",
",",
"re_flags",
"=",
"re",
".",
"IGNORECASE",
")",
":",
"output",
"=",
"\"\"",
"if",
"not",
"self",
".",
"check_enable_mode",
"(",
")",
":",
"self",
".",
"wr... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | MrvOptiswitchSSH.save_config | Saves configuration. | netmiko/mrv/mrv_ssh.py | 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=""):
"""Saves configuration."""
return super(MrvOptiswitchSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Saves",
"configuration",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/mrv/mrv_ssh.py#L39-L43 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"save config flash\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"MrvOptiswitchSSH",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"c... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | NetAppcDotSSH.session_preparation | Prepare the session after the connection has been established. | netmiko/netapp/netapp_cdot_ssh.py | 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):
"""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) | [
"Prepare",
"the",
"session",
"after",
"the",
"connection",
"has",
"been",
"established",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/netapp/netapp_cdot_ssh.py#L7-L11 | [
"def",
"session_preparation",
"(",
"self",
")",
":",
"self",
".",
"set_base_prompt",
"(",
")",
"cmd",
"=",
"self",
".",
"RETURN",
"+",
"\"rows 0\"",
"+",
"self",
".",
"RETURN",
"self",
".",
"disable_paging",
"(",
"command",
"=",
"cmd",
")"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._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 msg: Exception message if timeout was exceeded
:type msg: str | netmiko/base_connection.py | 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!"):
"""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... | [
"Raise",
"NetMikoTimeoutException",
"if",
"waiting",
"too",
"much",
"in",
"the",
"serving",
"queue",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L327-L342 | [
"def",
"_timeout_exceeded",
"(",
"self",
",",
"start",
",",
"msg",
"=",
"\"Timeout exceeded!\"",
")",
":",
"if",
"not",
"start",
":",
"# Must provide a comparison time",
"return",
"False",
"if",
"time",
".",
"time",
"(",
")",
"-",
"start",
">",
"self",
".",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._lock_netmiko_session | 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) | netmiko/base_connection.py | 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):
"""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",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L344-L358 | [
"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",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._write_channel | 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) | netmiko/base_connection.py | 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):
"""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... | [
"Generic",
"handler",
"that",
"will",
"write",
"to",
"both",
"SSH",
"and",
"telnet",
"channel",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L367-L392 | [
"def",
"_write_channel",
"(",
"self",
",",
"out_data",
")",
":",
"if",
"self",
".",
"protocol",
"==",
"\"ssh\"",
":",
"self",
".",
"remote_conn",
".",
"sendall",
"(",
"write_bytes",
"(",
"out_data",
",",
"encoding",
"=",
"self",
".",
"encoding",
")",
")"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.write_channel | 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) | netmiko/base_connection.py | 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):
"""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_... | [
"Generic",
"handler",
"that",
"will",
"write",
"to",
"both",
"SSH",
"and",
"telnet",
"channel",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L399-L410 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.is_alive | Returns a boolean flag with the state of the connection. | netmiko/base_connection.py | 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):
"""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:
... | [
"Returns",
"a",
"boolean",
"flag",
"with",
"the",
"state",
"of",
"the",
"connection",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L412-L441 | [
"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",
"."... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._read_channel | Generic handler that will read all the data from an SSH or telnet channel. | netmiko/base_connection.py | 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):
"""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)
... | [
"Generic",
"handler",
"that",
"will",
"read",
"all",
"the",
"data",
"from",
"an",
"SSH",
"or",
"telnet",
"channel",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L443-L465 | [
"def",
"_read_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"protocol",
"==",
"\"ssh\"",
":",
"output",
"=",
"\"\"",
"while",
"True",
":",
"if",
"self",
".",
"remote_conn",
".",
"recv_ready",
"(",
")",
":",
"outbuf",
"=",
"self",
".",
"remote_con... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.read_channel | Generic handler that will read all the data from an SSH or telnet channel. | netmiko/base_connection.py | 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):
"""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... | [
"Generic",
"handler",
"that",
"will",
"read",
"all",
"the",
"data",
"from",
"an",
"SSH",
"or",
"telnet",
"channel",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L467-L476 | [
"def",
"read_channel",
"(",
"self",
")",
":",
"output",
"=",
"\"\"",
"self",
".",
"_lock_netmiko_session",
"(",
")",
"try",
":",
"output",
"=",
"self",
".",
"_read_channel",
"(",
")",
"finally",
":",
"# Always unlock the SSH channel, even on exception.",
"self",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._read_channel_expect | 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... | netmiko/base_connection.py | 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):
"""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... | [
"Function",
"that",
"reads",
"channel",
"until",
"pattern",
"is",
"detected",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L478-L541 | [
"def",
"_read_channel_expect",
"(",
"self",
",",
"pattern",
"=",
"\"\"",
",",
"re_flags",
"=",
"0",
",",
"max_loops",
"=",
"150",
")",
":",
"output",
"=",
"\"\"",
"if",
"not",
"pattern",
":",
"pattern",
"=",
"re",
".",
"escape",
"(",
"self",
".",
"ba... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._read_channel_timing | 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... | netmiko/base_connection.py | 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):
"""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... | [
"Read",
"data",
"on",
"the",
"channel",
"based",
"on",
"timing",
"delays",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L543-L586 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.read_until_prompt_or_pattern | 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 ... | netmiko/base_connection.py | 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):
"""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... | [
"Read",
"until",
"either",
"self",
".",
"base_prompt",
"or",
"pattern",
"is",
"detected",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L596-L612 | [
"def",
"read_until_prompt_or_pattern",
"(",
"self",
",",
"pattern",
"=",
"\"\"",
",",
"re_flags",
"=",
"0",
")",
":",
"combined_pattern",
"=",
"re",
".",
"escape",
"(",
"self",
".",
"base_prompt",
")",
"if",
"pattern",
":",
"combined_pattern",
"=",
"r\"({}|{... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.telnet_login | 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... | netmiko/base_connection.py | 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=1,
max_loops=20,
):
"""Telnet login. Can be username/password or just p... | [
"Telnet",
"login",
".",
"Can",
"be",
"username",
"/",
"password",
"or",
"just",
"password",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L632-L713 | [
"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",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._use_ssh_config | Update SSH connection parameters based on contents of SSH 'config' file.
:param dict_arg: Dictionary of SSH connection parameters
:type dict_arg: dict | netmiko/base_connection.py | 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):
"""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.
... | [
"Update",
"SSH",
"connection",
"parameters",
"based",
"on",
"contents",
"of",
"SSH",
"config",
"file",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L751-L786 | [
"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",
".",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._connect_params_dict | Generate dictionary of Paramiko connection parameters. | netmiko/base_connection.py | 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):
"""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,
... | [
"Generate",
"dictionary",
"of",
"Paramiko",
"connection",
"parameters",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L788-L807 | [
"def",
"_connect_params_dict",
"(",
"self",
")",
":",
"conn_dict",
"=",
"{",
"\"hostname\"",
":",
"self",
".",
"host",
",",
"\"port\"",
":",
"self",
".",
"port",
",",
"\"username\"",
":",
"self",
".",
"username",
",",
"\"password\"",
":",
"self",
".",
"p... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._sanitize_output | 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: | netmiko/base_connection.py | 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
):
"""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:... | [
"Strip",
"out",
"command",
"echo",
"trailing",
"router",
"prompt",
"and",
"ANSI",
"escape",
"codes",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L809-L828 | [
"def",
"_sanitize_output",
"(",
"self",
",",
"output",
",",
"strip_command",
"=",
"False",
",",
"command_string",
"=",
"None",
",",
"strip_prompt",
"=",
"False",
")",
":",
"if",
"self",
".",
"ansi_escape_codes",
":",
"output",
"=",
"self",
".",
"strip_ansi_e... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.establish_connection | 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
... | netmiko/base_connection.py | 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):
"""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.
... | [
"Establish",
"SSH",
"connection",
"to",
"the",
"network",
"device"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L830-L892 | [
"def",
"establish_connection",
"(",
"self",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
")",
":",
"if",
"self",
".",
"protocol",
"==",
"\"telnet\"",
":",
"self",
".",
"remote_conn",
"=",
"telnetlib",
".",
"Telnet",
"(",
"self",
".",
"host",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._build_ssh_client | Prepare for Paramiko SSH connection. | netmiko/base_connection.py | 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):
"""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 ... | [
"Prepare",
"for",
"Paramiko",
"SSH",
"connection",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L935-L948 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.select_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 | netmiko/base_connection.py | 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):
"""
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",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L950-L967 | [
"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"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.set_terminal_width | 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... | netmiko/base_connection.py | 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):
"""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.
:... | [
"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",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L996-L1016 | [
"def",
"set_terminal_width",
"(",
"self",
",",
"command",
"=",
"\"\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"if",
"not",
"command",
":",
"return",
"\"\"",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"command",
"=",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.set_base_prompt | 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... | netmiko/base_connection.py | 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
):
"""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... | [
"Sets",
"self",
".",
"base_prompt"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1018-L1045 | [
"def",
"set_base_prompt",
"(",
"self",
",",
"pri_prompt_terminator",
"=",
"\"#\"",
",",
"alt_prompt_terminator",
"=",
"\">\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"prompt",
"=",
"self",
".",
"find_prompt",
"(",
"delay_factor",
"=",
"delay_factor",
")",
"i... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.find_prompt | Finds the current network device prompt, last line only.
:param delay_factor: See __init__: global_delay_factor
:type delay_factor: int | netmiko/base_connection.py | 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):
"""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... | [
"Finds",
"the",
"current",
"network",
"device",
"prompt",
"last",
"line",
"only",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1047-L1084 | [
"def",
"find_prompt",
"(",
"self",
",",
"delay_factor",
"=",
"1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"self",
".",
"clear_buffer",
"(",
")",
"self",
".",
"write_channel",
"(",
"self",
".",
"RETURN",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.send_command_timing | 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).
... | netmiko/base_connection.py | 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
... | [
"Execute",
"command_string",
"on",
"the",
"SSH",
"channel",
"using",
"a",
"delay",
"-",
"based",
"mechanism",
".",
"Generally",
"used",
"for",
"show",
"commands",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1090-L1145 | [
"def",
"send_command_timing",
"(",
"self",
",",
"command_string",
",",
"delay_factor",
"=",
"1",
",",
"max_loops",
"=",
"150",
",",
"strip_prompt",
"=",
"True",
",",
"strip_command",
"=",
"True",
",",
"normalize",
"=",
"True",
",",
"use_textfsm",
"=",
"False... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.strip_prompt | Strip the trailing router prompt from the output.
:param a_string: Returned string from device
:type a_string: str | netmiko/base_connection.py | 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):
"""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... | [
"Strip",
"the",
"trailing",
"router",
"prompt",
"from",
"the",
"output",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1147-L1158 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection._first_line_handler | 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... | netmiko/base_connection.py | 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):
"""
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... | [
"In",
"certain",
"situations",
"the",
"first",
"line",
"will",
"get",
"repainted",
"which",
"causes",
"a",
"false",
"match",
"on",
"the",
"terminating",
"pattern",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1160-L1185 | [
"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",
"."... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.send_command | 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... | netmiko/base_connection.py | 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=True,
normalize=True,
use_textfsm=False,
):
"""Execute command_string on the SSH ... | [
"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",
"... | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1187-L1309 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.strip_command | 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... | netmiko/base_connection.py | 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):
"""
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
... | [
"Strip",
"command_string",
"from",
"output",
"string"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1332-L1354 | [
"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... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.normalize_linefeeds | 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 | netmiko/base_connection.py | 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):
"""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|... | [
"Convert",
"\\",
"r",
"\\",
"r",
"\\",
"n",
"\\",
"r",
"\\",
"n",
"\\",
"n",
"\\",
"r",
"to",
"\\",
"n",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1356-L1367 | [
"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",
")",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.normalize_cmd | Normalize CLI commands to have a single trailing newline.
:param command: Command that may require line feed to be normalized
:type command: str | netmiko/base_connection.py | def normalize_cmd(self, command):
"""Normalize CLI commands to have a single trailing newline.
:param command: Command that may require line feed to be normalized
:type command: str
"""
command = command.rstrip()
command += self.RETURN
return command | def normalize_cmd(self, command):
"""Normalize CLI commands to have a single trailing newline.
:param command: Command that may require line feed to be normalized
:type command: str
"""
command = command.rstrip()
command += self.RETURN
return command | [
"Normalize",
"CLI",
"commands",
"to",
"have",
"a",
"single",
"trailing",
"newline",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1369-L1377 | [
"def",
"normalize_cmd",
"(",
"self",
",",
"command",
")",
":",
"command",
"=",
"command",
".",
"rstrip",
"(",
")",
"command",
"+=",
"self",
".",
"RETURN",
"return",
"command"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.check_enable_mode | Check if in enable mode. Return boolean.
:param check_string: Identification of privilege mode from device
:type check_string: str | netmiko/base_connection.py | def check_enable_mode(self, check_string=""):
"""Check if in enable mode. Return boolean.
:param check_string: Identification of privilege mode from device
:type check_string: str
"""
self.write_channel(self.RETURN)
output = self.read_until_prompt()
return check_... | def check_enable_mode(self, check_string=""):
"""Check if in enable mode. Return boolean.
:param check_string: Identification of privilege mode from device
:type check_string: str
"""
self.write_channel(self.RETURN)
output = self.read_until_prompt()
return check_... | [
"Check",
"if",
"in",
"enable",
"mode",
".",
"Return",
"boolean",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1379-L1387 | [
"def",
"check_enable_mode",
"(",
"self",
",",
"check_string",
"=",
"\"\"",
")",
":",
"self",
".",
"write_channel",
"(",
"self",
".",
"RETURN",
")",
"output",
"=",
"self",
".",
"read_until_prompt",
"(",
")",
"return",
"check_string",
"in",
"output"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.enable | Enter enable mode.
:param cmd: Device command to enter enable mode
:type cmd: str
:param pattern: pattern to search for indicating device is waiting for password
:type pattern: str
:param re_flags: Regular expression flags used in conjunction with pattern
:type re_flag... | netmiko/base_connection.py | def enable(self, cmd="", pattern="ssword", re_flags=re.IGNORECASE):
"""Enter enable mode.
:param cmd: Device command to enter enable mode
:type cmd: str
:param pattern: pattern to search for indicating device is waiting for password
:type pattern: str
:param re_flags: ... | def enable(self, cmd="", pattern="ssword", re_flags=re.IGNORECASE):
"""Enter enable mode.
:param cmd: Device command to enter enable mode
:type cmd: str
:param pattern: pattern to search for indicating device is waiting for password
:type pattern: str
:param re_flags: ... | [
"Enter",
"enable",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1389-L1418 | [
"def",
"enable",
"(",
"self",
",",
"cmd",
"=",
"\"\"",
",",
"pattern",
"=",
"\"ssword\"",
",",
"re_flags",
"=",
"re",
".",
"IGNORECASE",
")",
":",
"output",
"=",
"\"\"",
"msg",
"=",
"(",
"\"Failed to enter enable mode. Please ensure you pass \"",
"\"the 'secret'... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.exit_enable_mode | Exit enable mode.
:param exit_command: Command that exits the session from privileged mode
:type exit_command: str | netmiko/base_connection.py | def exit_enable_mode(self, exit_command=""):
"""Exit enable mode.
:param exit_command: Command that exits the session from privileged mode
:type exit_command: str
"""
output = ""
if self.check_enable_mode():
self.write_channel(self.normalize_cmd(exit_command)... | def exit_enable_mode(self, exit_command=""):
"""Exit enable mode.
:param exit_command: Command that exits the session from privileged mode
:type exit_command: str
"""
output = ""
if self.check_enable_mode():
self.write_channel(self.normalize_cmd(exit_command)... | [
"Exit",
"enable",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1420-L1432 | [
"def",
"exit_enable_mode",
"(",
"self",
",",
"exit_command",
"=",
"\"\"",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"check_enable_mode",
"(",
")",
":",
"self",
".",
"write_channel",
"(",
"self",
".",
"normalize_cmd",
"(",
"exit_command",
")",
")"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.check_config_mode | Checks if the device is in configuration mode or not.
:param check_string: Identification of configuration mode from the device
:type check_string: str
:param pattern: Pattern to terminate reading of channel
:type pattern: str | netmiko/base_connection.py | def check_config_mode(self, check_string="", pattern=""):
"""Checks if the device is in configuration mode or not.
:param check_string: Identification of configuration mode from the device
:type check_string: str
:param pattern: Pattern to terminate reading of channel
:type pat... | def check_config_mode(self, check_string="", pattern=""):
"""Checks if the device is in configuration mode or not.
:param check_string: Identification of configuration mode from the device
:type check_string: str
:param pattern: Pattern to terminate reading of channel
:type pat... | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1434-L1449 | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\"\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"self",
".",
"write_channel",
"(",
"self",
".",
"RETURN",
")",
"# You can encounter an issue here (on router name changes) prefer delay-based solution",
"if... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.config_mode | Enter into config_mode.
:param config_command: Configuration command to send to the device
:type config_command: str
:param pattern: Pattern to terminate reading of channel
:type pattern: str | netmiko/base_connection.py | def config_mode(self, config_command="", pattern=""):
"""Enter into config_mode.
:param config_command: Configuration command to send to the device
:type config_command: str
:param pattern: Pattern to terminate reading of channel
:type pattern: str
"""
output = ... | def config_mode(self, config_command="", pattern=""):
"""Enter into config_mode.
:param config_command: Configuration command to send to the device
:type config_command: str
:param pattern: Pattern to terminate reading of channel
:type pattern: str
"""
output = ... | [
"Enter",
"into",
"config_mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1451-L1466 | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"output",
"=",
"\"\"",
"if",
"not",
"self",
".",
"check_config_mode",
"(",
")",
":",
"self",
".",
"write_channel",
"(",
"self",
".",
"normalize_... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.exit_config_mode | Exit from configuration mode.
:param exit_config: Command to exit configuration mode
:type exit_config: str
:param pattern: Pattern to terminate reading of channel
:type pattern: str | netmiko/base_connection.py | def exit_config_mode(self, exit_config="", pattern=""):
"""Exit from configuration mode.
:param exit_config: Command to exit configuration mode
:type exit_config: str
:param pattern: Pattern to terminate reading of channel
:type pattern: str
"""
output = ""
... | def exit_config_mode(self, exit_config="", pattern=""):
"""Exit from configuration mode.
:param exit_config: Command to exit configuration mode
:type exit_config: str
:param pattern: Pattern to terminate reading of channel
:type pattern: str
"""
output = ""
... | [
"Exit",
"from",
"configuration",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1468-L1484 | [
"def",
"exit_config_mode",
"(",
"self",
",",
"exit_config",
"=",
"\"\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"check_config_mode",
"(",
")",
":",
"self",
".",
"write_channel",
"(",
"self",
".",
"normalize_cmd",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.send_config_from_file | Send configuration commands down the SSH channel from a file.
The file is processed line-by-line and each command is sent down the
SSH channel.
**kwargs are passed to send_config_set method.
:param config_file: Path to configuration file to be sent to the device
:type config_f... | netmiko/base_connection.py | def send_config_from_file(self, config_file=None, **kwargs):
"""
Send configuration commands down the SSH channel from a file.
The file is processed line-by-line and each command is sent down the
SSH channel.
**kwargs are passed to send_config_set method.
:param config... | def send_config_from_file(self, config_file=None, **kwargs):
"""
Send configuration commands down the SSH channel from a file.
The file is processed line-by-line and each command is sent down the
SSH channel.
**kwargs are passed to send_config_set method.
:param config... | [
"Send",
"configuration",
"commands",
"down",
"the",
"SSH",
"channel",
"from",
"a",
"file",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1486-L1502 | [
"def",
"send_config_from_file",
"(",
"self",
",",
"config_file",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"io",
".",
"open",
"(",
"config_file",
",",
"\"rt\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"as",
"cfg_file",
":",
"return",
"self"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.send_config_set | Send configuration commands down the SSH channel.
config_commands is an iterable containing all of the configuration commands.
The commands will be executed one after the other.
Automatically exits/enters configuration mode.
:param config_commands: Multiple configuration commands to b... | netmiko/base_connection.py | def send_config_set(
self,
config_commands=None,
exit_config_mode=True,
delay_factor=1,
max_loops=150,
strip_prompt=False,
strip_command=False,
config_mode_command=None,
):
"""
Send configuration commands down the SSH channel.
... | def send_config_set(
self,
config_commands=None,
exit_config_mode=True,
delay_factor=1,
max_loops=150,
strip_prompt=False,
strip_command=False,
config_mode_command=None,
):
"""
Send configuration commands down the SSH channel.
... | [
"Send",
"configuration",
"commands",
"down",
"the",
"SSH",
"channel",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1504-L1570 | [
"def",
"send_config_set",
"(",
"self",
",",
"config_commands",
"=",
"None",
",",
"exit_config_mode",
"=",
"True",
",",
"delay_factor",
"=",
"1",
",",
"max_loops",
"=",
"150",
",",
"strip_prompt",
"=",
"False",
",",
"strip_command",
"=",
"False",
",",
"config... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.strip_ansi_escape_codes | Remove any ANSI (VT100) ESC codes from the output
http://en.wikipedia.org/wiki/ANSI_escape_code
Note: this does not capture ALL possible ANSI Escape Codes only the ones
I have encountered
Current codes that are filtered:
ESC = '\x1b' or chr(27)
ESC = is the escape char... | netmiko/base_connection.py | def strip_ansi_escape_codes(self, string_buffer):
"""
Remove any ANSI (VT100) ESC codes from the output
http://en.wikipedia.org/wiki/ANSI_escape_code
Note: this does not capture ALL possible ANSI Escape Codes only the ones
I have encountered
Current codes that are filt... | def strip_ansi_escape_codes(self, string_buffer):
"""
Remove any ANSI (VT100) ESC codes from the output
http://en.wikipedia.org/wiki/ANSI_escape_code
Note: this does not capture ALL possible ANSI Escape Codes only the ones
I have encountered
Current codes that are filt... | [
"Remove",
"any",
"ANSI",
"(",
"VT100",
")",
"ESC",
"codes",
"from",
"the",
"output"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1572-L1658 | [
"def",
"strip_ansi_escape_codes",
"(",
"self",
",",
"string_buffer",
")",
":",
"# noqa",
"log",
".",
"debug",
"(",
"\"In strip_ansi_escape_codes\"",
")",
"log",
".",
"debug",
"(",
"\"repr = {}\"",
".",
"format",
"(",
"repr",
"(",
"string_buffer",
")",
")",
")"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.disconnect | Try to gracefully close the SSH connection. | netmiko/base_connection.py | def disconnect(self):
"""Try to gracefully close the SSH connection."""
try:
self.cleanup()
if self.protocol == "ssh":
self.paramiko_cleanup()
elif self.protocol == "telnet":
self.remote_conn.close()
elif self.protocol == "s... | def disconnect(self):
"""Try to gracefully close the SSH connection."""
try:
self.cleanup()
if self.protocol == "ssh":
self.paramiko_cleanup()
elif self.protocol == "telnet":
self.remote_conn.close()
elif self.protocol == "s... | [
"Try",
"to",
"gracefully",
"close",
"the",
"SSH",
"connection",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1669-L1685 | [
"def",
"disconnect",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"cleanup",
"(",
")",
"if",
"self",
".",
"protocol",
"==",
"\"ssh\"",
":",
"self",
".",
"paramiko_cleanup",
"(",
")",
"elif",
"self",
".",
"protocol",
"==",
"\"telnet\"",
":",
"self",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.open_session_log | Open the session_log file. | netmiko/base_connection.py | def open_session_log(self, filename, mode="write"):
"""Open the session_log file."""
if mode == "append":
self.session_log = open(filename, mode="ab")
else:
self.session_log = open(filename, mode="wb")
self._session_log_close = True | def open_session_log(self, filename, mode="write"):
"""Open the session_log file."""
if mode == "append":
self.session_log = open(filename, mode="ab")
else:
self.session_log = open(filename, mode="wb")
self._session_log_close = True | [
"Open",
"the",
"session_log",
"file",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1695-L1701 | [
"def",
"open_session_log",
"(",
"self",
",",
"filename",
",",
"mode",
"=",
"\"write\"",
")",
":",
"if",
"mode",
"==",
"\"append\"",
":",
"self",
".",
"session_log",
"=",
"open",
"(",
"filename",
",",
"mode",
"=",
"\"ab\"",
")",
"else",
":",
"self",
"."... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | BaseConnection.close_session_log | Close the session_log file (if it is a file that we opened). | netmiko/base_connection.py | def close_session_log(self):
"""Close the session_log file (if it is a file that we opened)."""
if self.session_log is not None and self._session_log_close:
self.session_log.close()
self.session_log = None | def close_session_log(self):
"""Close the session_log file (if it is a file that we opened)."""
if self.session_log is not None and self._session_log_close:
self.session_log.close()
self.session_log = None | [
"Close",
"the",
"session_log",
"file",
"(",
"if",
"it",
"is",
"a",
"file",
"that",
"we",
"opened",
")",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1703-L1707 | [
"def",
"close_session_log",
"(",
"self",
")",
":",
"if",
"self",
".",
"session_log",
"is",
"not",
"None",
"and",
"self",
".",
"_session_log_close",
":",
"self",
".",
"session_log",
".",
"close",
"(",
")",
"self",
".",
"session_log",
"=",
"None"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | IpInfusionOcNOSBase.save_config | Saves Config Using write command | netmiko/ipinfusion/ipinfusion_ocnos.py | def save_config(self, cmd="write", confirm=False, confirm_response=""):
"""Saves Config Using write command"""
return super(IpInfusionOcNOSBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | def save_config(self, cmd="write", confirm=False, confirm_response=""):
"""Saves Config Using write command"""
return super(IpInfusionOcNOSBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Saves",
"Config",
"Using",
"write",
"command"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ipinfusion/ipinfusion_ocnos.py#L24-L28 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"write\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"IpInfusionOcNOSBase",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"cmd",
",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | IpInfusionOcNOSTelnet._process_option | For all telnet options, re-implement the default telnetlib behaviour
and refuse to handle any options. If the server expresses interest in
'terminal type' option, then reply back with 'xterm' terminal type. | netmiko/ipinfusion/ipinfusion_ocnos.py | def _process_option(self, tsocket, command, option):
"""
For all telnet options, re-implement the default telnetlib behaviour
and refuse to handle any options. If the server expresses interest in
'terminal type' option, then reply back with 'xterm' terminal type.
"""
if c... | def _process_option(self, tsocket, command, option):
"""
For all telnet options, re-implement the default telnetlib behaviour
and refuse to handle any options. If the server expresses interest in
'terminal type' option, then reply back with 'xterm' terminal type.
"""
if c... | [
"For",
"all",
"telnet",
"options",
"re",
"-",
"implement",
"the",
"default",
"telnetlib",
"behaviour",
"and",
"refuse",
"to",
"handle",
"any",
"options",
".",
"If",
"the",
"server",
"expresses",
"interest",
"in",
"terminal",
"type",
"option",
"then",
"reply",
... | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ipinfusion/ipinfusion_ocnos.py#L40-L52 | [
"def",
"_process_option",
"(",
"self",
",",
"tsocket",
",",
"command",
",",
"option",
")",
":",
"if",
"command",
"==",
"DO",
"and",
"option",
"==",
"TTYPE",
":",
"tsocket",
".",
"sendall",
"(",
"IAC",
"+",
"WILL",
"+",
"TTYPE",
")",
"tsocket",
".",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | FortinetSSH.disable_paging | Disable paging is only available with specific roles so it may fail. | netmiko/fortinet/fortinet_ssh.py | def disable_paging(self, delay_factor=1):
"""Disable paging is only available with specific roles so it may fail."""
check_command = "get system status | grep Virtual"
output = self.send_command_timing(check_command)
self.allow_disable_global = True
self.vdoms = False
sel... | def disable_paging(self, delay_factor=1):
"""Disable paging is only available with specific roles so it may fail."""
check_command = "get system status | grep Virtual"
output = self.send_command_timing(check_command)
self.allow_disable_global = True
self.vdoms = False
sel... | [
"Disable",
"paging",
"is",
"only",
"available",
"with",
"specific",
"roles",
"so",
"it",
"may",
"fail",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/fortinet/fortinet_ssh.py#L27-L62 | [
"def",
"disable_paging",
"(",
"self",
",",
"delay_factor",
"=",
"1",
")",
":",
"check_command",
"=",
"\"get system status | grep Virtual\"",
"output",
"=",
"self",
".",
"send_command_timing",
"(",
"check_command",
")",
"self",
".",
"allow_disable_global",
"=",
"True... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | FortinetSSH._retrieve_output_mode | Save the state of the output mode so it can be reset at the end of the session. | netmiko/fortinet/fortinet_ssh.py | def _retrieve_output_mode(self):
"""Save the state of the output mode so it can be reset at the end of the session."""
reg_mode = re.compile(r"output\s+:\s+(?P<mode>.*)\s+\n")
output = self.send_command("get system console")
result_mode_re = reg_mode.search(output)
if result_mode... | def _retrieve_output_mode(self):
"""Save the state of the output mode so it can be reset at the end of the session."""
reg_mode = re.compile(r"output\s+:\s+(?P<mode>.*)\s+\n")
output = self.send_command("get system console")
result_mode_re = reg_mode.search(output)
if result_mode... | [
"Save",
"the",
"state",
"of",
"the",
"output",
"mode",
"so",
"it",
"can",
"be",
"reset",
"at",
"the",
"end",
"of",
"the",
"session",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/fortinet/fortinet_ssh.py#L64-L72 | [
"def",
"_retrieve_output_mode",
"(",
"self",
")",
":",
"reg_mode",
"=",
"re",
".",
"compile",
"(",
"r\"output\\s+:\\s+(?P<mode>.*)\\s+\\n\"",
")",
"output",
"=",
"self",
".",
"send_command",
"(",
"\"get system console\"",
")",
"result_mode_re",
"=",
"reg_mode",
".",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | FortinetSSH.cleanup | Re-enable paging globally. | netmiko/fortinet/fortinet_ssh.py | def cleanup(self):
"""Re-enable paging globally."""
if self.allow_disable_global:
# Return paging state
output_mode_cmd = "set output {}".format(self._output_mode)
enable_paging_commands = ["config system console", output_mode_cmd, "end"]
if self.vdoms:
... | def cleanup(self):
"""Re-enable paging globally."""
if self.allow_disable_global:
# Return paging state
output_mode_cmd = "set output {}".format(self._output_mode)
enable_paging_commands = ["config system console", output_mode_cmd, "end"]
if self.vdoms:
... | [
"Re",
"-",
"enable",
"paging",
"globally",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/fortinet/fortinet_ssh.py#L74-L84 | [
"def",
"cleanup",
"(",
"self",
")",
":",
"if",
"self",
".",
"allow_disable_global",
":",
"# Return paging state",
"output_mode_cmd",
"=",
"\"set output {}\"",
".",
"format",
"(",
"self",
".",
"_output_mode",
")",
"enable_paging_commands",
"=",
"[",
"\"config system ... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | AccedianSSH.set_base_prompt | Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output. | netmiko/accedian/accedian_ssh.py | def set_base_prompt(
self, pri_prompt_terminator=":", alt_prompt_terminator="#", delay_factor=2
):
"""Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output."""
super(AccedianSSH, self).set_base_prompt(
pri_prompt_terminator=pri_prompt_terminator,
... | def set_base_prompt(
self, pri_prompt_terminator=":", alt_prompt_terminator="#", delay_factor=2
):
"""Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output."""
super(AccedianSSH, self).set_base_prompt(
pri_prompt_terminator=pri_prompt_terminator,
... | [
"Sets",
"self",
".",
"base_prompt",
":",
"used",
"as",
"delimiter",
"for",
"stripping",
"of",
"trailing",
"prompt",
"in",
"output",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/accedian/accedian_ssh.py#L35-L44 | [
"def",
"set_base_prompt",
"(",
"self",
",",
"pri_prompt_terminator",
"=",
"\":\"",
",",
"alt_prompt_terminator",
"=",
"\"#\"",
",",
"delay_factor",
"=",
"2",
")",
":",
"super",
"(",
"AccedianSSH",
",",
"self",
")",
".",
"set_base_prompt",
"(",
"pri_prompt_termin... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HPProcurveBase.session_preparation | Prepare the session after the connection has been established.
Procurve uses - 'Press any key to continue' | netmiko/hp/hp_procurve.py | def session_preparation(self):
"""
Prepare the session after the connection has been established.
Procurve uses - 'Press any key to continue'
"""
delay_factor = self.select_delay_factor(delay_factor=0)
output = ""
count = 1
while count <= 30:
o... | def session_preparation(self):
"""
Prepare the session after the connection has been established.
Procurve uses - 'Press any key to continue'
"""
delay_factor = self.select_delay_factor(delay_factor=0)
output = ""
count = 1
while count <= 30:
o... | [
"Prepare",
"the",
"session",
"after",
"the",
"connection",
"has",
"been",
"established",
".",
"Procurve",
"uses",
"-",
"Press",
"any",
"key",
"to",
"continue"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L11-L41 | [
"def",
"session_preparation",
"(",
"self",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
"=",
"0",
")",
"output",
"=",
"\"\"",
"count",
"=",
"1",
"while",
"count",
"<=",
"30",
":",
"output",
"+=",
"self",
".",
"r... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HPProcurveBase.enable | Enter enable mode | netmiko/hp/hp_procurve.py | def enable(
self,
cmd="enable",
pattern="password",
re_flags=re.IGNORECASE,
default_username="manager",
):
"""Enter enable mode"""
if self.check_enable_mode():
return ""
output = self.send_command_timing(cmd)
if (
"usern... | def enable(
self,
cmd="enable",
pattern="password",
re_flags=re.IGNORECASE,
default_username="manager",
):
"""Enter enable mode"""
if self.check_enable_mode():
return ""
output = self.send_command_timing(cmd)
if (
"usern... | [
"Enter",
"enable",
"mode"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L43-L64 | [
"def",
"enable",
"(",
"self",
",",
"cmd",
"=",
"\"enable\"",
",",
"pattern",
"=",
"\"password\"",
",",
"re_flags",
"=",
"re",
".",
"IGNORECASE",
",",
"default_username",
"=",
"\"manager\"",
",",
")",
":",
"if",
"self",
".",
"check_enable_mode",
"(",
")",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HPProcurveBase.cleanup | Gracefully exit the SSH session. | netmiko/hp/hp_procurve.py | def cleanup(self):
"""Gracefully exit the SSH session."""
self.exit_config_mode()
self.write_channel("logout" + self.RETURN)
count = 0
while count <= 5:
time.sleep(0.5)
output = self.read_channel()
if "Do you want to log out" in output:
... | def cleanup(self):
"""Gracefully exit the SSH session."""
self.exit_config_mode()
self.write_channel("logout" + self.RETURN)
count = 0
while count <= 5:
time.sleep(0.5)
output = self.read_channel()
if "Do you want to log out" in output:
... | [
"Gracefully",
"exit",
"the",
"SSH",
"session",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L66-L86 | [
"def",
"cleanup",
"(",
"self",
")",
":",
"self",
".",
"exit_config_mode",
"(",
")",
"self",
".",
"write_channel",
"(",
"\"logout\"",
"+",
"self",
".",
"RETURN",
")",
"count",
"=",
"0",
"while",
"count",
"<=",
"5",
":",
"time",
".",
"sleep",
"(",
"0.5... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HPProcurveBase.save_config | Save Config. | netmiko/hp/hp_procurve.py | def save_config(self, cmd="write memory", confirm=False, confirm_response=""):
"""Save Config."""
return super(HPProcurveBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | def save_config(self, cmd="write memory", confirm=False, confirm_response=""):
"""Save Config."""
return super(HPProcurveBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Save",
"Config",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L88-L92 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"write memory\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"HPProcurveBase",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"cmd",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HPProcurveTelnet.telnet_login | Telnet login: can be username/password or just password. | netmiko/hp/hp_procurve.py | def telnet_login(
self,
pri_prompt_terminator="#",
alt_prompt_terminator=">",
username_pattern=r"Login Name:",
pwd_pattern=r"assword",
delay_factor=1,
max_loops=60,
):
"""Telnet login: can be username/password or just password."""
super(HPProcu... | def telnet_login(
self,
pri_prompt_terminator="#",
alt_prompt_terminator=">",
username_pattern=r"Login Name:",
pwd_pattern=r"assword",
delay_factor=1,
max_loops=60,
):
"""Telnet login: can be username/password or just password."""
super(HPProcu... | [
"Telnet",
"login",
":",
"can",
"be",
"username",
"/",
"password",
"or",
"just",
"password",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_procurve.py#L100-L117 | [
"def",
"telnet_login",
"(",
"self",
",",
"pri_prompt_terminator",
"=",
"\"#\"",
",",
"alt_prompt_terminator",
"=",
"\">\"",
",",
"username_pattern",
"=",
"r\"Login Name:\"",
",",
"pwd_pattern",
"=",
"r\"assword\"",
",",
"delay_factor",
"=",
"1",
",",
"max_loops",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.