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
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 37

def self.groups
  hash = {}
  return hash unless Feature.hsrp_enabled?
  Interface.interfaces.each do|intf, _obj|
    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



99
100
101
102
103
104
105
106
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
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 99

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



140
141
142
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 140

def authentication_auth_type
  authentication[:auth_type]
end

#authentication_auth_type=(val) ⇒ Object



144
145
146
147
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 144

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

#authentication_compatibilityObject



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

def authentication_compatibility
  authentication[:compat]
end

#authentication_compatibility=(val) ⇒ Object



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

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

#authentication_enc_typeObject



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

def authentication_enc_type
  authentication[:enc_type]
end

#authentication_enc_type=(val) ⇒ Object



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

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

#authentication_key_typeObject



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

def authentication_key_type
  authentication[:key_type]
end

#authentication_key_type=(val) ⇒ Object



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

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

#authentication_set(attrs) ⇒ Object



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 214

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]) unless attrs[p].nil?
  end
  return if @set_args[:passwd] == default_authentication_string
  @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] == default_authentication_key_type
    @set_args[:enctype] = @set_args[:compatible] = ''
    @set_args[:timeout] = @set_args[:tval] = ''
  end
  config_set('interface_hsrp_group', 'authentication', @set_args)
end

#authentication_stringObject



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

def authentication_string
  authentication[:password]
end

#authentication_string=(val) ⇒ Object



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

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

#authentication_timeoutObject



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

def authentication_timeout
  authentication[:timeout]
end

#authentication_timeout=(val) ⇒ Object



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

def authentication_timeout=(val)
  @set_args[:tval] = val
  @set_args[:timeout] = 'timeout'
end

#createObject

Create one interface hsrp group instance



69
70
71
72
73
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 69

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

#default_authentication_auth_typeObject



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

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

#default_authentication_compatibilityObject



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

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

#default_authentication_enc_typeObject



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

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

#default_authentication_key_typeObject



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

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

#default_authentication_stringObject



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

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

#default_authentication_timeoutObject



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

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

#default_group_nameObject



352
353
354
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 352

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

#default_ipv4_enableObject



250
251
252
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 250

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

#default_ipv4_vipObject



273
274
275
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 273

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

#default_ipv6_autoconfigObject



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

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

#default_ipv6_vipObject



316
317
318
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 316

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

#default_mac_addrObject



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

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

#default_preemptObject



403
404
405
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 403

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

#default_preempt_delay_minimumObject



407
408
409
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 407

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

#default_preempt_delay_reloadObject



411
412
413
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 411

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

#default_preempt_delay_syncObject



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

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

#default_priorityObject



440
441
442
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 440

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

#default_priority_forward_thresh_lowerObject



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

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

#default_priority_forward_thresh_upperObject



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

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

#default_timers_helloObject



507
508
509
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 507

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

#default_timers_hello_msecObject



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

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

#default_timers_holdObject



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

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

#default_timers_hold_msecObject



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

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

#destroyObject



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

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



341
342
343
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 341

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

#group_name=(val) ⇒ Object



345
346
347
348
349
350
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 345

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



244
245
246
247
248
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 244

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



254
255
256
257
258
259
260
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 254

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



262
263
264
265
266
267
268
269
270
271
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 262

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



277
278
279
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 277

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

#ipv6_autoconfig=(val) ⇒ Object



281
282
283
284
285
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 281

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

#ipv6_vipObject



291
292
293
294
295
296
297
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 291

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



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 299

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



322
323
324
325
326
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 322

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



330
331
332
333
334
335
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 330

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



375
376
377
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 375

def preempt
  preempt_get[:preempt]
end

#preempt_delay_minimumObject



379
380
381
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 379

def preempt_delay_minimum
  preempt_get[:minimum].to_i
end

#preempt_delay_reloadObject



383
384
385
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 383

def preempt_delay_reload
  preempt_get[:reload].to_i
end

#preempt_delay_syncObject



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

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



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 359

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



391
392
393
394
395
396
397
398
399
400
401
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 391

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



436
437
438
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 436

def priority
  priority_level_get[:priority]
end

#priority_forward_thresh_lowerObject



444
445
446
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 444

def priority_forward_thresh_lower
  priority_level_get[:lower]
end

#priority_forward_thresh_upperObject



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

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



422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 422

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



462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 462

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



63
64
65
66
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 63

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



56
57
58
59
60
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 56

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



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 481

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



499
500
501
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 499

def timers_hello
  timers_get[:hello]
end

#timers_hello_msecObject



503
504
505
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 503

def timers_hello_msec
  timers_get[:mshello]
end

#timers_holdObject



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

def timers_hold
  timers_get[:hold]
end

#timers_hold_msecObject



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

def timers_hold_msec
  timers_get[:mshold]
end

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



531
532
533
534
535
536
537
538
539
540
541
542
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 531

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