Class: Cisco::HsrpGlobal

Inherits:
NodeUtil show all
Defined in:
lib/cisco_node_utils/hsrp_global.rb

Overview

node_utils class for hsrp_global

Class Method Summary collapse

Instance Method Summary collapse

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(instantiate = true) ⇒ HsrpGlobal

Returns a new instance of HsrpGlobal


22
23
24
25
# File 'lib/cisco_node_utils/hsrp_global.rb', line 22

def initialize(instantiate=true)
  Feature.hsrp_enable if instantiate
  set_args_keys_default
end

Class Method Details

.globalsObject


27
28
29
30
31
# File 'lib/cisco_node_utils/hsrp_global.rb', line 27

def self.globals
  hash = {}
  hash['default'] = HsrpGlobal.new(false) if Feature.hsrp_enabled?
  hash
end

Instance Method Details

#bfd_all_intfObject

PROPERTIES #


59
60
61
# File 'lib/cisco_node_utils/hsrp_global.rb', line 59

def bfd_all_intf
  config_get('hsrp_global', 'bfd_all_intf')
end

#bfd_all_intf=(val) ⇒ Object


63
64
65
66
67
68
# File 'lib/cisco_node_utils/hsrp_global.rb', line 63

def bfd_all_intf=(val)
  state = val ? '' : 'no'
  set_args_keys(state: state)
  Feature.bfd_enable if val
  config_set('hsrp_global', 'bfd_all_intf', @set_args)
end

#default_bfd_all_intfObject


70
71
72
# File 'lib/cisco_node_utils/hsrp_global.rb', line 70

def default_bfd_all_intf
  config_get_default('hsrp_global', 'bfd_all_intf')
end

#default_extended_holdObject


93
94
95
# File 'lib/cisco_node_utils/hsrp_global.rb', line 93

def default_extended_hold
  config_get_default('hsrp_global', 'extended_hold')
end

#destroyObject


45
46
47
48
49
50
51
52
53
# File 'lib/cisco_node_utils/hsrp_global.rb', line 45

def destroy
  return unless Feature.hsrp_enabled?
  [:bfd_all_intf,
   :extended_hold,
  ].each do |prop|
    send("#{prop}=", send("default_#{prop}")) if send prop
  end
  set_args_keys_default
end

#extended_holdObject

CLI can be either of the following or none hsrp timers extended-hold (in this case, the time is 10) hsrp timers extended-hold <time>


77
78
79
80
81
82
83
84
# File 'lib/cisco_node_utils/hsrp_global.rb', line 77

def extended_hold
  hold = config_get('hsrp_global', 'extended_hold', @get_args)
  return default_extended_hold unless hold
  arr = hold.split('hsrp timers extended-hold')
  return config_get('hsrp_global', 'extended_hold_enable', @get_args) if
    arr.empty?
  arr[1].strip
end

#extended_hold=(val) ⇒ Object


86
87
88
89
90
91
# File 'lib/cisco_node_utils/hsrp_global.rb', line 86

def extended_hold=(val)
  state = val ? '' : 'no'
  time = val ? val : ''
  set_args_keys(state: state, time: time)
  config_set('hsrp_global', 'extended_hold', @set_args)
end

#set_args_keys(hash = {}) ⇒ Object

rubocop:disable Style/AccessorMethodName


40
41
42
43
# File 'lib/cisco_node_utils/hsrp_global.rb', line 40

def set_args_keys(hash={})
  set_args_keys_default
  @set_args = @get_args.merge!(hash) unless hash.empty?
end

#set_args_keys_defaultObject

Helper method to delete @set_args hash keys


34
35
36
37
# File 'lib/cisco_node_utils/hsrp_global.rb', line 34

def set_args_keys_default
  @set_args = {}
  @get_args = @set_args
end