Class: Cisco::InterfaceHsrpGroup
- Inherits:
-
NodeUtil
- Object
- NodeUtil
- Cisco::InterfaceHsrpGroup
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
-
#authentication ⇒ Object
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.
-
#authentication_auth_type ⇒ Object
-
#authentication_auth_type=(val) ⇒ Object
-
#authentication_compatibility ⇒ Object
-
#authentication_compatibility=(val) ⇒ Object
-
#authentication_enc_type ⇒ Object
-
#authentication_enc_type=(val) ⇒ Object
-
#authentication_key_type ⇒ Object
-
#authentication_key_type=(val) ⇒ Object
-
#authentication_set(attrs) ⇒ Object
-
#authentication_string ⇒ Object
-
#authentication_string=(val) ⇒ Object
-
#authentication_timeout ⇒ Object
-
#authentication_timeout=(val) ⇒ Object
-
#create ⇒ Object
Create one interface hsrp group instance.
-
#default_authentication_auth_type ⇒ Object
-
#default_authentication_compatibility ⇒ Object
-
#default_authentication_enc_type ⇒ Object
-
#default_authentication_key_type ⇒ Object
-
#default_authentication_string ⇒ Object
-
#default_authentication_timeout ⇒ Object
-
#default_group_name ⇒ Object
-
#default_ipv4_enable ⇒ Object
-
#default_ipv4_vip ⇒ Object
-
#default_ipv6_autoconfig ⇒ Object
-
#default_ipv6_vip ⇒ Object
-
#default_mac_addr ⇒ Object
-
#default_preempt ⇒ Object
-
#default_preempt_delay_minimum ⇒ Object
-
#default_preempt_delay_reload ⇒ Object
-
#default_preempt_delay_sync ⇒ Object
-
#default_priority ⇒ Object
-
#default_priority_forward_thresh_lower ⇒ Object
-
#default_priority_forward_thresh_upper ⇒ Object
-
#default_timers_hello ⇒ Object
-
#default_timers_hello_msec ⇒ Object
-
#default_timers_hold ⇒ Object
-
#default_timers_hold_msec ⇒ Object
-
#destroy ⇒ Object
-
#group_name ⇒ Object
-
#group_name=(val) ⇒ Object
-
#initialize(interface, group_id, ip_type, instantiate = true) ⇒ InterfaceHsrpGroup
constructor
A new instance of InterfaceHsrpGroup.
-
#ipv4_enable ⇒ Object
-
#ipv4_vip ⇒ Object
-
#ipv4_vip_set(ipenable, vip) ⇒ Object
-
#ipv6_autoconfig ⇒ Object
-
#ipv6_autoconfig=(val) ⇒ Object
-
#ipv6_vip ⇒ Object
-
#ipv6_vip=(list) ⇒ Object
-
#mac_addr ⇒ Object
CLI returns mac_addr in xxxx.xxxx.xxxx format so convert it to xx:xx:xx:xx:xx:xx format.
-
#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.
-
#preempt ⇒ Object
-
#preempt_delay_minimum ⇒ Object
-
#preempt_delay_reload ⇒ Object
-
#preempt_delay_sync ⇒ Object
-
#preempt_get ⇒ Object
The CLI can take forms like: preempt preempt delay minimum 3 reload 10 sync 15.
-
#preempt_set(pree, min, rel, sy) ⇒ Object
-
#priority ⇒ Object
-
#priority_forward_thresh_lower ⇒ Object
-
#priority_forward_thresh_upper ⇒ Object
-
#priority_level_get ⇒ Object
This CLI can take forms like: priority 10 priority 50 forwarding-threshold lower 10 upper 49.
-
#priority_level_set(pri, lower, upper) ⇒ Object
-
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName.
-
#set_args_keys_default ⇒ Object
Helper method to delete @set_args hash keys.
-
#timers_get ⇒ Object
This CLI can take forms like: timers 1 3 timers msec 300 3 timers msec 750 msec 2500.
-
#timers_hello ⇒ Object
-
#timers_hello_msec ⇒ Object
-
#timers_hold ⇒ Object
-
#timers_hold_msec ⇒ Object
-
#timers_set(mshello, hello, mshold, hold) ⇒ 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(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
#group ⇒ Object
Returns the value of attribute group.
24
25
26
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 24
def group
@group
end
|
#iptype ⇒ Object
Returns the value of attribute iptype.
24
25
26
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 24
def iptype
@iptype
end
|
#name ⇒ Object
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
.groups ⇒ Object
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
#authentication ⇒ Object
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
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
139
140
141
142
143
144
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 105
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
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_type ⇒ Object
146
147
148
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 146
def authentication_auth_type
authentication[:auth_type]
end
|
#authentication_auth_type=(val) ⇒ Object
150
151
152
153
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 150
def authentication_auth_type=(val)
@set_args[:authtype] = val
@set_args[:authtype] = 'text' if val.to_s == 'cleartext'
end
|
#authentication_compatibility ⇒ Object
195
196
197
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 195
def authentication_compatibility
authentication[:compat]
end
|
#authentication_compatibility=(val) ⇒ Object
199
200
201
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 199
def authentication_compatibility=(val)
@set_args[:compatible] = val ? 'compatibility' : ''
end
|
#authentication_enc_type ⇒ Object
171
172
173
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 171
def authentication_enc_type
authentication[:enc_type]
end
|
#authentication_enc_type=(val) ⇒ Object
175
176
177
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 175
def authentication_enc_type=(val)
@set_args[:enctype] = val
end
|
#authentication_key_type ⇒ Object
159
160
161
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 159
def authentication_key_type
authentication[:key_type]
end
|
#authentication_key_type=(val) ⇒ Object
163
164
165
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 163
def authentication_key_type=(val)
@set_args[:keytype] = val.to_s
end
|
#authentication_set(attrs) ⇒ Object
225
226
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
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 225
def authentication_set(attrs)
set_args_keys_default
@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_string ⇒ Object
183
184
185
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 183
def authentication_string
authentication[:password]
end
|
#authentication_string=(val) ⇒ Object
187
188
189
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 187
def authentication_string=(val)
@set_args[:passwd] = val
end
|
#authentication_timeout ⇒ Object
207
208
209
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 207
def authentication_timeout
authentication[:timeout]
end
|
#authentication_timeout=(val) ⇒ Object
211
212
213
214
215
216
217
218
219
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 211
def authentication_timeout=(val)
if val.nil?
@set_args[:tval] = ''
@set_args[:timeout] = ''
else
@set_args[:tval] = val
@set_args[:timeout] = 'timeout'
end
end
|
#create ⇒ Object
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_type ⇒ Object
155
156
157
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 155
def default_authentication_auth_type
config_get_default('interface_hsrp_group', 'authentication_auth_type')
end
|
#default_authentication_compatibility ⇒ Object
203
204
205
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 203
def default_authentication_compatibility
config_get_default('interface_hsrp_group', 'authentication_compatibility')
end
|
#default_authentication_enc_type ⇒ Object
179
180
181
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 179
def default_authentication_enc_type
config_get_default('interface_hsrp_group', 'authentication_enc_type')
end
|
#default_authentication_key_type ⇒ Object
167
168
169
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 167
def default_authentication_key_type
config_get_default('interface_hsrp_group', 'authentication_key_type')
end
|
#default_authentication_string ⇒ Object
191
192
193
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 191
def default_authentication_string
config_get_default('interface_hsrp_group', 'authentication_string')
end
|
#default_authentication_timeout ⇒ Object
221
222
223
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 221
def default_authentication_timeout
config_get_default('interface_hsrp_group', 'authentication_timeout')
end
|
#default_group_name ⇒ Object
363
364
365
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 363
def default_group_name
config_get_default('interface_hsrp_group', 'group_name')
end
|
#default_ipv4_enable ⇒ Object
261
262
263
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 261
def default_ipv4_enable
config_get_default('interface_hsrp_group', 'ipv4_enable')
end
|
#default_ipv4_vip ⇒ Object
284
285
286
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 284
def default_ipv4_vip
config_get_default('interface_hsrp_group', 'ipv4_vip')
end
|
#default_ipv6_autoconfig ⇒ Object
298
299
300
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 298
def default_ipv6_autoconfig
config_get_default('interface_hsrp_group', 'ipv6_autoconfig')
end
|
#default_ipv6_vip ⇒ Object
327
328
329
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 327
def default_ipv6_vip
config_get_default('interface_hsrp_group', 'ipv6_vip')
end
|
#default_mac_addr ⇒ Object
348
349
350
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 348
def default_mac_addr
config_get_default('interface_hsrp_group', 'mac_addr')
end
|
#default_preempt ⇒ Object
414
415
416
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 414
def default_preempt
config_get_default('interface_hsrp_group', 'preempt')
end
|
#default_preempt_delay_minimum ⇒ Object
418
419
420
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 418
def default_preempt_delay_minimum
config_get_default('interface_hsrp_group', 'preempt_delay_minimum')
end
|
#default_preempt_delay_reload ⇒ Object
422
423
424
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 422
def default_preempt_delay_reload
config_get_default('interface_hsrp_group', 'preempt_delay_reload')
end
|
#default_preempt_delay_sync ⇒ Object
426
427
428
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 426
def default_preempt_delay_sync
config_get_default('interface_hsrp_group', 'preempt_delay_sync')
end
|
#default_priority ⇒ Object
451
452
453
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 451
def default_priority
config_get_default('interface_hsrp_group', 'priority')
end
|
#default_priority_forward_thresh_lower ⇒ Object
459
460
461
462
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 459
def default_priority_forward_thresh_lower
config_get_default('interface_hsrp_group',
'priority_forward_thresh_lower')
end
|
#default_priority_forward_thresh_upper ⇒ Object
468
469
470
471
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 468
def default_priority_forward_thresh_upper
config_get_default('interface_hsrp_group',
'priority_forward_thresh_upper')
end
|
#default_timers_hello ⇒ Object
518
519
520
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 518
def default_timers_hello
config_get_default('interface_hsrp_group', 'timers_hello')
end
|
#default_timers_hello_msec ⇒ Object
522
523
524
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 522
def default_timers_hello_msec
config_get_default('interface_hsrp_group', 'timers_hello_msec')
end
|
#default_timers_hold ⇒ Object
538
539
540
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 538
def default_timers_hold
config_get_default('interface_hsrp_group', 'timers_hold')
end
|
#default_timers_hold_msec ⇒ Object
534
535
536
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 534
def default_timers_hold_msec
config_get_default('interface_hsrp_group', 'timers_hold_msec')
end
|
#destroy ⇒ Object
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?
set_args_keys(state: 'no', iptype: @iptype)
config_set('interface_hsrp_group', 'groups', @set_args)
end
|
#group_name ⇒ Object
352
353
354
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 352
def group_name
config_get('interface_hsrp_group', 'group_name', @get_args)
end
|
#group_name=(val) ⇒ Object
356
357
358
359
360
361
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 356
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_enable ⇒ Object
255
256
257
258
259
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 255
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_vip ⇒ Object
265
266
267
268
269
270
271
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 265
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
273
274
275
276
277
278
279
280
281
282
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 273
def ipv4_vip_set(ipenable, vip)
return if @iptype == 'ipv6'
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_autoconfig ⇒ Object
288
289
290
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 288
def ipv6_autoconfig
config_get('interface_hsrp_group', 'ipv6_autoconfig', @get_args)
end
|
#ipv6_autoconfig=(val) ⇒ Object
292
293
294
295
296
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 292
def ipv6_autoconfig=(val)
state = val ? '' : 'no'
set_args_keys(state: state)
config_set('interface_hsrp_group', 'ipv6_autoconfig', @set_args)
end
|
#ipv6_vip ⇒ Object
302
303
304
305
306
307
308
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 302
def ipv6_vip
return default_ipv6_vip if @iptype == 'ipv4'
list = config_get('interface_hsrp_group', 'ipv6_vip', @get_args)
list.delete('autoconfig')
list
end
|
#ipv6_vip=(list) ⇒ Object
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 310
def ipv6_vip=(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_addr ⇒ Object
CLI returns mac_addr in xxxx.xxxx.xxxx format so convert it to xx:xx:xx:xx:xx:xx format
333
334
335
336
337
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 333
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
341
342
343
344
345
346
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 341
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
|
#preempt ⇒ Object
386
387
388
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 386
def preempt
preempt_get[:preempt]
end
|
#preempt_delay_minimum ⇒ Object
390
391
392
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 390
def preempt_delay_minimum
preempt_get[:minimum].to_i
end
|
#preempt_delay_reload ⇒ Object
394
395
396
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 394
def preempt_delay_reload
preempt_get[:reload].to_i
end
|
#preempt_delay_sync ⇒ Object
398
399
400
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 398
def preempt_delay_sync
preempt_get[:sync].to_i
end
|
#preempt_get ⇒ Object
The CLI can take forms like: preempt preempt delay minimum 3 reload 10 sync 15
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 370
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
402
403
404
405
406
407
408
409
410
411
412
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 402
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
|
#priority ⇒ Object
447
448
449
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 447
def priority
priority_level_get[:priority]
end
|
#priority_forward_thresh_lower ⇒ Object
455
456
457
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 455
def priority_forward_thresh_lower
priority_level_get[:lower]
end
|
#priority_forward_thresh_upper ⇒ Object
464
465
466
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 464
def priority_forward_thresh_upper
priority_level_get[:upper]
end
|
#priority_level_get ⇒ Object
This CLI can take forms like: priority 10 priority 50 forwarding-threshold lower 10 upper 49
433
434
435
436
437
438
439
440
441
442
443
444
445
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 433
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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 473
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_default ⇒ Object
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_get ⇒ Object
This CLI can take forms like: timers 1 3 timers msec 300 3 timers msec 750 msec 2500
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 492
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_hello ⇒ Object
510
511
512
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 510
def timers_hello
timers_get[:hello]
end
|
#timers_hello_msec ⇒ Object
514
515
516
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 514
def timers_hello_msec
timers_get[:mshello]
end
|
#timers_hold ⇒ Object
526
527
528
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 526
def timers_hold
timers_get[:hold]
end
|
#timers_hold_msec ⇒ Object
530
531
532
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 530
def timers_hold_msec
timers_get[:mshold]
end
|
#timers_set(mshello, hello, mshold, hold) ⇒ Object
542
543
544
545
546
547
548
549
550
551
552
553
|
# File 'lib/cisco_node_utils/interface_hsrp_group.rb', line 542
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
|