Module netmiko.dell
Source code
from netmiko.dell.dell_dnos6 import DellDNOS6SSH
from netmiko.dell.dell_dnos6 import DellDNOS6Telnet
from netmiko.dell.dell_force10_ssh import DellForce10SSH
from netmiko.dell.dell_os10_ssh import DellOS10SSH, DellOS10FileTransfer
from netmiko.dell.dell_powerconnect import DellPowerConnectSSH
from netmiko.dell.dell_powerconnect import DellPowerConnectTelnet
from netmiko.dell.dell_isilon_ssh import DellIsilonSSH
__all__ = [
"DellForce10SSH",
"DellPowerConnectSSH",
"DellPowerConnectTelnet",
"DellOS10SSH",
"DellOS10FileTransfer",
"DellIsilonSSH",
"DellDNOS6SSH",
"DellDNOS6Telnet",
]
Sub-modules
netmiko.dell.dell_dnos6
-
Dell N2/3/4000 base driver- supports DNOS6.
netmiko.dell.dell_force10_ssh
-
Dell Force10 Driver - supports DNOS9.
netmiko.dell.dell_isilon_ssh
netmiko.dell.dell_os10_ssh
-
Dell EMC Networking OS10 Driver - supports dellos10.
netmiko.dell.dell_powerconnect
-
Dell PowerConnect Driver.
Classes
class DellDNOS6SSH (ip='', host='', username='', password=None, secret='', port=None, device_type='', verbose=False, global_delay_factor=1, global_cmd_verify=None, use_keys=False, key_file=None, pkey=None, passphrase=None, allow_agent=False, ssh_strict=False, system_host_keys=False, alt_host_keys=False, alt_key_file='', ssh_config_file=None, conn_timeout=5, auth_timeout=None, banner_timeout=15, blocking_timeout=20, timeout=100, session_timeout=60, keepalive=0, default_enter=None, response_return=None, serial_settings=None, fast_cli=False, session_log=None, session_log_record_writes=False, session_log_file_mode='write', allow_auto_change=False, encoding='ascii', sock=None, auto_connect=True)
-
Dell PowerConnect Driver.
Initialize attributes for establishing connection to target device. :param ip: IP address of target device. Not required if `host` is provided. :type ip: str :param host: Hostname of target device. Not required if `ip` is provided. :type host: str :param username: Username to authenticate against target device if required. :type username: str :param password: Password to authenticate against target device if required. :type password: str :param secret: The enable password if target device requires one. :type secret: str :param port: The destination port used to connect to the target device. :type port: int or None :param device_type: Class selection based on device type. :type device_type: str :param verbose: Enable additional messages to standard output. :type verbose: bool :param global_delay_factor: Multiplication factor affecting Netmiko delays (default: 1). :type global_delay_factor: int :param use_keys: Connect to target device using SSH keys. :type use_keys: bool :param key_file: Filename path of the SSH key file to use. :type key_file: str :param pkey: SSH key object to use. :type pkey: paramiko.PKey :param passphrase: Passphrase to use for encrypted key; password will be used for key decryption if not specified. :type passphrase: str :param allow_agent: Enable use of SSH key-agent. :type allow_agent: bool :param ssh_strict: Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). :type ssh_strict: bool :param system_host_keys: Load host keys from the users known_hosts file. :type system_host_keys: bool :param alt_host_keys: If `True` host keys will be loaded from the file specified in alt_key_file. :type alt_host_keys: bool :param alt_key_file: SSH host key file to use (if alt_host_keys=True). :type alt_key_file: str :param ssh_config_file: File name of OpenSSH configuration file. :type ssh_config_file: str :param timeout: Connection timeout. :type timeout: float :param session_timeout: Set a timeout for parallel requests. :type session_timeout: float :param auth_timeout: Set a timeout (in seconds) to wait for an authentication response. :type auth_timeout: float :param banner_timeout: Set a timeout to wait for the SSH banner (pass to Paramiko). :type banner_timeout: float :param keepalive: Send SSH keepalive packets at a specific interval, in seconds. Currently defaults to 0, for backwards compatibility (it will not attempt to keep the connection alive). :type keepalive: int :param default_enter: Character(s) to send to correspond to enter key (default:
). :type default_enter: str
:param response_return: Character(s) to use in normalized return data to represent enter key (default:
) :type response_return: str
:param fast_cli: Provide a way to optimize for performance. Converts select_delay_factor to select smallest of global and specific. Sets default global_delay_factor to .1 (default: False) :type fast_cli: boolean :param session_log: File path or BufferedIOBase subclass object to write the session log to. :type session_log: str :param session_log_record_writes: The session log generally only records channel reads due to eliminate command duplication due to command echo. You can enable this if you want to record both channel reads and channel writes in the log (default: False). :type session_log_record_writes: boolean :param session_log_file_mode: "write" or "append" for session_log file mode (default: "write") :type session_log_file_mode: str :param allow_auto_change: Allow automatic configuration changes for terminal settings. (default: False) :type allow_auto_change: bool :param encoding: Encoding to be used when writing bytes to the output channel. (default: ascii) :type encoding: str :param sock: An open socket or socket-like object (such as a `.Channel`) to use for communication to the target host (default: None). :type sock: socket :param global_cmd_verify: Control whether command echo verification is enabled or disabled (default: None). Global attribute takes precedence over function `cmd_verify` argument. Value of `None` indicates to use function `cmd_verify` argument. :type global_cmd_verify: bool|None :param auto_connect: Control whether Netmiko automatically establishes the connection as part of the object creation (default: True). :type auto_connect: bool
Source code
class DellDNOS6SSH(DellDNOS6Base): pass
Ancestors
Inherited members
DellDNOS6Base
:check_config_mode
check_enable_mode
cleanup
clear_buffer
close_session_log
commit
config_mode
disable_paging
disconnect
enable
establish_connection
exit_config_mode
exit_enable_mode
find_prompt
is_alive
normalize_cmd
normalize_linefeeds
open_session_log
paramiko_cleanup
read_channel
read_until_pattern
read_until_prompt
read_until_prompt_or_pattern
run_ttp
save_config
select_delay_factor
send_command
send_command_expect
send_command_timing
send_config_from_file
send_config_set
session_preparation
set_base_prompt
set_terminal_width
special_login_handler
strip_ansi_escape_codes
strip_backspaces
strip_command
strip_prompt
telnet_login
write_channel
class DellDNOS6Telnet (ip='', host='', username='', password=None, secret='', port=None, device_type='', verbose=False, global_delay_factor=1, global_cmd_verify=None, use_keys=False, key_file=None, pkey=None, passphrase=None, allow_agent=False, ssh_strict=False, system_host_keys=False, alt_host_keys=False, alt_key_file='', ssh_config_file=None, conn_timeout=5, auth_timeout=None, banner_timeout=15, blocking_timeout=20, timeout=100, session_timeout=60, keepalive=0, default_enter=None, response_return=None, serial_settings=None, fast_cli=False, session_log=None, session_log_record_writes=False, session_log_file_mode='write', allow_auto_change=False, encoding='ascii', sock=None, auto_connect=True)
-
Dell PowerConnect Driver.
Initialize attributes for establishing connection to target device. :param ip: IP address of target device. Not required if `host` is provided. :type ip: str :param host: Hostname of target device. Not required if `ip` is provided. :type host: str :param username: Username to authenticate against target device if required. :type username: str :param password: Password to authenticate against target device if required. :type password: str :param secret: The enable password if target device requires one. :type secret: str :param port: The destination port used to connect to the target device. :type port: int or None :param device_type: Class selection based on device type. :type device_type: str :param verbose: Enable additional messages to standard output. :type verbose: bool :param global_delay_factor: Multiplication factor affecting Netmiko delays (default: 1). :type global_delay_factor: int :param use_keys: Connect to target device using SSH keys. :type use_keys: bool :param key_file: Filename path of the SSH key file to use. :type key_file: str :param pkey: SSH key object to use. :type pkey: paramiko.PKey :param passphrase: Passphrase to use for encrypted key; password will be used for key decryption if not specified. :type passphrase: str :param allow_agent: Enable use of SSH key-agent. :type allow_agent: bool :param ssh_strict: Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). :type ssh_strict: bool :param system_host_keys: Load host keys from the users known_hosts file. :type system_host_keys: bool :param alt_host_keys: If `True` host keys will be loaded from the file specified in alt_key_file. :type alt_host_keys: bool :param alt_key_file: SSH host key file to use (if alt_host_keys=True). :type alt_key_file: str :param ssh_config_file: File name of OpenSSH configuration file. :type ssh_config_file: str :param timeout: Connection timeout. :type timeout: float :param session_timeout: Set a timeout for parallel requests. :type session_timeout: float :param auth_timeout: Set a timeout (in seconds) to wait for an authentication response. :type auth_timeout: float :param banner_timeout: Set a timeout to wait for the SSH banner (pass to Paramiko). :type banner_timeout: float :param keepalive: Send SSH keepalive packets at a specific interval, in seconds. Currently defaults to 0, for backwards compatibility (it will not attempt to keep the connection alive). :type keepalive: int :param default_enter: Character(s) to send to correspond to enter key (default:
). :type default_enter: str
:param response_return: Character(s) to use in normalized return data to represent enter key (default:
) :type response_return: str
:param fast_cli: Provide a way to optimize for performance. Converts select_delay_factor to select smallest of global and specific. Sets default global_delay_factor to .1 (default: False) :type fast_cli: boolean :param session_log: File path or BufferedIOBase subclass object to write the session log to. :type session_log: str :param session_log_record_writes: The session log generally only records channel reads due to eliminate command duplication due to command echo. You can enable this if you want to record both channel reads and channel writes in the log (default: False). :type session_log_record_writes: boolean :param session_log_file_mode: "write" or "append" for session_log file mode (default: "write") :type session_log_file_mode: str :param allow_auto_change: Allow automatic configuration changes for terminal settings. (default: False) :type allow_auto_change: bool :param encoding: Encoding to be used when writing bytes to the output channel. (default: ascii) :type encoding: str :param sock: An open socket or socket-like object (such as a `.Channel`) to use for communication to the target host (default: None). :type sock: socket :param global_cmd_verify: Control whether command echo verification is enabled or disabled (default: None). Global attribute takes precedence over function `cmd_verify` argument. Value of `None` indicates to use function `cmd_verify` argument. :type global_cmd_verify: bool|None :param auto_connect: Control whether Netmiko automatically establishes the connection as part of the object creation (default: True). :type auto_connect: bool
Source code
class DellDNOS6Telnet(DellDNOS6Base): pass
Ancestors
Inherited members
DellDNOS6Base
:check_config_mode
check_enable_mode
cleanup
clear_buffer
close_session_log
commit
config_mode
disable_paging
disconnect
enable
establish_connection
exit_config_mode
exit_enable_mode
find_prompt
is_alive
normalize_cmd
normalize_linefeeds
open_session_log
paramiko_cleanup
read_channel
read_until_pattern
read_until_prompt
read_until_prompt_or_pattern
run_ttp
save_config
select_delay_factor
send_command
send_command_expect
send_command_timing
send_config_from_file
send_config_set
session_preparation
set_base_prompt
set_terminal_width
special_login_handler
strip_ansi_escape_codes
strip_backspaces
strip_command
strip_prompt
telnet_login
write_channel
class DellForce10SSH (ip='', host='', username='', password=None, secret='', port=None, device_type='', verbose=False, global_delay_factor=1, global_cmd_verify=None, use_keys=False, key_file=None, pkey=None, passphrase=None, allow_agent=False, ssh_strict=False, system_host_keys=False, alt_host_keys=False, alt_key_file='', ssh_config_file=None, conn_timeout=5, auth_timeout=None, banner_timeout=15, blocking_timeout=20, timeout=100, session_timeout=60, keepalive=0, default_enter=None, response_return=None, serial_settings=None, fast_cli=False, session_log=None, session_log_record_writes=False, session_log_file_mode='write', allow_auto_change=False, encoding='ascii', sock=None, auto_connect=True)
-
Dell Force10 Driver - supports DNOS9.
Initialize attributes for establishing connection to target device. :param ip: IP address of target device. Not required if `host` is provided. :type ip: str :param host: Hostname of target device. Not required if `ip` is provided. :type host: str :param username: Username to authenticate against target device if required. :type username: str :param password: Password to authenticate against target device if required. :type password: str :param secret: The enable password if target device requires one. :type secret: str :param port: The destination port used to connect to the target device. :type port: int or None :param device_type: Class selection based on device type. :type device_type: str :param verbose: Enable additional messages to standard output. :type verbose: bool :param global_delay_factor: Multiplication factor affecting Netmiko delays (default: 1). :type global_delay_factor: int :param use_keys: Connect to target device using SSH keys. :type use_keys: bool :param key_file: Filename path of the SSH key file to use. :type key_file: str :param pkey: SSH key object to use. :type pkey: paramiko.PKey :param passphrase: Passphrase to use for encrypted key; password will be used for key decryption if not specified. :type passphrase: str :param allow_agent: Enable use of SSH key-agent. :type allow_agent: bool :param ssh_strict: Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). :type ssh_strict: bool :param system_host_keys: Load host keys from the users known_hosts file. :type system_host_keys: bool :param alt_host_keys: If `True` host keys will be loaded from the file specified in alt_key_file. :type alt_host_keys: bool :param alt_key_file: SSH host key file to use (if alt_host_keys=True). :type alt_key_file: str :param ssh_config_file: File name of OpenSSH configuration file. :type ssh_config_file: str :param timeout: Connection timeout. :type timeout: float :param session_timeout: Set a timeout for parallel requests. :type session_timeout: float :param auth_timeout: Set a timeout (in seconds) to wait for an authentication response. :type auth_timeout: float :param banner_timeout: Set a timeout to wait for the SSH banner (pass to Paramiko). :type banner_timeout: float :param keepalive: Send SSH keepalive packets at a specific interval, in seconds. Currently defaults to 0, for backwards compatibility (it will not attempt to keep the connection alive). :type keepalive: int :param default_enter: Character(s) to send to correspond to enter key (default:
). :type default_enter: str
:param response_return: Character(s) to use in normalized return data to represent enter key (default:
) :type response_return: str
:param fast_cli: Provide a way to optimize for performance. Converts select_delay_factor to select smallest of global and specific. Sets default global_delay_factor to .1 (default: False) :type fast_cli: boolean :param session_log: File path or BufferedIOBase subclass object to write the session log to. :type session_log: str :param session_log_record_writes: The session log generally only records channel reads due to eliminate command duplication due to command echo. You can enable this if you want to record both channel reads and channel writes in the log (default: False). :type session_log_record_writes: boolean :param session_log_file_mode: "write" or "append" for session_log file mode (default: "write") :type session_log_file_mode: str :param allow_auto_change: Allow automatic configuration changes for terminal settings. (default: False) :type allow_auto_change: bool :param encoding: Encoding to be used when writing bytes to the output channel. (default: ascii) :type encoding: str :param sock: An open socket or socket-like object (such as a `.Channel`) to use for communication to the target host (default: None). :type sock: socket :param global_cmd_verify: Control whether command echo verification is enabled or disabled (default: None). Global attribute takes precedence over function `cmd_verify` argument. Value of `None` indicates to use function `cmd_verify` argument. :type global_cmd_verify: bool|None :param auto_connect: Control whether Netmiko automatically establishes the connection as part of the object creation (default: True). :type auto_connect: bool
Source code
class DellForce10SSH(CiscoSSHConnection): """Dell Force10 Driver - supports DNOS9.""" def save_config( self, cmd="copy running-configuration startup-configuration", confirm=False, confirm_response="", ): """Saves Config""" return super().save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
Ancestors
Methods
def save_config(self, cmd='copy running-configuration startup-configuration', confirm=False, confirm_response='')
-
Saves Config
Source code
def save_config( self, cmd="copy running-configuration startup-configuration", confirm=False, confirm_response="", ): """Saves Config""" return super().save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
Inherited members
CiscoSSHConnection
:check_config_mode
check_enable_mode
cleanup
clear_buffer
close_session_log
commit
config_mode
disable_paging
disconnect
enable
establish_connection
exit_config_mode
exit_enable_mode
find_prompt
is_alive
normalize_cmd
normalize_linefeeds
open_session_log
paramiko_cleanup
read_channel
read_until_pattern
read_until_prompt
read_until_prompt_or_pattern
run_ttp
select_delay_factor
send_command
send_command_expect
send_command_timing
send_config_from_file
send_config_set
session_preparation
set_base_prompt
set_terminal_width
special_login_handler
strip_ansi_escape_codes
strip_backspaces
strip_command
strip_prompt
telnet_login
write_channel
class DellIsilonSSH (ip='', host='', username='', password=None, secret='', port=None, device_type='', verbose=False, global_delay_factor=1, global_cmd_verify=None, use_keys=False, key_file=None, pkey=None, passphrase=None, allow_agent=False, ssh_strict=False, system_host_keys=False, alt_host_keys=False, alt_key_file='', ssh_config_file=None, conn_timeout=5, auth_timeout=None, banner_timeout=15, blocking_timeout=20, timeout=100, session_timeout=60, keepalive=0, default_enter=None, response_return=None, serial_settings=None, fast_cli=False, session_log=None, session_log_record_writes=False, session_log_file_mode='write', allow_auto_change=False, encoding='ascii', sock=None, auto_connect=True)
-
Defines vendor independent methods.
Otherwise method left as a stub method.
Initialize attributes for establishing connection to target device. :param ip: IP address of target device. Not required if `host` is provided. :type ip: str :param host: Hostname of target device. Not required if `ip` is provided. :type host: str :param username: Username to authenticate against target device if required. :type username: str :param password: Password to authenticate against target device if required. :type password: str :param secret: The enable password if target device requires one. :type secret: str :param port: The destination port used to connect to the target device. :type port: int or None :param device_type: Class selection based on device type. :type device_type: str :param verbose: Enable additional messages to standard output. :type verbose: bool :param global_delay_factor: Multiplication factor affecting Netmiko delays (default: 1). :type global_delay_factor: int :param use_keys: Connect to target device using SSH keys. :type use_keys: bool :param key_file: Filename path of the SSH key file to use. :type key_file: str :param pkey: SSH key object to use. :type pkey: paramiko.PKey :param passphrase: Passphrase to use for encrypted key; password will be used for key decryption if not specified. :type passphrase: str :param allow_agent: Enable use of SSH key-agent. :type allow_agent: bool :param ssh_strict: Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). :type ssh_strict: bool :param system_host_keys: Load host keys from the users known_hosts file. :type system_host_keys: bool :param alt_host_keys: If `True` host keys will be loaded from the file specified in alt_key_file. :type alt_host_keys: bool :param alt_key_file: SSH host key file to use (if alt_host_keys=True). :type alt_key_file: str :param ssh_config_file: File name of OpenSSH configuration file. :type ssh_config_file: str :param timeout: Connection timeout. :type timeout: float :param session_timeout: Set a timeout for parallel requests. :type session_timeout: float :param auth_timeout: Set a timeout (in seconds) to wait for an authentication response. :type auth_timeout: float :param banner_timeout: Set a timeout to wait for the SSH banner (pass to Paramiko). :type banner_timeout: float :param keepalive: Send SSH keepalive packets at a specific interval, in seconds. Currently defaults to 0, for backwards compatibility (it will not attempt to keep the connection alive). :type keepalive: int :param default_enter: Character(s) to send to correspond to enter key (default:
). :type default_enter: str
:param response_return: Character(s) to use in normalized return data to represent enter key (default:
) :type response_return: str
:param fast_cli: Provide a way to optimize for performance. Converts select_delay_factor to select smallest of global and specific. Sets default global_delay_factor to .1 (default: False) :type fast_cli: boolean :param session_log: File path or BufferedIOBase subclass object to write the session log to. :type session_log: str :param session_log_record_writes: The session log generally only records channel reads due to eliminate command duplication due to command echo. You can enable this if you want to record both channel reads and channel writes in the log (default: False). :type session_log_record_writes: boolean :param session_log_file_mode: "write" or "append" for session_log file mode (default: "write") :type session_log_file_mode: str :param allow_auto_change: Allow automatic configuration changes for terminal settings. (default: False) :type allow_auto_change: bool :param encoding: Encoding to be used when writing bytes to the output channel. (default: ascii) :type encoding: str :param sock: An open socket or socket-like object (such as a `.Channel`) to use for communication to the target host (default: None). :type sock: socket :param global_cmd_verify: Control whether command echo verification is enabled or disabled (default: None). Global attribute takes precedence over function `cmd_verify` argument. Value of `None` indicates to use function `cmd_verify` argument. :type global_cmd_verify: bool|None :param auto_connect: Control whether Netmiko automatically establishes the connection as part of the object creation (default: True). :type auto_connect: bool
Source code
class DellIsilonSSH(BaseConnection): def set_base_prompt( self, pri_prompt_terminator="$", alt_prompt_terminator="#", delay_factor=1 ): """Determine base prompt.""" return super().set_base_prompt( pri_prompt_terminator=pri_prompt_terminator, alt_prompt_terminator=alt_prompt_terminator, delay_factor=delay_factor, ) def strip_ansi_escape_codes(self, string_buffer): """Remove Null code""" output = re.sub(r"\x00", "", string_buffer) return super().strip_ansi_escape_codes(output) 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_factor) self.clear_buffer() 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_factor) self.set_prompt() self.clear_buffer() def set_prompt(self, prompt_terminator="$"): prompt = f"PROMPT='%m{prompt_terminator}'" command = self.RETURN + prompt + self.RETURN self.write_channel(command) def disable_paging(self, *args, **kwargs): """Isilon doesn't have paging by default.""" pass def check_enable_mode(self, *args, **kwargs): """No enable mode on Isilon.""" pass def enable(self, *args, **kwargs): """No enable mode on Isilon.""" pass def exit_enable_mode(self, *args, **kwargs): """No enable mode on Isilon.""" pass def check_config_mode(self, check_string="#"): return super().check_config_mode(check_string=check_string) 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_command=False ) if "Password:" in output: output = self.write_channel(self.normalize_cmd(self.secret)) self.set_prompt(prompt_terminator="#") time.sleep(1 * delay_factor) self.set_base_prompt() if not self.check_config_mode(): raise ValueError("Failed to configuration mode") return output def exit_config_mode(self, exit_config="exit"): """Exit enable mode.""" return super().exit_config_mode(exit_config=exit_config)
Ancestors
Methods
def check_enable_mode(self, *args, **kwargs)
-
No enable mode on Isilon.
Source code
def check_enable_mode(self, *args, **kwargs): """No enable mode on Isilon.""" pass
def config_mode(self, config_command='sudo su')
-
Attempt to become root.
Source code
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_command=False ) if "Password:" in output: output = self.write_channel(self.normalize_cmd(self.secret)) self.set_prompt(prompt_terminator="#") time.sleep(1 * delay_factor) self.set_base_prompt() if not self.check_config_mode(): raise ValueError("Failed to configuration mode") return output
def disable_paging(self, *args, **kwargs)
-
Isilon doesn't have paging by default.
Source code
def disable_paging(self, *args, **kwargs): """Isilon doesn't have paging by default.""" pass
def enable(self, *args, **kwargs)
-
No enable mode on Isilon.
Source code
def enable(self, *args, **kwargs): """No enable mode on Isilon.""" pass
def exit_config_mode(self, exit_config='exit')
-
Exit enable mode.
Source code
def exit_config_mode(self, exit_config="exit"): """Exit enable mode.""" return super().exit_config_mode(exit_config=exit_config)
def exit_enable_mode(self, *args, **kwargs)
-
No enable mode on Isilon.
Source code
def exit_enable_mode(self, *args, **kwargs): """No enable mode on Isilon.""" pass
def session_preparation(self)
-
Prepare the session after the connection has been established.
Source code
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_factor) self.clear_buffer()
def set_base_prompt(self, pri_prompt_terminator='$', alt_prompt_terminator='#', delay_factor=1)
-
Determine base prompt.
Source code
def set_base_prompt( self, pri_prompt_terminator="$", alt_prompt_terminator="#", delay_factor=1 ): """Determine base prompt.""" return super().set_base_prompt( pri_prompt_terminator=pri_prompt_terminator, alt_prompt_terminator=alt_prompt_terminator, delay_factor=delay_factor, )
def set_prompt(self, prompt_terminator='$')
-
Source code
def set_prompt(self, prompt_terminator="$"): prompt = f"PROMPT='%m{prompt_terminator}'" command = self.RETURN + prompt + self.RETURN self.write_channel(command)
def strip_ansi_escape_codes(self, string_buffer)
-
Remove Null code
Source code
def strip_ansi_escape_codes(self, string_buffer): """Remove Null code""" output = re.sub(r"\x00", "", string_buffer) return super().strip_ansi_escape_codes(output)
def zsh_mode(self, delay_factor=1, prompt_terminator='$')
-
Run zsh command to unify the environment
Source code
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_factor) self.set_prompt() self.clear_buffer()
Inherited members
BaseConnection
:check_config_mode
cleanup
clear_buffer
close_session_log
commit
disconnect
establish_connection
find_prompt
is_alive
normalize_cmd
normalize_linefeeds
open_session_log
paramiko_cleanup
read_channel
read_until_pattern
read_until_prompt
read_until_prompt_or_pattern
run_ttp
save_config
select_delay_factor
send_command
send_command_expect
send_command_timing
send_config_from_file
send_config_set
set_terminal_width
special_login_handler
strip_backspaces
strip_command
strip_prompt
telnet_login
write_channel
class DellOS10FileTransfer (ssh_conn, source_file, dest_file, file_system='/home/admin', direction='put', **kwargs)
-
Dell EMC Networking OS10 SCP File Transfer driver.
Source code
class DellOS10FileTransfer(BaseFileTransfer): """Dell EMC Networking OS10 SCP File Transfer driver.""" def __init__( self, ssh_conn, source_file, dest_file, file_system="/home/admin", direction="put", **kwargs, ): super().__init__( ssh_conn=ssh_conn, source_file=source_file, dest_file=dest_file, file_system=file_system, direction=direction, **kwargs, ) self.folder_name = "/config" def remote_file_size(self, remote_cmd="", remote_file=None): """Get the file size of the remote file.""" if remote_file is None: if self.direction == "put": remote_file = self.dest_file elif self.direction == "get": remote_file = self.source_file remote_cmd = f'system "ls -l {self.file_system}/{remote_file}"' remote_out = self.ssh_ctl_chan.send_command(remote_cmd) for line in remote_out.splitlines(): if remote_file in line: file_size = line.split()[4] break if "Error opening" in remote_out or "No such file or directory" in remote_out: raise IOError("Unable to find file on remote system") else: return int(file_size) def remote_space_available(self, search_pattern=r"(\d+) bytes free"): """Return space available on remote device.""" remote_cmd = f'system "df {self.folder_name}"' remote_output = self.ssh_ctl_chan.send_command_expect(remote_cmd) for line in remote_output.splitlines(): if self.folder_name in line: space_available = line.split()[-3] break return int(space_available) @staticmethod def process_md5(md5_output, pattern=r"(.*) (.*)"): return super(DellOS10FileTransfer, DellOS10FileTransfer).process_md5( md5_output, pattern=r"(.*) (.*)" ) def remote_md5(self, base_cmd="verify /md5", remote_file=None): """Calculate remote MD5 and returns the hash. """ if remote_file is None: if self.direction == "put": remote_file = self.dest_file elif self.direction == "get": remote_file = self.source_file remote_md5_cmd = f'system "md5sum {self.file_system}/{remote_file}"' dest_md5 = self.ssh_ctl_chan.send_command(remote_md5_cmd, max_loops=1500) dest_md5 = self.process_md5(dest_md5) return dest_md5.strip() 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.dest_file) return bool(re.search(search_string, remote_out, flags=re.DOTALL)) elif self.direction == "get": return os.path.exists(self.dest_file) def put_file(self): """SCP copy the file from the local system to the remote device.""" destination = f"{self.dest_file}" self.scp_conn.scp_transfer_file(self.source_file, destination) # Must close the SCP connection to get the file written (flush) self.scp_conn.close() def get_file(self): """SCP copy the file from the remote device to local system.""" source_file = f"{self.source_file}" self.scp_conn.scp_get_file(source_file, self.dest_file) self.scp_conn.close()
Ancestors
Methods
def remote_md5(self, base_cmd='verify /md5', remote_file=None)
-
Calculate remote MD5 and returns the hash.
Source code
def remote_md5(self, base_cmd="verify /md5", remote_file=None): """Calculate remote MD5 and returns the hash. """ if remote_file is None: if self.direction == "put": remote_file = self.dest_file elif self.direction == "get": remote_file = self.source_file remote_md5_cmd = f'system "md5sum {self.file_system}/{remote_file}"' dest_md5 = self.ssh_ctl_chan.send_command(remote_md5_cmd, max_loops=1500) dest_md5 = self.process_md5(dest_md5) return dest_md5.strip()
Inherited members
class DellOS10SSH (ip='', host='', username='', password=None, secret='', port=None, device_type='', verbose=False, global_delay_factor=1, global_cmd_verify=None, use_keys=False, key_file=None, pkey=None, passphrase=None, allow_agent=False, ssh_strict=False, system_host_keys=False, alt_host_keys=False, alt_key_file='', ssh_config_file=None, conn_timeout=5, auth_timeout=None, banner_timeout=15, blocking_timeout=20, timeout=100, session_timeout=60, keepalive=0, default_enter=None, response_return=None, serial_settings=None, fast_cli=False, session_log=None, session_log_record_writes=False, session_log_file_mode='write', allow_auto_change=False, encoding='ascii', sock=None, auto_connect=True)
-
Dell EMC Networking OS10 Driver - supports dellos10.
Initialize attributes for establishing connection to target device. :param ip: IP address of target device. Not required if `host` is provided. :type ip: str :param host: Hostname of target device. Not required if `ip` is provided. :type host: str :param username: Username to authenticate against target device if required. :type username: str :param password: Password to authenticate against target device if required. :type password: str :param secret: The enable password if target device requires one. :type secret: str :param port: The destination port used to connect to the target device. :type port: int or None :param device_type: Class selection based on device type. :type device_type: str :param verbose: Enable additional messages to standard output. :type verbose: bool :param global_delay_factor: Multiplication factor affecting Netmiko delays (default: 1). :type global_delay_factor: int :param use_keys: Connect to target device using SSH keys. :type use_keys: bool :param key_file: Filename path of the SSH key file to use. :type key_file: str :param pkey: SSH key object to use. :type pkey: paramiko.PKey :param passphrase: Passphrase to use for encrypted key; password will be used for key decryption if not specified. :type passphrase: str :param allow_agent: Enable use of SSH key-agent. :type allow_agent: bool :param ssh_strict: Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). :type ssh_strict: bool :param system_host_keys: Load host keys from the users known_hosts file. :type system_host_keys: bool :param alt_host_keys: If `True` host keys will be loaded from the file specified in alt_key_file. :type alt_host_keys: bool :param alt_key_file: SSH host key file to use (if alt_host_keys=True). :type alt_key_file: str :param ssh_config_file: File name of OpenSSH configuration file. :type ssh_config_file: str :param timeout: Connection timeout. :type timeout: float :param session_timeout: Set a timeout for parallel requests. :type session_timeout: float :param auth_timeout: Set a timeout (in seconds) to wait for an authentication response. :type auth_timeout: float :param banner_timeout: Set a timeout to wait for the SSH banner (pass to Paramiko). :type banner_timeout: float :param keepalive: Send SSH keepalive packets at a specific interval, in seconds. Currently defaults to 0, for backwards compatibility (it will not attempt to keep the connection alive). :type keepalive: int :param default_enter: Character(s) to send to correspond to enter key (default:
). :type default_enter: str
:param response_return: Character(s) to use in normalized return data to represent enter key (default:
) :type response_return: str
:param fast_cli: Provide a way to optimize for performance. Converts select_delay_factor to select smallest of global and specific. Sets default global_delay_factor to .1 (default: False) :type fast_cli: boolean :param session_log: File path or BufferedIOBase subclass object to write the session log to. :type session_log: str :param session_log_record_writes: The session log generally only records channel reads due to eliminate command duplication due to command echo. You can enable this if you want to record both channel reads and channel writes in the log (default: False). :type session_log_record_writes: boolean :param session_log_file_mode: "write" or "append" for session_log file mode (default: "write") :type session_log_file_mode: str :param allow_auto_change: Allow automatic configuration changes for terminal settings. (default: False) :type allow_auto_change: bool :param encoding: Encoding to be used when writing bytes to the output channel. (default: ascii) :type encoding: str :param sock: An open socket or socket-like object (such as a `.Channel`) to use for communication to the target host (default: None). :type sock: socket :param global_cmd_verify: Control whether command echo verification is enabled or disabled (default: None). Global attribute takes precedence over function `cmd_verify` argument. Value of `None` indicates to use function `cmd_verify` argument. :type global_cmd_verify: bool|None :param auto_connect: Control whether Netmiko automatically establishes the connection as part of the object creation (default: True). :type auto_connect: bool
Source code
class DellOS10SSH(CiscoSSHConnection): """Dell EMC Networking OS10 Driver - supports dellos10.""" def save_config( self, cmd="copy running-configuration startup-configuration", confirm=False, confirm_response="", ): """Saves Config""" return super().save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
Ancestors
Methods
def save_config(self, cmd='copy running-configuration startup-configuration', confirm=False, confirm_response='')
-
Saves Config
Source code
def save_config( self, cmd="copy running-configuration startup-configuration", confirm=False, confirm_response="", ): """Saves Config""" return super().save_config( cmd=cmd, confirm=confirm, confirm_response=confirm_response )
Inherited members
CiscoSSHConnection
:check_config_mode
check_enable_mode
cleanup
clear_buffer
close_session_log
commit
config_mode
disable_paging
disconnect
enable
establish_connection
exit_config_mode
exit_enable_mode
find_prompt
is_alive
normalize_cmd
normalize_linefeeds
open_session_log
paramiko_cleanup
read_channel
read_until_pattern
read_until_prompt
read_until_prompt_or_pattern
run_ttp
select_delay_factor
send_command
send_command_expect
send_command_timing
send_config_from_file
send_config_set
session_preparation
set_base_prompt
set_terminal_width
special_login_handler
strip_ansi_escape_codes
strip_backspaces
strip_command
strip_prompt
telnet_login
write_channel
class DellPowerConnectSSH (ip='', host='', username='', password=None, secret='', port=None, device_type='', verbose=False, global_delay_factor=1, global_cmd_verify=None, use_keys=False, key_file=None, pkey=None, passphrase=None, allow_agent=False, ssh_strict=False, system_host_keys=False, alt_host_keys=False, alt_key_file='', ssh_config_file=None, conn_timeout=5, auth_timeout=None, banner_timeout=15, blocking_timeout=20, timeout=100, session_timeout=60, keepalive=0, default_enter=None, response_return=None, serial_settings=None, fast_cli=False, session_log=None, session_log_record_writes=False, session_log_file_mode='write', allow_auto_change=False, encoding='ascii', sock=None, auto_connect=True)
-
Dell PowerConnect Driver.
To make it work, we have to override the SSHClient _auth method. If we use login/password, the ssh server use the (none) auth mechanism.
Initialize attributes for establishing connection to target device. :param ip: IP address of target device. Not required if `host` is provided. :type ip: str :param host: Hostname of target device. Not required if `ip` is provided. :type host: str :param username: Username to authenticate against target device if required. :type username: str :param password: Password to authenticate against target device if required. :type password: str :param secret: The enable password if target device requires one. :type secret: str :param port: The destination port used to connect to the target device. :type port: int or None :param device_type: Class selection based on device type. :type device_type: str :param verbose: Enable additional messages to standard output. :type verbose: bool :param global_delay_factor: Multiplication factor affecting Netmiko delays (default: 1). :type global_delay_factor: int :param use_keys: Connect to target device using SSH keys. :type use_keys: bool :param key_file: Filename path of the SSH key file to use. :type key_file: str :param pkey: SSH key object to use. :type pkey: paramiko.PKey :param passphrase: Passphrase to use for encrypted key; password will be used for key decryption if not specified. :type passphrase: str :param allow_agent: Enable use of SSH key-agent. :type allow_agent: bool :param ssh_strict: Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). :type ssh_strict: bool :param system_host_keys: Load host keys from the users known_hosts file. :type system_host_keys: bool :param alt_host_keys: If `True` host keys will be loaded from the file specified in alt_key_file. :type alt_host_keys: bool :param alt_key_file: SSH host key file to use (if alt_host_keys=True). :type alt_key_file: str :param ssh_config_file: File name of OpenSSH configuration file. :type ssh_config_file: str :param timeout: Connection timeout. :type timeout: float :param session_timeout: Set a timeout for parallel requests. :type session_timeout: float :param auth_timeout: Set a timeout (in seconds) to wait for an authentication response. :type auth_timeout: float :param banner_timeout: Set a timeout to wait for the SSH banner (pass to Paramiko). :type banner_timeout: float :param keepalive: Send SSH keepalive packets at a specific interval, in seconds. Currently defaults to 0, for backwards compatibility (it will not attempt to keep the connection alive). :type keepalive: int :param default_enter: Character(s) to send to correspond to enter key (default:
). :type default_enter: str
:param response_return: Character(s) to use in normalized return data to represent enter key (default:
) :type response_return: str
:param fast_cli: Provide a way to optimize for performance. Converts select_delay_factor to select smallest of global and specific. Sets default global_delay_factor to .1 (default: False) :type fast_cli: boolean :param session_log: File path or BufferedIOBase subclass object to write the session log to. :type session_log: str :param session_log_record_writes: The session log generally only records channel reads due to eliminate command duplication due to command echo. You can enable this if you want to record both channel reads and channel writes in the log (default: False). :type session_log_record_writes: boolean :param session_log_file_mode: "write" or "append" for session_log file mode (default: "write") :type session_log_file_mode: str :param allow_auto_change: Allow automatic configuration changes for terminal settings. (default: False) :type allow_auto_change: bool :param encoding: Encoding to be used when writing bytes to the output channel. (default: ascii) :type encoding: str :param sock: An open socket or socket-like object (such as a `.Channel`) to use for communication to the target host (default: None). :type sock: socket :param global_cmd_verify: Control whether command echo verification is enabled or disabled (default: None). Global attribute takes precedence over function `cmd_verify` argument. Value of `None` indicates to use function `cmd_verify` argument. :type global_cmd_verify: bool|None :param auto_connect: Control whether Netmiko automatically establishes the connection as part of the object creation (default: True). :type auto_connect: bool
Source code
class DellPowerConnectSSH(DellPowerConnectBase): """Dell PowerConnect Driver. To make it work, we have to override the SSHClient _auth method. If we use login/password, the ssh server use the (none) auth mechanism. """ def _build_ssh_client(self): """Prepare for Paramiko SSH connection. See base_connection.py file for any updates. """ # Create instance of SSHClient object # If user does not provide SSH key, we use noauth if not self.use_keys: remote_conn_pre = SSHClient_noauth() else: remote_conn_pre = SSHClient() # Load host_keys for better SSH security if self.system_host_keys: remote_conn_pre.load_system_host_keys() if self.alt_host_keys and path.isfile(self.alt_key_file): remote_conn_pre.load_host_keys(self.alt_key_file) # Default is to automatically add untrusted hosts (make sure appropriate for your env) remote_conn_pre.set_missing_host_key_policy(self.key_policy) return remote_conn_pre def special_login_handler(self, delay_factor=1): """ Powerconnect presents with the following on login User Name: Password: **** """ delay_factor = self.select_delay_factor(delay_factor) i = 0 time.sleep(delay_factor * 0.5) output = "" while i <= 12: output = self.read_channel() if output: if "User Name:" in output: self.write_channel(self.username + self.RETURN) elif "Password:" in output: self.write_channel(self.password + self.RETURN) break time.sleep(delay_factor * 1) else: self.write_channel(self.RETURN) time.sleep(delay_factor * 1.5) i += 1
Ancestors
Methods
def special_login_handler(self, delay_factor=1)
-
Powerconnect presents with the following on login
User Name:
Password: ****
Source code
def special_login_handler(self, delay_factor=1): """ Powerconnect presents with the following on login User Name: Password: **** """ delay_factor = self.select_delay_factor(delay_factor) i = 0 time.sleep(delay_factor * 0.5) output = "" while i <= 12: output = self.read_channel() if output: if "User Name:" in output: self.write_channel(self.username + self.RETURN) elif "Password:" in output: self.write_channel(self.password + self.RETURN) break time.sleep(delay_factor * 1) else: self.write_channel(self.RETURN) time.sleep(delay_factor * 1.5) i += 1
Inherited members
DellPowerConnectBase
:check_config_mode
check_enable_mode
cleanup
clear_buffer
close_session_log
commit
config_mode
disable_paging
disconnect
enable
establish_connection
exit_config_mode
exit_enable_mode
find_prompt
is_alive
normalize_cmd
normalize_linefeeds
open_session_log
paramiko_cleanup
read_channel
read_until_pattern
read_until_prompt
read_until_prompt_or_pattern
run_ttp
save_config
select_delay_factor
send_command
send_command_expect
send_command_timing
send_config_from_file
send_config_set
session_preparation
set_base_prompt
set_terminal_width
strip_ansi_escape_codes
strip_backspaces
strip_command
strip_prompt
telnet_login
write_channel
class DellPowerConnectTelnet (ip='', host='', username='', password=None, secret='', port=None, device_type='', verbose=False, global_delay_factor=1, global_cmd_verify=None, use_keys=False, key_file=None, pkey=None, passphrase=None, allow_agent=False, ssh_strict=False, system_host_keys=False, alt_host_keys=False, alt_key_file='', ssh_config_file=None, conn_timeout=5, auth_timeout=None, banner_timeout=15, blocking_timeout=20, timeout=100, session_timeout=60, keepalive=0, default_enter=None, response_return=None, serial_settings=None, fast_cli=False, session_log=None, session_log_record_writes=False, session_log_file_mode='write', allow_auto_change=False, encoding='ascii', sock=None, auto_connect=True)
-
Dell PowerConnect Telnet Driver.
Initialize attributes for establishing connection to target device. :param ip: IP address of target device. Not required if `host` is provided. :type ip: str :param host: Hostname of target device. Not required if `ip` is provided. :type host: str :param username: Username to authenticate against target device if required. :type username: str :param password: Password to authenticate against target device if required. :type password: str :param secret: The enable password if target device requires one. :type secret: str :param port: The destination port used to connect to the target device. :type port: int or None :param device_type: Class selection based on device type. :type device_type: str :param verbose: Enable additional messages to standard output. :type verbose: bool :param global_delay_factor: Multiplication factor affecting Netmiko delays (default: 1). :type global_delay_factor: int :param use_keys: Connect to target device using SSH keys. :type use_keys: bool :param key_file: Filename path of the SSH key file to use. :type key_file: str :param pkey: SSH key object to use. :type pkey: paramiko.PKey :param passphrase: Passphrase to use for encrypted key; password will be used for key decryption if not specified. :type passphrase: str :param allow_agent: Enable use of SSH key-agent. :type allow_agent: bool :param ssh_strict: Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). :type ssh_strict: bool :param system_host_keys: Load host keys from the users known_hosts file. :type system_host_keys: bool :param alt_host_keys: If `True` host keys will be loaded from the file specified in alt_key_file. :type alt_host_keys: bool :param alt_key_file: SSH host key file to use (if alt_host_keys=True). :type alt_key_file: str :param ssh_config_file: File name of OpenSSH configuration file. :type ssh_config_file: str :param timeout: Connection timeout. :type timeout: float :param session_timeout: Set a timeout for parallel requests. :type session_timeout: float :param auth_timeout: Set a timeout (in seconds) to wait for an authentication response. :type auth_timeout: float :param banner_timeout: Set a timeout to wait for the SSH banner (pass to Paramiko). :type banner_timeout: float :param keepalive: Send SSH keepalive packets at a specific interval, in seconds. Currently defaults to 0, for backwards compatibility (it will not attempt to keep the connection alive). :type keepalive: int :param default_enter: Character(s) to send to correspond to enter key (default:
). :type default_enter: str
:param response_return: Character(s) to use in normalized return data to represent enter key (default:
) :type response_return: str
:param fast_cli: Provide a way to optimize for performance. Converts select_delay_factor to select smallest of global and specific. Sets default global_delay_factor to .1 (default: False) :type fast_cli: boolean :param session_log: File path or BufferedIOBase subclass object to write the session log to. :type session_log: str :param session_log_record_writes: The session log generally only records channel reads due to eliminate command duplication due to command echo. You can enable this if you want to record both channel reads and channel writes in the log (default: False). :type session_log_record_writes: boolean :param session_log_file_mode: "write" or "append" for session_log file mode (default: "write") :type session_log_file_mode: str :param allow_auto_change: Allow automatic configuration changes for terminal settings. (default: False) :type allow_auto_change: bool :param encoding: Encoding to be used when writing bytes to the output channel. (default: ascii) :type encoding: str :param sock: An open socket or socket-like object (such as a `.Channel`) to use for communication to the target host (default: None). :type sock: socket :param global_cmd_verify: Control whether command echo verification is enabled or disabled (default: None). Global attribute takes precedence over function `cmd_verify` argument. Value of `None` indicates to use function `cmd_verify` argument. :type global_cmd_verify: bool|None :param auto_connect: Control whether Netmiko automatically establishes the connection as part of the object creation (default: True). :type auto_connect: bool
Source code
class DellPowerConnectTelnet(DellPowerConnectBase): """Dell PowerConnect Telnet Driver.""" pass
Ancestors
Inherited members
DellPowerConnectBase
:check_config_mode
check_enable_mode
cleanup
clear_buffer
close_session_log
commit
config_mode
disable_paging
disconnect
enable
establish_connection
exit_config_mode
exit_enable_mode
find_prompt
is_alive
normalize_cmd
normalize_linefeeds
open_session_log
paramiko_cleanup
read_channel
read_until_pattern
read_until_prompt
read_until_prompt_or_pattern
run_ttp
save_config
select_delay_factor
send_command
send_command_expect
send_command_timing
send_config_from_file
send_config_set
session_preparation
set_base_prompt
set_terminal_width
special_login_handler
strip_ansi_escape_codes
strip_backspaces
strip_command
strip_prompt
telnet_login
write_channel