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

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

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


210
211
212
213
214
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 210

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



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

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


235
236
237
238
239
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 235

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



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

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>’]



113
114
115
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 113

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


117
118
119
120
121
122
123
124
125
126
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 117

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>’]



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

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


140
141
142
143
144
145
146
147
148
149
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 140

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



164
165
166
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 164

def allowas_in
  allowas_in_get.nil? ? false : true
end

#allowas_in_getObject


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



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

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



168
169
170
171
172
173
174
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 168

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



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

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



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

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

#as_override=(state) ⇒ Object



196
197
198
199
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 196

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



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

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

#default_additional_paths_receiveObject



226
227
228
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 226

def default_additional_paths_receive
  config_get_default('bgp_neighbor_af', 'additional_paths_receive').to_sym
end

#default_additional_paths_sendObject



251
252
253
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 251

def default_additional_paths_send
  config_get_default('bgp_neighbor_af', 'additional_paths_send').to_sym
end

#default_advertise_map_existObject



128
129
130
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 128

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

#default_advertise_map_non_existObject



151
152
153
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 151

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

#default_allowas_inObject



181
182
183
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 181

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

#default_allowas_in_maxObject



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

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

#default_as_overrideObject



201
202
203
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 201

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

#default_default_originateObject



280
281
282
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 280

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

#default_default_originate_route_mapObject



284
285
286
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 284

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

#default_disable_peer_as_checkObject



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

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

#default_filter_list_inObject



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

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

#default_filter_list_outObject



343
344
345
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 343

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

#default_max_prefix_intervalObject



402
403
404
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 402

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

#default_max_prefix_limitObject



398
399
400
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 398

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

#default_max_prefix_thresholdObject



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

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

#default_max_prefix_warningObject



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

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

#default_next_hop_selfObject



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

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

#default_next_hop_third_partyObject



442
443
444
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 442

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

#default_originateObject



264
265
266
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 264

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>’



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

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

#default_originate_route_mapObject



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

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



274
275
276
277
278
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 274

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

#default_prefix_list_inObject



464
465
466
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 464

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

#default_prefix_list_outObject



485
486
487
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 485

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

#default_route_map_inObject



507
508
509
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 507

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

#default_route_map_outObject



528
529
530
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 528

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

#default_route_reflector_clientObject



543
544
545
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 543

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

#default_send_communityObject



583
584
585
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 583

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

#default_soft_reconfiguration_inObject



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

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

#default_sooObject



628
629
630
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 628

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

#default_suppress_inactiveObject



643
644
645
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 643

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

#default_unsuppress_mapObject



663
664
665
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 663

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

#default_weightObject



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

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

#destroyObject



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

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

#disable_peer_as_checkObject


<state> disable-peer-as-check



290
291
292
293
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 290

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



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

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



306
307
308
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 306

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

#filter_list_in=(str) ⇒ Object



310
311
312
313
314
315
316
317
318
319
320
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 310

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



328
329
330
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 328

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

#filter_list_out=(str) ⇒ Object



332
333
334
335
336
337
338
339
340
341
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 332

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 ]



353
354
355
356
357
358
359
360
361
362
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 353

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



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

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



374
375
376
377
378
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 374

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



364
365
366
367
368
369
370
371
372
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 364

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



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

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



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

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



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

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

#next_hop_self=(state) ⇒ Object



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

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



432
433
434
435
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 432

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



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

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



448
449
450
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 448

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

#prefix_list_in=(str) ⇒ Object



452
453
454
455
456
457
458
459
460
461
462
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 452

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



470
471
472
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 470

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

#prefix_list_out=(str) ⇒ Object



474
475
476
477
478
479
480
481
482
483
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 474

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



491
492
493
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 491

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

#route_map_in=(str) ⇒ Object



495
496
497
498
499
500
501
502
503
504
505
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 495

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



513
514
515
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 513

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

#route_map_out=(str) ⇒ Object



517
518
519
520
521
522
523
524
525
526
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 517

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



534
535
536
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 534

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

#route_reflector_client=(state) ⇒ Object



538
539
540
541
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 538

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

#send_communityObject


<state> send-community [ both | extended | standard ] NOTE: ‘standard’ is default but does not nvgen on some platforms Returns: none, both, extended, or standard



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

def send_community
  val = config_get('bgp_neighbor_af', 'send_community', @get_args)
  return default_send_community if val.nil?
  val = val.split.last
  return 'standard' if val[/send-community/] # Workaround
  val
end

#send_community=(val) ⇒ Object



559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 559

def send_community=(val)
  if val[/none/]
    state = 'no'
    val = 'both'
  end
  if val[/extended|standard/]
    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

#set_args_keys(hash = {}) ⇒ Object

rubocop:disable Style/AccessorMethodName



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

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

#set_args_keys_defaultObject



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

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


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

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



598
599
600
601
602
603
604
605
606
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 598

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>



614
615
616
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 614

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

#soo=(str) ⇒ Object



618
619
620
621
622
623
624
625
626
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 618

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



634
635
636
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 634

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

#suppress_inactive=(state) ⇒ Object



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

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>



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

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

#unsuppress_map=(str) ⇒ Object



653
654
655
656
657
658
659
660
661
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 653

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
# 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

  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>



669
670
671
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 669

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

#weight=(int) ⇒ Object



673
674
675
676
677
678
679
680
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 673

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