pyntc.devices.eos_device
¶
Module for using an Arista EOS device over the eAPI.
pyntc.devices.eos_device.EOSDevice
¶
Bases: BaseDevice
Arista EOS Device Implementation.
boot_options
property
¶
Get current running software.
Returns:
| Type | Description |
|---|---|
dict
|
Key is |
fqdn
property
¶
Get fully-qualified domain name of device.
Returns:
| Type | Description |
|---|---|
str
|
Fully-qualified domain name of device. |
hostname
property
¶
Get hostname from device.
Returns:
| Type | Description |
|---|---|
str
|
Hostname of the device. |
interfaces
property
¶
Get list of interfaces on device.
Returns:
| Type | Description |
|---|---|
list
|
List of interfaces |
model
property
¶
Get model of device.
Returns:
| Type | Description |
|---|---|
str
|
Model of device. |
os_version
property
¶
Get OS version on device.
Returns:
| Type | Description |
|---|---|
str
|
OS version of device. |
running_config
property
¶
Return running config.
Returns:
| Type | Description |
|---|---|
str
|
Running configuration. |
serial_number
property
¶
Get serial number of device.
Returns:
| Type | Description |
|---|---|
str
|
Serial number of device. |
startup_config
property
¶
Get startup configuration.
Returns:
| Type | Description |
|---|---|
str
|
Startup configuration. |
uptime
property
¶
Get uptime of the device in seconds.
Returns:
| Type | Description |
|---|---|
int
|
Uptime of the device. |
uptime_string
property
¶
Get uptime of the device in the format of dd::hh::mm.
Returns:
| Type | Description |
|---|---|
str
|
Uptime in string format. |
vlans
property
¶
Get list of VLANS on device.
Returns:
| Type | Description |
|---|---|
list
|
List of VLANS on device. |
__init__(host, username, password, transport='http', port=None, timeout=None, **kwargs)
¶
PyNTC Device implementation for Arista EOS.
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 |
transport
|
str
|
The protocol to communicate with the device. Defaults to http. |
'http'
|
port
|
int
|
The port to use to establish the connection. Defaults to None. |
None
|
timeout
|
int
|
Timeout value used for connection with the device. Defaults to None. |
None
|
kwargs
|
dict
|
Additional keyword arguments. |
{}
|
backup_running_config(filename)
¶
Create backup file of running configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file that will be saved. |
required |
check_file_exists(filename, file_system=None)
¶
Check if a remote file exists by filename.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file to check for on the remote device. |
required |
file_system
|
str
|
Supported only for Arista. The file system for the
remote file. If no file_system is provided, then the |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the remote file exists, False if it doesn't. |
Raises:
| Type | Description |
|---|---|
CommandError
|
If there is an error in executing the command to check if the file exists. |
checkpoint(checkpoint_file)
¶
Copy running config checkpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_file
|
str
|
Checkpoint file name. |
required |
close()
¶
Not implemented. Just passes.
config(commands)
¶
Send configuration commands to a device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
(str, list)
|
String with single command, or list with multiple commands. |
required |
Raises:
| Type | Description |
|---|---|
CommandError
|
Issue with the command provided. |
CommandListError
|
Issue with a command in the list provided. |
enable()
¶
Ensure device is in enable mode.
Returns:
| Type | Description |
|---|---|
None
|
Device prompt is set to enable mode. |
file_copy(src, dest=None, file_system=None)
¶
Copy file to device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
string
|
source file |
required |
dest
|
string
|
Destintion file. Defaults to None. |
None
|
file_system
|
string
|
Describes device file system. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
FileTransferError
|
raise exception if there is an error |
NotEnoughFreeSpaceError
|
When |
file_copy_remote_exists(src, dest=None, file_system=None)
¶
Copy file to remote device if it exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
str
|
source file |
required |
dest
|
str
|
Destintion file. Defaults to None. |
None
|
file_system
|
str
|
Describes device file system. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if remote file exists. |
get_remote_checksum(filename, hashing_algorithm='md5', **kwargs)
¶
Get the checksum of a remote file on Arista EOS device using netmiko SSH.
Uses Arista's 'verify' command via SSH to compute file checksums.
Note, Netmiko FileTransfer only supports verify /md5
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file to check for on the remote device. |
required |
hashing_algorithm
|
str
|
The hashing algorithm to use (default: "md5"). |
'md5'
|
**kwargs
|
Any
|
Passible parameters such as file_system. |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The checksum of the remote file. |
Raises:
| Type | Description |
|---|---|
CommandError
|
If the verify command fails (but not if file doesn't exist). |
install_os(image_name, reboot=True, **vendor_specifics)
¶
Install new OS on device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Name of the image name to be installed. |
required |
reboot
|
bool
|
Whether to reboot the device after setting the boot options. Defaults to true. |
True
|
vendor_specifics
|
dict
|
Vendor specific options for installing OS, such as timeout. |
{}
|
Raises:
| Type | Description |
|---|---|
OSInstallError
|
Error in installing new OS. |
Returns:
| Type | Description |
|---|---|
bool
|
True if device OS is succesfully installed. |
open()
¶
Open ssh connection with Netmiko ConnectHandler to be used with FileTransfer.
reboot(wait_for_reload=False, **kwargs)
¶
Reload the controller or controller pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wait_for_reload
|
bool
|
Whether or not reboot method should also run _wait_for_device_reboot(). Defaults to False. |
False
|
kwargs
|
dict
|
Additional keyword arguments, such as confirm. |
{}
|
Raises:
| Type | Description |
|---|---|
RebootTimeoutError
|
When the device is still unreachable after the timeout period. |
Example
device = EOSDevice(**connection_args) device.reboot()
remote_file_copy(src, dest=None, file_system=None, **kwargs)
¶
Copy a file from remote source to device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
FileCopyModel
|
The source file model with transfer parameters. |
required |
dest
|
str
|
Destination filename (defaults to src.file_name). |
None
|
file_system
|
str
|
Device filesystem (auto-detected if not provided). |
None
|
**kwargs
|
Any
|
Passible parameters such as file_system. |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If src is not a FileCopyModel. |
ValueError
|
If the URL scheme is unsupported or URL contains query strings. |
FileTransferError
|
If transfer or verification fails. |
FileSystemNotFoundError
|
If filesystem cannot be determined. |
NotEnoughFreeSpaceError
|
If |
rollback(rollback_to)
¶
Rollback device configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rollback_to
|
str
|
Name of file to revert configuration to. |
required |
Raises:
| Type | Description |
|---|---|
RollbackError
|
When rollback is unsuccessful. |
save(filename='startup-config')
¶
Show running configuration.
Returns:
| Type | Description |
|---|---|
str
|
Running configuration. |
set_boot_options(image_name, **vendor_specifics)
¶
Set boot option to specified image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Name of the image file. |
required |
vendor_specifics
|
dict
|
Vendor specific options, such as file_system. |
{}
|
Raises:
| Type | Description |
|---|---|
NTCFileNotFoundError
|
File not found on device. |
CommandError
|
Error in trying to set image as boot option. |
show(commands, raw_text=False)
¶
Send configuration commands to a device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
(str, list)
|
String with single command, or list with multiple commands. |
required |
raw_text
|
bool
|
False if encode should be json, True if encoding is text. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
CommandError
|
Issue with the command provided. |
CommandListError
|
Issue with a command in the list provided. |
verify_file(checksum, filename, hashing_algorithm='md5', **kwargs)
¶
Verify a file on the remote device by confirming the file exists and validate the checksum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checksum
|
str
|
The checksum of the file. |
required |
filename
|
str
|
The name of the file to check for on the remote device. |
required |
hashing_algorithm
|
str
|
The hashing algorithm to use (default: "md5"). |
'md5'
|
**kwargs
|
Any
|
Passible parameters such as file_system. |
{}
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the file is verified successfully, False otherwise. |