pyaoscx.acl_entry module

class pyaoscx.acl_entry.AclEntry(session, sequence_number, parent_acl, uri=None, **kwargs)

Bases: pyaoscx.pyaoscx_module.PyaoscxModule

Provide configuration management for ACL Entry on AOS-CX devices.

apply()
Main method used to either create a new ACL Entry or update an existing
one. It is possible that in case the are differences between the ACE on the switch and the local representation on immutable attributes a replace (delete+create) will take place. Note that unspecified parameters will be kept intact.
Return modified:
 Boolean, True if object was created or modified.
create()
Perform a POST call to create a new ACL Entry. Only returns if no
exception is raised.
Return modified:
 Boolean, True if entry was created
delete()

Perform DELETE call to delete ACL Entry from parent ACL on the switch.

dst_ip

Getter method for destination ip attribute.

Returns:String value for dst_ip.
classmethod from_response(session, parent_acl, response_data)
Create a AclEntry object given a response_data related to the ACL Entry
sequence_number object.
Parameters:
  • cls – Class calling the method.
  • session – pyaoscx.Session object used to represent a logical connection to the device.
  • parent_acl – parent Acl object where ACL Entry is stored.
  • response_data – The response must be a dictionary of the form: { <seq_number>: “/rest/v10.04/system/acls/cfg_aces/<seq_number>” }
Returns:

AclEntry object.

classmethod from_uri(session, parent_acl, uri)

Create a AclEntry object given a URI.

Parameters:
  • session – pyaoscx.Session object used to represent a logical connection to the device.
  • parent_acl – parent Acl object where ACL Entry is stored.
  • uri – a String with a URI.
Return index, acl_entry_obj:
 

tuple containing both the AclEntry object and the acl_entry’s sequence_number.

get(depth=None, selector=None)
Perform a GET call to retrieve data for an ACL Entry 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, parent_acl)
Perform a GET call to retrieve all system ACL Entries inside an ACL,
and create a dictionary containing them.
Parameters:
  • cls – Object’s class.
  • session – pyaoscx.Session object used to represent a logical connection to the device.
  • parent_acl – parent Acl object where ACL Entry is stored.
Return acl_entry_dict:
 

Dictionary containing ACL Entry IDs as keys and an ACL Entry objects as values.

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

return: AclEntry object format depending on the API Version.

get_uri()

Method used to obtain the specific ACL Entry URI.

return: AclEntry object’s URI.

immutable_parameter_names = ['action', 'count', 'dscp', 'dst_ip', 'dst_ip_group', 'dst_l4_port_group', 'dst_l4_port_max', 'dst_l4_port_min', 'dst_mac', 'ecn', 'ethertype', 'fragment', 'icmp_code', 'icmp_type', 'ip_precedence', 'log', 'pcp', 'protocol', 'sequence_number', 'src_ip', 'src_ip_group', 'src_l4_port_group', 'src_l4_port_max', 'src_l4_port_min', 'src_mac', 'tcp_ack', 'tcp_cwr', 'tcp_ece', 'tcp_established', 'tcp_fin', 'tcp_psh', 'tcp_rst', 'tcp_syn', 'tcp_urg', 'tos', 'ttl', 'vlan']
indices = ['sequence_number']
modified
modify(action=None, count=None, src_ip=None, dst_ip=None, dst_l4_port_min=None, dst_l4_port_max=None, src_mac=None, dst_mac=None, ethertype=None)
Create an AclEntry object, ACL Entry already exists, value passed won’t
update the entry.
Parameters:
  • action – Action should be either “permit” or “deny”.
  • count – Optional boolean flag that when true, will make entry increment hit count for matched packets.
  • src_ip – Optional source IP address. Both IPv4 and IPv6 are supported. Example: 10.10.12.11/255.255.255.255 2001:db8::11/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
  • dst_ip – Optional destination IP address. Both IPv4 and IPv6 are supported. Example: 10.10.12.11/255.255.255.255 2001:db8::11/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
  • dst_l4_port_min – Optional minimum L4 port number in range; used in conjunction with dst_l4_port_max.
  • dst_l4_port_max – Optional maximum L4 port number in range; used in conjunction with dst_l4_port_min.
  • src_mac – Optional source MAC address. Example: ‘01:02:03:04:05:06’
  • dst_mac – Optional destination MAC address. Example: ‘01:02:03:04:05:06’
  • ethertype – Optional integer EtherType number.
Returns:

True if object was changed.

mutable_parameter_names = ['comment']
protocol_dict = {'ah': 51, 'esp': 50, 'gre': 47, 'icmp': 1, 'icmpv6': 58, 'igmp': 2, 'ospf': 89, 'pim': 103, 'sctp': 132, 'tcp': 6, 'udp': 17}
resource_uri_name = 'cfg_aces'
src_ip

Getter method for source ip attribute.

Returns:String value for src_ip.
update()

Perform a PUT call to apply changes to an existing ACL 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.