### session_preparation Source: https://ktbyers.github.io/netmiko/docs/netmiko/juniper/juniper_screenos.html Handles initial session setup specific to ScreenOS, addressing potential agreement prompts. ```APIDOC ## session_preparation ### Description Handles initial session setup specific to ScreenOS, addressing potential agreement prompts like 'Accept this agreement y/[n]'. ### Method Signature `session_preparation(self) -> None` ### Parameters None ``` -------------------------------- ### CienaSaos10SSH.session_preparation Source: https://ktbyers.github.io/netmiko/docs/netmiko/ciena/ciena_saos.html Performs essential session setup tasks for Ciena SAOS devices, including channel testing, prompt setting, and disabling pagination. ```APIDOC ## CienaSaos10SSH.session_preparation ### Description This method prepares the SSH session by performing initial channel checks, setting the base prompt, and disabling command output pagination. ### Method ```python def session_preparation(self) -> None: """Performs session preparation tasks. """ ``` ### Details - Calls `_test_channel_read()` to verify channel readability. - Calls `set_base_prompt()` to establish the device's command prompt. - Calls `disable_paging(command='set session more off')` to turn off output pagination. ``` -------------------------------- ### CienaSaos10SSH Session Preparation Source: https://ktbyers.github.io/netmiko/docs/netmiko/ciena/index.html This method is part of the CienaSaos10SSH class, handling initial connection setup. It tests the channel, sets the base prompt, and disables paging. ```python class CienaSaos10SSH(NoEnable, BaseConnection): def session_preparation(self) -> None: self._test_channel_read() self.set_base_prompt() self.disable_paging(command="set session more off") ``` -------------------------------- ### session_preparation Source: https://ktbyers.github.io/netmiko/docs/netmiko/hillstone/hillstone.html Performs necessary session setup after a connection to the Hillstone device has been established. ```APIDOC ## session_preparation ### Description Prepare the session after the connection to the Hillstone device has been established. ### Method Signature `session_preparation(self) -> None` ### Parameters None ``` -------------------------------- ### Generic SNMP GET Wrapper Source: https://ktbyers.github.io/netmiko/docs/netmiko/snmp_autodetect.html Wrapper function to select the appropriate SNMP GET method based on the configured SNMP version (v1, v2c, or v3). ```python def _get_snmp(self, oid: str) -> str: """Wrapper for generic SNMP call.""" if self.snmp_version in ["v1", "v2c"]: return self._get_snmpv2c(oid) else: return self._get_snmpv3(oid) ``` -------------------------------- ### Get Remote File Size (Dell OS10) Source: https://ktbyers.github.io/netmiko/docs/netmiko/dell/index.html Retrieves the size of a remote file on the Dell OS10 device. It constructs a 'ls -l' command to get file details. ```python def remote_file_size( self, remote_cmd: str = "", remote_file: Optional[str] = None ) -> int: """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 else: raise ValueError("self.direction is set to an invalid value") remote_cmd = f'system "ls -l {self.file_system}/{remote_file}"' remote_out = self.ssh_ctl_chan._send_command_str(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) ``` -------------------------------- ### Get Output Mode for FortiOS V7 Source: https://ktbyers.github.io/netmiko/docs/netmiko/fortinet/fortinet_ssh.html Retrieves the current console output mode for FortiOS V7 and later. It handles VDOM configurations and parses the 'get system console' output. ```python def _get_output_mode_v7(self) -> str: """ FortiOS V7 and later. Retrieve the current output mode. """ if self._vdoms: self._config_global() output = self._send_command_str( "get system console", expect_string=self.prompt_pattern ) if self._vdoms: self._exit_config_global() pattern = r"output\s+:\s+(?P\S+)\s*$" result_mode_re = re.search(pattern, output, flags=re.M) if result_mode_re: result_mode = result_mode_re.group("mode").strip() if result_mode in ["more", "standard"]: return result_mode raise ValueError("Unable to determine the output mode on the Fortinet device.") ``` -------------------------------- ### BintecBossBase Initialization Source: https://ktbyers.github.io/netmiko/docs/netmiko/bintec/bintec_boss.html Initialize attributes for establishing connection to target device. ```APIDOC ## BintecBossBase Class ### Description Provides support for BinTec/Funkwerk (BOSS) devices. ### Initialization Parameters - **ip** (str) - Optional - IP address of target device. Not required if `host` is provided. - **host** (str) - Optional - Hostname of target device. Not required if `ip` is provided. - **username** (str) - Optional - Username to authenticate against target device if required. - **password** (Optional[str]) - Optional - Password to authenticate against target device if required. - **secret** (str) - Optional - The enable password if target device requires one. - **port** (Optional[int]) - Optional - The destination port used to connect to the target device. - **device_type** (str) - Optional - Class selection based on device type. - **verbose** (bool) - Optional - Enable additional messages to standard output. - **global_delay_factor** (float) - Optional - Multiplication factor affecting Netmiko delays (default: 1.0). - **global_cmd_verify** (Optional[bool]) - Optional - Whether to verify commands globally. - **use_keys** (bool) - Optional - Connect to target device using SSH keys. - **key_file** (Optional[str]) - Optional - Filename path of the SSH key file to use. - **pkey** (Optional[paramiko.pkey.PKey]) - Optional - SSH key object to use. - **passphrase** (Optional[str]) - Optional - Passphrase to use for encrypted key; password will be used for key decryption if not specified. - **disabled_algorithms** (Optional[Dict[str, Any]]) - Optional - Dictionary of SSH algorithms to disable. Refer to the Paramiko documentation for a description of the expected format. - **disable_sha2_fix** (bool) - Optional - Boolean that fixes Paramiko issue with missing server-sig-algs (default: False). - **allow_agent** (bool) - Optional - Enable use of SSH key-agent. - **ssh_strict** (bool) - Optional - Automatically reject unknown SSH host keys (default: False). - **system_host_keys** (bool) - Optional - Load host keys from the users known_hosts file. - **alt_host_keys** (bool) - Optional - If `True` host keys will be loaded from the file specified in alt_key_file. - **alt_key_file** (str) - Optional - SSH host key file to use (if alt_host_keys=True). - **ssh_config_file** (Optional[str]) - Optional - File name of OpenSSH configuration file. - **conn_timeout** (int) - Optional - TCP connection timeout (default: 10). - **auth_timeout** (Optional[int]) - Optional - Set a timeout (in seconds) to wait for an authentication response. - **banner_timeout** (int) - Optional - Set a timeout to wait for the SSH banner (pass to Paramiko) (default: 15). - **blocking_timeout** (int) - Optional - Set a timeout for blocking operations (default: 20). - **timeout** (int) - Optional - General timeout for operations (default: 100). - **session_timeout** (int) - Optional - Set a timeout for parallel requests (default: 60). - **read_timeout_override** (Optional[float]) - Optional - Set a timeout that will override the default read_timeout of both send_command and send_command_timing. - **keepalive** (int) - Optional - Send SSH keepalive packets at a specific interval, in seconds (default: 0). - **default_enter** (Optional[str]) - Optional - Character(s) to send to correspond to enter key. - **response_return** (Optional[str]) - Optional - Character(s) to use in normalized return data to represent enter key. - **serial_settings** (Optional[Dict[str, Any]]) - Optional - Dictionary of settings for use with serial port (pySerial). - **fast_cli** (bool) - Optional - 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: True). - **session_log** (Optional[SessionLog]) - Optional - File path, SessionLog object, or BufferedIOBase subclass object to write the session log to. - **session_log_record_writes** (bool) - Optional - Whether to record writes to the session log. - **session_log_file_mode** (str) - Optional - Mode for writing to the session log file. - **allow_auto_change** (bool) - Optional - Whether to allow automatic changes. - **encoding** (str) - Optional - Encoding to use for session communication (default: 'utf-8'). - **sock** (Optional[socket.socket]) - Optional - A pre-established socket object to use for the connection. - **sock_telnet** (Optional[Dict[str, Any]]) - Optional - Dictionary of settings for Telnet over socket. - **auto_connect** (bool) - Optional - Whether to automatically connect upon instantiation (default: True). - **delay_factor_compat** (bool) - Optional - Compatibility flag for delay factor adjustments. - **disable_lf_normalization** (bool) - Optional - Whether to disable newline character normalization. ``` -------------------------------- ### BintecBossSSH Initialization Source: https://ktbyers.github.io/netmiko/docs/netmiko/bintec/bintec_boss.html Initialize attributes for establishing connection to target device. ```APIDOC ## BintecBossSSH ### Description Initializes attributes for establishing a connection to a BinTec/Funkwerk (BOSS) device via SSH. ### Parameters - **ip** (str) - Optional - IP address of target device. Not required if `host` is provided. - **host** (str) - Optional - Hostname of target device. Not required if `ip` is provided. - **username** (str) - Optional - Username to authenticate against target device if required. - **password** (str) - Optional - Password to authenticate against target device if required. - **secret** (str) - Optional - The enable password if target device requires one. - **port** (int) - Optional - The destination port used to connect to the target device. - **device_type** (str) - Optional - Class selection based on device type. - **verbose** (bool) - Optional - Enable additional messages to standard output. - **global_delay_factor** (float) - Optional - Multiplication factor affecting Netmiko delays (default: 1.0). - **use_keys** (bool) - Optional - Connect to target device using SSH keys. - **key_file** (str) - Optional - Filename path of the SSH key file to use. - **pkey** (paramiko.pkey.PKey) - Optional - SSH key object to use. - **passphrase** (str) - Optional - Passphrase to use for encrypted key; password will be used for key decryption if not specified. - **disabled_algorithms** (Dict[str, Any]) - Optional - Dictionary of SSH algorithms to disable. Refer to the Paramiko documentation for a description of the expected format. - **disable_sha2_fix** (bool) - Optional - Boolean that fixes Paramiko issue with missing server-sig-algs (default: False). - **allow_agent** (bool) - Optional - Enable use of SSH key-agent. - **ssh_strict** (bool) - Optional - Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). - **system_host_keys** (bool) - Optional - Load host keys from the users known_hosts file. - **alt_host_keys** (bool) - Optional - If `True` host keys will be loaded from the file specified in `alt_key_file`. - **alt_key_file** (str) - Optional - SSH host key file to use (if alt_host_keys=True). - **ssh_config_file** (str) - Optional - File name of OpenSSH configuration file. - **conn_timeout** (int) - Optional - TCP connection timeout. - **session_timeout** (int) - Optional - Set a timeout for parallel requests. - **auth_timeout** (int) - Optional - Set a timeout (in seconds) to wait for an authentication response. - **banner_timeout** (int) - Optional - Set a timeout to wait for the SSH banner (pass to Paramiko). - **read_timeout_override** (float) - Optional - Set a timeout that will override the default read_timeout of both send_command and send_command_timing. This is useful for 3rd party ``` -------------------------------- ### SNMPv2c GET Operation (Legacy) Source: https://ktbyers.github.io/netmiko/docs/netmiko/snmp_autodetect.html Performs an SNMP GET operation using SNMPv2c for a specified OID with legacy pysnmp versions. Returns the retrieved string value or an empty string if an error occurs or no data is found. ```python def _get_snmpv2c(self, oid: str) -> str: """ Try to send an SNMP GET operation using SNMPv2 for the specified OID. Parameters ---------- oid : str The SNMP OID that you want to get. Returns ------- string : str The string as part of the value from the OID you are trying to retrieve. """ if SNMP_MODE == "legacy": cmd_gen = cmdgen.CommandGenerator() (error_detected, error_status, error_index, snmp_data) = cmd_gen.getCmd( cmdgen.CommunityData(self.community), self.udp_transport_target, oid, lookupNames=True, lookupValues=True, ) if not error_detected and snmp_data[0][1]: return str(snmp_data[0][1]) return "" elif SNMP_MODE == "v6_async": return self._get_snmpv2c_asyncwr(oid=oid) else: raise ValueError("SNMP mode must be set to 'legacy' or 'v6_async'") ``` -------------------------------- ### SNMPv3 GET Operation (Legacy) Source: https://ktbyers.github.io/netmiko/docs/netmiko/snmp_autodetect.html Performs an SNMP GET operation using SNMPv3 for a specified OID with legacy pysnmp versions. Returns the retrieved string value or an empty string if an error occurs or no data is found. ```python def _get_snmpv3(self, oid: str) -> str: """ Try to send an SNMP GET operation using SNMPv3 for the specified OID. Parameters ---------- oid : str The SNMP OID that you want to get. Returns ------- string : str The string as part of the value from the OID you are trying to retrieve. """ if SNMP_MODE == "legacy": cmd_gen = cmdgen.CommandGenerator() (error_detected, error_status, error_index, snmp_data) = cmd_gen.getCmd( cmdgen.UsmUserData( self.user, self.auth_key, self.encrypt_key, authProtocol=self.auth_proto, privProtocol=self.encryp_proto, ), self.udp_transport_target, oid, lookupNames=True, lookupValues=True, ) if not error_detected and snmp_data[0][1]: return str(snmp_data[0][1]) return "" elif SNMP_MODE == "v6_async": return self._get_snmpv3_asyncwr(oid=oid) else: raise ValueError("SNMP mode must be set to 'legacy' or 'v6_async'") ``` -------------------------------- ### Check if Remote File Exists Source: https://ktbyers.github.io/netmiko/docs/netmiko/dell/index.html Determines if a file exists on the remote SONiC system. For 'put' operations, it checks the destination file; for 'get' operations, it would typically check the source file (though the provided snippet is incomplete for 'get'). Uses 'dir' command and regex search. ```python def check_file_exists(self, remote_cmd: str = "dir home:/") -> bool: """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_str(remote_cmd) search_string = rf"{self.dest_file}" return bool(re.search(search_string, remote_out, flags=re.DOTALL)) elif self.direction == "get": ``` -------------------------------- ### KeymileNOSSSH Initialization Source: https://ktbyers.github.io/netmiko/docs/netmiko/keymile/keymile_nos_ssh.html Initialize attributes for establishing a connection to a target Keymile device via SSH. ```APIDOC ## KeymileNOSSSH Constructor ### Description Initializes the KeymileNOSSSH class with parameters required for establishing an SSH connection to a Keymile device. ### Parameters - **ip** (str) - Optional - IP address of the target device. Not required if `host` is provided. - **host** (str) - Optional - Hostname of the target device. Not required if `ip` is provided. - **username** (str) - Optional - Username for authentication. - **password** (Optional[str]) - Optional - Password for authentication. - **secret** (str) - Optional - The enable password if required by the target device. - **port** (Optional[int]) - Optional - The destination port for the connection. - **device_type** (str) - Optional - Class selection based on device type. - **verbose** (bool) - Optional - Enable additional messages to standard output. - **global_delay_factor** (float) - Optional - Multiplication factor affecting Netmiko delays (default: 1.0). - **global_cmd_verify** (Optional[bool]) - Optional - Whether to verify commands globally. - **use_keys** (bool) - Optional - Connect using SSH keys (default: False). - **key_file** (Optional[str]) - Optional - Path to the SSH key file. - **pkey** (Optional[paramiko.pkey.PKey]) - Optional - SSH key object to use. - **passphrase** (Optional[str]) - Optional - Passphrase for encrypted keys. - **disabled_algorithms** (Optional[Dict[str, Any]]) - Optional - Dictionary of SSH algorithms to disable. - **disable_sha2_fix** (bool) - Optional - Fix for Paramiko issue with missing server-sig-algs (default: False). - **allow_agent** (bool) - Optional - Enable use of SSH key-agent (default: False). - **ssh_strict** (bool) - Optional - Automatically reject unknown SSH host keys (default: False). - **system_host_keys** (bool) - Optional - Load host keys from the user's known_hosts file. - **alt_host_keys** (bool) - Optional - Load host keys from `alt_key_file` if True. - **alt_key_file** (str) - Optional - SSH host key file to use when `alt_host_keys` is True. - **ssh_config_file** (Optional[str]) - Optional - Filename of OpenSSH configuration file. - **conn_timeout** (int) - Optional - TCP connection timeout (default: 10). - **auth_timeout** (Optional[int]) - Optional - Timeout for authentication response. - **banner_timeout** (int) - Optional - Timeout to wait for the SSH banner (default: 15). - **blocking_timeout** (int) - Optional - Blocking timeout (default: 20). - **timeout** (int) - Optional - General timeout (default: 100). - **session_timeout** (int) - Optional - Timeout for parallel requests (default: 60). - **read_timeout_override** (Optional[float]) - Optional - Override default read_timeout for send_command methods. - **keepalive** (int) - Optional - Interval in seconds to send SSH keepalive packets (default: 0). - **default_enter** (Optional[str]) - Optional - Character(s) to send for the enter key. - **response_return** (Optional[str]) - Optional - Character(s) to use in normalized return data for the enter key. - **serial_settings** (Optional[Dict[str, Any]]) - Optional - Dictionary of settings for serial port connections. - **fast_cli** (bool) - Optional - Optimize for performance (default: True). - **session_log** (Optional[SessionLog]) - Optional - File path or object to write the session log to. - **session_log_record_writes** (bool) - Optional - Record session writes to the log (default: False). - **session_log_file_mode** (str) - Optional - Mode for writing to the session log file (default: 'write'). - **allow_auto_change** (bool) - Optional - Allow automatic changes (default: False). - **encoding** (str) - Optional - Encoding for session data (default: 'utf-8'). - **sock** (Optional[socket.socket]) - Optional - Socket object to use for connection. - **sock_telnet** (Optional[Dict[str, Any]]) - Optional - Dictionary of settings for telnet socket. - **auto_connect** (bool) - Optional - Automatically connect upon initialization (default: True). - **delay_factor_compat** (bool) - Optional - Compatibility flag for delay factor (default: False). - **disable_lf_normalization** (bool) - Optional - Disable LF normalization (default: False). ``` -------------------------------- ### CienaSaosSSH Initialization Source: https://ktbyers.github.io/netmiko/docs/netmiko/ciena/ciena_saos.html Initialize attributes for establishing connection to target device. ```APIDOC ## CienaSaosSSH ### Description Ciena SAOS support. Implements methods for interacting Ciena Saos devices. ### Parameters - **ip** (str) - IP address of target device. Not required if `host` is provided. - **host** (str) - Hostname of target device. Not required if `ip` is provided. - **username** (str) - Username to authenticate against target device if required. - **password** (Optional[str]) - Password to authenticate against target device if required. - **secret** (str) - The enable password if target device requires one. - **port** (Optional[int]) - The destination port used to connect to the target device. - **device_type** (str) - Class selection based on device type. - **verbose** (bool) - Enable additional messages to standard output. - **global_delay_factor** (float) - Multiplication factor affecting Netmiko delays (default: 1.0). - **global_cmd_verify** (Optional[bool]) - Global command verification setting. - **use_keys** (bool) - Connect to target device using SSH keys. - **key_file** (Optional[str]) - Filename path of the SSH key file to use. - **pkey** (Optional[paramiko.pkey.PKey]) - SSH key object to use. - **passphrase** (Optional[str]) - Passphrase to use for encrypted key; password will be used for key decryption if not specified. - **disabled_algorithms** (Optional[Dict[str, Any]]) - Dictionary of SSH algorithms to disable. Refer to the Paramiko documentation for a description of the expected format. - **disable_sha2_fix** (bool) - Boolean that fixes Paramiko issue with missing server-sig-algs (default: False). - **allow_agent** (bool) - Enable use of SSH key-agent. - **ssh_strict** (bool) - Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). - **system_host_keys** (bool) - Load host keys from the users known_hosts file. - **alt_host_keys** (bool) - If `True` host keys will be loaded from the file specified in alt_key_file. - **alt_key_file** (str) - SSH host key file to use (if alt_host_keys=True). - **ssh_config_file** (Optional[str]) - File name of OpenSSH configuration file. - **conn_timeout** (int) - TCP connection timeout. - **auth_timeout** (Optional[int]) - Set a timeout (in seconds) to wait for an authentication response. - **banner_timeout** (int) - Set a timeout to wait for the SSH banner (pass to Paramiko). - **blocking_timeout** (int) - Set a timeout for blocking operations. - **timeout** (int) - General timeout for operations. - **session_timeout** (int) - Set a timeout for parallel requests. - **read_timeout_override** (Optional[float]) - Set a timeout that will override the default read_timeout of both send_command and send_command_timing. This is useful for 3rd party libraries where directly accessing method arguments might be impractical. - **keepalive** (int) - 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). - **default_enter** (Optional[str]) - Character(s) to send to correspond to enter key. - **response_return** (Optional[str]) - Character(s) to use in normalized return data to represent enter key. - **serial_settings** (Optional[Dict[str, Any]]) - Settings for serial connections. - **fast_cli** (bool) - Enable fast CLI mode (default: True). - **session_log** (Optional[SessionLog]) - Session log object. - **session_log_record_writes** (bool) - Record writes to the session log. - **session_log_file_mode** (str) - Mode for writing to the session log file. - **allow_auto_change** (bool) - Allow automatic change of privilege levels. - **encoding** (str) - Encoding to use for communication (default: 'utf-8'). - **sock** (Optional[socket.socket]) - Socket object to use for connection. - **sock_telnet** (Optional[Dict[str, Any]]) - Dictionary of settings for Telnet socket. - **auto_connect** (bool) - Automatically connect upon initialization (default: True). - **delay_factor_compat** (bool) - Enable delay factor compatibility mode (default: False). - **disable_lf_normalization** (bool) - Disable newline normalization (default: False). ``` -------------------------------- ### _remote_file_size_unix Source: https://ktbyers.github.io/netmiko/docs/netmiko/scp_handler.html Internal method to get the file size of a remote file on a Unix-like system. ```APIDOC ## _remote_file_size_unix ### Description Internal method to get the file size of a remote file on a Unix-like system. ### Method `_remote_file_size_unix(remote_cmd: str = "", remote_file: Optional[str] = None, search_pattern: str = "")` ### Parameters - **remote_cmd** (str) - Optional - The command to execute on the remote device. If not provided, a default command is used. - **remote_file** (Optional[str]) - Optional - The name of the remote file. If not provided, it defaults to `self.dest_file` for 'put' direction or `self.source_file` for 'get' direction. - **search_pattern** (str) - Optional - A regex pattern to expect in the command output, used to determine if the command completed successfully. ``` -------------------------------- ### Ubiquiti EdgeSwitch Session Preparation Source: https://ktbyers.github.io/netmiko/docs/netmiko/ubiquiti/index.html Initializes the session by testing channel read, setting the base prompt, entering enable mode, re-setting the prompt, setting terminal width, disabling paging, and clearing the buffer. ```python def session_preparation(self) -> None: self._test_channel_read() self.set_base_prompt() self.enable() self.set_base_prompt() self.set_terminal_width() self.disable_paging() # Clear the read buffer time.sleep(0.3 * self.global_delay_factor) self.clear_buffer() ``` -------------------------------- ### NetApp Session Preparation and Command Execution Source: https://ktbyers.github.io/netmiko/docs/netmiko/netapp/index.html This snippet shows how to prepare a NetApp session by setting the base prompt and disabling paging. It also includes a method for sending commands that might require a 'y/n' confirmation. ```python class NetAppcDotSSH(NoEnable, BaseConnection): def session_preparation(self) -> None: """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 send_command_with_y(self, *args: Any, **kwargs: Any) -> str: output = self._send_command_timing_str(*args, **kwargs) if "{y|n}" in output: output += self._send_command_timing_str( "y", strip_prompt=False, strip_command=False ) return output ``` -------------------------------- ### F5LinuxSSH Initialization Source: https://ktbyers.github.io/netmiko/docs/netmiko/f5/f5_linux_ssh.html Initializes attributes for establishing a connection to an F5 Linux target device. ```APIDOC ## Class: F5LinuxSSH ### Description Base Class for cisco-like behavior. ### Parameters - **ip** (str) - IP address of target device. Not required if `host` is provided. - **host** (str) - Hostname of target device. Not required if `ip` is provided. - **username** (str) - Username to authenticate against target device if required. - **password** (Optional[str]) - Password to authenticate against target device if required. - **secret** (str) - The enable password if target device requires one. - **port** (Optional[int]) - The destination port used to connect to the target device. - **device_type** (str) - Class selection based on device type. - **verbose** (bool) - Enable additional messages to standard output. - **global_delay_factor** (float) - Multiplication factor affecting Netmiko delays (default: 1.0). - **use_keys** (bool) - Connect to target device using SSH keys. - **key_file** (Optional[str]) - Filename path of the SSH key file to use. - **pkey** (Optional[paramiko.pkey.PKey]) - SSH key object to use. - **passphrase** (Optional[str]) - Passphrase to use for encrypted key; password will be used for key decryption if not specified. - **disabled_algorithms** (Optional[Dict[str, Any]]) - Dictionary of SSH algorithms to disable. Refer to the Paramiko documentation for a description of the expected format. - **disable_sha2_fix** (bool) - Boolean that fixes Paramiko issue with missing server-sig-algs (default: False). - **allow_agent** (bool) - Enable use of SSH key-agent. - **ssh_strict** (bool) - Automatically reject unknown SSH host keys (default: False). - **system_host_keys** (bool) - Load host keys from the users known_hosts file. - **alt_host_keys** (bool) - If `True` host keys will be loaded from the file specified in alt_key_file. - **alt_key_file** (str) - SSH host key file to use (if alt_host_keys=True). - **ssh_config_file** (Optional[str]) - File name of OpenSSH configuration file. - **conn_timeout** (int) - TCP connection timeout. - **auth_timeout** (Optional[int]) - Set a timeout (in seconds) to wait for an authentication response. - **banner_timeout** (int) - Set a timeout to wait for the SSH banner (pass to Paramiko). - **read_timeout_override** (Optional[float]) - Set a timeout that will override the default read_timeout of both send_command and send_command_timing. - **keepalive** (int) - Send SSH keepalive packets at a specific interval, in seconds (default: 0). - **default_enter** (Optional[str]) - Character(s) to send to correspond to enter key. - **response_return** (Optional[str]) - Character(s) to use in normalized return data to represent enter key. - **serial_settings** (Optional[Dict[str, Any]]) - Dictionary of settings for use with serial port (pySerial). - **fast_cli** (bool) - Optimize for performance by adjusting delay factors (default: True). - **session_log** (Optional[SessionLog]) - File path, SessionLog object, or BufferedIOBase subclass object to write the session log to. - **session_log_record_writes** (bool) - Whether to record writes to the session log. - **session_log_file_mode** (str) - Mode for writing to the session log file. - **allow_auto_change** (bool) - Allow automatic changes. - **encoding** (str) - Encoding to use for the session (default: 'utf-8'). - **sock** (Optional[socket.socket]) - Existing socket object to use for the connection. - **sock_telnet** (Optional[Dict[str, Any]]) - Dictionary of settings for Telnet socket. - **auto_connect** (bool) - Automatically connect to the device upon initialization (default: True). - **delay_factor_compat** (bool) - Enable delay factor compatibility mode. - **disable_lf_normalization** (bool) - Disable newline character normalization. ``` -------------------------------- ### main_ep Source: https://ktbyers.github.io/netmiko/docs/netmiko/cli_tools/netmiko_bulk_encrypt.html An alternative entry point for the netmiko_bulk_encrypt script, possibly for specific command-line interface setups. ```APIDOC ## main_ep ### Description This function provides an alternative entry point for the `netmiko_bulk_encrypt` script. It might be used in different execution contexts or for specific command-line interface configurations. ``` -------------------------------- ### BaseConnection Initialization Source: https://ktbyers.github.io/netmiko/docs/netmiko/base_connection.html The `BaseConnection` class constructor accepts numerous parameters to configure the connection to a network device. These parameters cover authentication, timeouts, SSH settings, and session logging. ```APIDOC ## BaseConnection ### Description Initializes attributes for establishing connection to target device. ### Parameters - **ip** (str) - IP address of target device. Not required if `host` is provided. - **host** (str) - Hostname of target device. Not required if `ip` is provided. - **username** (str) - Username to authenticate against target device if required. - **password** (Optional[str]) - Password to authenticate against target device if required. - **secret** (str) - The enable password if target device requires one. - **port** (Optional[int]) - The destination port used to connect to the target device. - **device_type** (str) - The type of network device (e.g., 'cisco_ios', 'juniper_junos'). - **verbose** (bool) - Enables verbose output for debugging. - **global_delay_factor** (float) - Multiplier for delays between commands. - **global_cmd_verify** (Optional[bool]) - Global control for command echo verification. - **use_keys** (bool) - Use SSH keys for authentication. - **key_file** (Optional[str]) - Path to the SSH private key file. - **pkey** (Optional[paramiko.PKey]) - SSH private key object. - **passphrase** (Optional[str]) - Passphrase for the SSH private key. - **disabled_algorithms** (Optional[Dict[str, Any]]) - Dictionary of disabled SSH algorithms. - **disable_sha2_fix** (bool) - Disable the SHA2 fix for certain SSH versions. - **allow_agent** (bool) - Allow SSH agent forwarding. - **ssh_strict** (bool) - Enforce strict SSH host key checking. - **system_host_keys** (bool) - Use system-wide SSH host keys. - **alt_host_keys** (bool) - Use alternative SSH host keys. - **alt_key_file** (str) - Path to alternative SSH host key file. - **ssh_config_file** (Optional[str]) - Path to SSH configuration file. - **conn_timeout** (int) - Timeout for establishing the TCP connection. - **auth_timeout** (Optional[int]) - Timeout for waiting for authentication response. - **banner_timeout** (int) - Timeout for waiting for the SSH banner. - **blocking_timeout** (int) - Timeout for read operations. - **timeout** (int) - General timeout for connection and read operations. - **session_timeout** (int) - Timeout for session locking/sharing. - **read_timeout_override** (Optional[float]) - Override for read timeout. - **keepalive** (int) - Interval for sending keepalive packets. - **default_enter** (Optional[str]) - Default string to send for Enter key. - **response_return** (Optional[str]) - String to indicate end of response. - **serial_settings** (Optional[Dict[str, Any]]) - Dictionary of serial port settings. - **fast_cli** (bool) - Enable fast CLI mode. - **_legacy_mode** (bool) - Enable legacy mode. - **session_log** (Optional[SessionLog]) - Session log object. - **session_log_record_writes** (bool) - Record channel writes in session log. - **session_log_file_mode** (str) - Mode for session log file ('write' or 'append'). - **allow_auto_change** (bool) - Allow automatic configuration changes for terminal settings. - **encoding** (str) - Encoding for writing bytes to the output channel. - **sock** (Optional[socket.socket]) - An open socket or socket-like object. - **sock_telnet** (Optional[Dict[str, Any]]) - Dictionary of telnet socket parameters. - **auto_connect** (bool) - Automatically establish the connection upon object creation. - **delay_factor_compat** (bool) - Use Netmiko 3.x delay factor behavior. - **disable_lf_normalization** (bool) - Disable linefeed normalization. ``` -------------------------------- ### SCP File Transfer (Get) Source: https://ktbyers.github.io/netmiko/docs/netmiko/scp_handler.html Retrieves a file from the remote device to the local system using SCP. ```python def scp_get_file(self, source_file: str, dest_file: str) -> None: """Get file using SCP.""" self.scp_client.get(source_file, dest_file) ``` -------------------------------- ### session_preparation Source: https://ktbyers.github.io/netmiko/docs/netmiko/adtran/adtran.html Prepares the network session after a connection to the Adtran device has been established. This is typically used for initial setup or verification. ```APIDOC ## session_preparation ### Description Prepare the session after the connection has been established. ### Method Signature `session_preparation(self) -> None` ### Parameters None ``` -------------------------------- ### Juniper Base Class Initialization and Session Preparation Source: https://ktbyers.github.io/netmiko/docs/netmiko/juniper/juniper.html Initializes the JuniperBase class and prepares the session by setting terminal width, disabling paging, and setting the base prompt. This method is crucial for ensuring a stable and predictable session with Juniper devices. ```python class JuniperBase(NoEnable, BaseConnection): """ Implement methods for interacting with Juniper Networks devices. methods. Overrides several methods for Juniper-specific compatibility. """ def session_preparation(self) -> None: """Prepare the session after the connection has been established.""" pattern = r"[%>$#]" self._test_channel_read(pattern=pattern) self.enter_cli_mode() cmd = "set cli screen-width 511" self.set_terminal_width(command=cmd, pattern=r"Screen width set to") # Overloading disable_paging which is confusing self.disable_paging( command="set cli complete-on-space off", pattern=r"Disabling complete-on-space", ) self.disable_paging( command="set cli screen-length 0", pattern=r"Screen length set to" ) self.set_base_prompt() ``` -------------------------------- ### enable Source: https://ktbyers.github.io/netmiko/docs/netmiko/linux/index.html Attempts to elevate privileges to root using a specified command. It handles password prompts and verifies successful elevation. ```APIDOC ## enable ### Description Attempts to elevate privileges to root using a specified command. It handles password prompts and verifies successful elevation. ### Method Signature def enable( self, cmd: str = "sudo -s", pattern: str = "ssword", enable_pattern: Optional[str] = None, check_state: bool = True, re_flags: int = re.IGNORECASE, ) -> str: ### Parameters - **cmd** (str) - Optional - The command to execute to gain root privileges (default: "sudo -s"). - **pattern** (str) - Optional - The pattern to look for to detect a password prompt (default: "ssword"). - **enable_pattern** (Optional[str]) - Optional - A specific pattern to use for detecting the root prompt. - **check_state** (bool) - Optional - If True, checks if already in enable mode before attempting to elevate (default: True). - **re_flags** (int) - Optional - Regular expression flags to use for pattern matching (default: re.IGNORECASE). ### Returns - str - Output from the commands executed during privilege escalation. ### Raises - ValueError - If Netmiko fails to elevate privileges or exit enable mode. ``` -------------------------------- ### get_template_dir Source: https://ktbyers.github.io/netmiko/docs/netmiko/utilities.html Finds and returns the directory containing the TextFSM index file. It checks environment variables and installed packages. ```APIDOC ## get_template_dir ### Description Finds and returns the directory containing the TextFSM index file. Order of preference is: 1) Find directory in `NET_TEXTFSM` Environment Variable. 2) Check for pip installed `ntc-templates` location in this environment. 3) ~/ntc-templates/ntc_templates/templates. If `index` file is not found in any of these locations, raise ValueError. ### Returns - **str** - The directory containing the TextFSM index file. ``` -------------------------------- ### ExtremeSlxSSH Initialization Source: https://ktbyers.github.io/netmiko/docs/netmiko/extreme/index.html Initialize attributes for establishing connection to target device. ```APIDOC ## ExtremeSlxSSH ### Description Initialize attributes for establishing connection to target device. ### Parameters * **ip** (str) - IP address of target device. Not required if `host` is provided. * **host** (str) - Hostname of target device. Not required if `ip` is provided. * **username** (str) - Username to authenticate against target device if required. * **password** (Optional[str]) - Password to authenticate against target device if required. * **secret** (str) - The enable password if target device requires one. * **port** (Optional[int]) - The destination port used to connect to the target device. * **device_type** (str) - Class selection based on device type. * **verbose** (bool) - Enable additional messages to standard output. * **global_delay_factor** (float) - Multiplication factor affecting Netmiko delays (default: 1.0). * **global_cmd_verify** (Optional[bool]) - * **use_keys** (bool) - Connect to target device using SSH keys. * **key_file** (Optional[str]) - Filename path of the SSH key file to use. * **pkey** (Optional[paramiko.pkey.PKey]) - SSH key object to use. * **passphrase** (Optional[str]) - Passphrase to use for encrypted key; password will be used for key decryption if not specified. * **disabled_algorithms** (Optional[Dict[str, Any]]) - Dictionary of SSH algorithms to disable. Refer to the Paramiko documentation for a description of the expected format. * **disable_sha2_fix** (bool) - Boolean that fixes Paramiko issue with missing server-sig-algs (default: False) * **allow_agent** (bool) - Enable use of SSH key-agent. * **ssh_strict** (bool) - Automatically reject unknown SSH host keys (default: False, which means unknown SSH host keys will be accepted). * **system_host_keys** (bool) - Load host keys from the users known_hosts file. * **alt_host_keys** (bool) - If `True` host keys will be loaded from the file specified in alt_key_file. * **alt_key_file** (str) - SSH host key file to use (if alt_host_keys=True). * **ssh_config_file** (Optional[str]) - File name of OpenSSH configuration file. * **conn_timeout** (int) - TCP connection timeout. * **auth_timeout** (Optional[int]) - Set a timeout (in seconds) to wait for an authentication response. * **banner_timeout** (int) - Set a timeout to wait for the SSH banner (pass to Paramiko). * **blocking_timeout** (int) - * **timeout** (int) - * **session_timeout** (int) - Set a timeout for parallel requests. * **read_timeout_override** (Optional[float]) - Set a timeout that will override the default read_timeout of both send_command and send_command_timing. This is useful for 3rd party * **keepalive** (int) - * **default_enter** (Optional[str]) - * **response_return** (Optional[str]) - * **serial_settings** (Optional[Dict[str, Any]]) - * **fast_cli** (bool) - * **session_log** (Optional[SessionLog]) - * **session_log_record_writes** (bool) - * **session_log_file_mode** (str) - * **allow_auto_change** (bool) - * **encoding** (str) - * **sock** (Optional[socket.socket]) - * **sock_telnet** (Optional[Dict[str, Any]]) - * **auto_connect** (bool) - * **delay_factor_compat** (bool) - * **disable_lf_normalization** (bool) - ``` -------------------------------- ### verify_file Source: https://ktbyers.github.io/netmiko/docs/netmiko/nokia/nokia_sros.html Verifies if a file has been transferred correctly by comparing file sizes. This method is applicable for both 'put' and 'get' file transfer directions. ```APIDOC ## verify_file ### Description Verify the file has been transferred correctly based on filesize. ### Method Signature `verify_file(self) -> bool` ### Returns - `bool`: True if the file transfer was successful, False otherwise. ```