Class: Cisco::RouterBgpNeighborAF
- 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_rewrite_evpn_rt_asn ⇒ 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, ra = nil, 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
- #rewrite_evpn_rt_asn ⇒ Object
- #rewrite_evpn_rt_asn=(state) ⇒ 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_comm_ios_xr_set(val) ⇒ Object
- #send_comm_nexus_set(val) ⇒ Object
-
#send_community ⇒ Object
———————– Nexus and XR implementations of send community differ enough that it makes sense to split up the individual methods to support them.
- #send_community=(val) ⇒ Object
-
#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.
-
#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.
-
#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, ra) ⇒ Object
-
#weight ⇒ Object
———————– <state> weight <int>.
- #weight=(int) ⇒ Object
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, ra = nil, 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, ra=nil, instantiate=true) validate_args(asn, vrf, nbr, af, ra) 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 64 |
# 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, ra| af_hash[asn][vrf][nbr] = {} get_args[:nbr] = nbr get_args[:ra] = ra 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, ra, 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_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
222 223 224 225 226 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 222 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
228 229 230 231 232 233 234 235 236 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 228 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
248 249 250 251 252 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 248 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
254 255 256 257 258 259 260 261 262 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 254 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>’]
125 126 127 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 125 def advertise_map_exist config_get('bgp_neighbor_af', 'advertise_map_exist', @get_args) end |
#advertise_map_exist=(arr) ⇒ Object
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 129 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>’]
148 149 150 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 148 def advertise_map_non_exist config_get('bgp_neighbor_af', 'advertise_map_non_exist', @get_args) end |
#advertise_map_non_exist=(arr) ⇒ Object
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 152 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
176 177 178 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 176 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
170 171 172 173 174 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 170 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
180 181 182 183 184 185 186 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 180 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
188 189 190 191 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 188 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
<state> as-override
203 204 205 206 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 203 def as_override state = config_get('bgp_neighbor_af', 'as_override', @get_args) state ? true : false end |
#as_override=(state) ⇒ Object
208 209 210 211 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 208 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
103 104 105 106 107 108 109 110 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 103 def create if platform == :nexus Feature.bgp_enable Feature. if @safi[/evpn/] end set_args_keys(state: '') config_set('bgp_neighbor', 'af', @set_args) end |
#default_additional_paths_receive ⇒ Object
238 239 240 241 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 238 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_send ⇒ Object
264 265 266 267 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 264 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_exist ⇒ Object
140 141 142 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 140 def default_advertise_map_exist config_get_default('bgp_neighbor_af', 'advertise_map_exist') end |
#default_advertise_map_non_exist ⇒ Object
163 164 165 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 163 def default_advertise_map_non_exist config_get_default('bgp_neighbor_af', 'advertise_map_non_exist') end |
#default_allowas_in ⇒ Object
193 194 195 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 193 def default_allowas_in config_get_default('bgp_neighbor_af', 'allowas_in') end |
#default_allowas_in_max ⇒ Object
197 198 199 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 197 def default_allowas_in_max config_get_default('bgp_neighbor_af', 'allowas_in_max') end |
#default_as_override ⇒ Object
213 214 215 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 213 def default_as_override config_get_default('bgp_neighbor_af', 'as_override') end |
#default_default_originate ⇒ Object
298 299 300 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 298 def default_default_originate config_get_default('bgp_neighbor_af', 'default_originate') end |
#default_default_originate_route_map ⇒ Object
302 303 304 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 302 def default_default_originate_route_map config_get_default('bgp_neighbor_af', 'default_originate_route_map') end |
#default_disable_peer_as_check ⇒ Object
318 319 320 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 318 def default_disable_peer_as_check config_get_default('bgp_neighbor_af', 'disable_peer_as_check') end |
#default_filter_list_in ⇒ Object
340 341 342 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 340 def default_filter_list_in config_get_default('bgp_neighbor_af', 'filter_list_in') end |
#default_filter_list_out ⇒ Object
361 362 363 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 361 def default_filter_list_out config_get_default('bgp_neighbor_af', 'filter_list_out') end |
#default_max_prefix_interval ⇒ Object
420 421 422 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 420 def default_max_prefix_interval config_get_default('bgp_neighbor_af', 'max_prefix_interval') end |
#default_max_prefix_limit ⇒ Object
416 417 418 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 416 def default_max_prefix_limit config_get_default('bgp_neighbor_af', 'max_prefix_limit') end |
#default_max_prefix_threshold ⇒ Object
424 425 426 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 424 def default_max_prefix_threshold config_get_default('bgp_neighbor_af', 'max_prefix_threshold') end |
#default_max_prefix_warning ⇒ Object
428 429 430 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 428 def default_max_prefix_warning config_get_default('bgp_neighbor_af', 'max_prefix_warning') end |
#default_next_hop_self ⇒ Object
444 445 446 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 444 def default_next_hop_self config_get_default('bgp_neighbor_af', 'next_hop_self') end |
#default_next_hop_third_party ⇒ Object
460 461 462 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 460 def default_next_hop_third_party config_get_default('bgp_neighbor_af', 'next_hop_third_party') end |
#default_originate ⇒ Object
278 279 280 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 278 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>’
272 273 274 275 276 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 272 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_map ⇒ Object
282 283 284 285 286 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 282 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
288 289 290 291 292 293 294 295 296 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 288 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_in ⇒ Object
482 483 484 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 482 def default_prefix_list_in config_get_default('bgp_neighbor_af', 'prefix_list_in') end |
#default_prefix_list_out ⇒ Object
503 504 505 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 503 def default_prefix_list_out config_get_default('bgp_neighbor_af', 'prefix_list_out') end |
#default_rewrite_evpn_rt_asn ⇒ Object
776 777 778 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 776 def default_rewrite_evpn_rt_asn config_get_default('bgp_neighbor_af', 'rewrite_evpn_rt_asn') end |
#default_route_map_in ⇒ Object
525 526 527 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 525 def default_route_map_in config_get_default('bgp_neighbor_af', 'route_map_in') end |
#default_route_map_out ⇒ Object
546 547 548 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 546 def default_route_map_out config_get_default('bgp_neighbor_af', 'route_map_out') end |
#default_route_reflector_client ⇒ Object
561 562 563 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 561 def default_route_reflector_client config_get_default('bgp_neighbor_af', 'route_reflector_client') end |
#default_send_community ⇒ Object
657 658 659 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 657 def default_send_community config_get_default('bgp_neighbor_af', 'send_community') end |
#default_soft_reconfiguration_in ⇒ Object
682 683 684 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 682 def default_soft_reconfiguration_in config_get_default('bgp_neighbor_af', 'soft_reconfiguration_in').to_sym end |
#default_soo ⇒ Object
702 703 704 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 702 def default_soo config_get_default('bgp_neighbor_af', 'soo') end |
#default_suppress_inactive ⇒ Object
717 718 719 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 717 def default_suppress_inactive config_get_default('bgp_neighbor_af', 'suppress_inactive') end |
#default_unsuppress_map ⇒ Object
737 738 739 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 737 def default_unsuppress_map config_get_default('bgp_neighbor_af', 'unsuppress_map') end |
#default_weight ⇒ Object
756 757 758 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 756 def default_weight config_get_default('bgp_neighbor_af', 'weight') end |
#destroy ⇒ Object
112 113 114 115 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 112 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
308 309 310 311 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 308 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
313 314 315 316 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 313 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
324 325 326 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 324 def filter_list_in config_get('bgp_neighbor_af', 'filter_list_in', @get_args) end |
#filter_list_in=(str) ⇒ Object
328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 328 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_out ⇒ Object
<state> filter-list <str> out
346 347 348 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 346 def filter_list_out config_get('bgp_neighbor_af', 'filter_list_out', @get_args) end |
#filter_list_out=(str) ⇒ Object
350 351 352 353 354 355 356 357 358 359 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 350 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_get ⇒ Object
<state> maximum-prefix <limit> <threshold> <opt>
<threshold> : optional <opt> : optional = [ restart <interval> | warning-only ]
371 372 373 374 375 376 377 378 379 380 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 371 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
398 399 400 401 402 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 398 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
392 393 394 395 396 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 392 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
382 383 384 385 386 387 388 389 390 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 382 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
404 405 406 407 408 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 404 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
410 411 412 413 414 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 410 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
<state> next-hop-self
434 435 436 437 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 434 def next_hop_self state = config_get('bgp_neighbor_af', 'next_hop_self', @get_args) state ? true : false end |
#next_hop_self=(state) ⇒ Object
439 440 441 442 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 439 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
450 451 452 453 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 450 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
455 456 457 458 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 455 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
466 467 468 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 466 def prefix_list_in config_get('bgp_neighbor_af', 'prefix_list_in', @get_args) end |
#prefix_list_in=(str) ⇒ Object
470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 470 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_out ⇒ Object
<state> prefix-list <str> out
488 489 490 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 488 def prefix_list_out config_get('bgp_neighbor_af', 'prefix_list_out', @get_args) end |
#prefix_list_out=(str) ⇒ Object
492 493 494 495 496 497 498 499 500 501 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 492 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 |
#rewrite_evpn_rt_asn ⇒ Object
760 761 762 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 760 def rewrite_evpn_rt_asn config_get('bgp_neighbor_af', 'rewrite_evpn_rt_asn', @get_args) end |
#rewrite_evpn_rt_asn=(state) ⇒ Object
764 765 766 767 768 769 770 771 772 773 774 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 764 def rewrite_evpn_rt_asn=(state) Feature. if state set_args_keys(state: (state ? '' : 'no')) if @set_args[:state] == 'no' unless rewrite_evpn_rt_asn == default_rewrite_evpn_rt_asn config_set('bgp_neighbor_af', 'rewrite_evpn_rt_asn', @set_args) end else config_set('bgp_neighbor_af', 'rewrite_evpn_rt_asn', @set_args) end end |
#route_map_in ⇒ Object
<state> route-map <str> in
509 510 511 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 509 def route_map_in config_get('bgp_neighbor_af', 'route_map_in', @get_args) end |
#route_map_in=(str) ⇒ Object
513 514 515 516 517 518 519 520 521 522 523 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 513 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_out ⇒ Object
<state> route-map <str> out
531 532 533 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 531 def route_map_out config_get('bgp_neighbor_af', 'route_map_out', @get_args) end |
#route_map_out=(str) ⇒ Object
535 536 537 538 539 540 541 542 543 544 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 535 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_client ⇒ Object
<state route-reflector-client
552 553 554 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 552 def route_reflector_client config_get('bgp_neighbor_af', 'route_reflector_client', @get_args) end |
#route_reflector_client=(state) ⇒ Object
556 557 558 559 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 556 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
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 630 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
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 605 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_community ⇒ Object
Nexus and XR implementations of send community differ enough that it makes sense to split up the individual methods to support them
568 569 570 571 572 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 568 def send_community val = config_get('bgp_neighbor_af', 'send_community', @get_args) return default_send_community if val.nil? || val.empty? platform == :nexus ? send_community_nexus(val) : send_community_xr(val) end |
#send_community=(val) ⇒ Object
601 602 603 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 601 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
577 578 579 580 581 582 583 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 577 def send_community_nexus(val) reg = 'send-community extended|send-community standard|send-community' return 'both' if val.grep(/#{reg}/).size == 2 val = val[0].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
590 591 592 593 594 595 596 597 598 599 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 590 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
97 98 99 100 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 97 def set_args_keys(hash={}) set_args_keys_default @set_args = @get_args.merge!(hash) unless hash.empty? end |
#set_args_keys_default ⇒ Object
90 91 92 93 94 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 90 def set_args_keys_default keys = { asnum: @asn, nbr: @nbr, ra: @ra, 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
666 667 668 669 670 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 666 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
672 673 674 675 676 677 678 679 680 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 672 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
<state> soo <str>
688 689 690 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 688 def soo config_get('bgp_neighbor_af', 'soo', @get_args) end |
#soo=(str) ⇒ Object
692 693 694 695 696 697 698 699 700 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 692 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
708 709 710 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 708 def suppress_inactive config_get('bgp_neighbor_af', 'suppress_inactive', @get_args) end |
#suppress_inactive=(state) ⇒ Object
712 713 714 715 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 712 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>
723 724 725 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 723 def unsuppress_map config_get('bgp_neighbor_af', 'unsuppress_map', @get_args) end |
#unsuppress_map=(str) ⇒ Object
727 728 729 730 731 732 733 734 735 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 727 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, ra) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 66 def validate_args(asn, vrf, nbr, af, ra) 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 @ra = ra @afi, @safi = af set_args_keys_default end |
#weight ⇒ Object
<state> weight <int>
743 744 745 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 743 def weight config_get('bgp_neighbor_af', 'weight', @get_args) end |
#weight=(int) ⇒ Object
747 748 749 750 751 752 753 754 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 747 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 |