Class: Cisco::ObjectGroup
- Defined in:
- lib/cisco_node_utils/object_group.rb
Overview
node_utils class for object_group
Instance Attribute Summary collapse
-
#afi ⇒ Object
readonly
Returns the value of attribute afi.
-
#grp_name ⇒ Object
readonly
Returns the value of attribute grp_name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
-
#initialize(afi, type, name, instantiate = true) ⇒ ObjectGroup
constructor
A new instance of ObjectGroup.
-
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName.
-
#set_args_keys_default ⇒ Object
Helper method to delete @set_args hash keys.
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
#initialize(afi, type, name, instantiate = true) ⇒ ObjectGroup
Returns a new instance of ObjectGroup.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cisco_node_utils/object_group.rb', line 26 def initialize(afi, type, name, instantiate=true) fail TypeError unless name.is_a?(String) fail ArgumentError unless type[/address|port/] @afi = Acl.afi_cli(afi) @type = type @grp_name = name set_args_keys_default create if instantiate end |
Instance Attribute Details
#afi ⇒ Object (readonly)
Returns the value of attribute afi.
24 25 26 |
# File 'lib/cisco_node_utils/object_group.rb', line 24 def afi @afi end |
#grp_name ⇒ Object (readonly)
Returns the value of attribute grp_name.
24 25 26 |
# File 'lib/cisco_node_utils/object_group.rb', line 24 def grp_name @grp_name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
24 25 26 |
# File 'lib/cisco_node_utils/object_group.rb', line 24 def type @type end |
Class Method Details
.object_groups ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cisco_node_utils/object_group.rb', line 61 def self.object_groups hash = {} grps = config_get('object_group', 'all_object_groups') return hash if grps.nil? grps.each do |afi, type, name| lafi = afi lafi = 'ipv4' if afi == 'ip' hash[lafi] ||= {} hash[lafi][type] ||= {} hash[lafi][type][name] = ObjectGroup.new(lafi, type, name, false) end hash end |
Instance Method Details
#==(other) ⇒ Object
57 58 59 |
# File 'lib/cisco_node_utils/object_group.rb', line 57 def ==(other) grp_name == other.grp_name && afi == other.afi && type == other.type end |
#create ⇒ Object
49 50 51 |
# File 'lib/cisco_node_utils/object_group.rb', line 49 def create config_set('object_group', 'create', @set_args) end |
#destroy ⇒ Object
53 54 55 |
# File 'lib/cisco_node_utils/object_group.rb', line 53 def destroy config_set('object_group', 'destroy', @set_args) end |
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName
44 45 46 47 |
# File 'lib/cisco_node_utils/object_group.rb', line 44 def set_args_keys(hash={}) set_args_keys_default @set_args = @get_args.merge!(hash) unless hash.empty? end |
#set_args_keys_default ⇒ Object
Helper method to delete @set_args hash keys
38 39 40 41 |
# File 'lib/cisco_node_utils/object_group.rb', line 38 def set_args_keys_default @set_args = { afi: @afi, type: @type, grp_name: @grp_name } @get_args = @set_args end |