pyaoscx.vlan module

class pyaoscx.vlan.Vlan(session, vlan_id, uri=None, **kwargs)

Bases: pyaoscx.pyaoscx_module.PyaoscxModule

Provide configuration management for VLANs on AOS-CX devices.

add_static_mac(port, mac_address)

Create an StaticMac object.

Parameters:
  • port – String for the Port’s name. Example: 1/1/1
  • mac_address – String MAC address. Example: ‘01:02:03:04:05:06’
Returns:

StaticMac object

apply()
Main method used to either create a VLAN, or update an existing one.
Checks whether the VLAN exists in the switch. Calls self.update() if VLAN is being updated. Calls self.create() if the VLAN doesn’t exist in the switch.
Return modified:
 Boolean, True if object was created or modified.
attach_acl_in(acl_name, list_type)

Update ACL IN values inside a Vlan object.

Parameters:
  • acl_name – Alphanumeric String that is the name of the ACL.
  • list_type – Alphanumeric String of ipv4, ipv6, or mac to specify the type of ACL.
Returns:

True if object was changed.

attach_acl_out(acl_name, list_type)

Update ACL OUT values inside a Vlan object.

Parameters:
  • acl_name – Alphanumeric String that is the name of the ACL.
  • list_type – Alphanumeric String of ipv4, ipv6, or mac to specify the type of ACL.
Returns:

True if object was changed.

base_uri = 'system/vlans'
create()
Perform a POST call to create a new VLAN using the object’s attributes
as POST body. Exception is raised if object is unable to be created.
Return modified:
 Boolean, True if VLAN was created.
delete()

Perform DELETE call to delete VLAN table entry.

detach_acl_in(acl_name, list_type)

Detach an ACL from a VLAN.

Parameters:
  • acl_name – Alphanumeric String that is the name of the ACL.
  • list_type – Alphanumeric String of ipv4, ipv6, or mac to specify the type of ACL.
Returns:

True if object was changed.

detach_acl_out(acl_name, list_type)

Detach an ACL from a VLAN.

Parameters:
  • acl_name – Alphanumeric String that is the name of the ACL.
  • list_type – Alphanumeric String of ipv4, ipv6, or mac to specify the type of ACL.
Returns:

True if object was changed.

classmethod from_response(session, response_data)

Create a Vlan object given a response_data related to the Vlan object.

Parameters:
  • cls – Object’s class.
  • session – pyaoscx.Session object used to represent a logical connection to the device.
  • response_data – The response must be a dictionary of the form: { 1: “/rest/v10.04/system/vlans/1” }
Returns:

Vlan Object.

classmethod from_uri(session, uri)

Create a Vlan object given a VLAN URI.

Parameters:
  • cls – Object’s class.
  • session – pyaoscx.Session object used to represent a logical connection to the device.
  • uri – a String with a URI.
Return vlan_id, vlan:
 

tuple with the Vlan object its ID.

get(depth=None, selector=None)
Perform a GET call to retrieve data for a VLAN table entry and fill the
object with the incoming attributes.
Parameters:
  • depth – Integer deciding how many levels into the API JSON that references will be returned.
  • selector – Alphanumeric option to select specific information to return.
Returns:

Returns True if no exception is raised.

classmethod get_all(session)
Perform a GET call to retrieve all system VLAN and create a dictionary
containing each respective VLAN.
Parameters:
  • cls – Object’s class.
  • session – pyaoscx.Session object used to represent a logical connection to the device.
Returns:

Dictionary containing VLAN IDs as keys and a Vlan object as value.

classmethod get_facts(session)
Modify this to Perform a GET call to retrieve all VLANs and their
respective data.
Parameters:
  • cls – Class reference.
  • session – pyaoscx.Session object used to represent a logical connection to the device.
Return facts:

Dictionary containing VLAN IDs as keys and Vlan objects as values.

get_info_format()
Method used to obtain correct object format for referencing inside
other objects.

return: Object format depending on the API Version.

get_mac(from_id, mac_address)

Create an Mac object.

Parameters:
  • from_id – String source of the MAC address. Must be “dynamic”, “VSX”, “static”, “VRRP”, “port-access-security”, “evpn”, or “hsc”.
  • mac_address – String MAC address. Example: ‘01:02:03:04:05:06’
Returns:

Mac object.

get_uri()

Method used to obtain the specific VLAN URI.

return: Object’s URI.

indices = ['id']
macs
Attribute descriptor class to keep track of a list that contains
pyaoscx_module objects simulating a Reference to a resource. If the list changes, then every pyaoscx_module object has to be changed.
modified

Return boolean with whether this object has been modified.

modify(vlan_name=None, vlan_desc=None, admin_conf_state=None)

Perform a PUT calls to modify an existing VLAN.

Parameters:
  • vlan_name – Optional Alphanumeric name of VLAN. Won’t be modified if not specified.
  • vlan_desc – Optional description to add to VLAN. Won’t be modified if not specified.
  • admin_conf_state – Optional administratively-configured state of VLAN. Won’t be modified if not specified. Only configurable for static VLANs.
Returns:

True if object was changed.

resource_uri_name = 'vlans'
static_macs
Attribute descriptor class to keep track of a list that contains
pyaoscx_module objects simulating a Reference to a resource. If the list changes, then every pyaoscx_module object has to be changed.
update()

Perform a PUT call to apply changes to an existing VLAN table entry.

Return modified:
 True if Object was modified and a PUT request was made.
was_modified()

Getter method for the __modified attribute.

Returns:Boolean True if the object was recently modified.