Class: Cisco::RouterBgp
Overview
RouterBgp - node utility class for BGP general config management
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(asnum, vrf = 'default', instantiate = true) ⇒ RouterBgp
Returns a new instance of RouterBgp.
27
28
29
30
31
32
33
34
|
# File 'lib/cisco_node_utils/bgp.rb', line 27
def initialize(asnum, vrf='default', instantiate=true)
fail ArgumentError unless vrf.is_a? String
fail ArgumentError unless vrf.length > 0
@asnum = RouterBgp.validate_asnum(asnum)
@vrf = vrf
set_args_keys_default
create if instantiate
end
|
Instance Attribute Details
#asnum ⇒ Object
Returns the value of attribute asnum.
25
26
27
|
# File 'lib/cisco_node_utils/bgp.rb', line 25
def asnum
@asnum
end
|
#vrf ⇒ Object
Returns the value of attribute vrf.
25
26
27
|
# File 'lib/cisco_node_utils/bgp.rb', line 25
def vrf
@vrf
end
|
Class Method Details
.routers ⇒ Object
Create a hash of all router bgp default and non-default vrf instances
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/cisco_node_utils/bgp.rb', line 42
def self.routers
asnum = config_get('bgp', 'router')
return {} if asnum.nil?
hash_final = {}
asnum = asnum.to_i unless /\d+.\d+/.match(asnum)
hash_tmp = {
asnum => { 'default' => RouterBgp.new(asnum, 'default', false) }
}
vrf_ids = config_get('bgp', 'vrf', asnum: asnum)
unless vrf_ids.nil?
vrf_ids.each do |vrf|
hash_tmp[asnum][vrf] = RouterBgp.new(asnum, vrf, false)
end
end
hash_final.merge!(hash_tmp)
return hash_final
rescue Cisco::CliError
raise if Feature.bgp_enabled?
return {}
end
|
.validate_asnum(asnum) ⇒ Object
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/cisco_node_utils/bgp.rb', line 65
def self.validate_asnum(asnum)
err_msg = 'BGP asnum must be type String or Integer'
fail ArgumentError, err_msg unless asnum.is_a?(Integer) ||
asnum.is_a?(String)
if asnum.is_a? String
fail ArgumentError unless /^(\d+|\d+\.\d+)$/.match(asnum)
end
asnum.to_s
end
|
Instance Method Details
#bestpath_always_compare_med ⇒ Object
132
133
134
|
# File 'lib/cisco_node_utils/bgp.rb', line 132
def bestpath_always_compare_med
config_get('bgp', 'bestpath_always_compare_med', @get_args)
end
|
#bestpath_always_compare_med=(enable) ⇒ Object
173
174
175
176
177
|
# File 'lib/cisco_node_utils/bgp.rb', line 173
def bestpath_always_compare_med=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'bestpath_always_compare_med', @set_args)
set_args_keys_default
end
|
#bestpath_aspath_multipath_relax ⇒ Object
136
137
138
|
# File 'lib/cisco_node_utils/bgp.rb', line 136
def bestpath_aspath_multipath_relax
config_get('bgp', 'bestpath_aspath_multipath_relax', @get_args)
end
|
#bestpath_aspath_multipath_relax=(enable) ⇒ Object
179
180
181
182
183
|
# File 'lib/cisco_node_utils/bgp.rb', line 179
def bestpath_aspath_multipath_relax=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'bestpath_aspath_multipath_relax', @set_args)
set_args_keys_default
end
|
#bestpath_compare_routerid ⇒ Object
140
141
142
|
# File 'lib/cisco_node_utils/bgp.rb', line 140
def bestpath_compare_routerid
config_get('bgp', 'bestpath_compare_routerid', @get_args)
end
|
#bestpath_compare_routerid=(enable) ⇒ Object
185
186
187
188
189
|
# File 'lib/cisco_node_utils/bgp.rb', line 185
def bestpath_compare_routerid=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'bestpath_compare_routerid', @set_args)
set_args_keys_default
end
|
144
145
146
|
# File 'lib/cisco_node_utils/bgp.rb', line 144
def
config_get('bgp', 'bestpath_cost_community_ignore', @get_args)
end
|
191
192
193
194
195
|
# File 'lib/cisco_node_utils/bgp.rb', line 191
def (enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'bestpath_cost_community_ignore', @set_args)
set_args_keys_default
end
|
#bestpath_med_confed ⇒ Object
148
149
150
151
|
# File 'lib/cisco_node_utils/bgp.rb', line 148
def bestpath_med_confed
return nil if platform == :ios_xr && @vrf != 'default'
config_get('bgp', 'bestpath_med_confed', @get_args)
end
|
#bestpath_med_confed=(enable) ⇒ Object
197
198
199
200
201
202
203
204
205
206
207
|
# File 'lib/cisco_node_utils/bgp.rb', line 197
def bestpath_med_confed=(enable)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp', 'bestpath_med_confed', 'set',
'bestpath_med_confed is not ' \
'configurable on a per-VRF basis ' \
'on IOS XR')
end
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'bestpath_med_confed', @set_args)
set_args_keys_default
end
|
#bestpath_med_missing_as_worst ⇒ Object
153
154
155
|
# File 'lib/cisco_node_utils/bgp.rb', line 153
def bestpath_med_missing_as_worst
config_get('bgp', 'bestpath_med_missing_as_worst', @get_args)
end
|
#bestpath_med_missing_as_worst=(enable) ⇒ Object
209
210
211
212
213
|
# File 'lib/cisco_node_utils/bgp.rb', line 209
def bestpath_med_missing_as_worst=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'bestpath_med_missing_as_worst', @set_args)
set_args_keys_default
end
|
#bestpath_med_non_deterministic ⇒ Object
157
158
159
|
# File 'lib/cisco_node_utils/bgp.rb', line 157
def bestpath_med_non_deterministic
config_get('bgp', 'bestpath_med_non_deterministic', @get_args)
end
|
#bestpath_med_non_deterministic=(enable) ⇒ Object
215
216
217
218
219
|
# File 'lib/cisco_node_utils/bgp.rb', line 215
def bestpath_med_non_deterministic=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'bestpath_med_non_deterministic', @set_args)
set_args_keys_default
end
|
#cluster_id ⇒ Object
Cluster Id (Getter/Setter/Default)
258
259
260
261
|
# File 'lib/cisco_node_utils/bgp.rb', line 258
def cluster_id
return nil if platform == :ios_xr && @vrf != 'default'
config_get('bgp', 'cluster_id', @get_args)
end
|
#cluster_id=(id) ⇒ Object
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
# File 'lib/cisco_node_utils/bgp.rb', line 263
def cluster_id=(id)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp', 'cluster_id', 'set',
'cluster-id is not configurable ' \
'on a per-VRF basis on IOS XR')
end
dummy_id = 1
if id == default_cluster_id
@set_args[:state] = 'no'
@set_args[:id] = dummy_id
else
@set_args[:state] = ''
@set_args[:id] = id
end
config_set('bgp', 'cluster_id', @set_args)
set_args_keys_default
end
|
#confederation_id ⇒ Object
Confederation Id (Getter/Setter/Default)
291
292
293
294
|
# File 'lib/cisco_node_utils/bgp.rb', line 291
def confederation_id
return nil if platform == :ios_xr && @vrf != 'default'
config_get('bgp', 'confederation_id', @get_args)
end
|
#confederation_id=(id) ⇒ Object
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
# File 'lib/cisco_node_utils/bgp.rb', line 296
def confederation_id=(id)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp', 'confederation_id', 'set',
'confederation-id is not ' \
'configurable ' \
'on a per-VRF basis on IOS XR')
end
dummy_id = 1
if id == default_confederation_id
@set_args[:state] = 'no'
@set_args[:id] = dummy_id
else
@set_args[:state] = ''
@set_args[:id] = id
end
config_set('bgp', 'confederation_id', @set_args)
set_args_keys_default
end
|
#confederation_peers ⇒ Object
Confederation Peers (Getter/Setter/Default)
566
567
568
569
570
571
572
573
574
575
|
# File 'lib/cisco_node_utils/bgp.rb', line 566
def confederation_peers
return nil if platform == :ios_xr && @vrf != 'default'
peers = config_get('bgp', 'confederation_peers', @get_args)
peers = peers.split(' ') if peers.is_a?(String)
peers.sort
end
|
#confederation_peers=(should) ⇒ Object
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
|
# File 'lib/cisco_node_utils/bgp.rb', line 577
def confederation_peers=(should)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp', 'confederation_peers', 'set',
'confederation-peers is not ' \
'configurable ' \
'on a per-VRF basis on IOS XR')
end
should = should.flatten
is = confederation_peers
delta_hash = Utils.delta_add_remove(should, is)
return if delta_hash.values.flatten.empty?
[:add, :remove].each do |action|
Cisco::Logger.debug('confederation_peers delta ' \
"#{@get_args}\n #{action}: " \
"#{delta_hash[action]}")
delta_hash[action].each do |peer|
state = (action == :add) ? '' : 'no'
@set_args[:state] = state
@set_args[:peer] = peer
config_set('bgp', 'confederation_peers', @set_args)
end
end
end
|
#create ⇒ Object
Create one router bgp instance
87
88
89
90
91
|
# File 'lib/cisco_node_utils/bgp.rb', line 87
def create
Feature.bgp_enable if platform == :nexus
router_bgp
wait_for_process_initialized
end
|
#default_bestpath_always_compare_med ⇒ Object
228
229
230
|
# File 'lib/cisco_node_utils/bgp.rb', line 228
def default_bestpath_always_compare_med
config_get_default('bgp', 'bestpath_always_compare_med')
end
|
#default_bestpath_aspath_multipath_relax ⇒ Object
232
233
234
|
# File 'lib/cisco_node_utils/bgp.rb', line 232
def default_bestpath_aspath_multipath_relax
config_get_default('bgp', 'bestpath_aspath_multipath_relax')
end
|
#default_bestpath_compare_routerid ⇒ Object
236
237
238
|
# File 'lib/cisco_node_utils/bgp.rb', line 236
def default_bestpath_compare_routerid
config_get_default('bgp', 'bestpath_compare_routerid')
end
|
240
241
242
|
# File 'lib/cisco_node_utils/bgp.rb', line 240
def
config_get_default('bgp', 'bestpath_cost_community_ignore')
end
|
#default_bestpath_med_confed ⇒ Object
244
245
246
247
|
# File 'lib/cisco_node_utils/bgp.rb', line 244
def default_bestpath_med_confed
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'bestpath_med_confed')
end
|
#default_bestpath_med_missing_as_worst ⇒ Object
249
250
251
|
# File 'lib/cisco_node_utils/bgp.rb', line 249
def default_bestpath_med_missing_as_worst
config_get_default('bgp', 'bestpath_med_missing_as_worst')
end
|
#default_bestpath_med_non_deterministic ⇒ Object
253
254
255
|
# File 'lib/cisco_node_utils/bgp.rb', line 253
def default_bestpath_med_non_deterministic
config_get_default('bgp', 'bestpath_med_non_deterministic')
end
|
#default_cluster_id ⇒ Object
285
286
287
288
|
# File 'lib/cisco_node_utils/bgp.rb', line 285
def default_cluster_id
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'cluster_id')
end
|
#default_confederation_id ⇒ Object
319
320
321
322
|
# File 'lib/cisco_node_utils/bgp.rb', line 319
def default_confederation_id
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'confederation_id')
end
|
#default_confederation_peers ⇒ Object
605
606
607
608
|
# File 'lib/cisco_node_utils/bgp.rb', line 605
def default_confederation_peers
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'confederation_peers')
end
|
#default_disable_policy_batching ⇒ Object
337
338
339
|
# File 'lib/cisco_node_utils/bgp.rb', line 337
def default_disable_policy_batching
config_get_default('bgp', 'disable_policy_batching')
end
|
#default_disable_policy_batching_ipv4 ⇒ Object
361
362
363
|
# File 'lib/cisco_node_utils/bgp.rb', line 361
def default_disable_policy_batching_ipv4
config_get_default('bgp', 'disable_policy_batching_ipv4')
end
|
#default_disable_policy_batching_ipv6 ⇒ Object
385
386
387
|
# File 'lib/cisco_node_utils/bgp.rb', line 385
def default_disable_policy_batching_ipv6
config_get_default('bgp', 'disable_policy_batching_ipv6')
end
|
#default_enforce_first_as ⇒ Object
408
409
410
|
# File 'lib/cisco_node_utils/bgp.rb', line 408
def default_enforce_first_as
config_get_default('bgp', 'enforce_first_as')
end
|
#default_fast_external_fallover ⇒ Object
546
547
548
|
# File 'lib/cisco_node_utils/bgp.rb', line 546
def default_fast_external_fallover
config_get_default('bgp', 'fast_external_fallover')
end
|
#default_flush_routes ⇒ Object
561
562
563
|
# File 'lib/cisco_node_utils/bgp.rb', line 561
def default_flush_routes
config_get_default('bgp', 'flush_routes')
end
|
#default_graceful_restart ⇒ Object
Graceful Restart Defaults
698
699
700
701
|
# File 'lib/cisco_node_utils/bgp.rb', line 698
def default_graceful_restart
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'graceful_restart')
end
|
#default_graceful_restart_helper ⇒ Object
713
714
715
716
|
# File 'lib/cisco_node_utils/bgp.rb', line 713
def default_graceful_restart_helper
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'graceful_restart_helper')
end
|
#default_graceful_restart_timers_restart ⇒ Object
703
704
705
706
|
# File 'lib/cisco_node_utils/bgp.rb', line 703
def default_graceful_restart_timers_restart
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'graceful_restart_timers_restart')
end
|
#default_graceful_restart_timers_stalepath_time ⇒ Object
708
709
710
711
|
# File 'lib/cisco_node_utils/bgp.rb', line 708
def default_graceful_restart_timers_stalepath_time
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'graceful_restart_timers_stalepath_time')
end
|
#default_isolate ⇒ Object
729
730
731
|
# File 'lib/cisco_node_utils/bgp.rb', line 729
def default_isolate
config_get_default('bgp', 'isolate')
end
|
#default_log_neighbor_changes ⇒ Object
772
773
774
|
# File 'lib/cisco_node_utils/bgp.rb', line 772
def default_log_neighbor_changes
config_get_default('bgp', 'log_neighbor_changes')
end
|
#default_maxas_limit ⇒ Object
750
751
752
|
# File 'lib/cisco_node_utils/bgp.rb', line 750
def default_maxas_limit
config_get_default('bgp', 'maxas_limit')
end
|
#default_neighbor_down_fib_accelerate ⇒ Object
787
788
789
|
# File 'lib/cisco_node_utils/bgp.rb', line 787
def default_neighbor_down_fib_accelerate
config_get_default('bgp', 'neighbor_down_fib_accelerate')
end
|
#default_nsr ⇒ Object
222
223
224
225
|
# File 'lib/cisco_node_utils/bgp.rb', line 222
def default_nsr
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'nsr')
end
|
#default_reconnect_interval ⇒ Object
808
809
810
|
# File 'lib/cisco_node_utils/bgp.rb', line 808
def default_reconnect_interval
config_get_default('bgp', 'reconnect_interval')
end
|
#default_route_distinguisher ⇒ Object
844
845
846
847
|
# File 'lib/cisco_node_utils/bgp.rb', line 844
def default_route_distinguisher
return nil if @vrf.nil? || @vrf == 'default'
config_get_default('bgp', 'route_distinguisher')
end
|
#default_router_id ⇒ Object
871
872
873
|
# File 'lib/cisco_node_utils/bgp.rb', line 871
def default_router_id
config_get_default('bgp', 'router_id')
end
|
#default_shutdown ⇒ Object
886
887
888
|
# File 'lib/cisco_node_utils/bgp.rb', line 886
def default_shutdown
config_get_default('bgp', 'shutdown')
end
|
#default_suppress_fib_pending ⇒ Object
902
903
904
|
# File 'lib/cisco_node_utils/bgp.rb', line 902
def default_suppress_fib_pending
config_get_default('bgp', 'suppress_fib_pending')
end
|
#default_timer_bestpath_limit ⇒ Object
978
979
980
981
|
# File 'lib/cisco_node_utils/bgp.rb', line 978
def default_timer_bestpath_limit
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'timer_bestpath_limit')
end
|
#default_timer_bestpath_limit_always ⇒ Object
983
984
985
986
|
# File 'lib/cisco_node_utils/bgp.rb', line 983
def default_timer_bestpath_limit_always
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'timer_bestpath_limit_always')
end
|
#default_timer_bgp_holdtime ⇒ Object
974
975
976
|
# File 'lib/cisco_node_utils/bgp.rb', line 974
def default_timer_bgp_holdtime
config_get_default('bgp', 'timer_bgp_hold')
end
|
#default_timer_bgp_keepalive ⇒ Object
970
971
972
|
# File 'lib/cisco_node_utils/bgp.rb', line 970
def default_timer_bgp_keepalive
config_get_default('bgp', 'timer_bgp_keepalive')
end
|
#default_timer_bgp_keepalive_hold ⇒ Object
966
967
968
|
# File 'lib/cisco_node_utils/bgp.rb', line 966
def default_timer_bgp_keepalive_hold
["#{default_timer_bgp_keepalive}", "#{default_timer_bgp_holdtime}"]
end
|
#destroy ⇒ Object
Destroy router bgp instance
94
95
96
|
# File 'lib/cisco_node_utils/bgp.rb', line 94
def destroy
router_bgp('no')
end
|
#disable_policy_batching ⇒ Object
disable-policy-batching (Getter/Setter/Default)
327
328
329
|
# File 'lib/cisco_node_utils/bgp.rb', line 327
def disable_policy_batching
config_get('bgp', 'disable_policy_batching', @get_args)
end
|
#disable_policy_batching=(enable) ⇒ Object
331
332
333
334
335
|
# File 'lib/cisco_node_utils/bgp.rb', line 331
def disable_policy_batching=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'disable_policy_batching', @set_args)
set_args_keys_default
end
|
#disable_policy_batching_ipv4 ⇒ Object
disable-policy-batching ipv4 prefix-list <prefix_list>
344
345
346
|
# File 'lib/cisco_node_utils/bgp.rb', line 344
def disable_policy_batching_ipv4
config_get('bgp', 'disable_policy_batching_ipv4', @get_args)
end
|
#disable_policy_batching_ipv4=(prefix_list) ⇒ Object
348
349
350
351
352
353
354
355
356
357
358
359
|
# File 'lib/cisco_node_utils/bgp.rb', line 348
def disable_policy_batching_ipv4=(prefix_list)
dummy_prefixlist = 'x'
if prefix_list == default_disable_policy_batching_ipv4
@set_args[:state] = 'no'
@set_args[:prefix_list] = dummy_prefixlist
else
@set_args[:state] = ''
@set_args[:prefix_list] = prefix_list
end
config_set('bgp', 'disable_policy_batching_ipv4', @set_args)
set_args_keys_default
end
|
#disable_policy_batching_ipv6 ⇒ Object
disable-policy-batching ipv6 prefix-list <prefix_list>
368
369
370
|
# File 'lib/cisco_node_utils/bgp.rb', line 368
def disable_policy_batching_ipv6
config_get('bgp', 'disable_policy_batching_ipv6', @get_args)
end
|
#disable_policy_batching_ipv6=(prefix_list) ⇒ Object
372
373
374
375
376
377
378
379
380
381
382
383
|
# File 'lib/cisco_node_utils/bgp.rb', line 372
def disable_policy_batching_ipv6=(prefix_list)
dummy_prefixlist = 'x'
if prefix_list == default_disable_policy_batching_ipv6
@set_args[:state] = 'no'
@set_args[:prefix_list] = dummy_prefixlist
else
@set_args[:state] = ''
@set_args[:prefix_list] = prefix_list
end
config_set('bgp', 'disable_policy_batching_ipv6', @set_args)
set_args_keys_default
end
|
#enforce_first_as ⇒ Object
Enforce First As (Getter/Setter/Default)
390
391
392
|
# File 'lib/cisco_node_utils/bgp.rb', line 390
def enforce_first_as
config_get('bgp', 'enforce_first_as', @get_args)
end
|
#enforce_first_as=(enable) ⇒ Object
394
395
396
397
398
399
400
401
402
403
404
405
406
|
# File 'lib/cisco_node_utils/bgp.rb', line 394
def enforce_first_as=(enable)
enable = !enable if platform == :ios_xr
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'enforce_first_as', @set_args)
set_args_keys_default
end
|
#event_history_cli ⇒ Object
event-history event-history cli [ size <size> ] Nvgen as True With optional ‘size <size>
415
416
417
418
419
420
421
422
|
# File 'lib/cisco_node_utils/bgp.rb', line 415
def event_history_cli
match = config_get('bgp', 'event_history_cli', @get_args)
return unless match.is_a?(Array)
return 'false' if match[0] == 'no '
return unless match[1]
return match[1] if match[1][/\A\d+\z/]
'size_' + match[1]
end
|
#event_history_cli=(val) ⇒ Object
424
425
426
427
428
429
430
|
# File 'lib/cisco_node_utils/bgp.rb', line 424
def event_history_cli=(val)
size = val[/small|medium|large|disable|\A\d+\z/]
@set_args[:size] = size.nil? ? '' : "size #{size}"
@set_args[:state] = val[/false/] ? 'no' : ''
config_set('bgp', 'event_history_cli', @set_args)
set_args_keys_default
end
|
#event_history_detail ⇒ Object
event-history detail [ size <size> ] Nvgen as True With optional ‘size <size>
434
435
436
437
438
439
440
441
|
# File 'lib/cisco_node_utils/bgp.rb', line 434
def event_history_detail
match = config_get('bgp', 'event_history_detail', @get_args)
return unless match.is_a?(Array)
return 'false' if match[0] == 'no '
return 'true' unless match[1]
return match[1] if match[1][/\A\d+\z/]
'size_' + match[1]
end
|
#event_history_detail=(val) ⇒ Object
443
444
445
446
447
448
449
|
# File 'lib/cisco_node_utils/bgp.rb', line 443
def event_history_detail=(val)
size = val[/small|medium|large|disable|\A\d+\z/]
@set_args[:size] = size.nil? ? '' : "size #{size}"
@set_args[:state] = val[/false/] ? 'no' : ''
config_set('bgp', 'event_history_detail', @set_args)
set_args_keys_default
end
|
#event_history_errors ⇒ Object
event-history errors [ size <size> ] Nvgen as True With optional ‘size <size>
453
454
455
456
457
458
459
460
|
# File 'lib/cisco_node_utils/bgp.rb', line 453
def event_history_errors
match = config_get('bgp', 'event_history_errors', @get_args)
return unless match.is_a?(Array)
return 'false' if match[0] == 'no '
return unless match[1]
return match[1] if match[1][/\A\d+\z/]
'size_' + match[1]
end
|
#event_history_errors=(val) ⇒ Object
462
463
464
465
466
467
468
|
# File 'lib/cisco_node_utils/bgp.rb', line 462
def event_history_errors=(val)
size = val[/small|medium|large|disable|\A\d+\z/]
@set_args[:size] = size.nil? ? '' : "size #{size}"
@set_args[:state] = val[/false/] ? 'no' : ''
config_set('bgp', 'event_history_errors', @set_args)
set_args_keys_default
end
|
#event_history_events ⇒ Object
event-history events [ size <size> ] Nvgen as True With optional ‘size <size>
472
473
474
475
476
477
478
479
|
# File 'lib/cisco_node_utils/bgp.rb', line 472
def event_history_events
match = config_get('bgp', 'event_history_events', @get_args)
return unless match.is_a?(Array)
return 'false' if match[0] == 'no '
return unless match[1]
return match[1] if match[1][/\A\d+\z/]
'size_' + match[1]
end
|
#event_history_events=(val) ⇒ Object
481
482
483
484
485
486
487
|
# File 'lib/cisco_node_utils/bgp.rb', line 481
def event_history_events=(val)
size = val[/small|medium|large|disable|\A\d+\z/]
@set_args[:size] = size.nil? ? '' : "size #{size}"
@set_args[:state] = val[/false/] ? 'no' : ''
config_set('bgp', 'event_history_events', @set_args)
set_args_keys_default
end
|
#event_history_objstore ⇒ Object
event-history objstore [ size <size> ] Nvgen as True With optional ‘size <size>
491
492
493
494
495
496
497
498
|
# File 'lib/cisco_node_utils/bgp.rb', line 491
def event_history_objstore
match = config_get('bgp', 'event_history_objstore', @get_args)
return unless match.is_a?(Array)
return 'false' if match[0] == 'no '
return 'true' unless match[1]
return match[1] if match[1][/\A\d+\z/]
'size_' + match[1]
end
|
#event_history_objstore=(val) ⇒ Object
500
501
502
503
504
505
506
|
# File 'lib/cisco_node_utils/bgp.rb', line 500
def event_history_objstore=(val)
size = val[/small|medium|large|disable|\A\d+\z/]
@set_args[:size] = size.nil? ? '' : "size #{size}"
@set_args[:state] = val[/false/] ? 'no' : ''
config_set('bgp', 'event_history_objstore', @set_args)
set_args_keys_default
end
|
#event_history_periodic ⇒ Object
event-history periodic [ size <size> ] Nvgen as True With optional ‘size <size>
510
511
512
513
514
515
516
517
|
# File 'lib/cisco_node_utils/bgp.rb', line 510
def event_history_periodic
match = config_get('bgp', 'event_history_periodic', @get_args)
return unless match.is_a?(Array)
return 'false' if match[0] == 'no '
return unless match[1]
return match[1] if match[1][/\A\d+\z/]
'size_' + match[1]
end
|
#event_history_periodic=(val) ⇒ Object
519
520
521
522
523
524
525
|
# File 'lib/cisco_node_utils/bgp.rb', line 519
def event_history_periodic=(val)
size = val[/small|medium|large|disable|\A\d+\z/] unless val[/false|true/]
@set_args[:size] = size.nil? ? '' : "size #{size}"
@set_args[:state] = val[/false/] ? 'no' : ''
config_set('bgp', 'event_history_periodic', @set_args)
set_args_keys_default
end
|
#fast_external_fallover ⇒ Object
Fast External fallover (Getter/Setter/Default)
528
529
530
|
# File 'lib/cisco_node_utils/bgp.rb', line 528
def fast_external_fallover
config_get('bgp', 'fast_external_fallover', @get_args)
end
|
#fast_external_fallover=(enable) ⇒ Object
532
533
534
535
536
537
538
539
540
541
542
543
544
|
# File 'lib/cisco_node_utils/bgp.rb', line 532
def fast_external_fallover=(enable)
enable = !enable if platform == :ios_xr
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'fast_external_fallover', @set_args)
set_args_keys_default
end
|
#flush_routes ⇒ Object
Flush Routes (Getter/Setter/Default)
551
552
553
|
# File 'lib/cisco_node_utils/bgp.rb', line 551
def flush_routes
config_get('bgp', 'flush_routes', @get_args)
end
|
#flush_routes=(enable) ⇒ Object
555
556
557
558
559
|
# File 'lib/cisco_node_utils/bgp.rb', line 555
def flush_routes=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'flush_routes', @set_args)
set_args_keys_default
end
|
#graceful_restart ⇒ Object
611
612
613
614
|
# File 'lib/cisco_node_utils/bgp.rb', line 611
def graceful_restart
return nil if platform == :ios_xr && @vrf != 'default'
config_get('bgp', 'graceful_restart', @get_args)
end
|
#graceful_restart=(enable) ⇒ Object
632
633
634
635
636
637
638
639
640
641
642
|
# File 'lib/cisco_node_utils/bgp.rb', line 632
def graceful_restart=(enable)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp', 'graceful_restart', 'set',
'graceful_restart is not ' \
'configurable ' \
'on a per-VRF basis on IOS XR')
end
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'graceful_restart', @set_args)
set_args_keys_default
end
|
#graceful_restart_helper ⇒ Object
626
627
628
629
|
# File 'lib/cisco_node_utils/bgp.rb', line 626
def graceful_restart_helper
return nil if platform == :ios_xr && @vrf != 'default'
config_get('bgp', 'graceful_restart_helper', @get_args)
end
|
#graceful_restart_helper=(enable) ⇒ Object
684
685
686
687
688
689
690
691
692
693
694
695
|
# File 'lib/cisco_node_utils/bgp.rb', line 684
def graceful_restart_helper=(enable)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp',
'graceful_restart_helper', 'set',
'graceful_restart_helper ' \
'is not configurable ' \
'on a per-VRF basis on IOS XR')
end
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'graceful_restart_helper', @set_args)
set_args_keys_default
end
|
#graceful_restart_timers_restart ⇒ Object
616
617
618
619
|
# File 'lib/cisco_node_utils/bgp.rb', line 616
def graceful_restart_timers_restart
return nil if platform == :ios_xr && @vrf != 'default'
config_get('bgp', 'graceful_restart_timers_restart', @get_args)
end
|
#graceful_restart_timers_restart=(seconds) ⇒ Object
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
|
# File 'lib/cisco_node_utils/bgp.rb', line 644
def graceful_restart_timers_restart=(seconds)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp',
'graceful_restart_timers_restart',
'set',
'graceful_restart_timers_restart is ' \
'not configurable ' \
'on a per-VRF basis on IOS XR')
end
if seconds == default_graceful_restart_timers_restart
@set_args[:state] = 'no'
@set_args[:seconds] = ''
else
@set_args[:state] = ''
@set_args[:seconds] = seconds
end
config_set('bgp', 'graceful_restart_timers_restart', @set_args)
set_args_keys_default
end
|
#graceful_restart_timers_stalepath_time ⇒ Object
621
622
623
624
|
# File 'lib/cisco_node_utils/bgp.rb', line 621
def graceful_restart_timers_stalepath_time
return nil if platform == :ios_xr && @vrf != 'default'
config_get('bgp', 'graceful_restart_timers_stalepath_time', @get_args)
end
|
#graceful_restart_timers_stalepath_time=(seconds) ⇒ Object
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
|
# File 'lib/cisco_node_utils/bgp.rb', line 664
def graceful_restart_timers_stalepath_time=(seconds)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp',
'graceful_restart_timers_' \
'stalepath_time', 'set',
'graceful_restart_timers_' \
'stalepath_time is not configurable ' \
'on a per-VRF basis on IOS XR')
end
if seconds == default_graceful_restart_timers_stalepath_time
@set_args[:state] = 'no'
@set_args[:seconds] = ''
else
@set_args[:state] = ''
@set_args[:seconds] = seconds
end
config_set('bgp', 'graceful_restart_timers_stalepath_time', @set_args)
set_args_keys_default
end
|
#isolate ⇒ Object
Isolate (Getter/Setter/Default)
719
720
721
|
# File 'lib/cisco_node_utils/bgp.rb', line 719
def isolate
config_get('bgp', 'isolate', @get_args)
end
|
#isolate=(enable) ⇒ Object
723
724
725
726
727
|
# File 'lib/cisco_node_utils/bgp.rb', line 723
def isolate=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'isolate', @set_args)
set_args_keys_default
end
|
#log_neighbor_changes ⇒ Object
Log Neighbor Changes (Getter/Setter/Default)
755
756
757
|
# File 'lib/cisco_node_utils/bgp.rb', line 755
def log_neighbor_changes
config_get('bgp', 'log_neighbor_changes', @get_args)
end
|
#log_neighbor_changes=(enable) ⇒ Object
759
760
761
762
763
764
765
766
767
768
769
770
|
# File 'lib/cisco_node_utils/bgp.rb', line 759
def log_neighbor_changes=(enable)
enable = !enable if platform == :ios_xr
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'log_neighbor_changes', @set_args)
set_args_keys_default
end
|
#maxas_limit ⇒ Object
MaxAs Limit (Getter/Setter/Default)
734
735
736
|
# File 'lib/cisco_node_utils/bgp.rb', line 734
def maxas_limit
config_get('bgp', 'maxas_limit', @get_args)
end
|
#maxas_limit=(limit) ⇒ Object
738
739
740
741
742
743
744
745
746
747
748
|
# File 'lib/cisco_node_utils/bgp.rb', line 738
def maxas_limit=(limit)
if limit == default_maxas_limit
@set_args[:state] = 'no'
@set_args[:limit] = ''
else
@set_args[:state] = ''
@set_args[:limit] = limit
end
config_set('bgp', 'maxas_limit', @set_args)
set_args_keys_default
end
|
#neighbor_down_fib_accelerate ⇒ Object
Neighbor down fib accelerate (Getter/Setter/Default)
777
778
779
|
# File 'lib/cisco_node_utils/bgp.rb', line 777
def neighbor_down_fib_accelerate
config_get('bgp', 'neighbor_down_fib_accelerate', @get_args)
end
|
#neighbor_down_fib_accelerate=(enable) ⇒ Object
781
782
783
784
785
|
# File 'lib/cisco_node_utils/bgp.rb', line 781
def neighbor_down_fib_accelerate=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'neighbor_down_fib_accelerate', @set_args)
set_args_keys_default
end
|
#nsr ⇒ Object
126
127
128
129
|
# File 'lib/cisco_node_utils/bgp.rb', line 126
def nsr
return nil if platform == :ios_xr && @vrf != 'default'
config_get('bgp', 'nsr', @get_args)
end
|
#nsr=(enable) ⇒ Object
162
163
164
165
166
167
168
169
170
|
# File 'lib/cisco_node_utils/bgp.rb', line 162
def nsr=(enable)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp', 'nsr', 'set', 'nsr is not ' \
'configurable on a per-VRF basis on ios_xr')
end
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'nsr', @set_args)
set_args_keys_default
end
|
#process_initialized? ⇒ Boolean
98
99
100
|
# File 'lib/cisco_node_utils/bgp.rb', line 98
def process_initialized?
config_get('bgp', 'process_initialized')
end
|
#reconnect_interval ⇒ Object
Reconnect Interval (Getter/Setter/Default)
792
793
794
|
# File 'lib/cisco_node_utils/bgp.rb', line 792
def reconnect_interval
config_get('bgp', 'reconnect_interval', @get_args)
end
|
#reconnect_interval=(seconds) ⇒ Object
796
797
798
799
800
801
802
803
804
805
806
|
# File 'lib/cisco_node_utils/bgp.rb', line 796
def reconnect_interval=(seconds)
if seconds == default_reconnect_interval
@set_args[:state] = 'no'
@set_args[:seconds] = ''
else
@set_args[:state] = ''
@set_args[:seconds] = seconds
end
config_set('bgp', 'reconnect_interval', @set_args)
set_args_keys_default
end
|
#route_distinguisher ⇒ Object
route_distinguisher Note that this property is supported by both bgp and vrf providers.
814
815
816
817
|
# File 'lib/cisco_node_utils/bgp.rb', line 814
def route_distinguisher
return nil if @vrf.nil? || @vrf == 'default'
config_get('bgp', 'route_distinguisher', @get_args)
end
|
#route_distinguisher=(rd) ⇒ Object
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
|
# File 'lib/cisco_node_utils/bgp.rb', line 819
def route_distinguisher=(rd)
if @vrf.nil? || @vrf == 'default'
fail Cisco::UnsupportedError.new('bgp', 'route_distinguisher', 'set',
'route_distinguisher is not ' \
'configurable on a default VRF')
end
Feature.nv_overlay_evpn_enable if
Utils.nexus_i2_image || node.product_id[/N[567]/]
if rd == default_route_distinguisher
return if route_distinguisher.empty?
@set_args[:state] = 'no'
@set_args[:rd] = route_distinguisher
else
@set_args[:state] = ''
@set_args[:rd] = rd
end
config_set('bgp', 'route_distinguisher', @set_args)
set_args_keys_default
end
|
#router_bgp(state = '') ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/cisco_node_utils/bgp.rb', line 76
def router_bgp(state='')
@set_args[:state] = state
if vrf == 'default'
config_set('bgp', 'router', @set_args)
else
config_set('bgp', 'vrf', @set_args)
end
set_args_keys_default
end
|
#router_id ⇒ Object
Router ID (Getter/Setter/Default)
850
851
852
|
# File 'lib/cisco_node_utils/bgp.rb', line 850
def router_id
config_get('bgp', 'router_id', @get_args)
end
|
#router_id=(id) ⇒ Object
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
|
# File 'lib/cisco_node_utils/bgp.rb', line 854
def router_id=(id)
if id == default_router_id
return if router_id == default_router_id
@set_args[:state] = 'no'
@set_args[:id] = router_id
else
@set_args[:state] = ''
@set_args[:id] = id
end
config_set('bgp', 'router_id', @set_args)
set_args_keys_default
end
|
#set_args_keys_default ⇒ Object
Helper method to delete @set_args hash keys
117
118
119
120
121
|
# File 'lib/cisco_node_utils/bgp.rb', line 117
def set_args_keys_default
@set_args = { asnum: @asnum }
@set_args[:vrf] = @vrf unless @vrf == 'default'
@get_args = @set_args
end
|
#shutdown ⇒ Object
Shutdown (Getter/Setter/Default)
876
877
878
|
# File 'lib/cisco_node_utils/bgp.rb', line 876
def shutdown
config_get('bgp', 'shutdown', @asnum)
end
|
#shutdown=(enable) ⇒ Object
880
881
882
883
884
|
# File 'lib/cisco_node_utils/bgp.rb', line 880
def shutdown=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'shutdown', @set_args)
set_args_keys_default
end
|
#suppress_fib_pending ⇒ Object
Supress Fib Pending (Getter/Setter/Default)
891
892
893
894
|
# File 'lib/cisco_node_utils/bgp.rb', line 891
def suppress_fib_pending
val = config_get('bgp', 'suppress_fib_pending', @get_args)
val.nil? ? false : val
end
|
#suppress_fib_pending=(enable) ⇒ Object
896
897
898
899
900
|
# File 'lib/cisco_node_utils/bgp.rb', line 896
def suppress_fib_pending=(enable)
enable == true ? @set_args[:state] = '' : @set_args[:state] = 'no'
config_set('bgp', 'suppress_fib_pending', @set_args)
set_args_keys_default
end
|
#timer_bestpath_limit ⇒ Object
924
925
926
|
# File 'lib/cisco_node_utils/bgp.rb', line 924
def timer_bestpath_limit
config_get('bgp', 'timer_bestpath_limit', @get_args)
end
|
#timer_bestpath_limit_always ⇒ Object
928
929
930
|
# File 'lib/cisco_node_utils/bgp.rb', line 928
def timer_bestpath_limit_always
config_get('bgp', 'timer_bestpath_limit_always', @get_args)
end
|
#timer_bestpath_limit_set(seconds, always = false) ⇒ Object
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
|
# File 'lib/cisco_node_utils/bgp.rb', line 948
def timer_bestpath_limit_set(seconds, always=false)
if always
opt = 'timer_bestpath_limit_always'
else
opt = 'timer_bestpath_limit'
end
if seconds == default_timer_bestpath_limit
@set_args[:state] = 'no'
@set_args[:seconds] = ''
else
@set_args[:state] = ''
@set_args[:seconds] = seconds
end
config_set('bgp', opt, @set_args)
set_args_keys_default
end
|
#timer_bgp_holdtime ⇒ Object
918
919
920
921
922
|
# File 'lib/cisco_node_utils/bgp.rb', line 918
def timer_bgp_holdtime
_keepalive, hold = timer_bgp_keepalive_hold
return default_timer_bgp_holdtime if hold.nil?
hold.to_i
end
|
#timer_bgp_keepalive ⇒ Object
912
913
914
915
916
|
# File 'lib/cisco_node_utils/bgp.rb', line 912
def timer_bgp_keepalive
keepalive, _hold = timer_bgp_keepalive_hold
return default_timer_bgp_keepalive if keepalive.nil?
keepalive.to_i
end
|
#timer_bgp_keepalive_hold ⇒ Object
907
908
909
910
|
# File 'lib/cisco_node_utils/bgp.rb', line 907
def timer_bgp_keepalive_hold
match = config_get('bgp', 'timer_bgp_keepalive_hold', @get_args)
match.nil? ? default_timer_bgp_keepalive_hold : match
end
|
#timer_bgp_keepalive_hold_set(keepalive, hold) ⇒ Object
933
934
935
936
937
938
939
940
941
942
943
944
945
946
|
# File 'lib/cisco_node_utils/bgp.rb', line 933
def timer_bgp_keepalive_hold_set(keepalive, hold)
if keepalive == default_timer_bgp_keepalive &&
hold == default_timer_bgp_holdtime
@set_args[:state] = 'no'
@set_args[:keepalive] = keepalive
@set_args[:hold] = hold
else
@set_args[:state] = ''
@set_args[:keepalive] = keepalive
@set_args[:hold] = hold
end
config_set('bgp', 'timer_bgp_keepalive_hold', @set_args)
set_args_keys_default
end
|
#to_s ⇒ Object
36
37
38
|
# File 'lib/cisco_node_utils/bgp.rb', line 36
def to_s
"BGP #{asnum} VRF '#{vrf}'"
end
|
#wait_for_process_initialized ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/cisco_node_utils/bgp.rb', line 102
def wait_for_process_initialized
return unless node.product_id[/N(5|6|8)/]
4.times do
return if process_initialized?
sleep 1
node.cache_flush
end
fail 'BGP process is not initialized yet'
end
|