Class: Cisco::RouterBgpAF
Overview
RouterBgpAF - node utility class for BGP address-family config management
Class Method Summary
collapse
Instance Method Summary
collapse
-
#additional_paths_install ⇒ Object
additional_paths_install.
-
#additional_paths_install=(state) ⇒ Object
-
#additional_paths_receive ⇒ Object
additional_paths_receive.
-
#additional_paths_receive=(state) ⇒ Object
-
#additional_paths_selection ⇒ Object
additional_paths_selection.
-
#additional_paths_selection=(route_map) ⇒ Object
-
#additional_paths_send ⇒ Object
-
#additional_paths_send=(state) ⇒ Object
-
#advertise_l2vpn_evpn ⇒ Object
-
#advertise_l2vpn_evpn=(state) ⇒ Object
-
#client_to_client ⇒ Object
Client to client (Getter/Setter/Default).
-
#client_to_client=(state) ⇒ Object
-
#create ⇒ Object
-
#dampen_igp_metric ⇒ Object
-
#dampen_igp_metric=(val) ⇒ Object
-
#dampening ⇒ Object
The data presented to or retrieved from the config_set and config_get for dampening is one of 4 possibilities:.
-
#dampening=(damp_array) ⇒ Object
-
#dampening_half_time ⇒ Object
For all of the following dampening getters, half_time, reuse_time, suppress_time, and max_suppress_time, return nil if dampening is not configured, but also return nil if a dampening routemap is configured because they are mutually exclusive.
-
#dampening_max_suppress_time ⇒ Object
-
#dampening_reuse_time ⇒ Object
-
#dampening_routemap ⇒ Object
-
#dampening_routemap_configured? ⇒ Boolean
-
#dampening_state ⇒ Object
Return true if dampening is enabled, else false.
-
#dampening_suppress_time ⇒ Object
-
#default_additional_paths_install ⇒ Object
-
#default_additional_paths_receive ⇒ Object
-
#default_additional_paths_selection ⇒ Object
-
#default_additional_paths_send ⇒ Object
-
#default_advertise_l2vpn_evpn ⇒ Object
-
#default_client_to_client ⇒ Object
-
#default_dampen_igp_metric ⇒ Object
-
#default_dampening ⇒ Object
-
#default_dampening_half_time ⇒ Object
-
#default_dampening_max_suppress_time ⇒ Object
-
#default_dampening_reuse_time ⇒ Object
-
#default_dampening_routemap ⇒ Object
-
#default_dampening_state ⇒ Object
-
#default_dampening_suppress_time ⇒ Object
-
#default_default_information_originate ⇒ Object
-
#default_default_metric ⇒ Object
-
#default_distance ⇒ Object
-
#default_distance_ebgp ⇒ Object
-
#default_distance_ibgp ⇒ Object
-
#default_distance_local ⇒ Object
-
#default_information_originate ⇒ Object
Default Information (Getter/Setter/Default).
-
#default_information_originate=(state) ⇒ Object
-
#default_inject_map ⇒ Object
-
#default_maximum_paths ⇒ Object
-
#default_maximum_paths_ibgp ⇒ Object
-
#default_metric ⇒ Object
-
#default_metric=(val) ⇒ Object
-
#default_networks ⇒ Object
-
#default_next_hop_route_map ⇒ Object
-
#default_redistribute ⇒ Object
-
#default_suppress_inactive ⇒ Object
-
#default_table_map ⇒ Object
-
#default_table_map_filter ⇒ Object
-
#destroy ⇒ Object
-
#distance ⇒ Object
-
#distance_ebgp ⇒ Object
-
#distance_ibgp ⇒ Object
-
#distance_local ⇒ Object
-
#distance_set(ebgp, ibgp, local) ⇒ Object
Distance (Getter/Setter/Default).
-
#initialize(asn, vrf, af, instantiate = true) ⇒ RouterBgpAF
constructor
A new instance of RouterBgpAF.
-
#inject_map ⇒ Object
inject_map (Getter/Setter/Default).
-
#inject_map=(should_list) ⇒ Object
-
#maximum_paths ⇒ Object
-
#maximum_paths=(val) ⇒ Object
-
#maximum_paths_ibgp ⇒ Object
-
#maximum_paths_ibgp=(val) ⇒ Object
-
#networks ⇒ Object
Build an array of all network commands currently on the device.
-
#networks=(should_list) ⇒ Object
-
#next_hop_route_map ⇒ Object
Next Hop route map (Getter/Setter/Default).
-
#next_hop_route_map=(route_map) ⇒ Object
-
#redistribute ⇒ Object
Build an array of all redistribute commands currently on the device.
-
#redistribute=(should) ⇒ Object
-
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName.
-
#set_args_keys_default ⇒ Object
Helper methods to delete @set_args hash keys.
-
#suppress_inactive ⇒ Object
Suppress Inactive (Getter/Setter/Default).
-
#suppress_inactive=(state) ⇒ Object
-
#table_map ⇒ Object
Table Map (Getter/Setter/Default).
-
#table_map_filter ⇒ Object
-
#table_map_set(map, filter = false) ⇒ Object
Methods inherited from NodeUtil
config_get, #config_get, config_get_default, #config_get_default, #config_set, config_set, #node, node, #show
Constructor Details
#initialize(asn, vrf, af, instantiate = true) ⇒ RouterBgpAF
Returns a new instance of RouterBgpAF.
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 26
def initialize(asn, vrf, af, instantiate=true)
fail ArgumentError if vrf.to_s.empty? || af.to_s.empty?
err_msg = '"af" argument must be an array of two string values ' \
'containing an afi + safi tuple'
fail ArgumentError, err_msg unless af.is_a?(Array) || af.length == 2
@asn = RouterBgp.validate_asnum(asn)
@vrf = vrf
@afi, @safi = af
set_args_keys_default
create if instantiate
end
|
Class Method Details
.afs ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 38
def self.afs
af_hash = {}
RouterBgp.routers.each do |asn, vrfs|
af_hash[asn] = {}
vrfs.keys.each do |vrf_name|
get_args = { asnum: asn }
get_args[:vrf] = vrf_name unless vrf_name == 'default'
af_list = config_get('bgp_af', 'all_afs', get_args)
next if af_list.nil?
af_hash[asn][vrf_name] = {}
af_list.each do |af|
af_hash[asn][vrf_name][af] =
RouterBgpAF.new(asn, vrf_name, af, false)
end
end
end
af_hash
end
|
Instance Method Details
#additional_paths_install ⇒ Object
188
189
190
191
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 188
def additional_paths_install
state = config_get('bgp_af', 'additional_paths_install', @get_args)
state ? true : false
end
|
#additional_paths_install=(state) ⇒ Object
193
194
195
196
197
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 193
def additional_paths_install=(state)
state = (state ? '' : 'no')
set_args_keys(state: state)
config_set('bgp_af', 'additional_paths_install', @set_args)
end
|
#additional_paths_receive ⇒ Object
172
173
174
175
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 172
def additional_paths_receive
state = config_get('bgp_af', 'additional_paths_receive', @get_args)
state ? true : false
end
|
#additional_paths_receive=(state) ⇒ Object
177
178
179
180
181
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 177
def additional_paths_receive=(state)
state = (state ? '' : 'no')
set_args_keys(state: state)
config_set('bgp_af', 'additional_paths_receive', @set_args)
end
|
#additional_paths_selection ⇒ Object
additional_paths_selection
204
205
206
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 204
def additional_paths_selection
config_get('bgp_af', 'additional_paths_selection', @get_args)
end
|
#additional_paths_selection=(route_map) ⇒ Object
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 208
def additional_paths_selection=(route_map)
route_map.strip!
if route_map.empty?
state = 'no'
if additional_paths_selection.empty?
route_map = 'dummy_routemap'
else
route_map = additional_paths_selection
end
end
set_args_keys(state: state, route_map: route_map)
config_set('bgp_af', 'additional_paths_selection', @set_args)
end
|
#additional_paths_send ⇒ Object
156
157
158
159
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 156
def additional_paths_send
state = config_get('bgp_af', 'additional_paths_send', @get_args)
state ? true : false
end
|
#additional_paths_send=(state) ⇒ Object
161
162
163
164
165
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 161
def additional_paths_send=(state)
state = (state ? '' : 'no')
set_args_keys(state: state)
config_set('bgp_af', 'additional_paths_send', @set_args)
end
|
#advertise_l2vpn_evpn ⇒ Object
228
229
230
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 228
def advertise_l2vpn_evpn
config_get('bgp_af', 'advertise_l2vpn_evpn', @get_args)
end
|
#advertise_l2vpn_evpn=(state) ⇒ Object
232
233
234
235
236
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 232
def advertise_l2vpn_evpn=(state)
Feature.nv_overlay_evpn_enable
set_args_keys(state: (state ? '' : 'no'))
config_set('bgp_af', 'advertise_l2vpn_evpn', @set_args)
end
|
#client_to_client ⇒ Object
Client to client (Getter/Setter/Default)
92
93
94
95
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 92
def client_to_client
state = config_get('bgp_af', 'client_to_client', @get_args)
state ? true : false
end
|
#client_to_client=(state) ⇒ Object
97
98
99
100
101
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 97
def client_to_client=(state)
state = (state ? '' : 'no')
set_args_keys(state: state)
config_set('bgp_af', 'client_to_client', @set_args)
end
|
#create ⇒ Object
60
61
62
63
64
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 60
def create
Feature.bgp_enable
set_args_keys(state: '')
config_set('bgp', 'address_family', @set_args)
end
|
#dampen_igp_metric ⇒ Object
247
248
249
250
251
252
253
254
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 247
def dampen_igp_metric
match = config_get('bgp_af', 'dampen_igp_metric', @get_args)
if match.is_a?(Array)
return nil if match[0] == 'no '
return match[1].to_i if match[1]
end
default_dampen_igp_metric
end
|
#dampen_igp_metric=(val) ⇒ Object
256
257
258
259
260
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 256
def dampen_igp_metric=(val)
set_args_keys(state: (val.nil?) ? 'no' : '',
num: (val.nil?) ? '' : val)
config_set('bgp_af', 'dampen_igp_metric', @set_args)
end
|
#dampening ⇒ Object
The data presented to or retrieved from the config_set and config_get for dampening is one of 4 possibilities:
Value Meaning —– ——- nil Dampening is not configured ” || [] Dampening is configured with no options
- 1,3,4,5,nil
-
Dampening + decay, reuse, suppress, suppress_max
- nil,nil,nil,‘route-map’
-
Dampening + routemap
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 279
def dampening
data = config_get('bgp_af', 'dampening', @get_args)
if data.nil?
return nil
end
data = data.flatten
val = ''
if !data[4].nil?
val = data[4]
elsif !data[3].nil? && data[4].nil?
val = data[0..3]
end
val
end
|
#dampening=(damp_array) ⇒ Object
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 363
def dampening=(damp_array)
fail ArgumentError if damp_array.kind_of?(Array) &&
!(damp_array.length == 4 ||
damp_array.length == 0)
state = ''
route_map = ''
decay = ''
reuse = ''
suppress = ''
suppress_max = ''
if damp_array.nil?
state = 'no'
CiscoLogger.debug("Dampening 'no dampening'")
elsif damp_array.empty?
CiscoLogger.debug("Dampening 'dampening'")
elsif damp_array.size == 4
decay = damp_array[0]
reuse = damp_array[1]
suppress = damp_array[2]
suppress_max = damp_array[3]
CiscoLogger.debug("Dampening 'dampening #{damp_array.join(' ')}''")
elsif route_map.is_a? String
route_map = "route-map #{damp_array}"
route_map.strip!
CiscoLogger.debug("Dampening 'dampening #{route_map}'")
else
fail ArgumentError
end
set_args_keys(
state: state,
route_map: route_map,
decay: decay,
reuse: reuse,
suppress: suppress,
suppress_max: suppress_max,
)
CiscoLogger.debug("Dampening args=#{@set_args}")
config_set('bgp_af', 'dampening', @set_args)
end
|
#dampening_half_time ⇒ Object
For all of the following dampening getters, half_time, reuse_time, suppress_time, and max_suppress_time, return nil if dampening is not configured, but also return nil if a dampening routemap is configured because they are mutually exclusive.
312
313
314
315
316
317
318
319
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 312
def dampening_half_time
return nil if dampening.nil? || dampening_routemap_configured?
if dampening.is_a?(Array)
dampening[0].to_i
else
default_dampening_half_time
end
end
|
#dampening_max_suppress_time ⇒ Object
339
340
341
342
343
344
345
346
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 339
def dampening_max_suppress_time
return nil if dampening.nil? || dampening_routemap_configured?
if dampening.is_a?(Array)
dampening[3].to_i
else
default_dampening_max_suppress_time
end
end
|
#dampening_reuse_time ⇒ Object
321
322
323
324
325
326
327
328
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 321
def dampening_reuse_time
return nil if dampening.nil? || dampening_routemap_configured?
if dampening.is_a?(Array)
dampening[1].to_i
else
default_dampening_reuse_time
end
end
|
#dampening_routemap ⇒ Object
348
349
350
351
352
353
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 348
def dampening_routemap
if dampening.nil? || (dampening.is_a?(String) && dampening.size > 0)
return dampening
end
default_dampening_routemap
end
|
355
356
357
358
359
360
361
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 355
def dampening_routemap_configured?
if dampening_routemap.is_a?(String) && dampening_routemap.size > 0
true
else
false
end
end
|
#dampening_state ⇒ Object
Return true if dampening is enabled, else false.
304
305
306
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 304
def dampening_state
!dampening.nil?
end
|
#dampening_suppress_time ⇒ Object
330
331
332
333
334
335
336
337
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 330
def dampening_suppress_time
return nil if dampening.nil? || dampening_routemap_configured?
if dampening.is_a?(Array)
dampening[2].to_i
else
default_dampening_suppress_time
end
end
|
#default_additional_paths_install ⇒ Object
199
200
201
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 199
def default_additional_paths_install
config_get_default('bgp_af', 'additional_paths_install')
end
|
#default_additional_paths_receive ⇒ Object
183
184
185
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 183
def default_additional_paths_receive
config_get_default('bgp_af', 'additional_paths_receive')
end
|
#default_additional_paths_selection ⇒ Object
223
224
225
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 223
def default_additional_paths_selection
config_get_default('bgp_af', 'additional_paths_selection')
end
|
#default_additional_paths_send ⇒ Object
167
168
169
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 167
def default_additional_paths_send
config_get_default('bgp_af', 'additional_paths_send')
end
|
#default_advertise_l2vpn_evpn ⇒ Object
238
239
240
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 238
def default_advertise_l2vpn_evpn
config_get_default('bgp_af', 'advertise_l2vpn_evpn')
end
|
#default_client_to_client ⇒ Object
103
104
105
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 103
def default_client_to_client
config_get_default('bgp_af', 'client_to_client')
end
|
#default_dampen_igp_metric ⇒ Object
262
263
264
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 262
def default_dampen_igp_metric
config_get_default('bgp_af', 'dampen_igp_metric')
end
|
#default_dampening ⇒ Object
414
415
416
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 414
def default_dampening
config_get_default('bgp_af', 'dampening')
end
|
#default_dampening_half_time ⇒ Object
426
427
428
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 426
def default_dampening_half_time
config_get_default('bgp_af', 'dampening_half_time')
end
|
#default_dampening_max_suppress_time ⇒ Object
422
423
424
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 422
def default_dampening_max_suppress_time
config_get_default('bgp_af', 'dampening_max_suppress_time')
end
|
#default_dampening_reuse_time ⇒ Object
430
431
432
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 430
def default_dampening_reuse_time
config_get_default('bgp_af', 'dampening_reuse_time')
end
|
#default_dampening_routemap ⇒ Object
434
435
436
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 434
def default_dampening_routemap
config_get_default('bgp_af', 'dampening_routemap')
end
|
#default_dampening_state ⇒ Object
418
419
420
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 418
def default_dampening_state
config_get_default('bgp_af', 'dampening_state')
end
|
#default_dampening_suppress_time ⇒ Object
438
439
440
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 438
def default_dampening_suppress_time
config_get_default('bgp_af', 'dampening_suppress_time')
end
|
121
122
123
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 121
def default_default_information_originate
config_get_default('bgp_af', 'default_information')
end
|
#default_default_metric ⇒ Object
508
509
510
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 508
def default_default_metric
config_get_default('bgp_af', 'default_metric')
end
|
#default_distance ⇒ Object
485
486
487
488
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 485
def default_distance
["#{default_distance_ebgp}", "#{default_distance_ibgp}",
"#{default_distance_local}"]
end
|
#default_distance_ebgp ⇒ Object
473
474
475
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 473
def default_distance_ebgp
config_get_default('bgp_af', 'distance_ebgp')
end
|
#default_distance_ibgp ⇒ Object
477
478
479
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 477
def default_distance_ibgp
config_get_default('bgp_af', 'distance_ibgp')
end
|
#default_distance_local ⇒ Object
481
482
483
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 481
def default_distance_local
config_get_default('bgp_af', 'distance_local')
end
|
Default Information (Getter/Setter/Default)
110
111
112
113
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 110
def default_information_originate
state = config_get('bgp_af', 'default_information', @get_args)
state ? true : false
end
|
115
116
117
118
119
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 115
def default_information_originate=(state)
state = (state ? '' : 'no')
set_args_keys(state: state)
config_set('bgp_af', 'default_information', @set_args)
end
|
#default_inject_map ⇒ Object
537
538
539
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 537
def default_inject_map
config_get_default('bgp_af', 'inject_map')
end
|
#default_maximum_paths ⇒ Object
556
557
558
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 556
def default_maximum_paths
config_get_default('bgp_af', 'maximum_paths')
end
|
#default_maximum_paths_ibgp ⇒ Object
575
576
577
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 575
def default_maximum_paths_ibgp
config_get_default('bgp_af', 'maximum_paths_ibgp')
end
|
#default_metric ⇒ Object
495
496
497
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 495
def default_metric
config_get('bgp_af', 'default_metric', @get_args)
end
|
#default_metric=(val) ⇒ Object
499
500
501
502
503
504
505
506
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 499
def default_metric=(val)
dummy_metric = 1
set_args_keys(state: (val == default_default_metric) ? 'no' : '',
num: (val == default_default_metric) ? dummy_metric : val)
config_set('bgp_af', 'default_metric', @set_args)
end
|
#default_networks ⇒ Object
606
607
608
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 606
def default_networks
config_get_default('bgp_af', 'network')
end
|
#default_next_hop_route_map ⇒ Object
147
148
149
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 147
def default_next_hop_route_map
config_get_default('bgp_af', 'next_hop_route_map')
end
|
#default_redistribute ⇒ Object
638
639
640
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 638
def default_redistribute
config_get_default('bgp_af', 'redistribute')
end
|
#default_suppress_inactive ⇒ Object
654
655
656
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 654
def default_suppress_inactive
config_get_default('bgp_af', 'suppress_inactive')
end
|
#default_table_map ⇒ Object
690
691
692
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 690
def default_table_map
config_get_default('bgp_af', 'table_map')
end
|
#default_table_map_filter ⇒ Object
694
695
696
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 694
def default_table_map_filter
config_get_default('bgp_af', 'table_map_filter')
end
|
#destroy ⇒ Object
66
67
68
69
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 66
def destroy
set_args_keys(state: 'no')
config_set('bgp', 'address_family', @set_args)
end
|
#distance ⇒ Object
468
469
470
471
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 468
def distance
match = config_get('bgp_af', 'distance', @get_args)
match.nil? ? default_distance : match
end
|
#distance_ebgp ⇒ Object
450
451
452
453
454
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 450
def distance_ebgp
ebgp, _ibgp, _local = distance
return default_distance_ebgp if ebgp.nil?
ebgp.to_i
end
|
#distance_ibgp ⇒ Object
456
457
458
459
460
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 456
def distance_ibgp
_ebgp, ibgp, _local = distance
return default_distance_ibgp if ibgp.nil?
ibgp.to_i
end
|
#distance_local ⇒ Object
462
463
464
465
466
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 462
def distance_local
_ebgp, _ibgp, local = distance
return default_distance_local if local.nil?
local.to_i
end
|
#distance_set(ebgp, ibgp, local) ⇒ Object
Distance (Getter/Setter/Default)
445
446
447
448
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 445
def distance_set(ebgp, ibgp, local)
set_args_keys(state: '', ebgp: ebgp, ibgp: ibgp, local: local)
config_set('bgp_af', 'distance', @set_args)
end
|
#inject_map ⇒ Object
inject_map (Getter/Setter/Default)
516
517
518
519
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 516
def inject_map
cmds = config_get('bgp_af', 'inject_map', @get_args).each(&:compact!)
cmds.sort
end
|
#inject_map=(should_list) ⇒ Object
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 521
def inject_map=(should_list)
delta_hash = Utils.delta_add_remove(should_list, inject_map)
return if delta_hash.values.flatten.empty?
[:add, :remove].each do |action|
CiscoLogger.debug("inject_map delta #{@get_args}\n #{action}: " \
"#{delta_hash[action]}")
delta_hash[action].each do |inject, exist, copy|
state = (action == :add) ? '' : 'no'
copy = 'copy-attributes' unless copy.nil?
set_args_keys(state: state, inject: inject, exist: exist, copy: copy)
config_set('bgp_af', 'inject_map', @set_args)
end
end
end
|
#maximum_paths ⇒ Object
546
547
548
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 546
def maximum_paths
config_get('bgp_af', 'maximum_paths', @get_args)
end
|
#maximum_paths=(val) ⇒ Object
550
551
552
553
554
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 550
def maximum_paths=(val)
set_args_keys(state: (val == default_maximum_paths) ? 'no' : '',
num: (val == default_maximum_paths) ? '' : val)
config_set('bgp_af', 'maximum_paths', @set_args)
end
|
#maximum_paths_ibgp ⇒ Object
565
566
567
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 565
def maximum_paths_ibgp
config_get('bgp_af', 'maximum_paths_ibgp', @get_args)
end
|
#maximum_paths_ibgp=(val) ⇒ Object
569
570
571
572
573
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 569
def maximum_paths_ibgp=(val)
set_args_keys(state: (val == default_maximum_paths_ibgp) ? 'no' : '',
num: (val == default_maximum_paths_ibgp) ? '' : val)
config_set('bgp_af', 'maximum_paths_ibgp', @set_args)
end
|
#networks ⇒ Object
Build an array of all network commands currently on the device
584
585
586
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 584
def networks
config_get('bgp_af', 'network', @get_args).each(&:compact!)
end
|
#networks=(should_list) ⇒ Object
networks setter. Processes a hash of network commands from delta_add_remove().
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 590
def networks=(should_list)
delta_hash = Utils.delta_add_remove(should_list, networks)
return if delta_hash.values.flatten.empty?
[:add, :remove].each do |action|
CiscoLogger.debug("networks delta #{@get_args}\n #{action}: " \
"#{delta_hash[action]}")
delta_hash[action].each do |network, route_map|
state = (action == :add) ? '' : 'no'
network = Utils.process_network_mask(network)
route_map = "route-map #{route_map}" unless route_map.nil?
set_args_keys(state: state, network: network, route_map: route_map)
config_set('bgp_af', 'network', @set_args)
end
end
end
|
#next_hop_route_map ⇒ Object
Next Hop route map (Getter/Setter/Default)
128
129
130
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 128
def next_hop_route_map
config_get('bgp_af', 'next_hop_route_map', @get_args)
end
|
#next_hop_route_map=(route_map) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 132
def next_hop_route_map=(route_map)
route_map.strip!
if route_map.empty?
state = 'no'
if next_hop_route_map.empty?
route_map = 'dummy_routemap'
else
route_map = next_hop_route_map
end
end
set_args_keys(state: state, route_map: route_map)
config_set('bgp_af', 'next_hop_route_map', @set_args)
end
|
#redistribute ⇒ Object
Build an array of all redistribute commands currently on the device
615
616
617
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 615
def redistribute
config_get('bgp_af', 'redistribute', @get_args).each(&:compact!)
end
|
#redistribute=(should) ⇒ Object
redistribute setter. Process a hash of redistribute commands from delta_add_remove().
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 621
def redistribute=(should)
delta_hash = Utils.delta_add_remove(should, redistribute)
return if delta_hash.values.flatten.empty?
[:add, :remove].each do |action|
CiscoLogger.debug("redistribute delta #{@get_args}\n #{action}: " \
"#{delta_hash[action]}")
delta_hash[action].each do |protocol, policy|
state = (action == :add) ? '' : 'no'
set_args_keys(state: state, protocol: protocol, policy: policy)
cmd = policy.nil? ? 'redistribute' : 'redistribute_policy'
config_set('bgp_af', cmd, @set_args)
end
end
end
|
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName
80
81
82
83
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 80
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 methods to delete @set_args hash keys
74
75
76
77
78
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 74
def set_args_keys_default
keys = { asnum: @asn, afi: @afi, safi: @safi }
keys[:vrf] = @vrf unless @vrf == 'default'
@get_args = @set_args = keys
end
|
#suppress_inactive ⇒ Object
Suppress Inactive (Getter/Setter/Default)
645
646
647
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 645
def suppress_inactive
config_get('bgp_af', 'suppress_inactive', @get_args)
end
|
#suppress_inactive=(state) ⇒ Object
649
650
651
652
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 649
def suppress_inactive=(state)
set_args_keys(state: state ? '' : 'no')
config_set('bgp_af', 'suppress_inactive', @set_args)
end
|
#table_map ⇒ Object
Table Map (Getter/Setter/Default)
662
663
664
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 662
def table_map
config_get('bgp_af', 'table_map', @get_args)
end
|
#table_map_filter ⇒ Object
666
667
668
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 666
def table_map_filter
config_get('bgp_af', 'table_map_filter', @get_args)
end
|
#table_map_set(map, filter = false) ⇒ Object
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
|
# File 'lib/cisco_node_utils/bgp_af.rb', line 670
def table_map_set(map, filter=false)
if filter
attr = 'table_map_filter'
else
attr = 'table_map'
end
dummy_map = 'dummy'
if map == default_table_map
@set_args[:state] = 'no'
@set_args[:map] = dummy_map
else
@set_args[:state] = ''
@set_args[:map] = map
end
config_set('bgp_af', attr, @set_args)
set_args_keys_default
end
|