pyaoscx.vlan module

pyaoscx.vlan.attach_vlan_acl(vlan_id, list_name, list_type, **kwargs)

Perform GET and PUT calls to attach an ACL to a VLAN

Parameters:
  • vlan_id – Numeric ID of VLAN
  • list_name – Alphanumeric name of the ACL
  • list_type – Type should be one of “ipv4,” “ipv6,” or “mac”
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.create_vlan(vlan_id, vlan_name, vlan_desc=None, vlan_type='static', admin_conf_state='up', **kwargs)

Perform a POST call to create a new VLAN.

Parameters:
  • vlan_id – Numeric ID of VLAN
  • vlan_name – Alphanumeric name of VLAN
  • vlan_desc – Optional description to add to VLAN
  • vlan_type – VLAN type. Defaults to “static” if not specified
  • admin_conf_state – Optional administratively-configured state of VLAN. Only configurable for static VLANs. Defaults to “up” for static VLANs.
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.create_vlan_and_svi(vlan_id, vlan_name, vlan_port_name, vlan_int_name, vlan_desc=None, ipv4=None, vrf_name='default', vlan_port_desc=None, **kwargs)

Perform POST and PUT calls to create a new VLAN and SVI.

Parameters:
  • vlan_id – Numeric ID of VLAN
  • vlan_name – Alphanumeric name of VLAN
  • vlan_port_name – Alphanumeric Port name
  • vlan_int_name – Alphanumeric name for the VLAN interface
  • vlan_desc – Optional description to add to VLAN
  • ipv4 – Optional IPv4 address to assign to the interface.Defaults to nothing if not specified.
  • vrf_name – VRF to attach the SVI to. Defaults to “default” if not specified
  • vlan_port_desc – Optional description for the interface. Defaults to nothing if not specified.
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.delete_vlan(vlan_id, **kwargs)

Perform a DELETE call to delete VLAN.

Parameters:
  • vlan_id – Numeric ID of VLAN
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.delete_vlan_and_svi(vlan_id, vlan_port_name, **kwargs)

Perform PUT and DELETE calls to delete SVI and VLAN.

Parameters:
  • vlan_id – Numeric ID of VLAN
  • vlan_port_name – Name of SVI’s entry in Port table
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.detach_vlan_acl(vlan_id, list_type, **kwargs)

Perform GET and PUT calls to detach ACL from a VLAN

Parameters:
  • vlan_id – Numeric ID of VLAN
  • list_type – Type should be one of “ipv4,” “ipv6,” or “mac”
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.get_all_vlans(**kwargs)

Perform a GET call to get a list (or dictionary) of all entries in VLANs table

Parameters:kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:List/dict of all VLANs in the table
pyaoscx.vlan.get_vlan(vlan_id, depth=0, selector='configuration', **kwargs)

Perform a GET call to retrieve data for a VLAN table entry

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. The options are ‘configuration’, ‘status’, or ‘statistics’. If running v10.04 or later, an additional option ‘writable’ is included.
  • vlan_id – Numeric ID of VLAN
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

Dictionary containing port data

pyaoscx.vlan.modify_vlan(vlan_id, vlan_name=None, vlan_desc=None, admin_conf_state=None, **kwargs)

Perform GET and PUT calls to modify an existing VLAN.

Parameters:
  • vlan_id – Numeric ID of VLAN
  • 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.
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.port_add_vlan_trunks(l2_port_name, vlan_trunk_ids=[], **kwargs)

Perform GET and PUT/POST calls to add specified VLANs to a trunk port. By default, this will also set the port to have ‘no routing’ and if there is not a native VLAN, will set the native VLAN to VLAN 1.

Parameters:
  • l2_port_name – L2 interface’s Port table entry name
  • vlan_trunk_ids – List of VLANs to specify as allowed on the trunk port. If empty, the interface will allow all VLANs on the trunk.
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.port_delete_vlan_port(l2_port_name, vlan_id, **kwargs)

Perform GET and PUT calls to remove a VLAN from a trunk port

Parameters:
  • l2_port_name – L2 interface’s Port table entry name
  • vlan_id – Numeric ID of VLAN to remove from trunk port
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.port_set_native_vlan(l2_port_name, vlan_id, tagged=True, **kwargs)

Perform GET and PUT/POST calls to set a VLAN to be the native VLAN on the trunk. Also gives the option to set the VLAN as tagged.

Parameters:
  • l2_port_name – L2 interface’s Port table entry name
  • vlan_id – Numeric ID of VLAN to add to trunk port
  • tagged – Boolean to determine if the native VLAN will be set as the tagged VLAN. If False, the VLAN will be set as the native untagged VLAN
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.port_set_untagged_vlan(l2_port_name, vlan_id, **kwargs)

Perform GET and PUT/POST calls to set a VLAN on an access port

Parameters:
  • l2_port_name – L2 interface’s Port table entry name
  • vlan_id – Numeric ID of VLAN to set on access port
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.port_set_vlan_mode(l2_port_name, vlan_mode, **kwargs)

Perform GET and PUT calls to set an L2 interface’s VLAN mode (native-tagged, native-untagged, or access)

Parameters:
  • l2_port_name – L2 interface’s Port table entry name
  • vlan_mode – A string, either ‘native-tagged’, ‘native-untagged’, or ‘access’, specifying the desired VLAN mode
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

True if successful, False otherwise

pyaoscx.vlan.vlan_get_all_mac_info(vlan_id, **kwargs)

Perform GET calls to get info for all MAC address(es) of VLAN

Parameters:
  • vlan_id – Numeric ID of VLAN
  • kwargs – keyword s: requests.session object with loaded cookie jar keyword url: URL in main() function
Returns:

List of dictionaries containing MAC info