pyntc.devices.eos_ssh_device
¶
Module for using an Arista EOS device over SSH.
This driver exists for environments where eAPI (management api http-commands) is not
available. It exposes the same public API as
:class:~pyntc.devices.eos_device.EOSDevice; only the transport differs.
Structured output is obtained with the CLI's | json pipe, which renders the same
document eAPI returns -- the pipe is a pure CLI feature and does not require eAPI to be
enabled. Because the key names match, every fact property, the boot-option handling and the
whole file-transfer family are inherited from EOSDevice unchanged.
pyntc.devices.eos_ssh_device.EOSSSHDevice
¶
Bases: EOSDevice
Arista EOS Device Implementation over SSH.
native_ssh
property
¶
Alias for native so inherited Netmiko-backed code works unchanged.
EOSDevice reaches for self.native_ssh in enable, file_copy,
check_file_exists, get_remote_checksum and remote_file_copy. Only
EOSDevice.open ever assigns it, and this class overrides open, so exposing
it read-only is safe.
Returns:
| Type | Description |
|---|---|
BaseConnection
|
The active Netmiko connection. |
os_version
property
¶
Get OS version on device.
Returns:
| Type | Description |
|---|---|
str
|
OS version of device. |
uptime
property
¶
Get device uptime in seconds.
vlans
property
¶
Get list of VLANs on device.
EOSDevice delegates to EOSVlans, which is pyeapi-only
(device.native.api("vlans")). Over SSH the same data comes from
show vlan | json, whose vlans key is a dict keyed by VLAN id.
Returns:
| Type | Description |
|---|---|
list
|
List of VLAN ids as strings. |
__init__(host, username, password, secret='', port=None, **kwargs)
¶
PyNTC Device implementation for Arista EOS over SSH.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
The address of the network device. |
required |
username
|
str
|
The username to authenticate with the device. |
required |
password
|
str
|
The password to authenticate with the device. |
required |
secret
|
str
|
The password to escalate privilege on the device. |
''
|
port
|
int
|
The SSH port to connect on. Defaults to 22. Note this differs from
|
None
|
kwargs
|
dict
|
Additional arguments passed to Netmiko's |
{}
|
close()
¶
Disconnect from the device.
Note this differs from EOSDevice.close, which is a no-op because eAPI is
stateless. An SSH session holds a real socket that should be released.
config(command)
¶
Send configuration commands to a device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
(str, list)
|
String with single command, or list with multiple commands. |
required |
Raises:
| Type | Description |
|---|---|
CommandError
|
When |
CommandListError
|
When |
file_copy(src, dest=None, file_system=None)
¶
Copy a local file to the device over SCP.
Mirrors IOSDevice.file_copy: existence and integrity are established with CLI
commands rather than Netmiko's shell-based helpers, so no bash access is needed.
AristaFileTransfer.enable_scp() raises NotImplementedError, so unlike IOS
there is no SCP-enable step -- EOS serves SCP without one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
str
|
Path to the local file to send. |
required |
dest
|
str
|
Remote filename. Defaults to the basename of |
None
|
file_system
|
str
|
Target filesystem. Auto-detected when omitted. |
None
|
Raises:
| Type | Description |
|---|---|
SocketClosedError
|
When the session drops mid-transfer and the file did not land. |
FileTransferError
|
When the transfer fails, or the file cannot be verified afterwards. |
NotEnoughFreeSpaceError
|
When |
file_copy_remote_exists(src, dest=None, file_system=None)
¶
Check whether src already exists on the device with a matching checksum.
EOSDevice answers this through Netmiko's AristaFileTransfer, which drops into
the switch's Linux shell (bash then /bin/ls). That requires shell privileges
the connecting account may not have. This override uses the CLI instead --
dir <file_system>/<file> and verify /md5 <file_system><file> -- matching how
IOSDevice already behaves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
str
|
Path to the local file to check for. |
required |
dest
|
str
|
Remote filename. Defaults to the basename of |
None
|
file_system
|
str
|
Target filesystem. Auto-detected when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True when the remote file exists and its checksum matches |
install_os(image_name, file_system=None, reboot=True, **vendor_specifics)
¶
Install a different OS version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
The target image filename to install. |
required |
file_system
|
str | None
|
The device's target file system where the software image is stored, defaults to None. |
None
|
reboot
|
bool
|
Reloads the device when True. |
True
|
vendor_specifics
|
dict
|
Any pre-loaded vendor-specific kwargs. |
{}
|
Returns:
| Type | Description |
|---|---|
bool
|
True when the installation is successful, False when the target image is already installed. |
Raises:
| Type | Description |
|---|---|
OSInstallError
|
If the image installation fails. |
maintenance_mode(unit='System', enable=True, transition_timer=300)
¶
Enter or exit maintenance mode.
Sends config commands to transition the maintenance mode state,
entering or exiting based on the enable value. Attempts to
confirm successful transition in the alloted time based on the
provided transition_timer value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
str
|
The specified unit to use when entering or
exiting maintenance mode, defaults to |
'System'
|
enable
|
bool
|
Enters maintenance mode when True, exits maintenance mode when False. |
True
|
transition_timer
|
int
|
Duration in seconds to wait for maintenance state to succesfully transition, defaults to 300 seconds. |
300
|
Returns:
| Type | Description |
|---|---|
bool
|
True if state transition successful, else False. |
Raises:
| Type | Description |
|---|---|
MaintModeProfileError
|
If the provided unit name does not already exist on the target device. |
open()
¶
Open, or re-validate, the Netmiko SSH connection to the device.
reboot(wait_for_reload=False, timeout=DEFAULT_REBOOT_TIMEOUT, **kwargs)
¶
Reload the device.
Unlike eAPI, the SSH session dies as the reload executes, so the command is sent
with send_command_timing and the resulting transport error is expected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wait_for_reload
|
bool
|
When True, block until the device's boot time advances past the pre-reboot value. Defaults to False. |
False
|
timeout
|
int
|
Max seconds to poll when |
DEFAULT_REBOOT_TIMEOUT
|
kwargs
|
dict
|
Additional keyword arguments, such as confirm. |
{}
|
Raises:
| Type | Description |
|---|---|
RebootTimeoutError
|
When the device does not return within |
Example
device = EOSSSHDevice(**connection_args) device.reboot()
show(commands, raw_text=False)
¶
Send show command(s) to the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
(str, list)
|
String with single command, or list with multiple commands. |
required |
raw_text
|
bool
|
False to return structured data via the |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
When |
str
|
When |
list
|
When |
Raises:
| Type | Description |
|---|---|
CommandError
|
When |
CommandListError
|
When |