Package: cisco-acl
cisco-aclPython package to parse and manage Cisco ACL (Access Control List).Supported platforms:Cisco IOS (tested on ISR4331/K9, IOS XE version 16.09.06)Cisco Nexus NX-OS (tested on N3K-C3172TQ-XL, NXOS version 7.0(3)I7(8))Main features:Supports wildcards, converts wildcards to prefixesSupports address groupsRepresents TCP/UDP ports and IP protocols as numbers or well-known namesConverts IOS syntax to NX-OS and vice veraGenerates sequence numbers for ACEsLooks for and removes ACEs in the shadow (rules without hits)Groups ACEs to blocks. After sorting, the order of ACEs within a group does not changeContentsAcronymsRequirementsInstallationacls()aces()addrgroups()range_ports()range_protocols()ObjectsAcronymsAcronymDefinitionACLAccess Control ListACEAccess Control EntryACEsMultiple Access Control EntriesRequirementsPython >=3.8InstallationInstall the package from pypi.org releasepipinstallcisco-aclor install the package from github.com releasepipinstallhttps://github.com/vladimirs-git/cisco-acl/archive/refs/tags/3.2.3.tar.gzor install the package from github.com repositorypipinstallgit+https://github.com/vladimirs-git/cisco-aclacls()cisco_acl.acls(config, kwargs)CreatesAclobjects based on the “show running-config” output.
Support address group objects.
Each ACE line is treated as an independentAce(default) or ACE lines can be
grouped toAceGroupby text in remarks (paramgroup_by)ParameterTypeDescriptionconfigstrCisco config, “show running-config” outputplatformstrPlatform: “ios” (default), “nxos”namesList[str]Parses only ACLs with specified names, skips any othermax_ncwbintMax count of non-contiguous wildcard bitsindentstrACE lines indentation (default “  “)protocol_nrboolWell-known ip protocols as numbers, True  - all ip protocols as numbers, False - well-known ip protocols as names (default)port_nrboolWell-known TCP/UDP ports as numbers, True  - all tcp/udp ports as numbers, False - well-known tcp/udp ports as names (default)group_bystrStartswith in remark line. ACEs group, starting from the Remark, where line startswithgroup_by, will be applied to the same AceGroup, until next Remark that also startswithgroup_byReturnList ofAclobjectsExamples./examples/functions_acls.pyaces()cisco_acl.aces(config, kwargs)CreatesAceobjects based on the “show running-config” outputParameterTypeDescriptionconfigstrCisco config, “show running-config” outputplatformstrPlatform: “ios” (default), “nxos”max_ncwbintMax count of non-contiguous wildcard bitsprotocol_nrboolWell-known ip protocols as numbers, True  - all ip protocols as numbers, False - well-known ip protocols as names (default)port_nrboolWell-known TCP/UDP ports as numbers, True  - all tcp/udp ports as numbers, False - well-known tcp/udp ports as names (default)group_bystrStartswith in remark line. ACEs group, starting from the Remark, where line startswithgroup_by, will be applied to the same AceGroup, until next Remark that also startswithgroup_byReturnList ofAceobjectsExamples./examples/functions_aces.pyaddrgroups()cisco_acl.addrgroups(config, kwargs)CreatesAddrGroupobjects based on the “show running-config” outputParameterTypeDescriptionconfigstrCisco config, “show running-config” outputplatformstrPlatform: “ios” (default), “nxos”max_ncwbintMax count of non-contiguous wildcard bitsindentstrACE lines indentation (default “  “)ReturnList ofAddrGroupobjectsrange_ports()cisco_acl.range_ports(srcports, dstports, line, platform, port_nr)Generates ACEs in required range of TCP/UDP source/destination portsParameterTypeDescriptionsrcportsstrRange of TCP/UDP source portsdstportsstrRange of TCP/UDP destination portslinestrACE pattern, on whose basis new ACEs will be generated (default “permit tcp any any”, operator “eq”)platformstrPlatform: “ios” (default), “nxos”port_nrboolWell-known TCP/UDP ports as numbers, True  - all tcp/udp ports as numbers, False - well-known tcp/udp ports as names (default)ReturnList of newly generated ACE linesExamples./examples/functions_range_ports.pyrange_protocols()cisco_acl.range_protocols(protocols, line, platform, protocol_nr)Generates ACEs in required range of IP protocolsParameterTypeDescriptionprotocolsstrRange of IP protocolslinestrACE pattern, on whose basis new ACEs will be generated (default “permit ip any any”)platformstrPlatform: “ios” (default), “nxos”protocol_nrboolWell-known ip protocols as numbers, True  - all ip protocols as numbers, False - well-known ip protocols as names (default)ReturnList of newly generated ACE linesExamples./examples/functions_range_protocols.pyObjectsDocumentation of objects for deep-code divers./docs/objects.rst