pyaoscx.device module

class pyaoscx.device.Device(session)

Bases: pyaoscx.pyaoscx_factory.PyaoscxFactory

Represents a Device and all of its attributes. Keeping all the important
information inside one class.
apply()

Main method to update an existing Device object.

Return modified:
 Boolean, True if object was created or modified.
base_uri = 'system'
boot_firmware(partition_name='primary')
Perform a POST request to Boot the AOS-CX switch with image present
to the specified partition.
Parameters:partition_name – Name of the partition for device to boot to.
Return bool:True if success.
delete_banner(banner_type='banner')

Perform a DELETE request to delete a device’s Banner.

Parameters:banner_type – Type of banner being removed on the switch either banner or banner_exec.
Return modified:
 Returns True if Banner was modified.
get()
Perform a GET call to retrieve device attributes. After data from
response, Device class attributes are generated using create_attrs().
get_data_planes()
Perform GET call to retrieve data-planes attributes and create a
dictionary containing them.
get_firmware_info()

Perform a GET call to retrieve device firmware information.

Returns:The versions of current, primary and secondary images.
get_firmware_status()

Perform a GET call to retrieve device firmware status.

Returns:firmware_status: The date, reason and status of the firmware upload.
get_firmware_version()

Perform a GET call to retrieve device firmware version.

Returns:The firmware version.
get_subsystems()
Perform GET call to retrieve subsystem attributes and create a
dictionary containing them.
is_capable(capability)

Check if the current Device has the given capability.

Parameters:capability – String name of a Device capability.
Returns:True if Device is capable.
modified

Verifies if there has been a modification for this object or not.

update()

Perform a PUT call to apply changes to a Device object.

Return modified:
 Boolean, True if object was created or modified.
update_banner(banner_info, banner_type='banner')

Perform a PUT request to modify a Device’s Banner.

Parameters:
  • banner_info – String to be configured as the banner.
  • banner_type – Type of banner being configured on the switch either banner or banner_exec.
Return modified:
 

Returns True if Banner was modified.

upload_firmware(partition_name=None, firmware_file_path=None, remote_firmware_file_path=None, vrf=None, try_pycurl=False)

Upload a firmware image from a local file OR from a remote location.

Parameters:
  • partition_name – Name of the partition for the image to be uploaded to.
  • firmware_file_path – File name and path for local file uploading firmware image. IMPORTANT: For this to be used, the remote_firmware_file_path parameter must be None.
  • remote_firmware_file_path – HTTP server address and path for uploading firmware image, must be reachable through provided vrf ex: ‘http://192.168.1.2:8000/TL_10_04_0030A.swi’.
  • vrf – VRF to be used to contact HTTP server, required if remote_firmware_file_path is provided.
  • try_pycurl – If True the function will try to use pycurl instead of requests.
Return bool:

True if success.

upload_firmware_http(remote_firmware_file_path, vrf, partition_name='primary')

Perform a PUT request to upload a firmware image given a http_request.

Parameters:
  • remote_firmware_file_path – “HTTP server address and path for uploading firmware image, must be reachable through provided vrf ex: http://192.168.1.2:8000/TL_10_04_0030A.swi”.
  • vrf – VRF to be used to contact HTTP server, required if remote_firmware_file_path is provided.
  • partition_name – Name of the partition for the image to be uploaded to.
Return bool:

True if success.

upload_firmware_local(partition_name='primary', firmware_file_path=None, try_pycurl=False)

Perform a POST request to upload a firmware image from a local file.

Parameters:
  • partition_name – Name of the partition for the image to be uploaded to.
  • firmware_file_path – File name and path for local file uploading firmware image.
  • try_pycurl – If True the function will try to use pycurl instead of requests.
Return success:

True if success.

vsx_capable()

Return whether this device supports the VSX functionality.

Returns:True if device supports VSX.