Class: Cisco::RouterBgp

Inherits:
NodeUtil show all
Defined in:
lib/cisco_node_utils/bgp.rb

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

config_get, #config_get, config_get_default, #config_get_default, #config_set, config_set, #node, node, #show

Constructor Details

#initialize(asnum, vrf = 'default', instantiate = true) ⇒ RouterBgp

Returns a new instance of RouterBgp.



26
27
28
29
30
31
32
33
# File 'lib/cisco_node_utils/bgp.rb', line 26

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

#asnumObject (readonly)

Returns the value of attribute asnum.



24
25
26
# File 'lib/cisco_node_utils/bgp.rb', line 24

def asnum
  @asnum
end

#vrfObject (readonly)

Returns the value of attribute vrf.



24
25
26
# File 'lib/cisco_node_utils/bgp.rb', line 24

def vrf
  @vrf
end

Class Method Details

.routersObject

Create a hash of all router bgp default and non-default vrf instances



37
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.rb', line 37

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
  # cmd will syntax reject when feature is not enabled
  raise unless e.clierror =~ /Syntax error/
  return {}
end

.validate_asnum(asnum) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/cisco_node_utils/bgp.rb', line 60

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
    # Match ASDOT '1.5' or ASPLAIN '55' strings
    fail ArgumentError unless /^(\d+|\d+\.\d+)$/.match(asnum)
  end
  asnum.to_s
end

Instance Method Details

#bestpath_always_compare_medObject

Bestpath Getters



102
103
104
# File 'lib/cisco_node_utils/bgp.rb', line 102

def bestpath_always_compare_med
  config_get('bgp', 'bestpath_always_compare_med', @get_args)
end

#bestpath_always_compare_med=(enable) ⇒ Object

Bestpath Setters



131
132
133
134
135
# File 'lib/cisco_node_utils/bgp.rb', line 131

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_relaxObject



106
107
108
# File 'lib/cisco_node_utils/bgp.rb', line 106

def bestpath_aspath_multipath_relax
  config_get('bgp', 'bestpath_aspath_multipath_relax', @get_args)
end

#bestpath_aspath_multipath_relax=(enable) ⇒ Object



137
138
139
140
141
# File 'lib/cisco_node_utils/bgp.rb', line 137

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_routeridObject



110
111
112
# File 'lib/cisco_node_utils/bgp.rb', line 110

def bestpath_compare_routerid
  config_get('bgp', 'bestpath_compare_routerid', @get_args)
end

#bestpath_compare_routerid=(enable) ⇒ Object



143
144
145
146
147
# File 'lib/cisco_node_utils/bgp.rb', line 143

def bestpath_compare_routerid=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'bestpath_compare_routerid', @set_args)
  set_args_keys_default
end

#bestpath_cost_community_ignoreObject



114
115
116
# File 'lib/cisco_node_utils/bgp.rb', line 114

def bestpath_cost_community_ignore
  config_get('bgp', 'bestpath_cost_community_ignore', @get_args)
end

#bestpath_cost_community_ignore=(enable) ⇒ Object



149
150
151
152
153
# File 'lib/cisco_node_utils/bgp.rb', line 149

def bestpath_cost_community_ignore=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'bestpath_cost_community_ignore', @set_args)
  set_args_keys_default
end

#bestpath_med_confedObject



118
119
120
# File 'lib/cisco_node_utils/bgp.rb', line 118

def bestpath_med_confed
  config_get('bgp', 'bestpath_med_confed', @get_args)
end

#bestpath_med_confed=(enable) ⇒ Object



155
156
157
158
159
# File 'lib/cisco_node_utils/bgp.rb', line 155

def bestpath_med_confed=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'bestpath_med_confed', @set_args)
  set_args_keys_default
end

#bestpath_med_missing_as_worstObject



122
123
124
# File 'lib/cisco_node_utils/bgp.rb', line 122

def bestpath_med_missing_as_worst
  config_get('bgp', 'bestpath_med_missing_as_worst', @get_args)
end

#bestpath_med_missing_as_worst=(enable) ⇒ Object



161
162
163
164
165
# File 'lib/cisco_node_utils/bgp.rb', line 161

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_deterministicObject



126
127
128
# File 'lib/cisco_node_utils/bgp.rb', line 126

def bestpath_med_non_deterministic
  config_get('bgp', 'bestpath_med_non_deterministic', @get_args)
end

#bestpath_med_non_deterministic=(enable) ⇒ Object



167
168
169
170
171
# File 'lib/cisco_node_utils/bgp.rb', line 167

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_idObject

Cluster Id (Getter/Setter/Default)



203
204
205
# File 'lib/cisco_node_utils/bgp.rb', line 203

def cluster_id
  config_get('bgp', 'cluster_id', @get_args)
end

#cluster_id=(id) ⇒ Object



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/cisco_node_utils/bgp.rb', line 207

def cluster_id=(id)
  # In order to remove a bgp cluster_id you cannot simply issue
  # 'no bgp cluster-id'.  IMO this should be possible because you
  # can only configure a single bgp cluster-id.
  #
  # HACK: specify a dummy id when removing the property.
  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_idObject

Confederation Id (Getter/Setter/Default)



230
231
232
# File 'lib/cisco_node_utils/bgp.rb', line 230

def confederation_id
  config_get('bgp', 'confederation_id', @get_args)
end

#confederation_id=(id) ⇒ Object



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/cisco_node_utils/bgp.rb', line 234

def confederation_id=(id)
  # In order to remove a bgp confed id you cannot simply issue
  # 'no bgp confederation id'.  IMO this should be possible
  # because you can only configure a single bgp confed id.
  #
  # HACK: specify a dummy id when removing the property.
  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_peersObject

Confederation Peers (Getter/Setter/Default)



461
462
463
# File 'lib/cisco_node_utils/bgp.rb', line 461

def confederation_peers
  config_get('bgp', 'confederation_peers', @get_args)
end

#confederation_peers_set(peers) ⇒ Object



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/cisco_node_utils/bgp.rb', line 465

def confederation_peers_set(peers)
  # The confederation peers command is additive so we first need to
  # remove any existing peers.
  unless confederation_peers.empty?
    @set_args[:state] = 'no'
    @set_args[:peer_list] = confederation_peers
    config_set('bgp', 'confederation_peers', @set_args)
  end
  unless peers == default_confederation_peers
    @set_args[:state] = ''
    @set_args[:peer_list] = peers
    config_set('bgp', 'confederation_peers', @set_args)
  end
  set_args_keys_default
end

#createObject

Create one router bgp instance



82
83
84
85
# File 'lib/cisco_node_utils/bgp.rb', line 82

def create
  Feature.bgp_enable
  router_bgp
end

#default_bestpath_always_compare_medObject

Bestpath Defaults



174
175
176
# File 'lib/cisco_node_utils/bgp.rb', line 174

def default_bestpath_always_compare_med
  config_get_default('bgp', 'bestpath_always_compare_med')
end

#default_bestpath_aspath_multipath_relaxObject



178
179
180
# File 'lib/cisco_node_utils/bgp.rb', line 178

def default_bestpath_aspath_multipath_relax
  config_get_default('bgp', 'bestpath_aspath_multipath_relax')
end

#default_bestpath_compare_routeridObject



182
183
184
# File 'lib/cisco_node_utils/bgp.rb', line 182

def default_bestpath_compare_routerid
  config_get_default('bgp', 'bestpath_compare_routerid')
end

#default_bestpath_cost_community_ignoreObject



186
187
188
# File 'lib/cisco_node_utils/bgp.rb', line 186

def default_bestpath_cost_community_ignore
  config_get_default('bgp', 'bestpath_cost_community_ignore')
end

#default_bestpath_med_confedObject



190
191
192
# File 'lib/cisco_node_utils/bgp.rb', line 190

def default_bestpath_med_confed
  config_get_default('bgp', 'bestpath_med_confed')
end

#default_bestpath_med_missing_as_worstObject



194
195
196
# File 'lib/cisco_node_utils/bgp.rb', line 194

def default_bestpath_med_missing_as_worst
  config_get_default('bgp', 'bestpath_med_missing_as_worst')
end

#default_bestpath_med_non_deterministicObject



198
199
200
# File 'lib/cisco_node_utils/bgp.rb', line 198

def default_bestpath_med_non_deterministic
  config_get_default('bgp', 'bestpath_med_non_deterministic')
end

#default_cluster_idObject



225
226
227
# File 'lib/cisco_node_utils/bgp.rb', line 225

def default_cluster_id
  config_get_default('bgp', 'cluster_id')
end

#default_confederation_idObject



252
253
254
# File 'lib/cisco_node_utils/bgp.rb', line 252

def default_confederation_id
  config_get_default('bgp', 'confederation_id')
end

#default_confederation_peersObject



481
482
483
# File 'lib/cisco_node_utils/bgp.rb', line 481

def default_confederation_peers
  config_get_default('bgp', 'confederation_peers')
end

#default_disable_policy_batchingObject



269
270
271
# File 'lib/cisco_node_utils/bgp.rb', line 269

def default_disable_policy_batching
  config_get_default('bgp', 'disable_policy_batching')
end

#default_disable_policy_batching_ipv4Object



293
294
295
# File 'lib/cisco_node_utils/bgp.rb', line 293

def default_disable_policy_batching_ipv4
  config_get_default('bgp', 'disable_policy_batching_ipv4')
end

#default_disable_policy_batching_ipv6Object



317
318
319
# File 'lib/cisco_node_utils/bgp.rb', line 317

def default_disable_policy_batching_ipv6
  config_get_default('bgp', 'disable_policy_batching_ipv6')
end

#default_enforce_first_asObject



332
333
334
# File 'lib/cisco_node_utils/bgp.rb', line 332

def default_enforce_first_as
  config_get_default('bgp', 'enforce_first_as')
end

#default_event_history_cliObject



356
357
358
# File 'lib/cisco_node_utils/bgp.rb', line 356

def default_event_history_cli
  config_get_default('bgp', 'event_history_cli')
end

#default_event_history_detailObject



380
381
382
# File 'lib/cisco_node_utils/bgp.rb', line 380

def default_event_history_detail
  config_get_default('bgp', 'event_history_detail')
end

#default_event_history_eventsObject



403
404
405
# File 'lib/cisco_node_utils/bgp.rb', line 403

def default_event_history_events
  config_get_default('bgp', 'event_history_events')
end

#default_event_history_periodicObject



426
427
428
# File 'lib/cisco_node_utils/bgp.rb', line 426

def default_event_history_periodic
  config_get_default('bgp', 'event_history_periodic')
end

#default_fast_external_falloverObject



441
442
443
# File 'lib/cisco_node_utils/bgp.rb', line 441

def default_fast_external_fallover
  config_get_default('bgp', 'fast_external_fallover')
end

#default_flush_routesObject



456
457
458
# File 'lib/cisco_node_utils/bgp.rb', line 456

def default_flush_routes
  config_get_default('bgp', 'flush_routes')
end

#default_graceful_restartObject

Graceful Restart Defaults



540
541
542
# File 'lib/cisco_node_utils/bgp.rb', line 540

def default_graceful_restart
  config_get_default('bgp', 'graceful_restart')
end

#default_graceful_restart_helperObject



552
553
554
# File 'lib/cisco_node_utils/bgp.rb', line 552

def default_graceful_restart_helper
  config_get_default('bgp', 'graceful_restart_helper')
end

#default_graceful_restart_timers_restartObject



544
545
546
# File 'lib/cisco_node_utils/bgp.rb', line 544

def default_graceful_restart_timers_restart
  config_get_default('bgp', 'graceful_restart_timers_restart')
end

#default_graceful_restart_timers_stalepath_timeObject



548
549
550
# File 'lib/cisco_node_utils/bgp.rb', line 548

def default_graceful_restart_timers_stalepath_time
  config_get_default('bgp', 'graceful_restart_timers_stalepath_time')
end

#default_isolateObject



567
568
569
# File 'lib/cisco_node_utils/bgp.rb', line 567

def default_isolate
  config_get_default('bgp', 'isolate')
end

#default_log_neighbor_changesObject



603
604
605
# File 'lib/cisco_node_utils/bgp.rb', line 603

def default_log_neighbor_changes
  config_get_default('bgp', 'log_neighbor_changes')
end

#default_maxas_limitObject



588
589
590
# File 'lib/cisco_node_utils/bgp.rb', line 588

def default_maxas_limit
  config_get_default('bgp', 'maxas_limit')
end

#default_neighbor_down_fib_accelerateObject



618
619
620
# File 'lib/cisco_node_utils/bgp.rb', line 618

def default_neighbor_down_fib_accelerate
  config_get_default('bgp', 'neighbor_down_fib_accelerate')
end

#default_reconnect_intervalObject



639
640
641
# File 'lib/cisco_node_utils/bgp.rb', line 639

def default_reconnect_interval
  config_get_default('bgp', 'reconnect_interval')
end

#default_route_distinguisherObject



662
663
664
# File 'lib/cisco_node_utils/bgp.rb', line 662

def default_route_distinguisher
  config_get_default('bgp', 'route_distinguisher')
end

#default_router_idObject



688
689
690
# File 'lib/cisco_node_utils/bgp.rb', line 688

def default_router_id
  config_get_default('bgp', 'router_id')
end

#default_shutdownObject



703
704
705
# File 'lib/cisco_node_utils/bgp.rb', line 703

def default_shutdown
  config_get_default('bgp', 'shutdown')
end

#default_suppress_fib_pendingObject



718
719
720
# File 'lib/cisco_node_utils/bgp.rb', line 718

def default_suppress_fib_pending
  config_get_default('bgp', 'suppress_fib_pending')
end

#default_timer_bestpath_limitObject



794
795
796
# File 'lib/cisco_node_utils/bgp.rb', line 794

def default_timer_bestpath_limit
  config_get_default('bgp', 'timer_bestpath_limit')
end

#default_timer_bestpath_limit_alwaysObject



798
799
800
# File 'lib/cisco_node_utils/bgp.rb', line 798

def default_timer_bestpath_limit_always
  config_get_default('bgp', 'timer_bestpath_limit_always')
end

#default_timer_bgp_holdtimeObject



790
791
792
# File 'lib/cisco_node_utils/bgp.rb', line 790

def default_timer_bgp_holdtime
  config_get_default('bgp', 'timer_bgp_hold')
end

#default_timer_bgp_keepaliveObject



786
787
788
# File 'lib/cisco_node_utils/bgp.rb', line 786

def default_timer_bgp_keepalive
  config_get_default('bgp', 'timer_bgp_keepalive')
end

#default_timer_bgp_keepalive_holdObject

BGP Timers Defaults



782
783
784
# File 'lib/cisco_node_utils/bgp.rb', line 782

def default_timer_bgp_keepalive_hold
  ["#{default_timer_bgp_keepalive}", "#{default_timer_bgp_holdtime}"]
end

#destroyObject

Destroy router bgp instance



88
89
90
# File 'lib/cisco_node_utils/bgp.rb', line 88

def destroy
  router_bgp('no')
end

#disable_policy_batchingObject

disable-policy-batching (Getter/Setter/Default)



259
260
261
# File 'lib/cisco_node_utils/bgp.rb', line 259

def disable_policy_batching
  config_get('bgp', 'disable_policy_batching', @get_args)
end

#disable_policy_batching=(enable) ⇒ Object



263
264
265
266
267
# File 'lib/cisco_node_utils/bgp.rb', line 263

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_ipv4Object

disable-policy-batching ipv4 prefix-list <prefix_list>



276
277
278
# File 'lib/cisco_node_utils/bgp.rb', line 276

def disable_policy_batching_ipv4
  config_get('bgp', 'disable_policy_batching_ipv4', @get_args)
end

#disable_policy_batching_ipv4=(prefix_list) ⇒ Object



280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/cisco_node_utils/bgp.rb', line 280

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_ipv6Object

disable-policy-batching ipv6 prefix-list <prefix_list>



300
301
302
# File 'lib/cisco_node_utils/bgp.rb', line 300

def disable_policy_batching_ipv6
  config_get('bgp', 'disable_policy_batching_ipv6', @get_args)
end

#disable_policy_batching_ipv6=(prefix_list) ⇒ Object



304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/cisco_node_utils/bgp.rb', line 304

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_asObject

Enforce First As (Getter/Setter/Default)



322
323
324
# File 'lib/cisco_node_utils/bgp.rb', line 322

def enforce_first_as
  config_get('bgp', 'enforce_first_as', @get_args)
end

#enforce_first_as=(enable) ⇒ Object



326
327
328
329
330
# File 'lib/cisco_node_utils/bgp.rb', line 326

def enforce_first_as=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'enforce_first_as', @set_args)
  set_args_keys_default
end

#event_history_cliObject

event-history event-history cli [ size <size> ] Nvgen as True With optional ‘size <size>



339
340
341
342
343
344
345
346
# File 'lib/cisco_node_utils/bgp.rb', line 339

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



348
349
350
351
352
353
354
# File 'lib/cisco_node_utils/bgp.rb', line 348

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_detailObject

event-history detail [ size <size> ] Nvgen as True With optional ‘size <size>



362
363
364
365
366
367
368
369
370
# File 'lib/cisco_node_utils/bgp.rb', line 362

def event_history_detail
  match = config_get('bgp', 'event_history_detail', @get_args)
  # This property requires auto_default=false
  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



372
373
374
375
376
377
378
# File 'lib/cisco_node_utils/bgp.rb', line 372

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_eventsObject

event-history events [ size <size> ] Nvgen as True With optional ‘size <size>



386
387
388
389
390
391
392
393
# File 'lib/cisco_node_utils/bgp.rb', line 386

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



395
396
397
398
399
400
401
# File 'lib/cisco_node_utils/bgp.rb', line 395

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_periodicObject

event-history periodic [ size <size> ] Nvgen as True With optional ‘size <size>



409
410
411
412
413
414
415
416
# File 'lib/cisco_node_utils/bgp.rb', line 409

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



418
419
420
421
422
423
424
# File 'lib/cisco_node_utils/bgp.rb', line 418

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_falloverObject

Fast External fallover (Getter/Setter/Default)



431
432
433
# File 'lib/cisco_node_utils/bgp.rb', line 431

def fast_external_fallover
  config_get('bgp', 'fast_external_fallover', @get_args)
end

#fast_external_fallover=(enable) ⇒ Object



435
436
437
438
439
# File 'lib/cisco_node_utils/bgp.rb', line 435

def fast_external_fallover=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'fast_external_fallover', @set_args)
  set_args_keys_default
end

#flush_routesObject

Flush Routes (Getter/Setter/Default)



446
447
448
# File 'lib/cisco_node_utils/bgp.rb', line 446

def flush_routes
  config_get('bgp', 'flush_routes', @get_args)
end

#flush_routes=(enable) ⇒ Object



450
451
452
453
454
# File 'lib/cisco_node_utils/bgp.rb', line 450

def flush_routes=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'flush_routes', @set_args)
  set_args_keys_default
end

#graceful_restartObject

Graceful Restart Getters



486
487
488
# File 'lib/cisco_node_utils/bgp.rb', line 486

def graceful_restart
  config_get('bgp', 'graceful_restart', @get_args)
end

#graceful_restart=(enable) ⇒ Object

Graceful Restart Setters



503
504
505
506
507
# File 'lib/cisco_node_utils/bgp.rb', line 503

def graceful_restart=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'graceful_restart', @set_args)
  set_args_keys_default
end

#graceful_restart_helperObject



498
499
500
# File 'lib/cisco_node_utils/bgp.rb', line 498

def graceful_restart_helper
  config_get('bgp', 'graceful_restart_helper', @get_args)
end

#graceful_restart_helper=(enable) ⇒ Object



533
534
535
536
537
# File 'lib/cisco_node_utils/bgp.rb', line 533

def graceful_restart_helper=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'graceful_restart_helper', @set_args)
  set_args_keys_default
end

#graceful_restart_timers_restartObject



490
491
492
# File 'lib/cisco_node_utils/bgp.rb', line 490

def graceful_restart_timers_restart
  config_get('bgp', 'graceful_restart_timers_restart', @get_args)
end

#graceful_restart_timers_restart=(seconds) ⇒ Object



509
510
511
512
513
514
515
516
517
518
519
# File 'lib/cisco_node_utils/bgp.rb', line 509

def graceful_restart_timers_restart=(seconds)
  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_timeObject



494
495
496
# File 'lib/cisco_node_utils/bgp.rb', line 494

def graceful_restart_timers_stalepath_time
  config_get('bgp', 'graceful_restart_timers_stalepath_time', @get_args)
end

#graceful_restart_timers_stalepath_time=(seconds) ⇒ Object



521
522
523
524
525
526
527
528
529
530
531
# File 'lib/cisco_node_utils/bgp.rb', line 521

def graceful_restart_timers_stalepath_time=(seconds)
  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

#isolateObject

Isolate (Getter/Setter/Default)



557
558
559
# File 'lib/cisco_node_utils/bgp.rb', line 557

def isolate
  config_get('bgp', 'isolate', @get_args)
end

#isolate=(enable) ⇒ Object



561
562
563
564
565
# File 'lib/cisco_node_utils/bgp.rb', line 561

def isolate=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'isolate', @set_args)
  set_args_keys_default
end

#log_neighbor_changesObject

Log Neighbor Changes (Getter/Setter/Default)



593
594
595
# File 'lib/cisco_node_utils/bgp.rb', line 593

def log_neighbor_changes
  config_get('bgp', 'log_neighbor_changes', @get_args)
end

#log_neighbor_changes=(enable) ⇒ Object



597
598
599
600
601
# File 'lib/cisco_node_utils/bgp.rb', line 597

def log_neighbor_changes=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'log_neighbor_changes', @set_args)
  set_args_keys_default
end

#maxas_limitObject

MaxAs Limit (Getter/Setter/Default)



572
573
574
# File 'lib/cisco_node_utils/bgp.rb', line 572

def maxas_limit
  config_get('bgp', 'maxas_limit', @get_args)
end

#maxas_limit=(limit) ⇒ Object



576
577
578
579
580
581
582
583
584
585
586
# File 'lib/cisco_node_utils/bgp.rb', line 576

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_accelerateObject

Neighbor down fib accelerate (Getter/Setter/Default)



608
609
610
# File 'lib/cisco_node_utils/bgp.rb', line 608

def neighbor_down_fib_accelerate
  config_get('bgp', 'neighbor_down_fib_accelerate', @get_args)
end

#neighbor_down_fib_accelerate=(enable) ⇒ Object



612
613
614
615
616
# File 'lib/cisco_node_utils/bgp.rb', line 612

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

#reconnect_intervalObject

Reconnect Interval (Getter/Setter/Default)



623
624
625
# File 'lib/cisco_node_utils/bgp.rb', line 623

def reconnect_interval
  config_get('bgp', 'reconnect_interval', @get_args)
end

#reconnect_interval=(seconds) ⇒ Object



627
628
629
630
631
632
633
634
635
636
637
# File 'lib/cisco_node_utils/bgp.rb', line 627

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_distinguisherObject

route_distinguisher Note that this property is supported by both bgp and vrf providers.



645
646
647
# File 'lib/cisco_node_utils/bgp.rb', line 645

def route_distinguisher
  config_get('bgp', 'route_distinguisher', @get_args)
end

#route_distinguisher=(rd) ⇒ Object



649
650
651
652
653
654
655
656
657
658
659
660
# File 'lib/cisco_node_utils/bgp.rb', line 649

def route_distinguisher=(rd)
  Feature.nv_overlay_evpn_enable
  if rd == default_route_distinguisher
    @set_args[:state] = 'no'
    @set_args[:rd] = ''
  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



71
72
73
74
75
76
77
78
79
# File 'lib/cisco_node_utils/bgp.rb', line 71

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_idObject

Router ID (Getter/Setter/Default)



667
668
669
# File 'lib/cisco_node_utils/bgp.rb', line 667

def router_id
  config_get('bgp', 'router_id', @get_args)
end

#router_id=(id) ⇒ Object



671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# File 'lib/cisco_node_utils/bgp.rb', line 671

def router_id=(id)
  # In order to remove a bgp router-id you cannot simply issue
  # 'no bgp router-id'. On some platforms you can specify a dummy
  # value, but on N7K at least you need the current router_id.
  if id == default_router_id
    # Nothing to do if router_id is already set to default.
    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_defaultObject

Helper method to delete @set_args hash keys



93
94
95
96
97
# File 'lib/cisco_node_utils/bgp.rb', line 93

def set_args_keys_default
  @set_args = { asnum: @asnum }
  @set_args[:vrf] = @vrf unless @vrf == 'default'
  @get_args = @set_args
end

#shutdownObject

Shutdown (Getter/Setter/Default)



693
694
695
# File 'lib/cisco_node_utils/bgp.rb', line 693

def shutdown
  config_get('bgp', 'shutdown', @asnum)
end

#shutdown=(enable) ⇒ Object



697
698
699
700
701
# File 'lib/cisco_node_utils/bgp.rb', line 697

def shutdown=(enable)
  @set_args[:state] = (enable ? '' : 'no')
  config_set('bgp', 'shutdown', @set_args)
  set_args_keys_default
end

#suppress_fib_pendingObject

Supress Fib Pending (Getter/Setter/Default)



708
709
710
# File 'lib/cisco_node_utils/bgp.rb', line 708

def suppress_fib_pending
  config_get('bgp', 'suppress_fib_pending', @get_args)
end

#suppress_fib_pending=(enable) ⇒ Object



712
713
714
715
716
# File 'lib/cisco_node_utils/bgp.rb', line 712

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_limitObject



740
741
742
# File 'lib/cisco_node_utils/bgp.rb', line 740

def timer_bestpath_limit
  config_get('bgp', 'timer_bestpath_limit', @get_args)
end

#timer_bestpath_limit_alwaysObject



744
745
746
# File 'lib/cisco_node_utils/bgp.rb', line 744

def timer_bestpath_limit_always
  config_get('bgp', 'timer_bestpath_limit_always', @get_args)
end

#timer_bestpath_limit_set(seconds, always = false) ⇒ Object



764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
# File 'lib/cisco_node_utils/bgp.rb', line 764

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_holdtimeObject



734
735
736
737
738
# File 'lib/cisco_node_utils/bgp.rb', line 734

def timer_bgp_holdtime
  _keepalive, hold = timer_bgp_keepalive_hold
  return default_timer_bgp_holdtime if hold.nil?
  hold.to_i
end

#timer_bgp_keepaliveObject



728
729
730
731
732
# File 'lib/cisco_node_utils/bgp.rb', line 728

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_holdObject

BGP Timers Getters



723
724
725
726
# File 'lib/cisco_node_utils/bgp.rb', line 723

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

BGP Timers Setters



749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'lib/cisco_node_utils/bgp.rb', line 749

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