1. acl

class fwOper.acl.ACL(acl_name, acl_lines_list, objs)[source]

Bases: fwOper.fwObj.Singulars

Individual access-list object

Parameters

Singulars (Singulars) – Inherits - individual object properties definitions

Raises
  • Exception – MissingMandatoryParameter

  • Exception – exact match process error

Returns

a single access-list object

Return type

ACL

Yields

tuple – tuple of (line-number, line-attributes)

add_str()[source]

String representation of acl recoded additions

Returns

recorded acl changes (adds)

Return type

str

append(attribs)[source]

append a line to acl display warning message - MatchingEntryAlreadyexistAtLine, if a match already exist in acl

Parameters

attribs (dict) – line attributes

Returns

delta change(s) for the append of entry

Return type

str

contains(item)[source]

check matching attributes in acl object, and return set of matching acl line numbers for containing item (sparse match)

Parameters

item (dict) – line attributes

Returns

set of matching acl line numbers (sparse match)

Return type

set

copy_and_append(attribs)[source]

create duplicate of self, append a new acl line in new object with provided attributes

Parameters

attribs (dict) – line attributes

Returns

copy of ACL with attributes appended

Return type

ACL

copy_and_delete(attribs)[source]

create duplicate of self, delete a line in new acl for given line number/attributes

Parameters

attribs (dict) – line attributes

Returns

copy of ACL with attributes/line removed

Return type

ACL

copy_and_insert(line_no, attribs)[source]

create duplicate of self, insert a new acl line in new acl object, with provided attributes at given line number and return new updated object. existing object remains untouched.

Parameters
  • line_no (int) – line number at which entry to be inserted

  • attribs (dict) – line attributes

Returns

copy of ACL with attributes/line insert

Return type

ACL

del_str()[source]

String representation of acl recoded deletions

Returns

recorded acl changes (removals)

Return type

str

delete(attribs, stop=None, step=1)[source]

delete a line in acl: can be use with standard delete command as well, del(acl_name[n])

Parameters
  • attribs (int, dict) – int->deletes an entry by line number, dict->delete entry which matches attribute

  • stop (int, optional) – to delete a range of lines provide end sequence. Defaults to None.

  • step (int, optional) – to delete line numbers in multiple of. Defaults to 1.

Returns

delta change(s) for the deletion of entry

Return type

str

difference(obj)[source]

difference between self and another ACL object elements

Parameters

obj (ACL) – another ACL object to compare differences

Returns

difference between self and another ACL object elements

Return type

dict

end_point_identifiers_pos = {0: 5, 1: 7, 2: 9}
exact(item)[source]

check matching attributes in acl object, and return set of matching acl line numbers for exact matches item only

Parameters

item (dict) – line attributes

Raises

Exception – exact match process error

Returns

set of matching acl line numbers (exact match)

Return type

set

insert(line_no, attribs)[source]

insert a line in acl: can be use with standard way as well, aclname[line_no] = attribs display warning message - MatchingEntryAlreadyexistAtLine, if a match already exist in acl

Parameters
  • line_no (int) – line number at which entry to be inserted

  • attribs (dict) – line attributes

Returns

delta change(s) for the insertion of entry

Return type

str

mandatory_item_values_for_str = ('acl_type', 'action', 'protocol', 'source', 'destination', 'ports', 'log_warning')
property max
property min
parse(objs)[source]

parse access-list-lines-list and set _repr_dic objs requires for acl lines having object-group-names

Parameters

objs (OBJS) – object of object-groups (OBJS)

same_elements(obj)[source]

compare self for similar elements with provided another ACL object.

Parameters

obj (ACL) – another ACL object to compare elements

Returns

if self and provided ACL has same elements or not

Return type

bool

property sequence
str()[source]

String representation of full acl

Returns

full acl

Return type

str

class fwOper.acl.ACLS(config_list, objs=None)[source]

Bases: fwOper.fwObj.Plurals

collection of ACL objects

Parameters

Plurals (Plurals) – Inherits - group of items properties definitions

changes(change)[source]

collate the delta changes recorded in all access-lists and provide delta for that change ( “ADDS”, “REMOVALS”)

Parameters

change (str) – type of change for which change output requested ( “ADDS”, “REMOVALS” )

Returns

delta changes

Return type

str

set_acl_names()[source]

sets available access-lists names in _repr_dic (key)

Returns

_repr_dict

Return type

dict

set_objects(objs)[source]

sets access-lists (ACL)s in _repr_dic (value)

Parameters

objs (OBJS) – object of dictionary of object-groups

fwOper.acl.access_list_list(config_list)[source]

extracts access-lists from provided configuration list ie.config_list.

Parameters

config_list (list) – configuration list

Returns

access-lists lines in a list

Return type

list

fwOper.acl.dummy_group(source_grp, item, values)[source]

create a dummy object-group with provided items, by taking template as source group

Parameters
  • source_grp (OBJ) – source group (will be a template to create new dummy group)

  • item (str) – acl line attribte name (‘source’, ‘destination’, ‘ports’, ‘protocol’)

  • values (str, set, tuple, list) – set of value(s)

Returns

object-group object with provided item: values

Return type

OBJ

fwOper.acl.update_obj_grp_str(item, what)[source]

update the object group and host string in acl

Parameters
  • item (dict) – acl line item

  • what (str) – acl line attribte name (‘source’, ‘destination’, ‘ports’, ‘protocol’)

Returns

string represenation of object group or host object in acl

Return type

str