Class: Cisco::Acl
Overview
Acl - node utility class for ACL configuration
Instance Attribute Summary collapse
-
#acl_name ⇒ Object
readonly
Returns the value of attribute acl_name.
-
#afi ⇒ Object
readonly
Returns the value of attribute afi.
Class Method Summary collapse
-
.acls ⇒ Object
Return all acls currently on the switch.
-
.afi_cli(afi) ⇒ Object
Platform-specific afi cli string.
Instance Method Summary collapse
-
#==(other) ⇒ Object
acl == overide func.
- #config_acl(state) ⇒ Object
- #create ⇒ Object
- #default_fragments ⇒ Object
- #default_stats_per_entry ⇒ Object
- #destroy ⇒ Object
- #fragments ⇒ Object
- #fragments=(action) ⇒ Object
-
#initialize(afi, acl_name, instantiate = true) ⇒ Acl
constructor
A new instance of Acl.
-
#stats_per_entry ⇒ Object
———- PROPERTIES ———-.
- #stats_per_entry=(state) ⇒ Object
Methods inherited from NodeUtil
client, #client, config_get, #config_get, #config_get_default, config_get_default, config_set, #config_set, #get, #ios_xr?, #nexus?, #node, node, platform, #platform, supports?, #supports?
Constructor Details
Instance Attribute Details
#acl_name ⇒ Object (readonly)
Returns the value of attribute acl_name.
20 21 22 |
# File 'lib/cisco_node_utils/acl.rb', line 20 def acl_name @acl_name end |
#afi ⇒ Object (readonly)
Returns the value of attribute afi.
20 21 22 |
# File 'lib/cisco_node_utils/acl.rb', line 20 def afi @afi end |
Class Method Details
.acls ⇒ Object
Return all acls currently on the switch
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cisco_node_utils/acl.rb', line 28 def self.acls afis = %w(ipv4 ipv6) acl_hash = {} afis.each do |afi| acl_hash[afi] = {} afi_cli = Acl.afi_cli(afi) instances = config_get('acl', 'all_acls', afi: afi_cli) next if instances.nil? instances.each do |acl_name| acl_hash[afi][acl_name] = Acl.new(afi, acl_name, false) end end acl_hash end |
.afi_cli(afi) ⇒ Object
Platform-specific afi cli string
45 46 47 48 49 50 |
# File 'lib/cisco_node_utils/acl.rb', line 45 def self.afi_cli(afi) fail ArgumentError, "Argument afi must be 'ipv4' or 'ipv6'" unless afi[/(ipv4|ipv6)/] afi = 'ip' if platform == :nexus && afi[/ipv4/] afi end |
Instance Method Details
#==(other) ⇒ Object
acl == overide func
97 98 99 |
# File 'lib/cisco_node_utils/acl.rb', line 97 def ==(other) acl_name == other.acl_name && afi == other.afi end |
#config_acl(state) ⇒ Object
60 61 62 63 |
# File 'lib/cisco_node_utils/acl.rb', line 60 def config_acl(state) @set_args[:state] = state config_set('acl', 'acl', @set_args) end |
#create ⇒ Object
52 53 54 |
# File 'lib/cisco_node_utils/acl.rb', line 52 def create config_acl('') end |
#default_fragments ⇒ Object
92 93 94 |
# File 'lib/cisco_node_utils/acl.rb', line 92 def default_fragments config_get_default('acl', 'fragments') end |
#default_stats_per_entry ⇒ Object
77 78 79 |
# File 'lib/cisco_node_utils/acl.rb', line 77 def default_stats_per_entry config_get_default('acl', 'stats_per_entry') end |
#destroy ⇒ Object
56 57 58 |
# File 'lib/cisco_node_utils/acl.rb', line 56 def destroy config_acl('no') end |
#fragments ⇒ Object
81 82 83 |
# File 'lib/cisco_node_utils/acl.rb', line 81 def fragments config_get('acl', 'fragments', @get_args) end |
#fragments=(action) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/cisco_node_utils/acl.rb', line 85 def fragments=(action) @set_args[:state] = (action ? '' : 'no') action = fragments unless action @set_args[:action] = action config_set('acl', 'fragments', @set_args) if action end |
#stats_per_entry ⇒ Object
PROPERTIES
68 69 70 |
# File 'lib/cisco_node_utils/acl.rb', line 68 def stats_per_entry config_get('acl', 'stats_per_entry', @get_args) end |
#stats_per_entry=(state) ⇒ Object
72 73 74 75 |
# File 'lib/cisco_node_utils/acl.rb', line 72 def stats_per_entry=(state) @set_args[:state] = (state ? '' : 'no') config_set('acl', 'stats_per_entry', @set_args) end |