pyntc.devices.aireos_device
¶
Module for using a Cisco WLC/AIREOS device over SSH.
pyntc.devices.aireos_device.AIREOSDevice
¶
Bases: BaseDevice
Cisco AIREOS Device Implementation.
ap_boot_options
property
¶
Boot Options for all APs associated with the controller.
Returns:
| Type | Description |
|---|---|
dict
|
The name of each AP are the keys, and the values are the primary and backup values. |
Example
device = AIREOSDevice(**connection_args) device.ap_boot_options { 'ap1': { 'backup': '8.8.125.0', 'primary': '8.9.110.0', 'status': 'complete' }, 'ap2': { 'backup': '8.8.125.0', 'primary': '8.9.110.0', 'status': 'complete' }, }
ap_image_stats
property
¶
Stats of downloading the the image to all APs.
Returns:
| Type | Description |
|---|---|
dict
|
The AP count, and the downloaded, unsupported, and failed APs. |
Example
device = AIREOSDevice(**connection_args) device.ap_image_stats { 'count': 2, 'downloaded': 2, 'unsupported': 0, 'failed': 0 }
boot_options
property
¶
Images that are candidates for booting on reload.
Returns:
| Type | Description |
|---|---|
dict
|
The boot options on the device. The "sys" key is the expected image on reload. |
Example
device = AIREOSDevice(**connection_args) device.boot_options { 'backup': '8.8.125.0', 'primary': '8.9.110.0', 'sys': '8.9.110.0' }
connected
property
writable
¶
Get connection status of the device.
Returns:
| Type | Description |
|---|---|
bool
|
True if the device is connected, else False. |
disabled_wlans
property
¶
IDs for all disabled WLANs.
Returns:
| Type | Description |
|---|---|
list
|
Disabled WLAN IDs. |
Example
device = AIREOSDevice(**connection_args) device.wlans { 1: {'profile': 'wlan 1', 'ssid': 'wifi', 'status': 'enabled', 'interface': '1'}, 2: {'profile': 'wlan 2', 'ssid': 'corp', 'status': 'disabled', 'interface': '1'}, 3: {'profile': 'wlan 3', 'ssid': 'guest', 'status': 'enabled', 'interface': '1'}, 4: {'profile': 'wlan 4', 'ssid': 'test', 'status': 'disabled', 'interface': '1'}, 7: {'profile': 'wlan 7', 'ssid': 'internet', 'status': 'enabled', 'interface': '1'}, 8: {'profile': 'wlan 8', 'ssid': 'wifi-v', 'status': 'disabled', 'interface': '1'} } device.disabled_wlans [2, 4, 8]
enabled_wlans
property
¶
IDs for all enabled WLANs.
Returns:
| Type | Description |
|---|---|
list
|
Enabled WLAN IDs. |
Example
device = AIREOSDevice(**connection_args) device.wlans { 1: {'profile': 'wlan 1', 'ssid': 'wifi', 'status': 'enabled', 'interface': '1'}, 2: {'profile': 'wlan 2', 'ssid': 'corp', 'status': 'disabled', 'interface': '1'}, 3: {'profile': 'wlan 3', 'ssid': 'guest', 'status': 'enabled', 'interface': '1'}, 4: {'profile': 'wlan 4', 'ssid': 'test', 'status': 'disabled', 'interface': '1'}, 7: {'profile': 'wlan 7', 'ssid': 'internet', 'status': 'enabled', 'interface': '1'}, 8: {'profile': 'wlan 8', 'ssid': 'wifi-v', 'status': 'disabled', 'interface': '1'} } device.enabled_wlans [1, 3, 7]
hostname
property
¶
Retrieve hostname from sysinfo.
peer_redundancy_state
property
¶
Determine the redundancy state of the peer processor.
Returns:
| Type | Description |
|---|---|
str
|
The redundancy state of the peer processor. |
None
|
When the processor does not support redundancy. |
Example
device = AIREOSDevice(**connection_args) device.peer_redundancy_state 'standby hot'
redundancy_mode
property
¶
Get operating redundancy mode of the controller.
Returns:
| Type | Description |
|---|---|
str
|
The redundancy mode the device is operating in. |
Example
device = AIREOSDevice(**connection_args) device.redundancy_mode 'sso enabled'
redundancy_state
property
¶
Determine the redundancy state of the current processor.
Returns:
| Type | Description |
|---|---|
str
|
The redundancy state of the current processor. |
None
|
When the processor does not support redundancy. |
Example
device = AIREOSDevice(**connection_args) device.redundancy_state 'active'
running_config
property
¶
Show running config.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Function currently not implemented. |
startup_config
property
¶
Get startup config.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Function currently not implemented. |
uptime
property
¶
Get uptime of the device in seconds.
Returns:
| Type | Description |
|---|---|
int
|
The number of seconds the device has been up. |
Example
device = AIREOSDevice(**connection_args) device.uptime 109303
uptime_string
property
¶
Get uptime of the device as a string in the format is dd::hh::mm.
Returns:
| Type | Description |
|---|---|
str
|
The uptime of the device. |
Example
device = AIREOSDevice(**connection_args) device.uptime_string 22:04:39
wlans
property
¶
All configured WLANs.
Returns:
| Type | Description |
|---|---|
dict
|
WLAN IDs mapped to their operational data. |
Example
device = AIREOSDevice(**connection_args) device.wlans { 1: {'profile': 'wlan 1', 'ssid': 'wifi', 'status': 'enabled', 'interface': '1'}, 2: {'profile': 'wlan 2', 'ssid': 'corp', 'status': 'disabled', 'interface': '1'}, 3: {'profile': 'wlan 3', 'ssid': 'guest', 'status': 'enabled', 'interface': '1'}, 4: {'profile': 'wlan 4', 'ssid': 'test', 'status': 'disabled', 'interface': '1'}, 7: {'profile': 'wlan 7', 'ssid': 'internet', 'status': 'enabled', 'interface': '1'}, 8: {'profile': 'wlan 8', 'ssid': 'wifi-v', 'status': 'disabled', 'interface': '1'} }
__init__(host, username, password, secret='', port=None, confirm_active=True, **kwargs)
¶
PyNTC Device implementation for Cisco WLC.
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 port to use to establish the connection. Defaults to 22. |
None
|
confirm_active
|
bool
|
Determines if device's high availability state should be validated before leaving connection open. |
True
|
**kwargs
|
dict
|
Additional keyword arguments for device customization. |
{}
|
backup_running_config(filename)
¶
Create backup of running config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Name of backup file. |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Function currently not implemented |
checkpoint(filename)
¶
Create a checkpoint file of the current config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Saves a checkpoint file with the name provided to the function. |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Function currently not implemented |
close()
¶
Close the SSH connection to the device.
config(command, **netmiko_args)
¶
Send config commands to device.
By default, entering and exiting config mode is handled automatically.
To disable entering and exiting config mode, pass enter_config_mode and exit_config_mode in **netmiko_args.
This supports all arguments supported by Netmiko's send_config_set method using netmiko_args.
This will send each command in command until either an Error is caught or all commands have been sent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str | list
|
The command or commands to send to the device. |
required |
**netmiko_args
|
dict
|
Any argument supported by |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
When |
list
|
When |
Raises:
| Type | Description |
|---|---|
TypeError
|
When sending an argument in |
CommandError
|
When |
CommandListError
|
When |
Example
device = AIREOSDevice(**connection_args) device.config("boot primary") '(host) config>boot primary\n\n(host) config>'
confirm_is_active()
¶
Confirm that the device is either standalone or the active device in a high availability cluster.
Returns:
| Type | Description |
|---|---|
bool
|
True when the device is considered active. |
Rasies
DeviceNotActiveError: When the device is not considered the active device.
Example
device = AIREOSDevice(**connection_args) device.redundancy_state 'standby hot' device.confirm_is_active() raised DeviceNotActiveError: host1 is not the active device.
device state: standby hot peer state: active
device.redundancy_state 'active' device.confirm_is_active() True
disable_wlans(wlan_ids)
¶
Disable all given WLAN IDs.
The string all can be passed to disable all WLANs.
Commands are sent to disable WLAN IDs that are not in self.disabled_wlans.
If trying to disable all WLANS, then "all" will be sent,
unless all WLANs in self.wlans are in self.disabled_wlans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wlan_ids
|
str | list
|
List of WLAN IDs or |
required |
Raises:
| Type | Description |
|---|---|
WLANDisableError
|
When |
Example
device = AIREOSDevice(**connection_args) device.disabled_wlans [2, 4, 8] device.disable_wlans([1]) device.disabled_wlans [1, 2, 4, 8] device.disable_wlans("all") [1, 2, 3, 4, 7, 8]
enable()
¶
Ensure device is in enable mode.
Returns:
| Type | Description |
|---|---|
None
|
Device prompt is set to enable mode. |
enable_wlans(wlan_ids)
¶
Enable all given WLAN IDs.
The string all can be passed to enable all WLANs.
Commands are sent to enable WLAN IDs that are not in self.enabled_wlans.
If trying to enable all WLANS, then "all" will be sent,
unless all WLANs in self.wlans are in self.enabled_wlans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wlan_ids
|
str | list
|
List of WLAN IDs or |
required |
Raises:
| Type | Description |
|---|---|
WLANEnableError
|
When |
Example
device = AIREOSDevice(**connection_args) device.enabled_wlans [1, 3, 7] device.enable_wlans([2]) device.enabled_wlans [1, 2, 3, 7] device.enable_wlans("all") dev.enabled_wlans [1, 2, 3, 4, 7, 8]
facts()
¶
Get facts from device.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Function currently not implemented. |
file_copy(username, password, server, filepath, protocol='sftp', filetype='code', read_timeout=1000)
¶
Copy a file from server to Controller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
The username to authenticate with the |
required |
password
|
str
|
The password to authenticate with the |
required |
server
|
str
|
The address of the file server. |
required |
filepath
|
str
|
The full path to the file on the |
required |
protocol
|
str
|
The transfer protocol to use to transfer the file. Defaults to "sftp". |
'sftp'
|
filetype
|
str
|
The type of file per aireos definitions. Defaults to "code". |
'code'
|
read_timeout
|
int
|
The Netmiko read_timeout to wait for device to complete transfer. Defaults to 1000. |
1000
|
Returns:
| Type | Description |
|---|---|
bool
|
True when the file was transferred, False when the file is deemed to already be on the device. |
Raises:
| Type | Description |
|---|---|
FileTransferError
|
When an error is detected in transferring the file. |
Example
device = AIREOSDevice(**connection_args) device.boot_options { 'backup': '8.8.125.0', 'primary': '8.9.100.0', 'sys': '8.9.100.0' } device.file_copy("user", "password", "10.1.1.1", "/images/aireos/AIR-CT5500-K9-8-10-105-0.aes") device.boot_options { 'backup': '8.9.100.0', 'primary': '8.10.105.0', 'sys': '8.10.105.0' }
file_copy_remote_exists(src, dest=None, **kwargs)
¶
Copy 'src' file to remote device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
str
|
The path to the file to be copied to the device. |
required |
dest
|
str
|
The name to use for storing the file on the device.
Defaults to use the name of the |
None
|
kwargs
|
dict
|
Any additional arguments supported by Netmiko's |
{}
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Function currently not implemented. |
install_os(image_name, reboot=True, controller='both', save_config=True, disable_wlans=None, **vendor_specifics)
¶
Install an operating system on the controller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
The version to install on the device. |
required |
reboot
|
bool
|
Whether to reboot the device after setting the boot options. Defaults to true. |
True
|
controller
|
str
|
The controller(s) to reboot for install (only applies to HA device). |
'both'
|
save_config
|
bool
|
Whether the config should be saved to the device before reboot. |
True
|
disable_wlans
|
str | list
|
Which WLANs to disable/enable before/after upgrade. Default is None.
To disable all WLANs, pass |
None
|
vendor_specifics
|
dict
|
Any vendor specific arguments to pass to the install method. |
{}
|
Returns:
| Type | Description |
|---|---|
bool
|
True when the install is successful, False when the version is deemed to already be running. |
Raises:
| Type | Description |
|---|---|
OSInstallError
|
When the device is not booted with the specified image after reload. |
RebootTimeoutError
|
When the device is unreachable longer than the reboot timeout value. |
WLANDisableError
|
When WLANs are not disabled properly before the upgrade. |
WLANEnableError
|
When WLANs are not enabled properly after the upgrade. |
Example
device = AIREOSDevice(**connection_args) device.boot_options { 'backup': '8.8.125.0', 'primary': '8.9.100.0', 'sys': '8.9.100.0' } device.file_copy("user", "password", "10.1.1.1", "/images/aireos/AIR-CT5500-K9-8-10-105-0.aes") device.boot_options { 'backup': '8.9.100.0', 'primary': '8.10.105.0', 'sys': '8.10.105.0' } device.install_os("8.10.105.0")
is_active()
¶
Determine if the current processor is the active processor.
Returns:
| Type | Description |
|---|---|
bool
|
True if the processor is active or does not support HA, else False. |
Example
device = AIREOSDevice(**connection_args) device.is_active() True
open(confirm_active=True)
¶
Open a connection to the controller.
This method will close the connection if confirm_active is True and the device is not active.
Devices that do not have high availibility are considred active.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
confirm_active
|
bool
|
Determines if device's high availability state should be validated before leaving connection open. |
True
|
Raises:
| Type | Description |
|---|---|
DeviceIsNotActiveError
|
When |
Example
device = AIREOSDevice(**connection_args) device.open() raised DeviceNotActiveError: host1 is not the active device.
device state: standby hot peer state: active
device.open(confirm_active=False) device.connected True
reboot(wait_for_reload=False, controller='self', save_config=True, **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
|
controller
|
str
|
Which controller(s) to reboot (only applies to HA pairs). |
'self'
|
save_config
|
bool
|
Whether the configuration should be saved before reload. |
True
|
kwargs
|
dict
|
Additional arguments that are not used, but are accepted for backwards compatibility. |
{}
|
Raises:
| Type | Description |
|---|---|
ReloadTimeoutError
|
When the device is still unreachable after the timeout period. |
Example
device = AIREOSDevice(**connection_args) device.reboot()
rollback()
¶
Rollback to stored file config.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Function currently not implemented. |
save()
¶
Save the configuration on the device.
Returns:
| Type | Description |
|---|---|
bool
|
True if the save command did not fail. |
Example
device = AIREOSDevice(**connection_args) device.save()
set_boot_options(image_name, **vendor_specifics)
¶
Set the version to boot on the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
The version to boot into on next reload. |
required |
**vendor_specifics
|
dict
|
Additional vendor-specific arguments (unused). |
{}
|
Raises:
| Type | Description |
|---|---|
NTCFileNotFoundError
|
When the version is not listed in |
Example
device = AIREOSDevice(**connection_args) device.boot_options { 'backup': '8.8.125.0', 'primary': '8.9.100.0', 'sys': '8.9.100.0' } device.set_boot_options("8.8.125.0") device.boot_options { 'backup': '8.8.125.0', 'primary': '8.9.100.0', 'sys': '8.8.125.0' }
show(command, expect_string=None, **netmiko_args)
¶
Send an operational command to the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str | list
|
The commands to send to the device. |
required |
expect_string
|
str
|
The expected prompt after running the command. |
None
|
**netmiko_args
|
dict
|
Any argument supported by |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
When |
list
|
When |
Raises:
| Type | Description |
|---|---|
TypeError
|
When sending an argument in |
CommandError
|
When |
CommandListError
|
When |
Example
device = AIREOSDevice(**connection_args) sysinfo = device._send_command("show sysinfo") print(sysinfo) Product Version.....8.2.170.0 System Up Time......3 days 2 hrs 20 mins 30 sec ... sysinfo = device._send_command(["show sysinfo"]) print(sysinfo[0]) Product Version.....8.2.170.0 System Up Time......3 days 2 hrs 20 mins 30 sec ...
transfer_image_to_ap(image)
¶
Transfer image file to all APs connected to the WLC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str
|
The image that should be sent to the APs. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if AP images are transferred or swapped, False otherwise. |
Example
device = AIREOSDevice(**connection_args) device.ap_boot_options { 'ap1': { 'backup': '8.8.125.0', 'primary': '8.9.110.0', 'status': 'complete' }, 'ap2': { 'backup': '8.8.125.0', 'primary': '8.9.110.0', 'status': 'complete' }, } device.transfer_image_to_ap("8.10.1.0") device.ap_boot_options { 'ap1': { 'backup': '8.9.110.0', 'primary': '8.10.1.0', 'status': 'complete' }, 'ap2': { 'backup': '8.9.110.0', 'primary': '8.10.1.0', 'status': 'complete' }, }
pyntc.devices.aireos_device.convert_filename_to_version(filename)
¶
Extract the aireos version number from image filename.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file downloaded from Cisco. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The version number. |
Example
version = convert_filename_to_version("AIR-CT5520-K9-8-8-125-0.aes") print(version) 8.8.125.0