Module netmiko.ciena.ciena_saos
+Ciena SAOS support.
+Source code
+"""Ciena SAOS support."""
+import time
+import re
+import os
+from netmiko.base_connection import BaseConnection
+from netmiko.scp_handler import BaseFileTransfer
+
+
+class CienaSaosBase(BaseConnection):
+ """
+ Ciena SAOS support.
+
+ Implements methods for interacting Ciena Saos devices.
+
+ Disables enable(), check_enable_mode(), config_mode() and
+ check_config_mode()
+ """
+
+ def session_preparation(self):
+ self._test_channel_read()
+ self.set_base_prompt()
+ self.disable_paging(command="system shell session set more off")
+ # Clear the read buffer
+ time.sleep(0.3 * self.global_delay_factor)
+ self.clear_buffer()
+
+ def _enter_shell(self):
+ """Enter the Bourne Shell."""
+ output = self.send_command("diag shell", expect_string=r"[$#>]")
+ if "SHELL PARSER FAILURE" in output:
+ msg = "SCP support on Ciena SAOS requires 'diag shell' permissions"
+ raise ValueError(msg)
+ return output
+
+ def _return_cli(self):
+ """Return to the Ciena SAOS CLI."""
+ return self.send_command("exit", expect_string=r"[>]")
+
+ def check_enable_mode(self, *args, **kwargs):
+ """No enable mode on Ciena SAOS."""
+ return True
+
+ def enable(self, *args, **kwargs):
+ """No enable mode on Ciena SAOS."""
+ return ""
+
+ def exit_enable_mode(self, *args, **kwargs):
+ """No enable mode on Ciena SAOS."""
+ return ""
+
+ def check_config_mode(self, check_string=">", pattern=""):
+ """No config mode on Ciena SAOS."""
+ return False
+
+ def config_mode(self, config_command=""):
+ """No config mode on Ciena SAOS."""
+ return ""
+
+ def exit_config_mode(self, exit_config=""):
+ """No config mode on Ciena SAOS."""
+ return ""
+
+ def save_config(self, cmd="configuration save", confirm=False, confirm_response=""):
+ """Saves Config."""
+ return self.send_command(command_string=cmd)
+
+
+class CienaSaosSSH(CienaSaosBase):
+ pass
+
+
+class CienaSaosTelnet(CienaSaosBase):
+ def __init__(self, *args, **kwargs):
+ default_enter = kwargs.get("default_enter")
+ kwargs["default_enter"] = "\r\n" if default_enter is None else default_enter
+ super().__init__(*args, **kwargs)
+
+
+class CienaSaosFileTransfer(BaseFileTransfer):
+ """Ciena SAOS SCP File Transfer driver."""
+
+ def __init__(
+ self,
+ ssh_conn,
+ source_file,
+ dest_file,
+ file_system="",
+ direction="put",
+ **kwargs,
+ ):
+ if file_system == "":
+ file_system = f"/tmp/users/{ssh_conn.username}"
+ return super().__init__(
+ ssh_conn=ssh_conn,
+ source_file=source_file,
+ dest_file=dest_file,
+ file_system=file_system,
+ direction=direction,
+ **kwargs,
+ )
+
+ def remote_space_available(self, search_pattern=""):
+ """
+ Return space available on Ciena SAOS
+
+ Output should only have the file-system that matches {self.file_system}
+
+ Filesystem 1K-blocks Used Available Use% Mounted on
+ tmpfs 1048576 648 1047928 0% /tmp
+ """
+ remote_cmd = f"file vols -P {self.file_system}"
+ remote_output = self.ssh_ctl_chan.send_command_expect(remote_cmd)
+ remote_output = remote_output.strip()
+ err_msg = (
+ f"Parsing error, unexpected output from {remote_cmd}:\n{remote_output}"
+ )
+
+ # First line is the header; file_system_line is the output we care about
+ header_line, filesystem_line = remote_output.splitlines()
+
+ filesystem, _, _, space_avail, *_ = header_line.split()
+ if "Filesystem" != filesystem or "Avail" not in space_avail:
+ # Filesystem 1K-blocks Used Available Use% Mounted on
+ raise ValueError(err_msg)
+
+ # Normalize output - in certain outputs ciena will line wrap (this fixes that)
+ # Strip the extra newline
+ # /dev/mapper/EN--VOL-config
+ # 4096 1476 2620 36% /etc/hosts
+ filesystem_line = re.sub(r"(^\S+$)\n", r"\1", filesystem_line, flags=re.M)
+
+ # Checks to make sure what was returned is what we expect
+ _, k_blocks, used, space_avail, _, _ = filesystem_line.split()
+ for integer_check in (k_blocks, used, space_avail):
+ try:
+ int(integer_check)
+ except ValueError:
+ raise ValueError(err_msg)
+
+ return int(space_avail) * 1024
+
+ def check_file_exists(self, remote_cmd=""):
+ """Check if the dest_file already exists on the file system (return boolean)."""
+ if self.direction == "put":
+ if not remote_cmd:
+ remote_cmd = f"file ls {self.file_system}/{self.dest_file}"
+ remote_out = self.ssh_ctl_chan.send_command_expect(remote_cmd)
+ search_string = re.escape(f"{self.file_system}/{self.dest_file}")
+ if "ERROR" in remote_out:
+ return False
+ elif re.search(search_string, remote_out):
+ return True
+ else:
+ raise ValueError("Unexpected output from check_file_exists")
+ elif self.direction == "get":
+ return os.path.exists(self.dest_file)
+
+ 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_file = f"{self.file_system}/{remote_file}"
+
+ if not remote_cmd:
+ remote_cmd = f"file ls -l {remote_file}"
+
+ remote_out = self.ssh_ctl_chan.send_command_expect(remote_cmd)
+
+ if "No such file or directory" in remote_out:
+ raise IOError("Unable to find file on remote system")
+
+ escape_file_name = re.escape(remote_file)
+ pattern = r"^.* ({}).*$".format(escape_file_name)
+ match = re.search(pattern, remote_out, flags=re.M)
+ if match:
+ # Format: -rw-r--r-- 1 pyclass wheel 12 Nov 5 19:07 /var/tmp/test3.txt
+ line = match.group(0)
+ file_size = line.split()[4]
+ return int(file_size)
+
+ raise ValueError(
+ "Search pattern not found for remote file size during SCP transfer."
+ )
+
+ def remote_md5(self, base_cmd="", remote_file=None):
+ """Calculate remote MD5 and returns the hash.
+
+ This command can be CPU intensive on the remote device.
+ """
+ if base_cmd == "":
+ base_cmd = "md5sum"
+ 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"{base_cmd} {self.file_system}/{remote_file}"
+
+ self.ssh_ctl_chan._enter_shell()
+ dest_md5 = self.ssh_ctl_chan.send_command(
+ remote_md5_cmd, expect_string=r"[$#>]"
+ )
+ self.ssh_ctl_chan._return_cli()
+ dest_md5 = self.process_md5(dest_md5, pattern=r"([0-9a-f]+)\s+")
+ return dest_md5
+
+ def enable_scp(self, cmd="system server scp enable"):
+ return super().enable_scp(cmd=cmd)
+
+ def disable_scp(self, cmd="system server scp disable"):
+ return super().disable_scp(cmd=cmd)
+Classes
+-
+
+class CienaSaosBase +(ip='', host='', username='', password=None, secret='', port=None, device_type='', verbose=False, global_delay_factor=1, 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, timeout=100, session_timeout=60, auth_timeout=None, blocking_timeout=20, banner_timeout=15, 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) +
+-
+
+Ciena SAOS support.
+Implements methods for interacting Ciena Saos devices.
+Disables enable(), check_enable_mode(), config_mode() and +check_config_mode()
+
+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 +
++Source code
+
+class CienaSaosBase(BaseConnection): + """ + Ciena SAOS support. + + Implements methods for interacting Ciena Saos devices. + + Disables enable(), check_enable_mode(), config_mode() and + check_config_mode() + """ + + def session_preparation(self): + self._test_channel_read() + self.set_base_prompt() + self.disable_paging(command="system shell session set more off") + # Clear the read buffer + time.sleep(0.3 * self.global_delay_factor) + self.clear_buffer() + + def _enter_shell(self): + """Enter the Bourne Shell.""" + output = self.send_command("diag shell", expect_string=r"[$#>]") + if "SHELL PARSER FAILURE" in output: + msg = "SCP support on Ciena SAOS requires 'diag shell' permissions" + raise ValueError(msg) + return output + + def _return_cli(self): + """Return to the Ciena SAOS CLI.""" + return self.send_command("exit", expect_string=r"[>]") + + def check_enable_mode(self, *args, **kwargs): + """No enable mode on Ciena SAOS.""" + return True + + def enable(self, *args, **kwargs): + """No enable mode on Ciena SAOS.""" + return "" + + def exit_enable_mode(self, *args, **kwargs): + """No enable mode on Ciena SAOS.""" + return "" + + def check_config_mode(self, check_string=">", pattern=""): + """No config mode on Ciena SAOS.""" + return False + + def config_mode(self, config_command=""): + """No config mode on Ciena SAOS.""" + return "" + + def exit_config_mode(self, exit_config=""): + """No config mode on Ciena SAOS.""" + return "" + + def save_config(self, cmd="configuration save", confirm=False, confirm_response=""): + """Saves Config.""" + return self.send_command(command_string=cmd)
Ancestors
+ +Subclasses
+ +Methods
+-
+
+def check_config_mode(self, check_string='>', pattern='') +
+-
+
+No config mode on Ciena SAOS.
++Source code
+
+def check_config_mode(self, check_string=">", pattern=""): + """No config mode on Ciena SAOS.""" + return False
+ +def check_enable_mode(self, *args, **kwargs) +
+-
+
+No enable mode on Ciena SAOS.
++Source code
+
+def check_enable_mode(self, *args, **kwargs): + """No enable mode on Ciena SAOS.""" + return True
+ +def config_mode(self, config_command='') +
+-
+
+No config mode on Ciena SAOS.
++Source code
+
+def config_mode(self, config_command=""): + """No config mode on Ciena SAOS.""" + return ""
+ +def enable(self, *args, **kwargs) +
+-
+
+No enable mode on Ciena SAOS.
++Source code
+
+def enable(self, *args, **kwargs): + """No enable mode on Ciena SAOS.""" + return ""
+ +def exit_config_mode(self, exit_config='') +
+-
+
+No config mode on Ciena SAOS.
++Source code
+
+def exit_config_mode(self, exit_config=""): + """No config mode on Ciena SAOS.""" + return ""
+ +def exit_enable_mode(self, *args, **kwargs) +
+-
+
+No enable mode on Ciena SAOS.
++Source code
+
+def exit_enable_mode(self, *args, **kwargs): + """No enable mode on Ciena SAOS.""" + return ""
+ +def save_config(self, cmd='configuration save', confirm=False, confirm_response='') +
+-
+
+Saves Config.
++Source code
+
+def save_config(self, cmd="configuration save", confirm=False, confirm_response=""): + """Saves Config.""" + return self.send_command(command_string=cmd)
+
Inherited members
+-
+
BaseConnection
: +-
+
cleanup
+clear_buffer
+close_session_log
+commit
+disable_paging
+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
+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 CienaSaosFileTransfer +(ssh_conn, source_file, dest_file, file_system='', direction='put', **kwargs) +
+-
+
+Ciena SAOS SCP File Transfer driver.
++Source code
+
+class CienaSaosFileTransfer(BaseFileTransfer): + """Ciena SAOS SCP File Transfer driver.""" + + def __init__( + self, + ssh_conn, + source_file, + dest_file, + file_system="", + direction="put", + **kwargs, + ): + if file_system == "": + file_system = f"/tmp/users/{ssh_conn.username}" + return super().__init__( + ssh_conn=ssh_conn, + source_file=source_file, + dest_file=dest_file, + file_system=file_system, + direction=direction, + **kwargs, + ) + + def remote_space_available(self, search_pattern=""): + """ + Return space available on Ciena SAOS + + Output should only have the file-system that matches {self.file_system} + + Filesystem 1K-blocks Used Available Use% Mounted on + tmpfs 1048576 648 1047928 0% /tmp + """ + remote_cmd = f"file vols -P {self.file_system}" + remote_output = self.ssh_ctl_chan.send_command_expect(remote_cmd) + remote_output = remote_output.strip() + err_msg = ( + f"Parsing error, unexpected output from {remote_cmd}:\n{remote_output}" + ) + + # First line is the header; file_system_line is the output we care about + header_line, filesystem_line = remote_output.splitlines() + + filesystem, _, _, space_avail, *_ = header_line.split() + if "Filesystem" != filesystem or "Avail" not in space_avail: + # Filesystem 1K-blocks Used Available Use% Mounted on + raise ValueError(err_msg) + + # Normalize output - in certain outputs ciena will line wrap (this fixes that) + # Strip the extra newline + # /dev/mapper/EN--VOL-config + # 4096 1476 2620 36% /etc/hosts + filesystem_line = re.sub(r"(^\S+$)\n", r"\1", filesystem_line, flags=re.M) + + # Checks to make sure what was returned is what we expect + _, k_blocks, used, space_avail, _, _ = filesystem_line.split() + for integer_check in (k_blocks, used, space_avail): + try: + int(integer_check) + except ValueError: + raise ValueError(err_msg) + + return int(space_avail) * 1024 + + def check_file_exists(self, remote_cmd=""): + """Check if the dest_file already exists on the file system (return boolean).""" + if self.direction == "put": + if not remote_cmd: + remote_cmd = f"file ls {self.file_system}/{self.dest_file}" + remote_out = self.ssh_ctl_chan.send_command_expect(remote_cmd) + search_string = re.escape(f"{self.file_system}/{self.dest_file}") + if "ERROR" in remote_out: + return False + elif re.search(search_string, remote_out): + return True + else: + raise ValueError("Unexpected output from check_file_exists") + elif self.direction == "get": + return os.path.exists(self.dest_file) + + 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_file = f"{self.file_system}/{remote_file}" + + if not remote_cmd: + remote_cmd = f"file ls -l {remote_file}" + + remote_out = self.ssh_ctl_chan.send_command_expect(remote_cmd) + + if "No such file or directory" in remote_out: + raise IOError("Unable to find file on remote system") + + escape_file_name = re.escape(remote_file) + pattern = r"^.* ({}).*$".format(escape_file_name) + match = re.search(pattern, remote_out, flags=re.M) + if match: + # Format: -rw-r--r-- 1 pyclass wheel 12 Nov 5 19:07 /var/tmp/test3.txt + line = match.group(0) + file_size = line.split()[4] + return int(file_size) + + raise ValueError( + "Search pattern not found for remote file size during SCP transfer." + ) + + def remote_md5(self, base_cmd="", remote_file=None): + """Calculate remote MD5 and returns the hash. + + This command can be CPU intensive on the remote device. + """ + if base_cmd == "": + base_cmd = "md5sum" + 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"{base_cmd} {self.file_system}/{remote_file}" + + self.ssh_ctl_chan._enter_shell() + dest_md5 = self.ssh_ctl_chan.send_command( + remote_md5_cmd, expect_string=r"[$#>]" + ) + self.ssh_ctl_chan._return_cli() + dest_md5 = self.process_md5(dest_md5, pattern=r"([0-9a-f]+)\s+") + return dest_md5 + + def enable_scp(self, cmd="system server scp enable"): + return super().enable_scp(cmd=cmd) + + def disable_scp(self, cmd="system server scp disable"): + return super().disable_scp(cmd=cmd)
Ancestors
+ +Methods
+-
+
+def remote_space_available(self, search_pattern='') +
+-
+
+Return space available on Ciena SAOS
+Output should only have the file-system that matches {self.file_system}
+Filesystem +1K-blocks +Used Available Use% Mounted on +tmpfs +1048576 +648 +1047928 +0% /tmp
++Source code
+
+def remote_space_available(self, search_pattern=""): + """ + Return space available on Ciena SAOS + + Output should only have the file-system that matches {self.file_system} + + Filesystem 1K-blocks Used Available Use% Mounted on + tmpfs 1048576 648 1047928 0% /tmp + """ + remote_cmd = f"file vols -P {self.file_system}" + remote_output = self.ssh_ctl_chan.send_command_expect(remote_cmd) + remote_output = remote_output.strip() + err_msg = ( + f"Parsing error, unexpected output from {remote_cmd}:\n{remote_output}" + ) + + # First line is the header; file_system_line is the output we care about + header_line, filesystem_line = remote_output.splitlines() + + filesystem, _, _, space_avail, *_ = header_line.split() + if "Filesystem" != filesystem or "Avail" not in space_avail: + # Filesystem 1K-blocks Used Available Use% Mounted on + raise ValueError(err_msg) + + # Normalize output - in certain outputs ciena will line wrap (this fixes that) + # Strip the extra newline + # /dev/mapper/EN--VOL-config + # 4096 1476 2620 36% /etc/hosts + filesystem_line = re.sub(r"(^\S+$)\n", r"\1", filesystem_line, flags=re.M) + + # Checks to make sure what was returned is what we expect + _, k_blocks, used, space_avail, _, _ = filesystem_line.split() + for integer_check in (k_blocks, used, space_avail): + try: + int(integer_check) + except ValueError: + raise ValueError(err_msg) + + return int(space_avail) * 1024
+
Inherited members
+ +
+ +class CienaSaosSSH +(ip='', host='', username='', password=None, secret='', port=None, device_type='', verbose=False, global_delay_factor=1, 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, timeout=100, session_timeout=60, auth_timeout=None, blocking_timeout=20, banner_timeout=15, 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) +
+-
+
+Ciena SAOS support.
+Implements methods for interacting Ciena Saos devices.
+Disables enable(), check_enable_mode(), config_mode() and +check_config_mode()
+
+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 +
++Source code
+
+class CienaSaosSSH(CienaSaosBase): + pass
Ancestors
+ +Inherited members
+-
+
CienaSaosBase
: +-
+
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
+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 CienaSaosTelnet +(*args, **kwargs) +
+-
+
+Ciena SAOS support.
+Implements methods for interacting Ciena Saos devices.
+Disables enable(), check_enable_mode(), config_mode() and +check_config_mode()
+
+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 +
++Source code
+
+class CienaSaosTelnet(CienaSaosBase): + def __init__(self, *args, **kwargs): + default_enter = kwargs.get("default_enter") + kwargs["default_enter"] = "\r\n" if default_enter is None else default_enter + super().__init__(*args, **kwargs)
Ancestors
+ +Inherited members
+-
+
CienaSaosBase
: +-
+
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
+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
+
+
+