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 => e
raise unless e.clierror =~ /Syntax error/
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)
545
546
547
548
549
550
551
552
553
554
|
# File 'lib/cisco_node_utils/bgp.rb', line 545
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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
|
# File 'lib/cisco_node_utils/bgp.rb', line 556
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
584
585
586
587
|
# File 'lib/cisco_node_utils/bgp.rb', line 584
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_event_history_cli ⇒ Object
432
433
434
|
# File 'lib/cisco_node_utils/bgp.rb', line 432
def default_event_history_cli
config_get_default('bgp', 'event_history_cli')
end
|
#default_event_history_detail ⇒ Object
456
457
458
|
# File 'lib/cisco_node_utils/bgp.rb', line 456
def default_event_history_detail
config_get_default('bgp', 'event_history_detail')
end
|
#default_event_history_events ⇒ Object
479
480
481
|
# File 'lib/cisco_node_utils/bgp.rb', line 479
def default_event_history_events
config_get_default('bgp', 'event_history_events')
end
|
#default_event_history_periodic ⇒ Object
502
503
504
|
# File 'lib/cisco_node_utils/bgp.rb', line 502
def default_event_history_periodic
config_get_default('bgp', 'event_history_periodic')
end
|
#default_fast_external_fallover ⇒ Object
525
526
527
|
# File 'lib/cisco_node_utils/bgp.rb', line 525
def default_fast_external_fallover
config_get_default('bgp', 'fast_external_fallover')
end
|
#default_flush_routes ⇒ Object
540
541
542
|
# File 'lib/cisco_node_utils/bgp.rb', line 540
def default_flush_routes
config_get_default('bgp', 'flush_routes')
end
|
#default_graceful_restart ⇒ Object
Graceful Restart Defaults
677
678
679
680
|
# File 'lib/cisco_node_utils/bgp.rb', line 677
def default_graceful_restart
return nil if platform == :ios_xr && @vrf != 'default'
config_get_default('bgp', 'graceful_restart')
end
|
#default_graceful_restart_helper ⇒ Object
692
693
694
695
|
# File 'lib/cisco_node_utils/bgp.rb', line 692
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
682
683
684
685
|
# File 'lib/cisco_node_utils/bgp.rb', line 682
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
687
688
689
690
|
# File 'lib/cisco_node_utils/bgp.rb', line 687
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
708
709
710
|
# File 'lib/cisco_node_utils/bgp.rb', line 708
def default_isolate
config_get_default('bgp', 'isolate')
end
|
#default_log_neighbor_changes ⇒ Object
751
752
753
|
# File 'lib/cisco_node_utils/bgp.rb', line 751
def default_log_neighbor_changes
config_get_default('bgp', 'log_neighbor_changes')
end
|
#default_maxas_limit ⇒ Object
729
730
731
|
# File 'lib/cisco_node_utils/bgp.rb', line 729
def default_maxas_limit
config_get_default('bgp', 'maxas_limit')
end
|
#default_neighbor_down_fib_accelerate ⇒ Object
766
767
768
|
# File 'lib/cisco_node_utils/bgp.rb', line 766
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
787
788
789
|
# File 'lib/cisco_node_utils/bgp.rb', line 787
def default_reconnect_interval
config_get_default('bgp', 'reconnect_interval')
end
|
#default_route_distinguisher ⇒ Object
822
823
824
825
|
# File 'lib/cisco_node_utils/bgp.rb', line 822
def default_route_distinguisher
return nil if @vrf.nil? || @vrf == 'default'
config_get_default('bgp', 'route_distinguisher')
end
|
#default_router_id ⇒ Object
849
850
851
|
# File 'lib/cisco_node_utils/bgp.rb', line 849
def default_router_id
config_get_default('bgp', 'router_id')
end
|
#default_shutdown ⇒ Object
864
865
866
|
# File 'lib/cisco_node_utils/bgp.rb', line 864
def default_shutdown
config_get_default('bgp', 'shutdown')
end
|
#default_suppress_fib_pending ⇒ Object
879
880
881
|
# File 'lib/cisco_node_utils/bgp.rb', line 879
def default_suppress_fib_pending
config_get_default('bgp', 'suppress_fib_pending')
end
|
#default_timer_bestpath_limit ⇒ Object
955
956
957
958
|
# File 'lib/cisco_node_utils/bgp.rb', line 955
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
960
961
962
963
|
# File 'lib/cisco_node_utils/bgp.rb', line 960
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
951
952
953
|
# File 'lib/cisco_node_utils/bgp.rb', line 951
def default_timer_bgp_holdtime
config_get_default('bgp', 'timer_bgp_hold')
end
|
#default_timer_bgp_keepalive ⇒ Object
947
948
949
|
# File 'lib/cisco_node_utils/bgp.rb', line 947
def default_timer_bgp_keepalive
config_get_default('bgp', 'timer_bgp_keepalive')
end
|
#default_timer_bgp_keepalive_hold ⇒ Object
943
944
945
|
# File 'lib/cisco_node_utils/bgp.rb', line 943
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)
if match.is_a?(Array)
return 'false' if match[0] == 'no '
return 'size_' + match[1] if match[1]
end
default_event_history_cli
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/]
@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>
438
439
440
441
442
443
444
445
446
|
# File 'lib/cisco_node_utils/bgp.rb', line 438
def event_history_detail
match = config_get('bgp', 'event_history_detail', @get_args)
if match.is_a?(Array)
return 'false' if match[0] == 'no '
return 'size_' + match[1] if match[1]
end
default_event_history_detail
end
|
#event_history_detail=(val) ⇒ Object
448
449
450
451
452
453
454
|
# File 'lib/cisco_node_utils/bgp.rb', line 448
def event_history_detail=(val)
size = val[/small|medium|large|disable/]
@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_events ⇒ Object
event-history events [ size <size> ] Nvgen as True With optional ‘size <size>
462
463
464
465
466
467
468
469
|
# File 'lib/cisco_node_utils/bgp.rb', line 462
def event_history_events
match = config_get('bgp', 'event_history_events', @get_args)
if match.is_a?(Array)
return 'false' if match[0] == 'no '
return 'size_' + match[1] if match[1]
end
default_event_history_events
end
|
#event_history_events=(val) ⇒ Object
471
472
473
474
475
476
477
|
# File 'lib/cisco_node_utils/bgp.rb', line 471
def event_history_events=(val)
size = val[/small|medium|large|disable/]
@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_periodic ⇒ Object
event-history periodic [ size <size> ] Nvgen as True With optional ‘size <size>
485
486
487
488
489
490
491
492
|
# File 'lib/cisco_node_utils/bgp.rb', line 485
def event_history_periodic
match = config_get('bgp', 'event_history_periodic', @get_args)
if match.is_a?(Array)
return 'false' if match[0] == 'no '
return 'size_' + match[1] if match[1]
end
default_event_history_periodic
end
|
#event_history_periodic=(val) ⇒ Object
494
495
496
497
498
499
500
|
# File 'lib/cisco_node_utils/bgp.rb', line 494
def event_history_periodic=(val)
size = val[/small|medium|large|disable/]
@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)
507
508
509
|
# File 'lib/cisco_node_utils/bgp.rb', line 507
def fast_external_fallover
config_get('bgp', 'fast_external_fallover', @get_args)
end
|
#fast_external_fallover=(enable) ⇒ Object
511
512
513
514
515
516
517
518
519
520
521
522
523
|
# File 'lib/cisco_node_utils/bgp.rb', line 511
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)
530
531
532
|
# File 'lib/cisco_node_utils/bgp.rb', line 530
def flush_routes
config_get('bgp', 'flush_routes', @get_args)
end
|
#flush_routes=(enable) ⇒ Object
534
535
536
537
538
|
# File 'lib/cisco_node_utils/bgp.rb', line 534
def flush_routes=(enable)
@set_args[:state] = (enable ? '' : 'no')
config_set('bgp', 'flush_routes', @set_args)
set_args_keys_default
end
|
#graceful_restart ⇒ Object
590
591
592
593
|
# File 'lib/cisco_node_utils/bgp.rb', line 590
def graceful_restart
return nil if platform == :ios_xr && @vrf != 'default'
config_get('bgp', 'graceful_restart', @get_args)
end
|
#graceful_restart=(enable) ⇒ Object
611
612
613
614
615
616
617
618
619
620
621
|
# File 'lib/cisco_node_utils/bgp.rb', line 611
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
605
606
607
608
|
# File 'lib/cisco_node_utils/bgp.rb', line 605
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
663
664
665
666
667
668
669
670
671
672
673
674
|
# File 'lib/cisco_node_utils/bgp.rb', line 663
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
595
596
597
598
|
# File 'lib/cisco_node_utils/bgp.rb', line 595
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
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
|
# File 'lib/cisco_node_utils/bgp.rb', line 623
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
600
601
602
603
|
# File 'lib/cisco_node_utils/bgp.rb', line 600
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
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
|
# File 'lib/cisco_node_utils/bgp.rb', line 643
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)
698
699
700
|
# File 'lib/cisco_node_utils/bgp.rb', line 698
def isolate
config_get('bgp', 'isolate', @get_args)
end
|
#isolate=(enable) ⇒ Object
702
703
704
705
706
|
# File 'lib/cisco_node_utils/bgp.rb', line 702
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)
734
735
736
|
# File 'lib/cisco_node_utils/bgp.rb', line 734
def log_neighbor_changes
config_get('bgp', 'log_neighbor_changes', @get_args)
end
|
#log_neighbor_changes=(enable) ⇒ Object
738
739
740
741
742
743
744
745
746
747
748
749
|
# File 'lib/cisco_node_utils/bgp.rb', line 738
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)
713
714
715
|
# File 'lib/cisco_node_utils/bgp.rb', line 713
def maxas_limit
config_get('bgp', 'maxas_limit', @get_args)
end
|
#maxas_limit=(limit) ⇒ Object
717
718
719
720
721
722
723
724
725
726
727
|
# File 'lib/cisco_node_utils/bgp.rb', line 717
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)
756
757
758
|
# File 'lib/cisco_node_utils/bgp.rb', line 756
def neighbor_down_fib_accelerate
config_get('bgp', 'neighbor_down_fib_accelerate', @get_args)
end
|
#neighbor_down_fib_accelerate=(enable) ⇒ Object
760
761
762
763
764
|
# File 'lib/cisco_node_utils/bgp.rb', line 760
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)
771
772
773
|
# File 'lib/cisco_node_utils/bgp.rb', line 771
def reconnect_interval
config_get('bgp', 'reconnect_interval', @get_args)
end
|
#reconnect_interval=(seconds) ⇒ Object
775
776
777
778
779
780
781
782
783
784
785
|
# File 'lib/cisco_node_utils/bgp.rb', line 775
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.
793
794
795
796
|
# File 'lib/cisco_node_utils/bgp.rb', line 793
def route_distinguisher
return nil if @vrf.nil? || @vrf == 'default'
config_get('bgp', 'route_distinguisher', @get_args)
end
|
#route_distinguisher=(rd) ⇒ Object
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
|
# File 'lib/cisco_node_utils/bgp.rb', line 798
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
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)
828
829
830
|
# File 'lib/cisco_node_utils/bgp.rb', line 828
def router_id
config_get('bgp', 'router_id', @get_args)
end
|
#router_id=(id) ⇒ Object
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
|
# File 'lib/cisco_node_utils/bgp.rb', line 832
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)
854
855
856
|
# File 'lib/cisco_node_utils/bgp.rb', line 854
def shutdown
config_get('bgp', 'shutdown', @asnum)
end
|
#shutdown=(enable) ⇒ Object
858
859
860
861
862
|
# File 'lib/cisco_node_utils/bgp.rb', line 858
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)
869
870
871
|
# File 'lib/cisco_node_utils/bgp.rb', line 869
def suppress_fib_pending
config_get('bgp', 'suppress_fib_pending', @get_args)
end
|
#suppress_fib_pending=(enable) ⇒ Object
873
874
875
876
877
|
# File 'lib/cisco_node_utils/bgp.rb', line 873
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
901
902
903
|
# File 'lib/cisco_node_utils/bgp.rb', line 901
def timer_bestpath_limit
config_get('bgp', 'timer_bestpath_limit', @get_args)
end
|
#timer_bestpath_limit_always ⇒ Object
905
906
907
|
# File 'lib/cisco_node_utils/bgp.rb', line 905
def timer_bestpath_limit_always
config_get('bgp', 'timer_bestpath_limit_always', @get_args)
end
|
#timer_bestpath_limit_set(seconds, always = false) ⇒ Object
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
|
# File 'lib/cisco_node_utils/bgp.rb', line 925
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
895
896
897
898
899
|
# File 'lib/cisco_node_utils/bgp.rb', line 895
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
889
890
891
892
893
|
# File 'lib/cisco_node_utils/bgp.rb', line 889
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
884
885
886
887
|
# File 'lib/cisco_node_utils/bgp.rb', line 884
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
910
911
912
913
914
915
916
917
918
919
920
921
922
923
|
# File 'lib/cisco_node_utils/bgp.rb', line 910
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)/]
4.times do
return if process_initialized?
sleep 1
node.cache_flush
end
fail 'BGP process is not initialized yet'
end
|