Class: Cisco::RouterBgpNeighborAF
- Inherits:
-
NodeUtil
- Object
- NodeUtil
- Cisco::RouterBgpNeighborAF
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
-
#additional_paths_receive ⇒ Object
———————– <state> capability additional-paths receive <disable> :enable = capability additional-paths receive :disable = capability additional-paths receive disable :inherit = no capability additional-paths receive.
-
#additional_paths_receive=(val) ⇒ Object
-
#additional_paths_send ⇒ Object
———————– <state> capability additional-paths send <disable> :enable = capability additional-paths send :disable = capability additional-paths send disable :inherit = no capability additional-paths send.
-
#additional_paths_send=(val) ⇒ Object
-
#advertise_map_exist ⇒ Object
Returns [‘<map1>’, ‘<map2>’].
-
#advertise_map_exist=(arr) ⇒ Object
-
#advertise_map_non_exist ⇒ Object
Returns [‘<map1>’, ‘<map2>’].
-
#advertise_map_non_exist=(arr) ⇒ Object
-
#allowas_in ⇒ Object
-
#allowas_in_get ⇒ Object
———————– <state> allowas-in <max> Nvgens as True -OR- max-occurrences integer.
-
#allowas_in_max ⇒ Object
-
#allowas_in_set(state, max = nil) ⇒ Object
-
#as_override ⇒ Object
———————– <state> as-override.
-
#as_override=(state) ⇒ Object
-
#create ⇒ Object
rubocop:enable Style/AccessorMethodNamefor.
-
#default_additional_paths_receive ⇒ Object
-
#default_additional_paths_send ⇒ Object
-
#default_advertise_map_exist ⇒ Object
-
#default_advertise_map_non_exist ⇒ Object
-
#default_allowas_in ⇒ Object
-
#default_allowas_in_max ⇒ Object
-
#default_as_override ⇒ Object
-
#default_default_originate ⇒ Object
-
#default_default_originate_route_map ⇒ Object
-
#default_disable_peer_as_check ⇒ Object
-
#default_filter_list_in ⇒ Object
-
#default_filter_list_out ⇒ Object
-
#default_max_prefix_interval ⇒ Object
-
#default_max_prefix_limit ⇒ Object
-
#default_max_prefix_threshold ⇒ Object
-
#default_max_prefix_warning ⇒ Object
-
#default_next_hop_self ⇒ Object
-
#default_next_hop_third_party ⇒ Object
-
#default_originate ⇒ Object
-
#default_originate_get ⇒ Object
———————– <state> default-originate [ route-map <map> ] Nvgens as True with optional ‘route-map <map>’.
-
#default_originate_route_map ⇒ Object
-
#default_originate_set(state, map = nil) ⇒ Object
-
#default_prefix_list_in ⇒ Object
-
#default_prefix_list_out ⇒ Object
-
#default_route_map_in ⇒ Object
-
#default_route_map_out ⇒ Object
-
#default_route_reflector_client ⇒ Object
-
#default_send_community ⇒ Object
-
#default_soft_reconfiguration_in ⇒ Object
-
#default_soo ⇒ Object
-
#default_suppress_inactive ⇒ Object
-
#default_unsuppress_map ⇒ Object
-
#default_weight ⇒ Object
-
#destroy ⇒ Object
-
#disable_peer_as_check ⇒ Object
———————– <state> disable-peer-as-check.
-
#disable_peer_as_check=(state) ⇒ Object
-
#filter_list_in ⇒ Object
———————– <state> filter-list <str> in.
-
#filter_list_in=(str) ⇒ Object
-
#filter_list_out ⇒ Object
———————– <state> filter-list <str> out.
-
#filter_list_out=(str) ⇒ Object
-
#initialize(asn, vrf, nbr, af, instantiate = true) ⇒ RouterBgpNeighborAF
constructor
A new instance of RouterBgpNeighborAF.
-
#max_prefix_get ⇒ Object
———————– <state> maximum-prefix <limit> <threshold> <opt>.
-
#max_prefix_interval ⇒ Object
-
#max_prefix_limit ⇒ Object
-
#max_prefix_set(limit, threshold = nil, opt = nil) ⇒ Object
-
#max_prefix_threshold ⇒ Object
-
#max_prefix_warning ⇒ Object
-
#next_hop_self ⇒ Object
———————– <state> next-hop-self.
-
#next_hop_self=(state) ⇒ Object
-
#next_hop_third_party ⇒ Object
———————– <state> next-hop-third-party.
-
#next_hop_third_party=(state) ⇒ Object
-
#prefix_list_in ⇒ Object
———————– <state> prefix-list <str> in.
-
#prefix_list_in=(str) ⇒ Object
-
#prefix_list_out ⇒ Object
———————– <state> prefix-list <str> out.
-
#prefix_list_out=(str) ⇒ Object
-
#route_map_in ⇒ Object
———————– <state> route-map <str> in.
-
#route_map_in=(str) ⇒ Object
-
#route_map_out ⇒ Object
———————– <state> route-map <str> out.
-
#route_map_out=(str) ⇒ Object
-
#route_reflector_client ⇒ Object
———————– <state route-reflector-client.
-
#route_reflector_client=(state) ⇒ Object
-
#send_community ⇒ Object
———————– <state> send-community [ both | extended | standard ] NOTE: ‘standard’ is default but does not nvgen on some platforms Returns: none, both, extended, or standard.
-
#send_community=(val) ⇒ Object
-
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName.
-
#set_args_keys_default ⇒ Object
-
#soft_reconfiguration_in ⇒ Object
———————– <state> soft-reconfiguration inbound <always> :enable = soft-reconfiguration inbound :always = soft-reconfiguration inbound always :inherit = no soft-reconfiguration inbound.
-
#soft_reconfiguration_in=(val) ⇒ Object
-
#soo ⇒ Object
———————– <state> soo <str>.
-
#soo=(str) ⇒ Object
-
#suppress_inactive ⇒ Object
———————– <state> suppress-inactive.
-
#suppress_inactive=(state) ⇒ Object
-
#unsuppress_map ⇒ Object
———————– <state> unsuppress-map <str>.
-
#unsuppress_map=(str) ⇒ Object
-
#validate_args(asn, vrf, nbr, af) ⇒ Object
-
#weight ⇒ Object
———————– <state> weight <int>.
-
#weight=(int) ⇒ Object
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
.afs ⇒ Object
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
raise unless e.clierror =~ /Syntax error/
return {}
end
|
Instance Method Details
#additional_paths_receive ⇒ Object
<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_send ⇒ Object
<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
|
#advertise_map_exist ⇒ Object
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
|
#advertise_map_exist=(arr) ⇒ Object
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
|
#advertise_map_non_exist ⇒ Object
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
|
#advertise_map_non_exist=(arr) ⇒ Object
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_in ⇒ Object
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_get ⇒ Object
<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_max ⇒ Object
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 = 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_override ⇒ Object
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
|
#create ⇒ Object
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_receive ⇒ Object
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_send ⇒ Object
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_exist ⇒ Object
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_exist ⇒ Object
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_in ⇒ Object
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_max ⇒ Object
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_override ⇒ Object
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_originate ⇒ Object
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_map ⇒ Object
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_check ⇒ Object
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_in ⇒ Object
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_out ⇒ Object
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_interval ⇒ Object
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_limit ⇒ Object
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_threshold ⇒ Object
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_warning ⇒ Object
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_self ⇒ Object
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_party ⇒ Object
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_originate ⇒ Object
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_get ⇒ Object
<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_map ⇒ Object
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_in ⇒ Object
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_out ⇒ Object
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_in ⇒ Object
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_out ⇒ Object
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_client ⇒ Object
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
|
583
584
585
|
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 583
def
config_get_default('bgp_neighbor_af', 'send_community')
end
|
#default_soft_reconfiguration_in ⇒ Object
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_soo ⇒ Object
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_inactive ⇒ Object
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_map ⇒ Object
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_weight ⇒ Object
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
|
#destroy ⇒ Object
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_check ⇒ Object
<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_in ⇒ Object
<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'
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_out ⇒ Object
<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'
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_get ⇒ Object
<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_interval ⇒ Object
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_limit ⇒ Object
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_threshold ⇒ Object
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_warning ⇒ Object
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_self ⇒ Object
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_party ⇒ Object
<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_in ⇒ Object
<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'
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_out ⇒ Object
<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'
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_in ⇒ Object
<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'
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_out ⇒ Object
<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'
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_client ⇒ Object
<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
|
<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
val = config_get('bgp_neighbor_af', 'send_community', @get_args)
return if val.nil?
val = val.split.last
return 'standard' if val[/send-community/] val
end
|
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 (val)
if val[/none/]
state = 'no'
val = 'both'
end
if val[/extended|standard/]
case
when /both/
state = 'no'
val = val[/extended/] ? 'standard' : 'extended'
when /extended|standard/
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_default ⇒ Object
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_in ⇒ Object
<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
|
#soo ⇒ Object
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_inactive ⇒ Object
<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_map ⇒ Object
<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
|
#weight ⇒ Object
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
|