Class: Cisco::ItdService
Overview
node_utils class for itd_device_group
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#access_list ⇒ Object
-
#access_list=(val) ⇒ Object
-
#attach_prefix(val, prop, prefix = nil) ⇒ Object
prepend property name prefix/keyword to value.
-
#create ⇒ Object
-
#default_access_list ⇒ Object
-
#default_device_group ⇒ Object
-
#default_exclude_access_list ⇒ Object
-
#default_fail_action ⇒ Object
-
#default_ingress_interface ⇒ Object
-
#default_load_bal_buckets ⇒ Object
-
#default_load_bal_enable ⇒ Object
-
#default_load_bal_mask_pos ⇒ Object
-
#default_load_bal_method_bundle_hash ⇒ Object
-
#default_load_bal_method_bundle_select ⇒ Object
-
#default_load_bal_method_end_port ⇒ Object
-
#default_load_bal_method_proto ⇒ Object
-
#default_load_bal_method_start_port ⇒ Object
-
#default_nat_destination ⇒ Object
-
#default_peer_local ⇒ Object
-
#default_peer_vdc ⇒ Object
-
#default_shutdown ⇒ Object
-
#default_virtual_ip ⇒ Object
-
#destroy ⇒ Object
-
#device_group ⇒ Object
-
#device_group=(val) ⇒ Object
-
#exclude_access_list ⇒ Object
-
#exclude_access_list=(val) ⇒ Object
-
#extract_value(prop, prefix = nil) ⇒ Object
extract value of property from load-balance.
-
#fail_action ⇒ Object
-
#fail_action=(state) ⇒ Object
-
#ingress_interface ⇒ Object
this is an array like: [[‘ethernet 1/1’, ‘1.1.1.1’], [‘port-channel 100’, ‘2.2.2.2’], [‘vlan 2’, ‘3.3.3.3’]] show command output is like: Eth1/1, Po100, Vlan2 so translate back to the input format.
-
#ingress_interface=(list) ⇒ Object
only one next-hop is allowed per interface but due to nxos issues, it allows more than one; so the workaround is to clean up the current ingress intf and configure all of them again.
-
#ingress_interface_cleanup ⇒ Object
-
#initialize(name, instantiate = true) ⇒ ItdService
constructor
A new instance of ItdService.
-
#lb_get ⇒ Object
the load-balance command can take several forms like: load-balance method dst ip load-balance method dst ip-l4port tcp range 3 6 load-balance method dst ip-l4port tcp range 3 6 buckets 8 mask-position 2 load-balance buckets 8 load-balance mask-position 2.
-
#load_bal_buckets ⇒ Object
-
#load_bal_buckets=(buckets) ⇒ Object
-
#load_bal_enable ⇒ Object
-
#load_bal_enable=(enable) ⇒ Object
-
#load_bal_mask_pos ⇒ Object
-
#load_bal_mask_pos=(mask) ⇒ Object
-
#load_bal_method_bundle_hash ⇒ Object
-
#load_bal_method_bundle_hash=(bh) ⇒ Object
-
#load_bal_method_bundle_select ⇒ Object
-
#load_bal_method_bundle_select=(bs) ⇒ Object
-
#load_bal_method_end_port ⇒ Object
-
#load_bal_method_end_port=(enport) ⇒ Object
-
#load_bal_method_proto ⇒ Object
-
#load_bal_method_proto=(proto) ⇒ Object
-
#load_bal_method_start_port ⇒ Object
-
#load_bal_method_start_port=(start) ⇒ Object
-
#load_balance_set(attrs) ⇒ Object
-
#nat_destination ⇒ Object
-
#nat_destination=(state) ⇒ Object
-
#peer_local ⇒ Object
-
#peer_local=(val) ⇒ Object
-
#peer_vdc ⇒ Object
peer_vdc is an array of vdc and service.
-
#peer_vdc=(parray) ⇒ Object
peer_vdc is an array of vdc and service only one peer_vdc is allowed per service ex: [‘switch’, ‘myservice’].
-
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName.
-
#set_args_keys_default ⇒ Object
Helper method to delete @set_args hash keys.
-
#shutdown ⇒ Object
show command shows nothing when the service is shutdown which is default, but it shows “no shut” when it is not shut.
-
#shutdown=(state) ⇒ Object
-
#virtual_ip ⇒ Object
-
#virtual_ip=(values) ⇒ Object
VIP is a large string like: virtual ip 2.2.2.2 10.0.0.0 udp 10 advertise enable device-group icmpGroup virtual ip 2.2.2.2 10.0.0.0 udp 10 advertise enable virtual ip 2.2.2.2 10.0.0.0 udp 10 virtual ip 2.2.2.2 10.0.0.0 all of the above are unique and can be added one after the other the entire string is unique but not individual parts of it currently, only one VIP can be configured due to nxos issue else, the switch crashes, this limitation will be set in puppet manifest.
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(name, instantiate = true) ⇒ ItdService
Returns a new instance of ItdService.
24
25
26
27
28
29
30
31
|
# File 'lib/cisco_node_utils/itd_service.rb', line 24
def initialize(name, instantiate=true)
fail TypeError unless name.is_a?(String)
fail ArgumentError unless name.length > 0
@name = name
set_args_keys_default
create if instantiate
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
22
23
24
|
# File 'lib/cisco_node_utils/itd_service.rb', line 22
def name
@name
end
|
Class Method Details
.itds ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/cisco_node_utils/itd_service.rb', line 33
def self.itds
hash = {}
list = []
services = config_get('itd_service',
'all_itds')
return hash if services.nil?
services.each do |service|
next if service.include?('device-group')
next if service.include?('session')
next if service.include?('statistics')
list << service
end
list.each do |id|
hash[id] = ItdService.new(id, false)
end
hash
end
|
Instance Method Details
#access_list ⇒ Object
107
108
109
|
# File 'lib/cisco_node_utils/itd_service.rb', line 107
def access_list
config_get('itd_service', 'access_list', @get_args)
end
|
#access_list=(val) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/cisco_node_utils/itd_service.rb', line 111
def access_list=(val)
if val.empty?
@set_args[:state] = 'no'
@set_args[:al] = access_list
config_set('itd_service', 'access_list', @set_args) unless
access_list.empty?
else
@set_args[:state] = ''
@set_args[:al] = val
config_set('itd_service', 'access_list', @set_args)
end
set_args_keys_default
end
|
#attach_prefix(val, prop, prefix = nil) ⇒ Object
prepend property name prefix/keyword to value
102
103
104
105
|
# File 'lib/cisco_node_utils/itd_service.rb', line 102
def attach_prefix(val, prop, prefix=nil)
prefix = prop.to_s if prefix.nil?
@set_args[prop] = val.to_s.empty? ? val : "#{prefix} #{val}"
end
|
#create ⇒ Object
60
61
62
63
|
# File 'lib/cisco_node_utils/itd_service.rb', line 60
def create
Feature.itd_enable
config_set('itd_service', 'create', name: @name)
end
|
#default_access_list ⇒ Object
125
126
127
|
# File 'lib/cisco_node_utils/itd_service.rb', line 125
def default_access_list
config_get_default('itd_service', 'access_list')
end
|
#default_device_group ⇒ Object
147
148
149
|
# File 'lib/cisco_node_utils/itd_service.rb', line 147
def default_device_group
config_get_default('itd_service', 'device_group')
end
|
#default_exclude_access_list ⇒ Object
169
170
171
|
# File 'lib/cisco_node_utils/itd_service.rb', line 169
def default_exclude_access_list
config_get_default('itd_service', 'exclude_access_list')
end
|
#default_fail_action ⇒ Object
184
185
186
|
# File 'lib/cisco_node_utils/itd_service.rb', line 184
def default_fail_action
config_get_default('itd_service', 'fail_action')
end
|
#default_ingress_interface ⇒ Object
236
237
238
|
# File 'lib/cisco_node_utils/itd_service.rb', line 236
def default_ingress_interface
config_get_default('itd_service', 'ingress_interface')
end
|
#default_load_bal_buckets ⇒ Object
279
280
281
|
# File 'lib/cisco_node_utils/itd_service.rb', line 279
def default_load_bal_buckets
config_get_default('itd_service', 'load_bal_buckets')
end
|
#default_load_bal_enable ⇒ Object
378
379
380
|
# File 'lib/cisco_node_utils/itd_service.rb', line 378
def default_load_bal_enable
config_get_default('itd_service', 'load_bal_enable')
end
|
#default_load_bal_mask_pos ⇒ Object
293
294
295
|
# File 'lib/cisco_node_utils/itd_service.rb', line 293
def default_load_bal_mask_pos
config_get_default('itd_service', 'load_bal_mask_pos')
end
|
#default_load_bal_method_bundle_hash ⇒ Object
308
309
310
|
# File 'lib/cisco_node_utils/itd_service.rb', line 308
def default_load_bal_method_bundle_hash
config_get_default('itd_service', 'load_bal_method_bundle_hash')
end
|
#default_load_bal_method_bundle_select ⇒ Object
322
323
324
|
# File 'lib/cisco_node_utils/itd_service.rb', line 322
def default_load_bal_method_bundle_select
config_get_default('itd_service', 'load_bal_method_bundle_select')
end
|
#default_load_bal_method_end_port ⇒ Object
337
338
339
|
# File 'lib/cisco_node_utils/itd_service.rb', line 337
def default_load_bal_method_end_port
config_get_default('itd_service', 'load_bal_method_end_port')
end
|
#default_load_bal_method_proto ⇒ Object
366
367
368
|
# File 'lib/cisco_node_utils/itd_service.rb', line 366
def default_load_bal_method_proto
config_get_default('itd_service', 'load_bal_method_proto')
end
|
#default_load_bal_method_start_port ⇒ Object
351
352
353
|
# File 'lib/cisco_node_utils/itd_service.rb', line 351
def default_load_bal_method_start_port
config_get_default('itd_service', 'load_bal_method_start_port')
end
|
#default_nat_destination ⇒ Object
415
416
417
|
# File 'lib/cisco_node_utils/itd_service.rb', line 415
def default_nat_destination
config_get_default('itd_service', 'nat_destination')
end
|
#default_peer_local ⇒ Object
438
439
440
|
# File 'lib/cisco_node_utils/itd_service.rb', line 438
def default_peer_local
config_get_default('itd_service', 'peer_local')
end
|
#default_peer_vdc ⇒ Object
467
468
469
|
# File 'lib/cisco_node_utils/itd_service.rb', line 467
def default_peer_vdc
config_get_default('itd_service', 'peer_vdc')
end
|
#default_shutdown ⇒ Object
485
486
487
|
# File 'lib/cisco_node_utils/itd_service.rb', line 485
def default_shutdown
config_get_default('itd_service', 'shutdown')
end
|
#default_virtual_ip ⇒ Object
519
520
521
|
# File 'lib/cisco_node_utils/itd_service.rb', line 519
def default_virtual_ip
config_get_default('itd_service', 'virtual_ip')
end
|
#destroy ⇒ Object
65
66
67
68
69
|
# File 'lib/cisco_node_utils/itd_service.rb', line 65
def destroy
config_set('itd_service', 'shutdown', name: @name, state: '')
config_set('itd_service', 'destroy', name: @name)
end
|
#device_group ⇒ Object
129
130
131
|
# File 'lib/cisco_node_utils/itd_service.rb', line 129
def device_group
config_get('itd_service', 'device_group', @get_args)
end
|
#device_group=(val) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/cisco_node_utils/itd_service.rb', line 133
def device_group=(val)
if val.empty?
@set_args[:state] = 'no'
@set_args[:dg] = device_group
config_set('itd_service', 'device_group', @set_args) unless
device_group.empty?
else
@set_args[:state] = ''
@set_args[:dg] = val
config_set('itd_service', 'device_group', @set_args)
end
set_args_keys_default
end
|
#exclude_access_list ⇒ Object
151
152
153
|
# File 'lib/cisco_node_utils/itd_service.rb', line 151
def exclude_access_list
config_get('itd_service', 'exclude_access_list', @get_args)
end
|
#exclude_access_list=(val) ⇒ Object
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/cisco_node_utils/itd_service.rb', line 155
def exclude_access_list=(val)
if val.empty?
@set_args[:state] = 'no'
@set_args[:al] = exclude_access_list
config_set('itd_service', 'exclude_access_list', @set_args) unless
exclude_access_list.empty?
else
@set_args[:state] = ''
@set_args[:al] = val
config_set('itd_service', 'exclude_access_list', @set_args)
end
set_args_keys_default
end
|
extract value of property from load-balance
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/cisco_node_utils/itd_service.rb', line 84
def (prop, prefix=nil)
prefix = prop if prefix.nil?
lb_match = lb_get
return nil if lb_match.nil?
return nil unless lb_match.names.include?(prop)
regexp = Regexp.new("#{Regexp.escape(prefix)} (?<extracted>.*)")
value_match = regexp.match(lb_match[prop])
return nil if value_match.nil?
value_match[:extracted]
end
|
#fail_action ⇒ Object
173
174
175
|
# File 'lib/cisco_node_utils/itd_service.rb', line 173
def fail_action
config_get('itd_service', 'fail_action', @get_args)
end
|
#fail_action=(state) ⇒ Object
177
178
179
180
181
182
|
# File 'lib/cisco_node_utils/itd_service.rb', line 177
def fail_action=(state)
no_cmd = (state ? '' : 'no')
@set_args[:state] = no_cmd
config_set('itd_service', 'fail_action', @set_args)
set_args_keys_default
end
|
#ingress_interface ⇒ Object
this is an array like: [[‘ethernet 1/1’, ‘1.1.1.1’], [‘port-channel 100’, ‘2.2.2.2’],
- ‘vlan 2’, ‘3.3.3.3’]
-
show command output is like: Eth1/1, Po100, Vlan2 so translate back to the input format
193
194
195
196
197
198
199
200
201
|
# File 'lib/cisco_node_utils/itd_service.rb', line 193
def ingress_interface
list = config_get('itd_service', 'ingress_interface', @get_args)
list.each do |intf, _next_hop|
intf.gsub!('Eth', 'ethernet ')
intf.gsub!('Po', 'port-channel ')
intf.gsub!('Vlan', 'vlan ')
end
list
end
|
#ingress_interface=(list) ⇒ Object
only one next-hop is allowed per interface but due to nxos issues, it allows more than one; so the workaround is to clean up the current ingress intf and configure all of them again
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
# File 'lib/cisco_node_utils/itd_service.rb', line 220
def ingress_interface=(list)
ingress_interface_cleanup
@set_args[:state] = ''
list.each do |intf, next_hop|
@set_args[:interface] = intf
@set_args[:next] = ''
@set_args[:nhop] = ''
unless next_hop == '' || next_hop == 'default'
@set_args[:next] = 'next-hop'
@set_args[:nhop] = next_hop
end
config_set('itd_service', 'ingress_interface', @set_args)
end
set_args_keys_default
end
|
#ingress_interface_cleanup ⇒ Object
203
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/cisco_node_utils/itd_service.rb', line 203
def ingress_interface_cleanup
cur_list = ingress_interface
return if cur_list.empty?
@set_args[:state] = 'no'
@set_args[:next] = ''
@set_args[:nhop] = ''
cur_list.each do |intf, _next_hop|
@set_args[:interface] = intf
config_set('itd_service', 'ingress_interface', @set_args)
end
end
|
#lb_get ⇒ Object
the load-balance command can take several forms like: load-balance method dst ip load-balance method dst ip-l4port tcp range 3 6 load-balance method dst ip-l4port tcp range 3 6 buckets 8 mask-position 2 load-balance buckets 8 load-balance mask-position 2
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
# File 'lib/cisco_node_utils/itd_service.rb', line 246
def lb_get
str = config_get('itd_service', 'load_balance', @get_args)
return nil if str.nil?
if str.include?('method') && str.include?('range')
regexp = Regexp.new('load-balance *(?<bundle_select>method \S+)?'\
' *(?<bundle_hash>\S+)?'\
' *(?<proto>\S+)?'\
' *(?<start_port>range \d+)?'\
' *(?<end_port>\d+)?'\
' *(?<buckets>buckets \d+)?'\
' *(?<mask>mask-position \d+)?')
elsif str.include?('method')
regexp = Regexp.new('load-balance *(?<bundle_select>method \S+)?'\
' *(?<bundle_hash>\S+)?'\
' *(?<buckets>buckets \d+)?'\
' *(?<mask>mask-position \d+)?') unless str.include?('range')
else
regexp = Regexp.new('load-balance *(?<buckets>buckets \d+)?'\
' *(?<mask>mask-position \d+)?')
end
regexp.match(str)
end
|
#load_bal_buckets ⇒ Object
269
270
271
272
273
|
# File 'lib/cisco_node_utils/itd_service.rb', line 269
def load_bal_buckets
val = ('buckets')
return default_load_bal_buckets if val.nil?
val.to_i
end
|
#load_bal_buckets=(buckets) ⇒ Object
275
276
277
|
# File 'lib/cisco_node_utils/itd_service.rb', line 275
def load_bal_buckets=(buckets)
attach_prefix(buckets, :buckets)
end
|
#load_bal_enable ⇒ Object
370
371
372
|
# File 'lib/cisco_node_utils/itd_service.rb', line 370
def load_bal_enable
lb_get.nil? ? default_load_bal_enable : true
end
|
#load_bal_enable=(enable) ⇒ Object
374
375
376
|
# File 'lib/cisco_node_utils/itd_service.rb', line 374
def load_bal_enable=(enable)
@set_args[:state] = enable ? '' : 'no'
end
|
#load_bal_mask_pos ⇒ Object
283
284
285
286
287
|
# File 'lib/cisco_node_utils/itd_service.rb', line 283
def load_bal_mask_pos
val = ('mask', 'mask-position')
return default_load_bal_mask_pos if val.nil?
val.to_i
end
|
#load_bal_mask_pos=(mask) ⇒ Object
289
290
291
|
# File 'lib/cisco_node_utils/itd_service.rb', line 289
def load_bal_mask_pos=(mask)
attach_prefix(mask, :mask, 'mask-position')
end
|
#load_bal_method_bundle_hash ⇒ Object
297
298
299
300
301
302
|
# File 'lib/cisco_node_utils/itd_service.rb', line 297
def load_bal_method_bundle_hash
val = default_load_bal_method_bundle_hash
match = lb_get
return val if match.nil?
match.names.include?('bundle_hash') ? match[:bundle_hash] : val
end
|
#load_bal_method_bundle_hash=(bh) ⇒ Object
304
305
306
|
# File 'lib/cisco_node_utils/itd_service.rb', line 304
def load_bal_method_bundle_hash=(bh)
@set_args[:bundle_hash] = bh
end
|
#load_bal_method_bundle_select ⇒ Object
312
313
314
315
316
|
# File 'lib/cisco_node_utils/itd_service.rb', line 312
def load_bal_method_bundle_select
val = ('bundle_select', 'method')
return default_load_bal_method_bundle_select if val.nil?
val
end
|
#load_bal_method_bundle_select=(bs) ⇒ Object
318
319
320
|
# File 'lib/cisco_node_utils/itd_service.rb', line 318
def load_bal_method_bundle_select=(bs)
attach_prefix(bs, :bundle_select, 'method')
end
|
#load_bal_method_end_port ⇒ Object
326
327
328
329
330
331
|
# File 'lib/cisco_node_utils/itd_service.rb', line 326
def load_bal_method_end_port
val = default_load_bal_method_end_port
match = lb_get
return val if match.nil?
match.names.include?('end_port') ? match[:end_port].to_i : val
end
|
#load_bal_method_end_port=(enport) ⇒ Object
333
334
335
|
# File 'lib/cisco_node_utils/itd_service.rb', line 333
def load_bal_method_end_port=(enport)
@set_args[:endPort] = enport
end
|
#load_bal_method_proto ⇒ Object
355
356
357
358
359
360
|
# File 'lib/cisco_node_utils/itd_service.rb', line 355
def load_bal_method_proto
val = default_load_bal_method_proto
match = lb_get
return val if match.nil?
match.names.include?('proto') ? match[:proto] : val
end
|
#load_bal_method_proto=(proto) ⇒ Object
362
363
364
|
# File 'lib/cisco_node_utils/itd_service.rb', line 362
def load_bal_method_proto=(proto)
@set_args[:proto] = proto
end
|
#load_bal_method_start_port ⇒ Object
341
342
343
344
345
|
# File 'lib/cisco_node_utils/itd_service.rb', line 341
def load_bal_method_start_port
val = ('start_port', 'range')
return default_load_bal_method_start_port if val.nil?
val.to_i
end
|
#load_bal_method_start_port=(start) ⇒ Object
347
348
349
|
# File 'lib/cisco_node_utils/itd_service.rb', line 347
def load_bal_method_start_port=(start)
attach_prefix(start, :start_port, 'range')
end
|
#load_balance_set(attrs) ⇒ Object
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
# File 'lib/cisco_node_utils/itd_service.rb', line 382
def load_balance_set(attrs)
set_args_keys_default
set_args_keys(attrs)
[:load_bal_buckets,
:load_bal_mask_pos,
:load_bal_method_bundle_hash,
:load_bal_method_bundle_select,
:load_bal_method_end_port,
:load_bal_method_start_port,
:load_bal_method_proto,
:load_bal_enable,
].each do |p|
attrs[p] = '' if attrs[p].nil? || attrs[p] == false
send(p.to_s + '=', attrs[p])
end
send('load_bal_enable=', false) if attrs[:load_bal_enable] == ''
@get_args = @set_args
config_set('itd_service', 'load_balance', @set_args)
set_args_keys_default
end
|
#nat_destination ⇒ Object
404
405
406
|
# File 'lib/cisco_node_utils/itd_service.rb', line 404
def nat_destination
config_get('itd_service', 'nat_destination', @get_args)
end
|
#nat_destination=(state) ⇒ Object
408
409
410
411
412
413
|
# File 'lib/cisco_node_utils/itd_service.rb', line 408
def nat_destination=(state)
no_cmd = (state ? '' : 'no')
@set_args[:state] = no_cmd
config_set('itd_service', 'nat_destination', @set_args)
set_args_keys_default
end
|
#peer_local ⇒ Object
419
420
421
|
# File 'lib/cisco_node_utils/itd_service.rb', line 419
def peer_local
config_get('itd_service', 'peer_local', @get_args)
end
|
#peer_local=(val) ⇒ Object
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
# File 'lib/cisco_node_utils/itd_service.rb', line 423
def peer_local=(val)
if val.empty?
@set_args[:state] = 'no'
current_peer_local = peer_local
@set_args[:service] = current_peer_local
config_set('itd_service', 'peer_local', @set_args) unless
current_peer_local.nil? || current_peer_local.empty?
else
@set_args[:state] = ''
@set_args[:service] = val
config_set('itd_service', 'peer_local', @set_args)
end
set_args_keys_default
end
|
#peer_vdc ⇒ Object
peer_vdc is an array of vdc and service
443
444
445
|
# File 'lib/cisco_node_utils/itd_service.rb', line 443
def peer_vdc
config_get('itd_service', 'peer_vdc', @get_args)
end
|
#peer_vdc=(parray) ⇒ Object
peer_vdc is an array of vdc and service only one peer_vdc is allowed per service ex: [‘switch’, ‘myservice’]
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
# File 'lib/cisco_node_utils/itd_service.rb', line 450
def peer_vdc=(parray)
if parray.empty?
@set_args[:state] = 'no'
current_peer_vdc = peer_vdc
@set_args[:vdc] = current_peer_vdc[0]
@set_args[:service] = current_peer_vdc[1]
config_set('itd_service', 'peer_vdc', @set_args) unless
current_peer_vdc[0].nil? || current_peer_vdc[1].nil?
else
@set_args[:state] = ''
@set_args[:vdc] = parray[0]
@set_args[:service] = parray[1]
config_set('itd_service', 'peer_vdc', @set_args)
end
set_args_keys_default
end
|
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName
78
79
80
81
|
# File 'lib/cisco_node_utils/itd_service.rb', line 78
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
72
73
74
75
|
# File 'lib/cisco_node_utils/itd_service.rb', line 72
def set_args_keys_default
keys = { name: @name }
@get_args = @set_args = keys
end
|
#shutdown ⇒ Object
show command shows nothing when the service is shutdown which is default, but it shows “no shut” when it is not shut
474
475
476
|
# File 'lib/cisco_node_utils/itd_service.rb', line 474
def shutdown
config_get('itd_service', 'shutdown', @get_args)
end
|
#shutdown=(state) ⇒ Object
478
479
480
481
482
483
|
# File 'lib/cisco_node_utils/itd_service.rb', line 478
def shutdown=(state)
no_cmd = (state ? '' : 'no')
@set_args[:state] = no_cmd
config_set('itd_service', 'shutdown', @set_args)
set_args_keys_default
end
|
#virtual_ip ⇒ Object
489
490
491
|
# File 'lib/cisco_node_utils/itd_service.rb', line 489
def virtual_ip
config_get('itd_service', 'virtual_ip', @get_args)
end
|
#virtual_ip=(values) ⇒ Object
VIP is a large string like: virtual ip 2.2.2.2 10.0.0.0 udp 10 advertise enable device-group icmpGroup virtual ip 2.2.2.2 10.0.0.0 udp 10 advertise enable virtual ip 2.2.2.2 10.0.0.0 udp 10 virtual ip 2.2.2.2 10.0.0.0 all of the above are unique and can be added one after the other the entire string is unique but not individual parts of it currently, only one VIP can be configured due to nxos issue else, the switch crashes, this limitation will be set in puppet manifest. Also remove the current VIPs before configuring more
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
# File 'lib/cisco_node_utils/itd_service.rb', line 503
def virtual_ip=(values)
@set_args[:state] = 'no'
list = virtual_ip
list.each do |line|
@set_args[:string] = line
config_set('itd_service', 'virtual_ip', @set_args)
end
@set_args[:state] = ''
values.each do |value|
@set_args[:string] = value
config_set('itd_service', 'virtual_ip', @set_args)
end
set_args_keys_default
end
|