Class: Cisco::RouterBgpNeighborAF

Inherits:
NodeUtil
  • Object
show all
Defined in:
lib/cisco_node_utils/bgp_neighbor_af.rb

Overview

RouterBgpNeighborAF - node utility class for BGP per-neighbor, per-AF config

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(asn, vrf, nbr, af, instantiate = true) ⇒ RouterBgpNeighborAF

Returns a new instance of RouterBgpNeighborAF.



28
29
30
31
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 28

def initialize(asn, vrf, nbr, af, instantiate=true)
  validate_args(asn, vrf, nbr, af)
  create if instantiate
end

Class Method Details

.afsObject



33
34
35
36
37
38
39
40
41
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_neighbor_af.rb', line 33

def self.afs
  af_hash = {}
  RouterBgp.routers.each do |asn, vrfs|
    af_hash[asn] = {}

    vrfs.keys.each do |vrf|
      af_hash[asn][vrf] = {}
      get_args = { asnum: asn }
      get_args[:vrf] = vrf unless vrf == 'default'

      nbrs = config_get('bgp_neighbor', 'all_neighbors', get_args)
      next if nbrs.nil?
      nbrs.each do |nbr|
        af_hash[asn][vrf][nbr] = {}
        get_args[:nbr] = nbr
        afs = config_get('bgp_neighbor_af', 'all_afs', get_args)

        next if afs.nil?
        afs.each do |af|
          af_hash[asn][vrf][nbr][af] =
            RouterBgpNeighborAF.new(asn, vrf, nbr, af, false)
        end
      end
    end
  end
  af_hash
rescue Cisco::CliError => e
  # cmd will syntax reject when feature is not enabled
  raise unless e.clierror =~ /Syntax error/
  return {}
end

Instance Method Details

#additional_paths_receiveObject


<state> capability additional-paths receive <disable>

:enable  = capability additional-paths receive
:disable = capability additional-paths receive disable
:inherit = no capability additional-paths receive


217
218
219
220
221
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 217

def additional_paths_receive
  val = config_get('bgp_neighbor_af', 'additional_paths_receive', @get_args)
  return default_additional_paths_receive if val.nil?
  /disable/.match(val) ? :disable : :enable
end

#additional_paths_receive=(val) ⇒ Object



223
224
225
226
227
228
229
230
231
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 223

def additional_paths_receive=(val)
  val = val.to_sym
  if val == default_additional_paths_receive
    set_args_keys(state: 'no', disable: '')
  else
    set_args_keys(state: '', disable: (val == :enable) ? '' : 'disable')
  end
  config_set('bgp_neighbor_af', 'additional_paths_receive', @set_args)
end

#additional_paths_sendObject


<state> capability additional-paths send <disable>

:enable  = capability additional-paths send
:disable = capability additional-paths send disable
:inherit = no capability additional-paths send


243
244
245
246
247
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 243

def additional_paths_send
  val = config_get('bgp_neighbor_af', 'additional_paths_send', @get_args)
  return default_additional_paths_send if val.nil?
  /disable/.match(val) ? :disable : :enable
end

#additional_paths_send=(val) ⇒ Object



249
250
251
252
253
254
255
256
257
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 249

def additional_paths_send=(val)
  val = val.to_sym
  if val == default_additional_paths_send
    set_args_keys(state: 'no', disable: '')
  else
    set_args_keys(state: '', disable: (val == :enable) ? '' : 'disable')
  end
  config_set('bgp_neighbor_af', 'additional_paths_send', @set_args)
end

Returns [‘<map1>’, ‘<map2>’]



120
121
122
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 120

def advertise_map_exist
  config_get('bgp_neighbor_af', 'advertise_map_exist', @get_args)
end


124
125
126
127
128
129
130
131
132
133
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 124

def advertise_map_exist=(arr)
  if arr.empty?
    state = 'no'
    map1, map2 = advertise_map_exist
  else
    map1, map2 = arr
  end
  set_args_keys(state: state, map1: map1, map2: map2)
  config_set('bgp_neighbor_af', 'advertise_map_exist', @set_args)
end

Returns [‘<map1>’, ‘<map2>’]



143
144
145
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 143

def advertise_map_non_exist
  config_get('bgp_neighbor_af', 'advertise_map_non_exist', @get_args)
end


147
148
149
150
151
152
153
154
155
156
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 147

def advertise_map_non_exist=(arr)
  if arr.empty?
    state = 'no'
    map1, map2 = advertise_map_non_exist
  else
    map1, map2 = arr
  end
  set_args_keys(state: state, map1: map1, map2: map2)
  config_set('bgp_neighbor_af', 'advertise_map_non_exist', @set_args)
end

#allowas_inObject



171
172
173
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 171

def allowas_in
  allowas_in_get.nil? ? false : true
end

#allowas_in_getObject


<state> allowas-in <max> Nvgens as True -OR- max-occurrences integer



165
166
167
168
169
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 165

def allowas_in_get
  val = config_get('bgp_neighbor_af', 'allowas_in', @get_args)
  return nil if val.nil?
  val.split.last.to_i
end

#allowas_in_maxObject



175
176
177
178
179
180
181
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 175

def allowas_in_max
  val = allowas_in_get
  # val.zero? check below is needed to handle a cli defect wherein the
  # default max value does not reliably nvgen
  val = default_allowas_in_max if val.nil? || val.zero?
  val
end

#allowas_in_set(state, max = nil) ⇒ Object



183
184
185
186
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 183

def allowas_in_set(state, max=nil)
  set_args_keys(state: (state ? '' : 'no'), max: max)
  config_set('bgp_neighbor_af', 'allowas_in', @set_args)
end

#as_overrideObject


<state> as-override



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

def as_override
  state = config_get('bgp_neighbor_af', 'as_override', @get_args)
  state ? true : false
end

#as_override=(state) ⇒ Object



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

def as_override=(state)
  set_args_keys(state: (state ? '' : 'no'))
  config_set('bgp_neighbor_af', 'as_override', @set_args)
end

#createObject

rubocop:enable Style/AccessorMethodNamefor



101
102
103
104
105
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 101

def create
  Feature.bgp_enable if platform == :nexus
  set_args_keys(state: '')
  config_set('bgp_neighbor', 'af', @set_args)
end

#default_additional_paths_receiveObject



233
234
235
236
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 233

def default_additional_paths_receive
  ret = config_get_default('bgp_neighbor_af', 'additional_paths_receive')
  ret.to_sym unless ret.nil?
end

#default_additional_paths_sendObject



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

def default_additional_paths_send
  ret = config_get_default('bgp_neighbor_af', 'additional_paths_send')
  ret.to_sym unless ret.to_s == ''
end

#default_advertise_map_existObject



135
136
137
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 135

def default_advertise_map_exist
  config_get_default('bgp_neighbor_af', 'advertise_map_exist')
end

#default_advertise_map_non_existObject



158
159
160
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 158

def default_advertise_map_non_exist
  config_get_default('bgp_neighbor_af', 'advertise_map_non_exist')
end

#default_allowas_inObject



188
189
190
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 188

def default_allowas_in
  config_get_default('bgp_neighbor_af', 'allowas_in')
end

#default_allowas_in_maxObject



192
193
194
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 192

def default_allowas_in_max
  config_get_default('bgp_neighbor_af', 'allowas_in_max')
end

#default_as_overrideObject



208
209
210
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 208

def default_as_override
  config_get_default('bgp_neighbor_af', 'as_override')
end

#default_default_originateObject



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

def default_default_originate
  config_get_default('bgp_neighbor_af', 'default_originate')
end

#default_default_originate_route_mapObject



297
298
299
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 297

def default_default_originate_route_map
  config_get_default('bgp_neighbor_af', 'default_originate_route_map')
end

#default_disable_peer_as_checkObject



313
314
315
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 313

def default_disable_peer_as_check
  config_get_default('bgp_neighbor_af', 'disable_peer_as_check')
end

#default_filter_list_inObject



335
336
337
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 335

def default_filter_list_in
  config_get_default('bgp_neighbor_af', 'filter_list_in')
end

#default_filter_list_outObject



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

def default_filter_list_out
  config_get_default('bgp_neighbor_af', 'filter_list_out')
end

#default_max_prefix_intervalObject



415
416
417
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 415

def default_max_prefix_interval
  config_get_default('bgp_neighbor_af', 'max_prefix_interval')
end

#default_max_prefix_limitObject



411
412
413
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 411

def default_max_prefix_limit
  config_get_default('bgp_neighbor_af', 'max_prefix_limit')
end

#default_max_prefix_thresholdObject



419
420
421
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 419

def default_max_prefix_threshold
  config_get_default('bgp_neighbor_af', 'max_prefix_threshold')
end

#default_max_prefix_warningObject



423
424
425
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 423

def default_max_prefix_warning
  config_get_default('bgp_neighbor_af', 'max_prefix_warning')
end

#default_next_hop_selfObject



439
440
441
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 439

def default_next_hop_self
  config_get_default('bgp_neighbor_af', 'next_hop_self')
end

#default_next_hop_third_partyObject



455
456
457
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 455

def default_next_hop_third_party
  config_get_default('bgp_neighbor_af', 'next_hop_third_party')
end

#default_originateObject



273
274
275
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 273

def default_originate
  default_originate_get.nil? ? false : true
end

#default_originate_getObject


<state> default-originate [ route-map <map> ] Nvgens as True with optional ‘route-map <map>’



267
268
269
270
271
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 267

def default_originate_get
  val = config_get('bgp_neighbor_af', 'default_originate', @get_args)
  return nil unless val
  (val[/route-(map|policy)/]) ? val.split.last : true
end

#default_originate_route_mapObject



277
278
279
280
281
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 277

def default_originate_route_map
  val = default_originate_get
  return default_default_originate_route_map if val.nil?
  val.is_a?(String) ? val : nil
end

#default_originate_set(state, map = nil) ⇒ Object



283
284
285
286
287
288
289
290
291
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 283

def default_originate_set(state, map=nil)
  if platform == :ios_xr
    map = "route-policy #{map}" unless map.nil?
  else
    map = "route-map #{map}" unless map.nil?
  end
  set_args_keys(state: (state ? '' : 'no'), map: map)
  config_set('bgp_neighbor_af', 'default_originate', @set_args)
end

#default_prefix_list_inObject



477
478
479
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 477

def default_prefix_list_in
  config_get_default('bgp_neighbor_af', 'prefix_list_in')
end

#default_prefix_list_outObject



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

def default_prefix_list_out
  config_get_default('bgp_neighbor_af', 'prefix_list_out')
end

#default_route_map_inObject



520
521
522
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 520

def default_route_map_in
  config_get_default('bgp_neighbor_af', 'route_map_in')
end

#default_route_map_outObject



541
542
543
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 541

def default_route_map_out
  config_get_default('bgp_neighbor_af', 'route_map_out')
end

#default_route_reflector_clientObject



556
557
558
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 556

def default_route_reflector_client
  config_get_default('bgp_neighbor_af', 'route_reflector_client')
end

#default_send_communityObject



650
651
652
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 650

def default_send_community
  config_get_default('bgp_neighbor_af', 'send_community')
end

#default_soft_reconfiguration_inObject



675
676
677
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 675

def default_soft_reconfiguration_in
  config_get_default('bgp_neighbor_af', 'soft_reconfiguration_in').to_sym
end

#default_sooObject



695
696
697
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 695

def default_soo
  config_get_default('bgp_neighbor_af', 'soo')
end

#default_suppress_inactiveObject



710
711
712
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 710

def default_suppress_inactive
  config_get_default('bgp_neighbor_af', 'suppress_inactive')
end

#default_unsuppress_mapObject



730
731
732
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 730

def default_unsuppress_map
  config_get_default('bgp_neighbor_af', 'unsuppress_map')
end

#default_weightObject



749
750
751
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 749

def default_weight
  config_get_default('bgp_neighbor_af', 'weight')
end

#destroyObject



107
108
109
110
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 107

def destroy
  set_args_keys(state: 'no')
  config_set('bgp_neighbor', 'af', @set_args)
end

#disable_peer_as_checkObject


<state> disable-peer-as-check



303
304
305
306
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 303

def disable_peer_as_check
  state = config_get('bgp_neighbor_af', 'disable_peer_as_check', @get_args)
  state ? true : default_disable_peer_as_check
end

#disable_peer_as_check=(state) ⇒ Object



308
309
310
311
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 308

def disable_peer_as_check=(state)
  set_args_keys(state: (state ? '' : 'no'))
  config_set('bgp_neighbor_af', 'disable_peer_as_check', @set_args)
end

#filter_list_inObject


<state> filter-list <str> in



319
320
321
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 319

def filter_list_in
  config_get('bgp_neighbor_af', 'filter_list_in', @get_args)
end

#filter_list_in=(str) ⇒ Object



323
324
325
326
327
328
329
330
331
332
333
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 323

def filter_list_in=(str)
  str.strip! unless str.nil?
  if str == default_filter_list_in
    state = 'no'
    # Current filter-list name is required for removal
    str = filter_list_in
    return if str.nil?
  end
  set_args_keys(state: state, str: str)
  config_set('bgp_neighbor_af', 'filter_list_in', @set_args)
end

#filter_list_outObject


<state> filter-list <str> out



341
342
343
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 341

def filter_list_out
  config_get('bgp_neighbor_af', 'filter_list_out', @get_args)
end

#filter_list_out=(str) ⇒ Object



345
346
347
348
349
350
351
352
353
354
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 345

def filter_list_out=(str)
  str.strip! unless str.nil?
  if str == default_filter_list_out
    state = 'no'
    # Current filter-list name is required for removal
    str = filter_list_out
  end
  set_args_keys(state: state, str: str)
  config_set('bgp_neighbor_af', 'filter_list_out', @set_args)
end

#max_prefix_getObject


<state> maximum-prefix <limit> <threshold> <opt>

<threshold> : optional <opt> : optional = [ restart <interval> | warning-only ]



366
367
368
369
370
371
372
373
374
375
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 366

def max_prefix_get
  str = config_get('bgp_neighbor_af', 'max_prefix', @get_args)
  return nil if str.nil?

  regexp = Regexp.new('maximum-prefix (?<limit>\d+)' \
                      ' *(?<threshold>\d+)?' \
                      ' *(?<opt>restart|warning-only)?' \
                      ' *(?<interval>\d+)?')
  regexp.match(str)
end

#max_prefix_intervalObject



393
394
395
396
397
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 393

def max_prefix_interval
  val = max_prefix_get
  return default_max_prefix_interval if val.nil?
  (val[:interval].nil?) ? nil : val[:interval].to_i
end

#max_prefix_limitObject



387
388
389
390
391
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 387

def max_prefix_limit
  val = max_prefix_get
  return default_max_prefix_limit if val.nil?
  val[:limit].to_i
end

#max_prefix_set(limit, threshold = nil, opt = nil) ⇒ Object



377
378
379
380
381
382
383
384
385
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 377

def max_prefix_set(limit, threshold=nil, opt=nil)
  state = limit.nil? ? 'no' : ''
  unless opt.nil?
    opt = opt.respond_to?(:to_i) ? "restart #{opt}" : 'warning-only'
  end
  set_args_keys(state: state, limit: limit,
                threshold: threshold, opt: opt)
  config_set('bgp_neighbor_af', 'max_prefix', @set_args)
end

#max_prefix_thresholdObject



399
400
401
402
403
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 399

def max_prefix_threshold
  val = max_prefix_get
  return default_max_prefix_threshold if val.nil?
  (val[:threshold].nil?) ? nil : val[:threshold].to_i
end

#max_prefix_warningObject



405
406
407
408
409
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 405

def max_prefix_warning
  val = max_prefix_get
  return default_max_prefix_warning if val.nil?
  (val[:opt] == 'warning-only') ? true : nil
end

#next_hop_selfObject


<state> next-hop-self



429
430
431
432
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 429

def next_hop_self
  state = config_get('bgp_neighbor_af', 'next_hop_self', @get_args)
  state ? true : false
end

#next_hop_self=(state) ⇒ Object



434
435
436
437
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 434

def next_hop_self=(state)
  set_args_keys(state: (state ? '' : 'no'))
  config_set('bgp_neighbor_af', 'next_hop_self', @set_args)
end

#next_hop_third_partyObject


<state> next-hop-third-party



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

def next_hop_third_party
  state = config_get('bgp_neighbor_af', 'next_hop_third_party', @get_args)
  state ? true : false
end

#next_hop_third_party=(state) ⇒ Object



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

def next_hop_third_party=(state)
  set_args_keys(state: (state ? '' : 'no'))
  config_set('bgp_neighbor_af', 'next_hop_third_party', @set_args)
end

#prefix_list_inObject


<state> prefix-list <str> in



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

def prefix_list_in
  config_get('bgp_neighbor_af', 'prefix_list_in', @get_args)
end

#prefix_list_in=(str) ⇒ Object



465
466
467
468
469
470
471
472
473
474
475
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 465

def prefix_list_in=(str)
  str.strip! unless str.nil?
  if str == default_prefix_list_in
    state = 'no'
    # Current prefix-list name is required for removal
    str = prefix_list_in
    return if str.nil?
  end
  set_args_keys(state: state, str: str)
  config_set('bgp_neighbor_af', 'prefix_list_in', @set_args)
end

#prefix_list_outObject


<state> prefix-list <str> out



483
484
485
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 483

def prefix_list_out
  config_get('bgp_neighbor_af', 'prefix_list_out', @get_args)
end

#prefix_list_out=(str) ⇒ Object



487
488
489
490
491
492
493
494
495
496
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 487

def prefix_list_out=(str)
  str.strip! unless str.nil?
  if str == default_prefix_list_out
    state = 'no'
    # Current prefix-list name is required for removal
    str = prefix_list_out
  end
  set_args_keys(state: state, str: str)
  config_set('bgp_neighbor_af', 'prefix_list_out', @set_args)
end

#route_map_inObject


<state> route-map <str> in



504
505
506
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 504

def route_map_in
  config_get('bgp_neighbor_af', 'route_map_in', @get_args)
end

#route_map_in=(str) ⇒ Object



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

def route_map_in=(str)
  str.strip! unless str.nil?
  if str == default_route_map_in
    state = 'no'
    # Current route-map name is required for removal
    str = route_map_in
    return if str.nil?
  end
  set_args_keys(state: state, str: str)
  config_set('bgp_neighbor_af', 'route_map_in', @set_args)
end

#route_map_outObject


<state> route-map <str> out



526
527
528
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 526

def route_map_out
  config_get('bgp_neighbor_af', 'route_map_out', @get_args)
end

#route_map_out=(str) ⇒ Object



530
531
532
533
534
535
536
537
538
539
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 530

def route_map_out=(str)
  str.strip! unless str.nil?
  if str == default_route_map_out
    state = 'no'
    # Current route-map name is required for removal
    str = route_map_out
  end
  set_args_keys(state: state, str: str)
  config_set('bgp_neighbor_af', 'route_map_out', @set_args)
end

#route_reflector_clientObject


<state route-reflector-client



547
548
549
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 547

def route_reflector_client
  config_get('bgp_neighbor_af', 'route_reflector_client', @get_args)
end

#route_reflector_client=(state) ⇒ Object



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

def route_reflector_client=(state)
  set_args_keys(state: (state ? '' : 'no'))
  config_set('bgp_neighbor_af', 'route_reflector_client', @set_args)
end

#send_comm_ios_xr_set(val) ⇒ Object



623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 623

def send_comm_ios_xr_set(val)
  case val.to_s
  when 'none'
    set_args_keys(state: 'no', attr: 'send-community-ebgp')
    config_set('bgp_neighbor_af', 'send_community', @set_args)
    set_args_keys(state: 'no', attr: 'send-extended-community-ebgp')
    config_set('bgp_neighbor_af', 'send_community', @set_args)
  when 'standard'
    set_args_keys(state: '', attr: 'send-community-ebgp')
    config_set('bgp_neighbor_af', 'send_community', @set_args)
    set_args_keys(state: 'no', attr: 'send-extended-community-ebgp')
    config_set('bgp_neighbor_af', 'send_community', @set_args)
  when 'extended'
    set_args_keys(state: 'no', attr: 'send-community-ebgp')
    config_set('bgp_neighbor_af', 'send_community', @set_args)
    set_args_keys(state: '', attr: 'send-extended-community-ebgp')
    config_set('bgp_neighbor_af', 'send_community', @set_args)
  when 'both'
    set_args_keys(state: '', attr: 'send-community-ebgp')
    config_set('bgp_neighbor_af', 'send_community', @set_args)
    set_args_keys(state: '', attr: 'send-extended-community-ebgp')
    config_set('bgp_neighbor_af', 'send_community', @set_args)
  else
    fail ArgumentError, "Invalid value '#{val}'"
  end
end

#send_comm_nexus_set(val) ⇒ Object



598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 598

def send_comm_nexus_set(val)
  if val[/none/]
    state = 'no'
    val = 'both'
  end
  if val[/extended|standard/]
    # Case where already configured.
    case send_community
    when /both/
      state = 'no'
      # Unset the opposite property
      val = val[/extended/] ? 'standard' : 'extended'

    when /extended|standard/
      # This is an additive property therefore remove the entire command
      # when switching from: ext <--> std
      set_args_keys(state: 'no', attr: 'both')
      config_set('bgp_neighbor_af', 'send_community', @set_args)
      state = ''
    end
  end
  set_args_keys(state: state, attr: val)
  config_set('bgp_neighbor_af', 'send_community', @set_args)
end

#send_communityObject


Nexus and XR implementations of send community differ enough that it makes sense to split up the individual methods to support them



563
564
565
566
567
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 563

def send_community
  val = config_get('bgp_neighbor_af', 'send_community', @get_args)
  return default_send_community if val.nil?
  platform == :nexus ? send_community_nexus(val) : send_community_xr(val)
end

#send_community=(val) ⇒ Object



594
595
596
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 594

def send_community=(val)
  platform == :nexus ? send_comm_nexus_set(val) : send_comm_ios_xr_set(val)
end

#send_community_nexus(val) ⇒ Object

Nexus: <state> send-community [ both | extended | standard ]

NOTE: 'standard' is default but does not nvgen on some platforms
Returns: none, both, extended, or standard


572
573
574
575
576
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 572

def send_community_nexus(val)
  val = val.split.last
  return 'standard' if val[/send-community/] # Workaround
  val
end

#send_community_xr(val) ⇒ Object

XR: ‘send-community-ebgp’ and ‘send-extended-community-ebgp’ are

the equivalents of the NXOS: standard | extended functionality
Returns: node, 'send-community-ebgp', 'send-extended-community-ebgp' or
'send-community-ebgp send-extended-community-ebgp' which is the 'both'

keyword equivalent



583
584
585
586
587
588
589
590
591
592
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 583

def send_community_xr(val)
  if val == ['send-community-ebgp', 'send-extended-community-ebgp']
    val = 'both'
  elsif val == ['send-community-ebgp']
    val = 'standard'
  else # val == ['send-extended-community-ebgp']
    val = 'extended'
  end
  val
end

#set_args_keys(hash = {}) ⇒ Object

rubocop:disable Style/AccessorMethodName



95
96
97
98
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 95

def set_args_keys(hash={})
  set_args_keys_default
  @set_args = @get_args.merge!(hash) unless hash.empty?
end

#set_args_keys_defaultObject



88
89
90
91
92
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 88

def set_args_keys_default
  keys = { asnum: @asn, nbr: @nbr, afi: @afi, safi: @safi }
  keys[:vrf] = @vrf unless @vrf == 'default'
  @get_args = @set_args = keys
end

#soft_reconfiguration_inObject


<state> soft-reconfiguration inbound <always>

:enable  = soft-reconfiguration inbound
:always = soft-reconfiguration inbound always
:inherit = no soft-reconfiguration inbound


659
660
661
662
663
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 659

def soft_reconfiguration_in
  val = config_get('bgp_neighbor_af', 'soft_reconfiguration_in', @get_args)
  return default_soft_reconfiguration_in if val.nil?
  /always/.match(val) ? :always : :enable
end

#soft_reconfiguration_in=(val) ⇒ Object



665
666
667
668
669
670
671
672
673
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 665

def soft_reconfiguration_in=(val)
  val = val.to_sym
  if val == default_soft_reconfiguration_in
    set_args_keys(state: 'no', always: '')
  else
    set_args_keys(state: '', always: (val == :enable) ? '' : 'always')
  end
  config_set('bgp_neighbor_af', 'soft_reconfiguration_in', @set_args)
end

#sooObject


<state> soo <str>



681
682
683
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 681

def soo
  config_get('bgp_neighbor_af', 'soo', @get_args)
end

#soo=(str) ⇒ Object



685
686
687
688
689
690
691
692
693
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 685

def soo=(str)
  str.strip! unless str.nil?
  if str == default_soo
    state = 'no'
    str = soo
  end
  set_args_keys(state: state, str: str)
  config_set('bgp_neighbor_af', 'soo', @set_args)
end

#suppress_inactiveObject


<state> suppress-inactive



701
702
703
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 701

def suppress_inactive
  config_get('bgp_neighbor_af', 'suppress_inactive', @get_args)
end

#suppress_inactive=(state) ⇒ Object



705
706
707
708
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 705

def suppress_inactive=(state)
  set_args_keys(state: (state ? '' : 'no'))
  config_set('bgp_neighbor_af', 'suppress_inactive', @set_args)
end

#unsuppress_mapObject


<state> unsuppress-map <str>



716
717
718
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 716

def unsuppress_map
  config_get('bgp_neighbor_af', 'unsuppress_map', @get_args)
end

#unsuppress_map=(str) ⇒ Object



720
721
722
723
724
725
726
727
728
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 720

def unsuppress_map=(str)
  str.strip! unless str.nil?
  if str == default_unsuppress_map
    state = 'no'
    str = unsuppress_map
  end
  set_args_keys(state: state, str: str)
  config_set('bgp_neighbor_af', 'unsuppress_map', @set_args)
end

#validate_args(asn, vrf, nbr, af) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 65

def validate_args(asn, vrf, nbr, af)
  fail ArgumentError unless
    vrf.is_a?(String) && (vrf.length > 0)
  fail ArgumentError unless
    nbr.is_a?(String) && (nbr.length > 0)
  fail ArgumentError, "'af' must be an array specifying afi and safi" unless
    af.is_a?(Array) || af.length == 2

  # XR BGP does not support <address>/<mask>
  if platform == :ios_xr && nbr['/'] == '/'
    fail UnsupportedError.new(
      'validate_args',
      "IOS XR does not support 'slash' notation")
  end

  nbr = Utils.process_network_mask(nbr)
  @asn = RouterBgp.validate_asnum(asn)
  @vrf = vrf
  @nbr = nbr
  @afi, @safi = af
  set_args_keys_default
end

#weightObject


<state> weight <int>



736
737
738
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 736

def weight
  config_get('bgp_neighbor_af', 'weight', @get_args)
end

#weight=(int) ⇒ Object



740
741
742
743
744
745
746
747
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 740

def weight=(int)
  if int == default_weight
    state = 'no'
    int = ''
  end
  set_args_keys(state: state, int: int)
  config_set('bgp_neighbor_af', 'weight', @set_args)
end