API Documentation¶
Overview¶
You should use separate class for each device vendor.
For this purpose are used Factory method create()
. You should specify device_type in params
for taking right class
Factory method¶
Classes¶
Base classes¶
These classes are abstract and used as parent by other classes:
BaseDevice¶
-
class
netdev.vendors.
BaseDevice
(host='', username='', password='', port=22, device_type='', timeout=15, loop=None, known_hosts=None, local_addr=None, client_keys=None, passphrase=None, tunnel=None, pattern=None, agent_forwarding=False, agent_path=(), client_version='netdev', family=0, kex_algs=(), encryption_algs=(), mac_algs=(), compression_algs=(), signature_algs=())[source]¶ Base Abstract Class for working with network devices
-
__init__
(host='', username='', password='', port=22, device_type='', timeout=15, loop=None, known_hosts=None, local_addr=None, client_keys=None, passphrase=None, tunnel=None, pattern=None, agent_forwarding=False, agent_path=(), client_version='netdev', family=0, kex_algs=(), encryption_algs=(), mac_algs=(), compression_algs=(), signature_algs=())[source]¶ Initialize base class for asynchronous working with network devices
- Parameters
host (str) – device hostname or ip address for connection
username (str) – username for logging to device
password (str) – user password for logging to device
port (int) – ssh port for connection. Default is 22
device_type (str) – network device type
timeout (int) – timeout in second for getting information from channel
loop (
AbstractEventLoop
) – asyncio loop objectknown_hosts (see SpecifyingKnownHosts) – file with known hosts. Default is None (no policy). With () it will use default file
local_addr (tuple(str, int)) – local address for binding source of tcp connection
client_keys (see SpecifyingPrivateKeys) – path for client keys. Default in None. With () it will use default file in OS
passphrase (str) – password for encrypted client keys
tunnel (
BaseDevice
) – An existing SSH connection that this new connection should be tunneled overpattern (str) – pattern for searching the end of device prompt. Example: r”{hostname}.*?((.*?))?[{delimeters}]”
agent_forwarding (bool) – Allow or not allow agent forward for server
agent_path (str) – The path of a UNIX domain socket to use to contact an ssh-agent process which will perform the operations needed for client public key authentication. If this is not specified and the environment variable SSH_AUTH_SOCK is set, its value will be used as the path. If client_keys is specified or this argument is explicitly set to None, an ssh-agent will not be used.
client_version (str) – version which advertised to ssh server
family (
socket.AF_UNSPEC
orsocket.AF_INET
orsocket.AF_INET6
) – The address family to use when creating the socket. By default, the address family is automatically selected based on the host.kex_algs (list[str]) – A list of allowed key exchange algorithms in the SSH handshake, taken from key exchange algorithms
encryption_algs (list[str]) – A list of encryption algorithms to use during the SSH handshake, taken from encryption algorithms
mac_algs (list[str]) – A list of MAC algorithms to use during the SSH handshake, taken from MAC algorithms
compression_algs (list[str]) – A list of compression algorithms to use during the SSH handshake, taken from compression algorithms, or None to disable compression
signature_algs (list[str]) – A list of public key signature algorithms to use during the SSH handshake, taken from signature algorithms
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
connect
()[source]¶ Basic asynchronous connection method
It connects to device and makes some preparation steps for working. Usual using 3 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_disable_paging() for non interactive output in commands
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)[source]¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
IOSLikeDevice¶
-
class
netdev.vendors.
IOSLikeDevice
(secret='', *args, **kwargs)[source]¶ This Class is abstract class for working with Cisco IOS like devices
Cisco IOS like devices having several concepts:
user exec or unprivileged exec. This mode allows you perform basic tests and get system information.
privilege exec. This mode allows the use of all EXEC mode commands available on the system
configuration mode or config mode. This mode are used for configuration whole system.
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
connect
()[source]¶ Basic asynchronous connection method for Cisco IOS like devices
It connects to device and makes some preparation steps for working. Usual using 4 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_enable() for getting privilege exec mode
_disable_paging() for non interact output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
enable_mode
(pattern='password', re_flags=<RegexFlag.IGNORECASE: 2>)[source]¶ Enter to privilege exec
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
ComwareLikeDevice¶
-
class
netdev.vendors.
ComwareLikeDevice
(host='', username='', password='', port=22, device_type='', timeout=15, loop=None, known_hosts=None, local_addr=None, client_keys=None, passphrase=None, tunnel=None, pattern=None, agent_forwarding=False, agent_path=(), client_version='netdev', family=0, kex_algs=(), encryption_algs=(), mac_algs=(), compression_algs=(), signature_algs=())[source]¶ This Class for working with hp comware like devices
HP Comware like devices having several concepts:
user exec or user view. This mode is using for getting information from device
system view. This mode is using for configuration system
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
connect
()¶ Basic asynchronous connection method
It connects to device and makes some preparation steps for working. Usual using 3 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_disable_paging() for non interactive output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
JunOSLikeDevice¶
-
class
netdev.vendors.
JunOSLikeDevice
(host='', username='', password='', port=22, device_type='', timeout=15, loop=None, known_hosts=None, local_addr=None, client_keys=None, passphrase=None, tunnel=None, pattern=None, agent_forwarding=False, agent_path=(), client_version='netdev', family=0, kex_algs=(), encryption_algs=(), mac_algs=(), compression_algs=(), signature_algs=())[source]¶ JunOSLikeDevice Class for working with Juniper JunOS like devices
Juniper JunOS like devices having several concepts:
shell mode (csh). This is csh shell for FreeBSD. This mode is not covered by this Class.
cli mode (specific shell). The entire configuration is usual configured in this shell:
operation mode. This mode is using for getting information from device
configuration mode. This mode is using for configuration system
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
connect
()¶ Basic asynchronous connection method
It connects to device and makes some preparation steps for working. Usual using 3 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_disable_paging() for non interactive output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, with_commit=True, commit_comment='', exit_config_mode=True)[source]¶ Sending configuration commands to device By default automatically exits/enters configuration mode.
- Parameters
config_commands (list) – iterable string list with commands for applying to network devices in system view
with_commit (bool) – if true it commit all changes after applying all config_commands
commit_comment (string) – message for configuration commit
exit_config_mode (bool) – If true it will quit from configuration mode automatically
- Returns
The output of these commands
End classes¶
These classes are using for particular connection to end devices
CiscoIOS¶
-
class
netdev.vendors.
CiscoIOS
(secret='', *args, **kwargs)[source]¶ Class for working with Cisco IOS/IOS XE
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
check_config_mode
()¶ Checks if the device is in configuration mode or not
-
async
check_enable_mode
()¶ Check if we are in privilege exec. Return boolean
-
async
config_mode
()¶ Enter into config_mode
-
async
connect
()¶ Basic asynchronous connection method for Cisco IOS like devices
It connects to device and makes some preparation steps for working. Usual using 4 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_enable() for getting privilege exec mode
_disable_paging() for non interact output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
enable_mode
(pattern='password', re_flags=<RegexFlag.IGNORECASE: 2>)¶ Enter to privilege exec
-
async
exit_config_mode
()¶ Exit from configuration mode
-
async
exit_enable_mode
()¶ Exit from privilege exec
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, exit_config_mode=True)¶ Sending configuration commands to Cisco IOS like devices Automatically exits/enters configuration mode.
-
property
CiscoIOSXR¶
-
class
netdev.vendors.
CiscoIOSXR
(secret='', *args, **kwargs)[source]¶ Class for working with Cisco IOS XR
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
check_config_mode
()¶ Checks if the device is in configuration mode or not
-
async
check_enable_mode
()¶ Check if we are in privilege exec. Return boolean
-
async
config_mode
()¶ Enter into config_mode
-
async
connect
()¶ Basic asynchronous connection method for Cisco IOS like devices
It connects to device and makes some preparation steps for working. Usual using 4 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_enable() for getting privilege exec mode
_disable_paging() for non interact output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
enable_mode
(pattern='password', re_flags=<RegexFlag.IGNORECASE: 2>)¶ Enter to privilege exec
-
async
exit_enable_mode
()¶ Exit from privilege exec
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, with_commit=True, commit_comment='', exit_config_mode=True)[source]¶ Sending configuration commands to device By default automatically exits/enters configuration mode.
- Parameters
config_commands (list) – iterable string list with commands for applying to network devices in system view
with_commit (bool) – if true it commit all changes after applying all config_commands
commit_comment (string) – message for configuration commit
exit_config_mode (bool) – If true it will quit from configuration mode automatically
- Returns
The output of these commands
-
property
CiscoASA¶
-
class
netdev.vendors.
CiscoASA
(*args, **kwargs)[source]¶ Class for working with Cisco ASA
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
check_config_mode
()¶ Checks if the device is in configuration mode or not
-
async
check_enable_mode
()¶ Check if we are in privilege exec. Return boolean
-
async
config_mode
()¶ Enter into config_mode
-
async
connect
()[source]¶ Async Connection method
Using 5 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_enable() for getting privilege exec mode
_disable_paging() for non interact output in commands
_check_multiple_mode() for checking multiple mode in ASA
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
enable_mode
(pattern='password', re_flags=<RegexFlag.IGNORECASE: 2>)¶ Enter to privilege exec
-
async
exit_config_mode
()¶ Exit from configuration mode
-
async
exit_enable_mode
()¶ Exit from privilege exec
-
property
multiple_mode
¶ Returning Bool True if ASA in multiple mode
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, exit_config_mode=True)¶ Sending configuration commands to Cisco IOS like devices Automatically exits/enters configuration mode.
-
property
CiscoNXOS¶
-
class
netdev.vendors.
CiscoNXOS
(secret='', *args, **kwargs)[source]¶ Class for working with Cisco Nexus/NX-OS
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
check_config_mode
()¶ Checks if the device is in configuration mode or not
-
async
check_enable_mode
()¶ Check if we are in privilege exec. Return boolean
-
async
config_mode
()¶ Enter into config_mode
-
async
connect
()¶ Basic asynchronous connection method for Cisco IOS like devices
It connects to device and makes some preparation steps for working. Usual using 4 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_enable() for getting privilege exec mode
_disable_paging() for non interact output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
enable_mode
(pattern='password', re_flags=<RegexFlag.IGNORECASE: 2>)¶ Enter to privilege exec
-
async
exit_config_mode
()¶ Exit from configuration mode
-
async
exit_enable_mode
()¶ Exit from privilege exec
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, exit_config_mode=True)¶ Sending configuration commands to Cisco IOS like devices Automatically exits/enters configuration mode.
-
property
FujitsuSwitch¶
-
class
netdev.vendors.
FujitsuSwitch
(secret='', *args, **kwargs)[source]¶ Class for working with Fujitsu Blade switch
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
check_config_mode
()¶ Checks if the device is in configuration mode or not
-
async
check_enable_mode
()¶ Check if we are in privilege exec. Return boolean
-
async
config_mode
()¶ Enter into config_mode
-
async
connect
()¶ Basic asynchronous connection method for Cisco IOS like devices
It connects to device and makes some preparation steps for working. Usual using 4 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_enable() for getting privilege exec mode
_disable_paging() for non interact output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
enable_mode
(pattern='password', re_flags=<RegexFlag.IGNORECASE: 2>)¶ Enter to privilege exec
-
async
exit_config_mode
()¶ Exit from configuration mode
-
async
exit_enable_mode
()¶ Exit from privilege exec
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, exit_config_mode=True)¶ Sending configuration commands to Cisco IOS like devices Automatically exits/enters configuration mode.
-
property
HPComware¶
-
class
netdev.vendors.
HPComware
(host='', username='', password='', port=22, device_type='', timeout=15, loop=None, known_hosts=None, local_addr=None, client_keys=None, passphrase=None, tunnel=None, pattern=None, agent_forwarding=False, agent_path=(), client_version='netdev', family=0, kex_algs=(), encryption_algs=(), mac_algs=(), compression_algs=(), signature_algs=())[source]¶ Class for working with HP Comware
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
connect
()¶ Basic asynchronous connection method
It connects to device and makes some preparation steps for working. Usual using 3 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_disable_paging() for non interactive output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, exit_system_view=False)¶ Sending configuration commands to device Automatically exits/enters system-view.
-
property
HPComwareLimited¶
-
class
netdev.vendors.
HPComwareLimited
(cmdline_password='', *args, **kwargs)[source]¶ Class for working with HP Comware Limited like 1910 and 1920 models
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
connect
()[source]¶ Basic asynchronous connection method
It connects to device and makes some preparation steps for working. Usual using 4 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_cmdline_mode_enter() for entering hidden full functional mode
_disable_paging() for non interact output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, exit_system_view=False)¶ Sending configuration commands to device Automatically exits/enters system-view.
-
property
MikrotikRouterOS¶
-
class
netdev.vendors.
MikrotikRouterOS
(*args, **kwargs)[source]¶ Class for working with Mikrotik RouterOS
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
connect
()[source]¶ Async Connection method
RouterOS using 2 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
property
AristaEOS¶
-
class
netdev.vendors.
AristaEOS
(secret='', *args, **kwargs)[source]¶ Class for working with Arista EOS
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
check_config_mode
()¶ Checks if the device is in configuration mode or not
-
async
check_enable_mode
()¶ Check if we are in privilege exec. Return boolean
-
async
config_mode
()¶ Enter into config_mode
-
async
connect
()¶ Basic asynchronous connection method for Cisco IOS like devices
It connects to device and makes some preparation steps for working. Usual using 4 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_enable() for getting privilege exec mode
_disable_paging() for non interact output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
enable_mode
(pattern='password', re_flags=<RegexFlag.IGNORECASE: 2>)¶ Enter to privilege exec
-
async
exit_config_mode
()¶ Exit from configuration mode
-
async
exit_enable_mode
()¶ Exit from privilege exec
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, exit_config_mode=True)¶ Sending configuration commands to Cisco IOS like devices Automatically exits/enters configuration mode.
-
property
ArubaAOS6¶
-
class
netdev.vendors.
ArubaAOS6
(secret='', *args, **kwargs)[source]¶ Class for working with Aruba OS 6.X
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
check_config_mode
()¶ Checks if the device is in configuration mode or not
-
async
check_enable_mode
()¶ Check if we are in privilege exec. Return boolean
-
async
config_mode
()¶ Enter into config_mode
-
async
connect
()¶ Basic asynchronous connection method for Cisco IOS like devices
It connects to device and makes some preparation steps for working. Usual using 4 functions:
_establish_connection() for connecting to device
_set_base_prompt() for finding and setting device prompt
_enable() for getting privilege exec mode
_disable_paging() for non interact output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
enable_mode
(pattern='password', re_flags=<RegexFlag.IGNORECASE: 2>)¶ Enter to privilege exec
-
async
exit_config_mode
()¶ Exit from configuration mode
-
async
exit_enable_mode
()¶ Exit from privilege exec
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, exit_config_mode=True)¶ Sending configuration commands to Cisco IOS like devices Automatically exits/enters configuration mode.
-
property
JuniperJunOS¶
-
class
netdev.vendors.
JuniperJunOS
(host='', username='', password='', port=22, device_type='', timeout=15, loop=None, known_hosts=None, local_addr=None, client_keys=None, passphrase=None, tunnel=None, pattern=None, agent_forwarding=False, agent_path=(), client_version='netdev', family=0, kex_algs=(), encryption_algs=(), mac_algs=(), compression_algs=(), signature_algs=())[source]¶ Class for working with Juniper JunOS
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
check_config_mode
()¶ Check if are in configuration mode. Return boolean
-
async
config_mode
()¶ Enter to configuration mode
-
async
connect
()[source]¶ Juniper JunOS asynchronous connection method
It connects to device and makes some preparation steps for working:
_establish_connection() for connecting to device
cli_mode() for checking shell mode. If we are in shell - we automatically enter to cli
_set_base_prompt() for finding and setting device prompt
_disable_paging() for non interact output in commands
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
exit_config_mode
()¶ Exit from configuration mode
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
async
send_config_set
(config_commands=None, with_commit=True, commit_comment='', exit_config_mode=True)¶ Sending configuration commands to device By default automatically exits/enters configuration mode.
- Parameters
config_commands (list) – iterable string list with commands for applying to network devices in system view
with_commit (bool) – if true it commit all changes after applying all config_commands
commit_comment (string) – message for configuration commit
exit_config_mode (bool) – If true it will quit from configuration mode automatically
- Returns
The output of these commands
-
property
Terminal¶
-
class
netdev.vendors.
Terminal
(delimeter_list=None, *args, **kwargs)[source]¶ Class for working with General Terminal
-
property
base_prompt
¶ Returning base prompt for this network device
-
async
connect
()[source]¶ Async Connection method
General Terminal using 2 functions:
_establish_connection() for connecting to device
_set_base_prompt() for setting base pattern without setting base prompt
-
async
disconnect
()¶ Gracefully close the SSH connection
-
async
send_command
(command_string, pattern='', re_flags=0, strip_command=True, strip_prompt=True)¶ Sending command to device (support interactive commands with pattern)
- Parameters
command_string (str) – command for executing basically in privilege mode
pattern (str) – pattern for waiting in output (for interactive commands)
re_flags (re.flags) – re flags for pattern
strip_command (bool) – True or False for stripping command from output
strip_prompt (bool) – True or False for stripping ending device prompt
- Returns
The output of the command
-
property