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_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_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) ⇒ 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, 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 # 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
220 221 222 223 224 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 220 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
226 227 228 229 230 231 232 233 234 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 226 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
246 247 248 249 250 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 246 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
252 253 254 255 256 257 258 259 260 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 252 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>’]
123 124 125 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 123 def advertise_map_exist config_get('bgp_neighbor_af', 'advertise_map_exist', @get_args) end |
#advertise_map_exist=(arr) ⇒ Object
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 127 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>’]
146 147 148 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 146 def advertise_map_non_exist config_get('bgp_neighbor_af', 'advertise_map_non_exist', @get_args) end |
#advertise_map_non_exist=(arr) ⇒ Object
150 151 152 153 154 155 156 157 158 159 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 150 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
174 175 176 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 174 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
168 169 170 171 172 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 168 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
178 179 180 181 182 183 184 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 178 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
186 187 188 189 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 186 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
201 202 203 204 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 201 def as_override state = config_get('bgp_neighbor_af', 'as_override', @get_args) state ? true : false end |
#as_override=(state) ⇒ Object
206 207 208 209 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 206 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
101 102 103 104 105 106 107 108 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 101 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
236 237 238 239 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 236 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
262 263 264 265 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 262 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
138 139 140 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 138 def default_advertise_map_exist config_get_default('bgp_neighbor_af', 'advertise_map_exist') end |
#default_advertise_map_non_exist ⇒ Object
161 162 163 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 161 def default_advertise_map_non_exist config_get_default('bgp_neighbor_af', 'advertise_map_non_exist') end |
#default_allowas_in ⇒ Object
191 192 193 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 191 def default_allowas_in config_get_default('bgp_neighbor_af', 'allowas_in') end |
#default_allowas_in_max ⇒ Object
195 196 197 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 195 def default_allowas_in_max config_get_default('bgp_neighbor_af', 'allowas_in_max') end |
#default_as_override ⇒ Object
211 212 213 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 211 def default_as_override config_get_default('bgp_neighbor_af', 'as_override') end |
#default_default_originate ⇒ Object
296 297 298 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 296 def default_default_originate config_get_default('bgp_neighbor_af', 'default_originate') end |
#default_default_originate_route_map ⇒ Object
300 301 302 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 300 def default_default_originate_route_map config_get_default('bgp_neighbor_af', 'default_originate_route_map') end |
#default_disable_peer_as_check ⇒ Object
316 317 318 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 316 def default_disable_peer_as_check config_get_default('bgp_neighbor_af', 'disable_peer_as_check') end |
#default_filter_list_in ⇒ Object
338 339 340 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 338 def default_filter_list_in config_get_default('bgp_neighbor_af', 'filter_list_in') end |
#default_filter_list_out ⇒ Object
359 360 361 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 359 def default_filter_list_out config_get_default('bgp_neighbor_af', 'filter_list_out') end |
#default_max_prefix_interval ⇒ Object
418 419 420 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 418 def default_max_prefix_interval config_get_default('bgp_neighbor_af', 'max_prefix_interval') end |
#default_max_prefix_limit ⇒ Object
414 415 416 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 414 def default_max_prefix_limit config_get_default('bgp_neighbor_af', 'max_prefix_limit') end |
#default_max_prefix_threshold ⇒ Object
422 423 424 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 422 def default_max_prefix_threshold config_get_default('bgp_neighbor_af', 'max_prefix_threshold') end |
#default_max_prefix_warning ⇒ Object
426 427 428 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 426 def default_max_prefix_warning config_get_default('bgp_neighbor_af', 'max_prefix_warning') end |
#default_next_hop_self ⇒ Object
442 443 444 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 442 def default_next_hop_self config_get_default('bgp_neighbor_af', 'next_hop_self') end |
#default_next_hop_third_party ⇒ Object
458 459 460 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 458 def default_next_hop_third_party config_get_default('bgp_neighbor_af', 'next_hop_third_party') end |
#default_originate ⇒ Object
276 277 278 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 276 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>’
270 271 272 273 274 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 270 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
280 281 282 283 284 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 280 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
286 287 288 289 290 291 292 293 294 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 286 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
480 481 482 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 480 def default_prefix_list_in config_get_default('bgp_neighbor_af', 'prefix_list_in') end |
#default_prefix_list_out ⇒ Object
501 502 503 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 501 def default_prefix_list_out config_get_default('bgp_neighbor_af', 'prefix_list_out') end |
#default_route_map_in ⇒ Object
523 524 525 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 523 def default_route_map_in config_get_default('bgp_neighbor_af', 'route_map_in') end |
#default_route_map_out ⇒ Object
544 545 546 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 544 def default_route_map_out config_get_default('bgp_neighbor_af', 'route_map_out') end |
#default_route_reflector_client ⇒ Object
559 560 561 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 559 def default_route_reflector_client config_get_default('bgp_neighbor_af', 'route_reflector_client') end |
#default_send_community ⇒ Object
655 656 657 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 655 def default_send_community config_get_default('bgp_neighbor_af', 'send_community') end |
#default_soft_reconfiguration_in ⇒ Object
680 681 682 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 680 def default_soft_reconfiguration_in config_get_default('bgp_neighbor_af', 'soft_reconfiguration_in').to_sym end |
#default_soo ⇒ Object
700 701 702 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 700 def default_soo config_get_default('bgp_neighbor_af', 'soo') end |
#default_suppress_inactive ⇒ Object
715 716 717 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 715 def default_suppress_inactive config_get_default('bgp_neighbor_af', 'suppress_inactive') end |
#default_unsuppress_map ⇒ Object
735 736 737 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 735 def default_unsuppress_map config_get_default('bgp_neighbor_af', 'unsuppress_map') end |
#default_weight ⇒ Object
754 755 756 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 754 def default_weight config_get_default('bgp_neighbor_af', 'weight') end |
#destroy ⇒ Object
110 111 112 113 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 110 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
306 307 308 309 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 306 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
311 312 313 314 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 311 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
322 323 324 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 322 def filter_list_in config_get('bgp_neighbor_af', 'filter_list_in', @get_args) end |
#filter_list_in=(str) ⇒ Object
326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 326 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
344 345 346 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 344 def filter_list_out config_get('bgp_neighbor_af', 'filter_list_out', @get_args) end |
#filter_list_out=(str) ⇒ Object
348 349 350 351 352 353 354 355 356 357 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 348 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 ]
369 370 371 372 373 374 375 376 377 378 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 369 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
396 397 398 399 400 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 396 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
390 391 392 393 394 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 390 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
380 381 382 383 384 385 386 387 388 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 380 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
402 403 404 405 406 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 402 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
408 409 410 411 412 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 408 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
432 433 434 435 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 432 def next_hop_self state = config_get('bgp_neighbor_af', 'next_hop_self', @get_args) state ? true : false end |
#next_hop_self=(state) ⇒ Object
437 438 439 440 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 437 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
448 449 450 451 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 448 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
453 454 455 456 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 453 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
464 465 466 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 464 def prefix_list_in config_get('bgp_neighbor_af', 'prefix_list_in', @get_args) end |
#prefix_list_in=(str) ⇒ Object
468 469 470 471 472 473 474 475 476 477 478 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 468 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
486 487 488 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 486 def prefix_list_out config_get('bgp_neighbor_af', 'prefix_list_out', @get_args) end |
#prefix_list_out=(str) ⇒ Object
490 491 492 493 494 495 496 497 498 499 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 490 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_in ⇒ Object
<state> route-map <str> in
507 508 509 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 507 def route_map_in config_get('bgp_neighbor_af', 'route_map_in', @get_args) end |
#route_map_in=(str) ⇒ Object
511 512 513 514 515 516 517 518 519 520 521 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 511 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
529 530 531 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 529 def route_map_out config_get('bgp_neighbor_af', 'route_map_out', @get_args) end |
#route_map_out=(str) ⇒ Object
533 534 535 536 537 538 539 540 541 542 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 533 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
550 551 552 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 550 def route_reflector_client config_get('bgp_neighbor_af', 'route_reflector_client', @get_args) end |
#route_reflector_client=(state) ⇒ Object
554 555 556 557 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 554 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
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 628 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
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 603 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
566 567 568 569 570 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 566 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
599 600 601 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 599 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
575 576 577 578 579 580 581 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 575 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
588 589 590 591 592 593 594 595 596 597 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 588 def send_community_xr(val) if val == ['send-community-ebgp', 'send-extended-community-ebgp'] val = 'both' elsif val == ['send-community-ebgp'] val = 'standard' else # val == ['send-extended-community-ebgp'] val = 'extended' end val end |
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName
95 96 97 98 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 95 def set_args_keys(hash={}) set_args_keys_default @set_args = @get_args.merge!(hash) unless hash.empty? end |
#set_args_keys_default ⇒ Object
88 89 90 91 92 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 88 def set_args_keys_default keys = { asnum: @asn, nbr: @nbr, afi: @afi, safi: @safi } keys[:vrf] = @vrf unless @vrf == 'default' @get_args = @set_args = keys end |
#soft_reconfiguration_in ⇒ Object
<state> soft-reconfiguration inbound <always>
:enable = soft-reconfiguration inbound
:always = soft-reconfiguration inbound always
:inherit = no soft-reconfiguration inbound
664 665 666 667 668 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 664 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
670 671 672 673 674 675 676 677 678 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 670 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>
686 687 688 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 686 def soo config_get('bgp_neighbor_af', 'soo', @get_args) end |
#soo=(str) ⇒ Object
690 691 692 693 694 695 696 697 698 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 690 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
706 707 708 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 706 def suppress_inactive config_get('bgp_neighbor_af', 'suppress_inactive', @get_args) end |
#suppress_inactive=(state) ⇒ Object
710 711 712 713 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 710 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>
721 722 723 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 721 def unsuppress_map config_get('bgp_neighbor_af', 'unsuppress_map', @get_args) end |
#unsuppress_map=(str) ⇒ Object
725 726 727 728 729 730 731 732 733 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 725 def unsuppress_map=(str) str.strip! unless str.nil? if str == default_unsuppress_map state = 'no' str = unsuppress_map end set_args_keys(state: state, str: str) config_set('bgp_neighbor_af', 'unsuppress_map', @set_args) end |
#validate_args(asn, vrf, nbr, af) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 65 def validate_args(asn, vrf, nbr, af) fail ArgumentError unless vrf.is_a?(String) && (vrf.length > 0) fail ArgumentError unless nbr.is_a?(String) && (nbr.length > 0) fail ArgumentError, "'af' must be an array specifying afi and safi" unless af.is_a?(Array) || af.length == 2 # XR BGP does not support <address>/<mask> if platform == :ios_xr && nbr['/'] == '/' fail UnsupportedError.new( 'validate_args', "IOS XR does not support 'slash' notation") end nbr = Utils.process_network_mask(nbr) @asn = RouterBgp.validate_asnum(asn) @vrf = vrf @nbr = nbr @afi, @safi = af set_args_keys_default end |
#weight ⇒ Object
<state> weight <int>
741 742 743 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 741 def weight config_get('bgp_neighbor_af', 'weight', @get_args) end |
#weight=(int) ⇒ Object
745 746 747 748 749 750 751 752 |
# File 'lib/cisco_node_utils/bgp_neighbor_af.rb', line 745 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 |