Class: Cisco::Pim
Overview
node_utils class for Pim
Instance Attribute Summary collapse
-
#afi ⇒ Object
readonly
Returns the value of attribute afi.
-
#vrf ⇒ Object
readonly
Returns the value of attribute vrf.
Class Method Summary collapse
- .afi_cli(afi) ⇒ Object
-
.pims ⇒ Object
self.pims returns a hash of all current pim objects.
Instance Method Summary collapse
-
#destroy ⇒ Object
This destroy method is different than most because pim does not have a “container” for properties, they simply exist in a given vrf context.
-
#initialize(afi, vrf, instantiate = true) ⇒ Pim
constructor
Constructor with vrf ———————.
-
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName.
- #set_args_keys_default ⇒ Object
-
#ssm_range ⇒ Object
———– Properties ———–.
- #ssm_range=(range) ⇒ 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
#initialize(afi, vrf, instantiate = true) ⇒ Pim
Constructor with vrf
29 30 31 32 33 34 35 36 |
# File 'lib/cisco_node_utils/pim.rb', line 29 def initialize(afi, vrf, instantiate=true) fail ArgumentError unless vrf.is_a?(String) || vrf.length > 0 @vrf = vrf @afi = Pim.afi_cli(afi) set_args_keys_default Feature.pim_enable if instantiate end |
Instance Attribute Details
#afi ⇒ Object (readonly)
Returns the value of attribute afi.
25 26 27 |
# File 'lib/cisco_node_utils/pim.rb', line 25 def afi @afi end |
#vrf ⇒ Object (readonly)
Returns the value of attribute vrf.
25 26 27 |
# File 'lib/cisco_node_utils/pim.rb', line 25 def vrf @vrf end |
Class Method Details
.afi_cli(afi) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/cisco_node_utils/pim.rb', line 68 def self.afi_cli(afi) # Add ipv6 support later fail ArgumentError, "Argument afi must be 'ipv4'" unless afi[/(ipv4)/] afi[/ipv4/] ? 'ip' : afi end |
.pims ⇒ Object
self.pims returns a hash of all current pim objects. There will be one object for each vrf. This method has slightly different behavior than most of the other “get all objects” methods because the pim properties are standalone and do not reside in a “pim” container; therefore, this method simply returns a pim object for each vrf regardless of whether there are any specific pim properties currently defined for the context.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/cisco_node_utils/pim.rb', line 45 def self.pims afis = %w(ipv4) # TBD: No support for ipv6 at this time hash_final = {} return hash_final unless Feature.pim_enabled? afis.each do |afi| hash_final[afi] = {} default_vrf = 'default' hash_final[afi][default_vrf] = Pim.new(afi, default_vrf, false) # Now the vrf's vrf_ids = config_get('vrf', 'all_vrfs') vrf_ids.delete_if { |vrf_id| vrf_id == 'management' } vrf_ids.each do |vrf| hash_final[afi][vrf] = Pim.new(afi, vrf, false) end end hash_final rescue Cisco::CliError => e # cmd will syntax reject when feature is not enabled raise unless e.clierror =~ /Syntax error/ return {} end |
Instance Method Details
#destroy ⇒ Object
This destroy method is different than most because pim does not have a “container” for properties, they simply exist in a given vrf context. For that reason destroy needs to explicitly set each property to its default state.
90 91 92 93 |
# File 'lib/cisco_node_utils/pim.rb', line 90 def destroy return unless Feature.pim_enabled? self.ssm_range = '' end |
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName
81 82 83 84 |
# File 'lib/cisco_node_utils/pim.rb', line 81 def set_args_keys(hash={}) # rubocop:disable Style/AccessorMethodName set_args_keys_default @set_args = @get_args.merge!(hash) unless hash.empty? end |
#set_args_keys_default ⇒ Object
75 76 77 78 79 |
# File 'lib/cisco_node_utils/pim.rb', line 75 def set_args_keys_default keys = { afi: @afi } keys[:vrf] = @vrf unless @vrf == 'default' @get_args = @set_args = keys end |
#ssm_range ⇒ Object
Properties
98 99 100 |
# File 'lib/cisco_node_utils/pim.rb', line 98 def ssm_range config_get('pim', 'ssm_range', @get_args) end |
#ssm_range=(range) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/cisco_node_utils/pim.rb', line 102 def ssm_range=(range) if range.empty? state = 'no' range = ssm_range return if range.nil? else state = '' end set_args_keys(state: state, ssm_range: range) config_set('pim', 'ssm_range', @set_args) end |