Class: Cisco::InterfaceHsrpGroup

Inherits:
NodeUtil
  • Object
show all
Defined in:
lib/cisco_node_utils/interface_hsrp_group.rb

Overview

node_utils class for interface_hsrp_group

Instance Attribute Summary collapse

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(interface, group_id, ip_type, instantiate = true) ⇒ InterfaceHsrpGroup

Returns a new instance of InterfaceHsrpGroup.



26
27
28
29
30
31
32
33
34
35
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 26

def initialize(interface, group_id, ip_type, instantiate=true)
  fail TypeError unless interface.is_a?(String)
  fail ArgumentError unless ip_type[/ipv4|ipv6/]
  @name = interface.downcase
  @group = group_id
  @iptype = ip_type

  set_args_keys_default
  create if instantiate
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



24
25
26
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 24

def group
  @group
end

#iptypeObject (readonly)

Returns the value of attribute iptype.



24
25
26
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 24

def iptype
  @iptype
end

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 24

def name
  @name
end

Class Method Details

.groupsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 37

def self.groups
  hash = {}
  return hash unless Feature.hsrp_enabled?
  all_hsrp = config_get('interface_hsrp_group', 'all_hsrp')
  interfaces = all_hsrp.scan(/interface (.*)/).flatten
  interfaces.each do|intf|
    groups = config_get('interface_hsrp_group', 'groups', name: intf)
    next if groups.nil?
    hash[intf] = {}
    groups.each do |id, type|
      iptype = type
      iptype = 'ipv4' if type.nil?
      hash[intf][id] ||= {}
      hash[intf][id][iptype] =
        InterfaceHsrpGroup.new(intf, id, iptype, false)
    end
  end
  hash
end

Instance Method Details

#authenticationObject

This CLI is very complicated, it can take many forms authentication text Test authentication md5 key-chain abcd authentication md5 key-string 7 => 7 is key-string authentication md5 key-string 7 12345678901234567890 authentication md5 key-string ABCXYZ => enctype is 0 authentication md5 key-string ABCXYZ compatibility authentication md5 key-string ABCXYZ compatibility timeout 22 authentication md5 key-string ABCXYZ timeout 22 authentication md5 key-string 7 12345678901234567890 timeout 22 authentication md5 key-string 7 123456789 compatibility timeout 22 if passwd

req auth_enc_type

if encrypted

req authentication_key_type, authentication_enc_type
if key-string
  optional compat and timeout


107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 107

def authentication
  hash = {}
  hash[:auth_type] = default_authentication_auth_type
  hash[:key_type] = default_authentication_key_type
  hash[:enc_type] = default_authentication_enc_type
  hash[:password] = default_authentication_string
  hash[:compat] = default_authentication_compatibility
  hash[:timeout] = default_authentication_timeout
  str = config_get('interface_hsrp_group', 'authentication', @get_args)
  return hash if str.nil?
  regexp = Regexp.new('(?<authtype>text|md5)'\
       ' *(?<keytype>key-chain|key-string|\S+)'\
       ' *(?<enctype>7|\S+)?'\
       ' *(?<keystring>\S+)?')
  params = regexp.match(str)
  if params[:authtype] == 'text'
    hash[:password] = params[:keytype]
  else
    hash[:auth_type] = 'md5'
    hash[:key_type] = params[:keytype]
    if hash[:key_type] == 'key-chain'
      hash[:password] = params[:enctype]
    else
      if params[:enctype] == '7' && params[:keystring].nil?
        hash[:password] = '7'
      elsif params[:enctype] == '7' && !params[:keystring].nil?
        hash[:enc_type] = '7'
        hash[:password] = params[:keystring]
      else
        hash[:password] = params[:enctype]
      end
      # get rid of password from str just in case the password is
      # compatibility or timeout
      str.sub!(hash[:password], '')
      hash[:compat] = true if str.include?('compatibility')
      hash[:timeout] = str.split.last.to_i if str.include?('timeout')
    end
  end
  hash
end

#authentication_auth_typeObject



148
149
150
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 148

def authentication_auth_type
  authentication[:auth_type]
end

#authentication_auth_type=(val) ⇒ Object



152
153
154
155
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 152

def authentication_auth_type=(val)
  @set_args[:authtype] = val
  @set_args[:authtype] = 'text' if val.to_s == 'cleartext'
end

#authentication_compatibilityObject



197
198
199
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 197

def authentication_compatibility
  authentication[:compat]
end

#authentication_compatibility=(val) ⇒ Object



201
202
203
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 201

def authentication_compatibility=(val)
  @set_args[:compatible] = val ? 'compatibility' : ''
end

#authentication_enc_typeObject



173
174
175
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 173

def authentication_enc_type
  authentication[:enc_type]
end

#authentication_enc_type=(val) ⇒ Object



177
178
179
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 177

def authentication_enc_type=(val)
  @set_args[:enctype] = val
end

#authentication_key_typeObject



161
162
163
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 161

def authentication_key_type
  authentication[:key_type]
end

#authentication_key_type=(val) ⇒ Object



165
166
167
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 165

def authentication_key_type=(val)
  @set_args[:keytype] = val.to_s
end

#authentication_set(attrs) ⇒ Object



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 227

def authentication_set(attrs)
  set_args_keys_default
  # reset the authentication first
  @set_args[:state] = 'no'
  @set_args[:passwd] = ''
  @set_args[:authtype] = @set_args[:keytype] = @set_args[:enctype] = ''
  @set_args[:compatible] = @set_args[:timeout] = @set_args[:tval] = ''
  config_set('interface_hsrp_group', 'authentication', @set_args)
  set_args_keys(attrs)
  [:authentication_auth_type,
   :authentication_key_type,
   :authentication_enc_type,
   :authentication_string,
   :authentication_compatibility,
   :authentication_timeout,
  ].each do |p|
    send(p.to_s + '=', attrs[p])
  end
  return if @set_args[:passwd].nil? || @set_args[:passwd].empty?
  @set_args[:state] = ''
  if @set_args[:authtype] == 'text'
    @set_args[:keytype] = @set_args[:enctype] = ''
    @set_args[:compatible] = @set_args[:timeout] = @set_args[:tval] = ''
  elsif @set_args[:keytype] == 'key-chain'
    @set_args[:enctype] = @set_args[:compatible] = ''
    @set_args[:timeout] = @set_args[:tval] = ''
  end
  config_set('interface_hsrp_group', 'authentication', @set_args)
end

#authentication_stringObject



185
186
187
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 185

def authentication_string
  authentication[:password]
end

#authentication_string=(val) ⇒ Object



189
190
191
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 189

def authentication_string=(val)
  @set_args[:passwd] = val
end

#authentication_timeoutObject



209
210
211
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 209

def authentication_timeout
  authentication[:timeout]
end

#authentication_timeout=(val) ⇒ Object



213
214
215
216
217
218
219
220
221
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 213

def authentication_timeout=(val)
  if val.nil?
    @set_args[:tval] = ''
    @set_args[:timeout] = ''
  else
    @set_args[:tval] = val
    @set_args[:timeout] = 'timeout'
  end
end

#createObject

Create one interface hsrp group instance



71
72
73
74
75
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 71

def create
  Feature.hsrp_enable
  set_args_keys(state: '')
  config_set('interface_hsrp_group', 'groups', @set_args)
end

#default_authentication_auth_typeObject



157
158
159
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 157

def default_authentication_auth_type
  config_get_default('interface_hsrp_group', 'authentication_auth_type')
end

#default_authentication_compatibilityObject



205
206
207
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 205

def default_authentication_compatibility
  config_get_default('interface_hsrp_group', 'authentication_compatibility')
end

#default_authentication_enc_typeObject



181
182
183
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 181

def default_authentication_enc_type
  config_get_default('interface_hsrp_group', 'authentication_enc_type')
end

#default_authentication_key_typeObject



169
170
171
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 169

def default_authentication_key_type
  config_get_default('interface_hsrp_group', 'authentication_key_type')
end

#default_authentication_stringObject



193
194
195
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 193

def default_authentication_string
  config_get_default('interface_hsrp_group', 'authentication_string')
end

#default_authentication_timeoutObject



223
224
225
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 223

def default_authentication_timeout
  config_get_default('interface_hsrp_group', 'authentication_timeout')
end

#default_group_nameObject



365
366
367
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 365

def default_group_name
  config_get_default('interface_hsrp_group', 'group_name')
end

#default_ipv4_enableObject



263
264
265
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 263

def default_ipv4_enable
  config_get_default('interface_hsrp_group', 'ipv4_enable')
end

#default_ipv4_vipObject



286
287
288
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 286

def default_ipv4_vip
  config_get_default('interface_hsrp_group', 'ipv4_vip')
end

#default_ipv6_autoconfigObject



300
301
302
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 300

def default_ipv6_autoconfig
  config_get_default('interface_hsrp_group', 'ipv6_autoconfig')
end

#default_ipv6_vipObject



329
330
331
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 329

def default_ipv6_vip
  config_get_default('interface_hsrp_group', 'ipv6_vip')
end

#default_mac_addrObject



350
351
352
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 350

def default_mac_addr
  config_get_default('interface_hsrp_group', 'mac_addr')
end

#default_preemptObject



416
417
418
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 416

def default_preempt
  config_get_default('interface_hsrp_group', 'preempt')
end

#default_preempt_delay_minimumObject



420
421
422
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 420

def default_preempt_delay_minimum
  config_get_default('interface_hsrp_group', 'preempt_delay_minimum')
end

#default_preempt_delay_reloadObject



424
425
426
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 424

def default_preempt_delay_reload
  config_get_default('interface_hsrp_group', 'preempt_delay_reload')
end

#default_preempt_delay_syncObject



428
429
430
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 428

def default_preempt_delay_sync
  config_get_default('interface_hsrp_group', 'preempt_delay_sync')
end

#default_priorityObject



453
454
455
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 453

def default_priority
  config_get_default('interface_hsrp_group', 'priority')
end

#default_priority_forward_thresh_lowerObject



461
462
463
464
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 461

def default_priority_forward_thresh_lower
  config_get_default('interface_hsrp_group',
                     'priority_forward_thresh_lower')
end

#default_priority_forward_thresh_upperObject



470
471
472
473
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 470

def default_priority_forward_thresh_upper
  config_get_default('interface_hsrp_group',
                     'priority_forward_thresh_upper')
end

#default_timers_helloObject



520
521
522
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 520

def default_timers_hello
  config_get_default('interface_hsrp_group', 'timers_hello')
end

#default_timers_hello_msecObject



524
525
526
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 524

def default_timers_hello_msec
  config_get_default('interface_hsrp_group', 'timers_hello_msec')
end

#default_timers_holdObject



540
541
542
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 540

def default_timers_hold
  config_get_default('interface_hsrp_group', 'timers_hold')
end

#default_timers_hold_msecObject



536
537
538
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 536

def default_timers_hold_msec
  config_get_default('interface_hsrp_group', 'timers_hold_msec')
end

#destroyObject



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

def destroy
  return unless Feature.hsrp_enabled?
  # for ipv4 types, 'no' cmd needs the type to be specified
  # explicitly if another ipv6 group exists with the same
  # group id
  set_args_keys(state: 'no', iptype: @iptype)
  config_set('interface_hsrp_group', 'groups', @set_args)
end

#group_nameObject



354
355
356
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 354

def group_name
  config_get('interface_hsrp_group', 'group_name', @get_args)
end

#group_name=(val) ⇒ Object



358
359
360
361
362
363
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 358

def group_name=(val)
  state = val ? '' : 'no'
  word = val ? val : ''
  set_args_keys(state: state, word: word)
  config_set('interface_hsrp_group', 'group_name', @set_args)
end

#ipv4_enableObject



257
258
259
260
261
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 257

def ipv4_enable
  return default_ipv4_enable if @iptype == 'ipv6'
  ip = config_get('interface_hsrp_group', 'ipv4_vip', @get_args)
  ip.empty? ? false : true
end

#ipv4_vipObject



267
268
269
270
271
272
273
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 267

def ipv4_vip
  return default_ipv4_vip if @iptype == 'ipv6'
  ip = config_get('interface_hsrp_group', 'ipv4_vip', @get_args)
  return default_ipv4_vip unless ip
  arr = ip.split
  arr[1] ? arr[1] : default_ipv4_vip
end

#ipv4_vip_set(ipenable, vip) ⇒ Object



275
276
277
278
279
280
281
282
283
284
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 275

def ipv4_vip_set(ipenable, vip)
  return if @iptype == 'ipv6'
  # reset it first
  set_args_keys(state: 'no', vip: '')
  config_set('interface_hsrp_group', 'ipv4_vip', @set_args)
  return unless ipenable
  vip = vip ? vip : ''
  set_args_keys(state: '', vip: vip)
  config_set('interface_hsrp_group', 'ipv4_vip', @set_args)
end

#ipv6_autoconfigObject



290
291
292
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 290

def ipv6_autoconfig
  config_get('interface_hsrp_group', 'ipv6_autoconfig', @get_args)
end

#ipv6_autoconfig=(val) ⇒ Object



294
295
296
297
298
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 294

def ipv6_autoconfig=(val)
  state = val ? '' : 'no'
  set_args_keys(state: state)
  config_set('interface_hsrp_group', 'ipv6_autoconfig', @set_args)
end

#ipv6_vipObject



304
305
306
307
308
309
310
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 304

def ipv6_vip
  return default_ipv6_vip if @iptype == 'ipv4'
  list = config_get('interface_hsrp_group', 'ipv6_vip', @get_args)
  # remove autoconfig from the list
  list.delete('autoconfig')
  list
end

#ipv6_vip=(list) ⇒ Object



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 312

def ipv6_vip=(list)
  # reset the current list
  cur = ipv6_vip
  cur.each do |addr|
    state = 'no'
    vip = addr
    set_args_keys(state: state, vip: vip)
    config_set('interface_hsrp_group', 'ipv6_vip', @set_args)
  end
  list.each do |addr|
    state = ''
    vip = addr
    set_args_keys(state: state, vip: vip)
    config_set('interface_hsrp_group', 'ipv6_vip', @set_args)
  end
end

#mac_addrObject

CLI returns mac_addr in xxxx.xxxx.xxxx format so convert it to xx:xx:xx:xx:xx:xx format



335
336
337
338
339
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 335

def mac_addr
  mac = config_get('interface_hsrp_group', 'mac_addr', @get_args)
  return default_mac_addr unless mac
  mac.tr('.', '').scan(/.{1,2}/).join(':')
end

#mac_addr=(val) ⇒ Object

CLI expects mac_addr to be in xxxx.xxxx.xxxx format so convert from xx:xx:xx:xx:xx:xx format



343
344
345
346
347
348
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 343

def mac_addr=(val)
  state = val ? '' : 'no'
  mac = val ? val.tr(':', '').scan(/.{1,4}/).join('.') : ''
  set_args_keys(state: state, mac: mac)
  config_set('interface_hsrp_group', 'mac_addr', @set_args)
end

#preemptObject



388
389
390
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 388

def preempt
  preempt_get[:preempt]
end

#preempt_delay_minimumObject



392
393
394
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 392

def preempt_delay_minimum
  preempt_get[:minimum].to_i
end

#preempt_delay_reloadObject



396
397
398
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 396

def preempt_delay_reload
  preempt_get[:reload].to_i
end

#preempt_delay_syncObject



400
401
402
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 400

def preempt_delay_sync
  preempt_get[:sync].to_i
end

#preempt_getObject

The CLI can take forms like: preempt preempt delay minimum 3 reload 10 sync 15



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 372

def preempt_get
  hash = {}
  hash[:preempt] = default_preempt
  hash[:minimum] = default_preempt_delay_minimum
  hash[:reload] = default_preempt_delay_reload
  hash[:sync] = default_preempt_delay_sync
  arr = config_get('interface_hsrp_group', 'preempt', @get_args)
  if arr
    hash[:preempt] = true
    hash[:minimum] = arr[0]
    hash[:reload] = arr[1]
    hash[:sync] = arr[2]
  end
  hash
end

#preempt_set(pree, min, rel, sy) ⇒ Object



404
405
406
407
408
409
410
411
412
413
414
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 404

def preempt_set(pree, min, rel, sy)
  if pree
    set_args_keys(state: '', delay: 'delay', minimum: 'minimum',
                  minval: min, reload: 'reload', relval: rel,
                  sync: 'sync', syncval: sy)
  else
    set_args_keys(state: 'no', delay: '', minimum: '', minval: '',
                  reload: '', relval: '', sync: '', syncval: '')
  end
  config_set('interface_hsrp_group', 'preempt', @set_args)
end

#priorityObject



449
450
451
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 449

def priority
  priority_level_get[:priority]
end

#priority_forward_thresh_lowerObject



457
458
459
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 457

def priority_forward_thresh_lower
  priority_level_get[:lower]
end

#priority_forward_thresh_upperObject



466
467
468
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 466

def priority_forward_thresh_upper
  priority_level_get[:upper]
end

#priority_level_getObject

This CLI can take forms like: priority 10 priority 50 forwarding-threshold lower 10 upper 49



435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 435

def priority_level_get
  hash = {}
  hash[:priority] = default_priority
  hash[:lower] = default_priority_forward_thresh_lower
  hash[:upper] = default_priority_forward_thresh_upper
  arr = config_get('interface_hsrp_group', 'priority_level', @get_args)
  if arr
    hash[:priority] = arr[0].to_i
    hash[:lower] = arr[1].to_i if arr[1]
    hash[:upper] = arr[2].to_i if arr[2]
  end
  hash
end

#priority_level_set(pri, lower, upper) ⇒ Object



475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 475

def priority_level_set(pri, lower, upper)
  if pri && !lower.to_s.empty? && !upper.to_s.empty?
    set_args_keys(state: '', pri: pri,
                  forward: 'forwarding-threshold lower',
                  lval: lower, upper: 'upper', uval: upper)
  elsif pri
    set_args_keys(state: '', pri: pri,
                  forward: '', lval: '', upper: '', uval: '')
  else
    set_args_keys(state: 'no', pri: pri, forward: '', lval: '',
                  upper: '', uval: '')
  end
  config_set('interface_hsrp_group', 'priority_level', @set_args)
end

#set_args_keys(hash = {}) ⇒ Object

rubocop:disable Style/AccessorMethodName



65
66
67
68
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 65

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



58
59
60
61
62
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 58

def set_args_keys_default
  @set_args = { name: @name, group: @group, iptype: iptype }
  @set_args[:iptype] = '' if @iptype == 'ipv4'
  @get_args = @set_args
end

#timers_getObject

This CLI can take forms like: timers 1 3 timers msec 300 3 timers msec 750 msec 2500



494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 494

def timers_get
  hash = {}
  hash[:hello] = default_timers_hello
  hash[:mshello] = default_timers_hello_msec
  hash[:hold] = default_timers_hold
  hash[:mshold] = default_timers_hold_msec
  str = config_get('interface_hsrp_group', 'timers', @get_args)
  return hash if str.nil?
  regexp = Regexp.new('(?<msec1>msec)?'\
           ' *(?<he>\d+) *(?<msec2>msec)? *(?<ho>\d+)')
  params = regexp.match(str)
  hash[:mshello] = true if params[:msec1]
  hash[:mshold] = true if params[:msec2]
  hash[:hello] = params[:he].to_i
  hash[:hold] = params[:ho].to_i
  hash
end

#timers_helloObject



512
513
514
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 512

def timers_hello
  timers_get[:hello]
end

#timers_hello_msecObject



516
517
518
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 516

def timers_hello_msec
  timers_get[:mshello]
end

#timers_holdObject



528
529
530
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 528

def timers_hold
  timers_get[:hold]
end

#timers_hold_msecObject



532
533
534
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 532

def timers_hold_msec
  timers_get[:mshold]
end

#timers_set(mshello, hello, mshold, hold) ⇒ Object



544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 544

def timers_set(mshello, hello, mshold, hold)
  if hello && hold
    msechello = mshello ? 'msec' : ''
    msechold = mshold ? 'msec' : ''
    set_args_keys(state: '', mshello: msechello,
                  hello: hello, mshold: msechold, hold: hold)
  else
    set_args_keys(state: 'no', mshello: '', hello: '',
                  mshold: '', hold: '')
  end
  config_set('interface_hsrp_group', 'timers', @set_args)
end