| 1 |
|
| 2 |
|
| 3 |
. |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
""" |
| 8 |
The module file for sonic_bgp_af |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
__metaclass__ = type |
| 13 |
|
| 14 |
|
| 15 |
DOCUMENTATION = """ |
| 16 |
--- |
| 17 |
module: sonic_bgp_af |
| 18 |
version_added: 1.0.0 |
| 19 |
notes: |
| 20 |
- Tested against Enterprise SONiC Distribution by Dell Technologies. |
| 21 |
- Supports C(check_mode). |
| 22 |
author: Niraimadaiselvam M (@niraimadaiselvamm) |
| 23 |
short_description: Manage global BGP address-family and its parameters |
| 24 |
description: |
| 25 |
- This module provides configuration management of global BGP_AF parameters on devices running Enterprise SONiC. |
| 26 |
- bgp_as and vrf_name must be created in advance on the device. |
| 27 |
options: |
| 28 |
config: |
| 29 |
description: |
| 30 |
- Specifies the BGP_AF related configuration. |
| 31 |
type: list |
| 32 |
elements: dict |
| 33 |
suboptions: |
| 34 |
bgp_as: |
| 35 |
description: |
| 36 |
- Specifies the BGP autonomous system (AS) number which is already configured on the device. |
| 37 |
type: str |
| 38 |
required: true |
| 39 |
vrf_name: |
| 40 |
description: |
| 41 |
- Specifies the VRF name which is already configured on the device. |
| 42 |
type: str |
| 43 |
default: 'default' |
| 44 |
address_family: |
| 45 |
description: |
| 46 |
- Specifies BGP address family related configurations. |
| 47 |
type: dict |
| 48 |
suboptions: |
| 49 |
afis: |
| 50 |
description: |
| 51 |
- List of address families, such as ipv4, ipv6, and l2vpn. |
| 52 |
- afi and safi are required together. |
| 53 |
type: list |
| 54 |
elements: dict |
| 55 |
suboptions: |
| 56 |
afi: |
| 57 |
description: |
| 58 |
- Type of address family to configure. |
| 59 |
type: str |
| 60 |
choices: |
| 61 |
- ipv4 |
| 62 |
- ipv6 |
| 63 |
- l2vpn |
| 64 |
required: true |
| 65 |
safi: |
| 66 |
description: |
| 67 |
- Specifies the type of communication for the address family. |
| 68 |
type: str |
| 69 |
choices: |
| 70 |
- unicast |
| 71 |
- evpn |
| 72 |
default: unicast |
| 73 |
dampening: |
| 74 |
description: |
| 75 |
- Enable route flap dampening if set to true |
| 76 |
type: bool |
| 77 |
network: |
| 78 |
description: |
| 79 |
- Enable routing on an IP network for each prefix provided in the network |
| 80 |
type: list |
| 81 |
elements: str |
| 82 |
redistribute: |
| 83 |
description: |
| 84 |
- Specifies the redistribute information from another routing protocol. |
| 85 |
type: list |
| 86 |
elements: dict |
| 87 |
suboptions: |
| 88 |
protocol: |
| 89 |
description: |
| 90 |
- Specifies the protocol for configuring redistribute information. |
| 91 |
type: str |
| 92 |
choices: ['ospf', 'static', 'connected'] |
| 93 |
required: true |
| 94 |
metric: |
| 95 |
description: |
| 96 |
- Specifies the metric for redistributed routes. |
| 97 |
type: str |
| 98 |
route_map: |
| 99 |
description: |
| 100 |
- Specifies the route map reference. |
| 101 |
type: str |
| 102 |
import: |
| 103 |
description: |
| 104 |
- Specifies the routes to be imported to this address family. |
| 105 |
version_added: '2.5.0' |
| 106 |
type: dict |
| 107 |
suboptions: |
| 108 |
vrf: |
| 109 |
description: |
| 110 |
- Import routes from other VRFs. |
| 111 |
type: dict |
| 112 |
suboptions: |
| 113 |
vrf_list: |
| 114 |
description: |
| 115 |
- Specifies the VRFs to import routes from. |
| 116 |
type: list |
| 117 |
elements: str |
| 118 |
route_map: |
| 119 |
description: |
| 120 |
- Specifies the route-map. |
| 121 |
type: str |
| 122 |
advertise_pip: |
| 123 |
description: |
| 124 |
- Enables advertise PIP |
| 125 |
type: bool |
| 126 |
advertise_pip_ip: |
| 127 |
description: |
| 128 |
- PIP IPv4 address |
| 129 |
type: str |
| 130 |
advertise_pip_peer_ip: |
| 131 |
description: |
| 132 |
- PIP peer IPv4 address |
| 133 |
type: str |
| 134 |
advertise_svi_ip: |
| 135 |
description: |
| 136 |
- Enables advertise SVI MACIP routes |
| 137 |
type: bool |
| 138 |
route_advertise_list: |
| 139 |
description: |
| 140 |
- List of advertise routes |
| 141 |
type: list |
| 142 |
elements: dict |
| 143 |
suboptions: |
| 144 |
advertise_afi: |
| 145 |
required: true |
| 146 |
type: str |
| 147 |
choices: |
| 148 |
- ipv4 |
| 149 |
- ipv6 |
| 150 |
description: |
| 151 |
- Specifies the address family |
| 152 |
route_map: |
| 153 |
type: str |
| 154 |
description: |
| 155 |
- Specifies the route-map reference |
| 156 |
advertise_default_gw: |
| 157 |
description: |
| 158 |
- Specifies the advertise default gateway flag. |
| 159 |
type: bool |
| 160 |
advertise_all_vni: |
| 161 |
description: |
| 162 |
- Specifies the advertise all vni flag. |
| 163 |
type: bool |
| 164 |
dup_addr_detection: |
| 165 |
description: |
| 166 |
- Duplicate address detection configuration. |
| 167 |
- I(max_moves) and I(time) are required together. |
| 168 |
version_added: '3.1.0' |
| 169 |
type: dict |
| 170 |
suboptions: |
| 171 |
enabled: |
| 172 |
description: |
| 173 |
- Enable duplicate address detection. |
| 174 |
type: bool |
| 175 |
freeze: |
| 176 |
description: |
| 177 |
- Specifies duplicate address detection freeze. |
| 178 |
- Value can be C(permanent) or time in the range 30 to 3600. |
| 179 |
- C(permanent) - Enable permanent freeze. |
| 180 |
type: str |
| 181 |
max_moves: |
| 182 |
description: |
| 183 |
- Specifies the max allowed moves before address is detected as duplicate. |
| 184 |
- The range is from 2 to 1000. |
| 185 |
type: int |
| 186 |
time: |
| 187 |
description: |
| 188 |
- Specifies the duplicate address detection time. |
| 189 |
- The range is from 2 to 1800. |
| 190 |
type: int |
| 191 |
max_path: |
| 192 |
description: |
| 193 |
- Specifies the maximum paths of ibgp and ebgp count. |
| 194 |
type: dict |
| 195 |
suboptions: |
| 196 |
ibgp: |
| 197 |
description: |
| 198 |
- Specifies the count of the ibgp multipaths count. |
| 199 |
type: int |
| 200 |
ebgp: |
| 201 |
description: |
| 202 |
- Specifies the count of the ebgp multipaths count. |
| 203 |
type: int |
| 204 |
rd: |
| 205 |
description: |
| 206 |
- Specifies the route distiguisher to be used by the VRF instance. |
| 207 |
type: str |
| 208 |
rt_in: |
| 209 |
description: |
| 210 |
- Route-targets to be imported. |
| 211 |
type: list |
| 212 |
elements: str |
| 213 |
rt_out: |
| 214 |
description: |
| 215 |
- Route-targets to be exported. |
| 216 |
type: list |
| 217 |
elements: str |
| 218 |
vnis: |
| 219 |
description: |
| 220 |
- VNI configuration for the EVPN. |
| 221 |
type: list |
| 222 |
elements: dict |
| 223 |
suboptions: |
| 224 |
vni_number: |
| 225 |
description: |
| 226 |
- Specifies the VNI number. |
| 227 |
type: int |
| 228 |
required: true |
| 229 |
advertise_default_gw: |
| 230 |
description: |
| 231 |
- Specifies the advertise default gateway flag. |
| 232 |
type: bool |
| 233 |
advertise_svi_ip: |
| 234 |
description: |
| 235 |
- Enables advertise SVI MACIP routes |
| 236 |
type: bool |
| 237 |
rd: |
| 238 |
description: |
| 239 |
- Specifies the route distiguisher to be used by the VRF instance. |
| 240 |
type: str |
| 241 |
rt_in: |
| 242 |
description: |
| 243 |
- Route-targets to be imported. |
| 244 |
type: list |
| 245 |
elements: str |
| 246 |
rt_out: |
| 247 |
description: |
| 248 |
- Route-targets to be exported. |
| 249 |
type: list |
| 250 |
elements: str |
| 251 |
aggregate_address_config: |
| 252 |
description: |
| 253 |
- Aggregate address configuration |
| 254 |
version_added: 2.5.0 |
| 255 |
type: list |
| 256 |
elements: dict |
| 257 |
suboptions: |
| 258 |
prefix: |
| 259 |
description: |
| 260 |
- Aggregate address prefix |
| 261 |
type: str |
| 262 |
required: true |
| 263 |
as_set: |
| 264 |
description: |
| 265 |
- Enables/disables generation of AS set path information |
| 266 |
type: bool |
| 267 |
policy_name: |
| 268 |
description: |
| 269 |
- Preconfigured routing policy (route map name) to be applied to aggregate network |
| 270 |
type: str |
| 271 |
summary_only: |
| 272 |
description: |
| 273 |
- Enables/disables restriction of route information included in updates |
| 274 |
type: bool |
| 275 |
state: |
| 276 |
description: |
| 277 |
- Specifies the operation to be performed on the BGP_AF process configured on the device. |
| 278 |
- In case of merged, the input configuration is merged with the existing BGP_AF configuration on the device. |
| 279 |
- In case of deleted, the existing BGP_AF configuration is removed from the device. |
| 280 |
- In case of replaced, the existing BGP_AF of specified BGP AS will be replaced with provided configuration. |
| 281 |
- In case of overridden, the existing BGP_AF configuration will be overridden with the provided configuration. |
| 282 |
default: merged |
| 283 |
choices: ['merged', 'deleted', 'overridden', 'replaced'] |
| 284 |
type: str |
| 285 |
""" |
| 286 |
|
| 287 |
EXAMPLES = """ |
| 288 |
# Using "deleted" state |
| 289 |
# |
| 290 |
# Before state: |
| 291 |
# ------------- |
| 292 |
# |
| 293 |
# sonic# show running-configuration bgp |
| 294 |
# ! |
| 295 |
# router bgp 51 vrf VrfReg1 |
| 296 |
# log-neighbor-changes |
| 297 |
# timers 60 180 |
| 298 |
# ! |
| 299 |
# address-family ipv4 unicast |
| 300 |
# maximum-paths 1 |
| 301 |
# maximum-paths ibgp 1 |
| 302 |
# network 3.3.3.3/16 |
| 303 |
# aggregate-address 1.1.1.1/1 |
| 304 |
# aggregate-address 5.5.5.5/5 as-set summary-only route-map rmap-1 |
| 305 |
# dampening |
| 306 |
# import vrf route-map rmap-1 |
| 307 |
# import vrf default |
| 308 |
# ! |
| 309 |
# router bgp 51 |
| 310 |
# router-id 111.2.2.41 |
| 311 |
# timers 60 180 |
| 312 |
# ! |
| 313 |
# address-family ipv4 unicast |
| 314 |
# maximum-paths 1 |
| 315 |
# maximum-paths ibgp 1 |
| 316 |
# dampening |
| 317 |
# ! |
| 318 |
# address-family ipv6 unicast |
| 319 |
# redistribute connected route-map bb metric 21 |
| 320 |
# redistribute ospf route-map aa metric 27 |
| 321 |
# redistribute static route-map bb metric 26 |
| 322 |
# maximum-paths 4 |
| 323 |
# maximum-paths ibgp 5 |
| 324 |
# ! |
| 325 |
# address-family l2vpn evpn |
| 326 |
# advertise-svi-ip |
| 327 |
# advertise ipv6 unicast route-map aa |
| 328 |
# rd 3.3.3.3:33 |
| 329 |
# route-target import 22:22 |
| 330 |
# route-target export 33:33 |
| 331 |
# dup-addr-detection |
| 332 |
# advertise-pip ip 1.1.1.1 peer-ip 2.2.2.2 |
| 333 |
# ! |
| 334 |
# vni 1 |
| 335 |
# advertise-default-gw |
| 336 |
# advertise-svi-ip |
| 337 |
# rd 5.5.5.5:55 |
| 338 |
# route-target import 88:88 |
| 339 |
# route-target export 77:77 |
| 340 |
# |
| 341 |
|
| 342 |
- name: Delete BGP Address family configuration from the device |
| 343 |
dellemc.enterprise_sonic.sonic_bgp_af: |
| 344 |
config: |
| 345 |
- bgp_as: 51 |
| 346 |
address_family: |
| 347 |
afis: |
| 348 |
- afi: l2vpn |
| 349 |
safi: evpn |
| 350 |
advertise_pip: true |
| 351 |
advertise_pip_ip: "1.1.1.1" |
| 352 |
advertise_pip_peer_ip: "2.2.2.2" |
| 353 |
advertise_svi_ip: true |
| 354 |
advertise_all_vni: false |
| 355 |
advertise_default_gw: false |
| 356 |
route_advertise_list: |
| 357 |
- advertise_afi: ipv6 |
| 358 |
route_map: aa |
| 359 |
rd: "3.3.3.3:33" |
| 360 |
rt_in: |
| 361 |
- "22:22" |
| 362 |
rt_out: |
| 363 |
- "33:33" |
| 364 |
vnis: |
| 365 |
- vni_number: 1 |
| 366 |
- afi: ipv4 |
| 367 |
safi: unicast |
| 368 |
- afi: ipv6 |
| 369 |
safi: unicast |
| 370 |
max_path: |
| 371 |
ebgp: 2 |
| 372 |
ibgp: 5 |
| 373 |
redistribute: |
| 374 |
- metric: "21" |
| 375 |
protocol: connected |
| 376 |
route_map: bb |
| 377 |
- metric: "27" |
| 378 |
protocol: ospf |
| 379 |
route_map: aa |
| 380 |
- metric: "26" |
| 381 |
protocol: static |
| 382 |
route_map: bb |
| 383 |
- bgp_as: 51 |
| 384 |
vrf_name: VrfReg1 |
| 385 |
address_family: |
| 386 |
afis: |
| 387 |
- afi: ipv4 |
| 388 |
safi: unicast |
| 389 |
import: |
| 390 |
vrf: |
| 391 |
vrf_list: |
| 392 |
- default |
| 393 |
route_map: rmap-1 |
| 394 |
aggregate_address_config: |
| 395 |
- prefix: "1.1.1.1/1" |
| 396 |
- prefix: "5.5.5.5/5" |
| 397 |
as_set: true |
| 398 |
policy_name: rmap-1 |
| 399 |
summary_only: true |
| 400 |
state: deleted |
| 401 |
|
| 402 |
# After state: |
| 403 |
# ------------ |
| 404 |
# |
| 405 |
# sonic# show running-configuration bgp |
| 406 |
# ! |
| 407 |
# router bgp 51 vrf VrfReg1 |
| 408 |
# log-neighbor-changes |
| 409 |
# timers 60 180 |
| 410 |
# ! |
| 411 |
# address-family ipv4 unicast |
| 412 |
# maximum-paths 1 |
| 413 |
# maximum-paths ibgp 1 |
| 414 |
# network 3.3.3.3/16 |
| 415 |
# aggregate-address 5.5.5.5/5 |
| 416 |
# dampening |
| 417 |
# ! |
| 418 |
# router bgp 51 |
| 419 |
# router-id 111.2.2.41 |
| 420 |
# timers 60 180 |
| 421 |
# ! |
| 422 |
# address-family ipv6 unicast |
| 423 |
# ! |
| 424 |
# address-family l2vpn evpn |
| 425 |
# dup-addr-detection |
| 426 |
# |
| 427 |
|
| 428 |
# Using "deleted" state |
| 429 |
# |
| 430 |
# Before state: |
| 431 |
# ------------- |
| 432 |
# |
| 433 |
# sonic# show running-configuration bgp |
| 434 |
# ! |
| 435 |
# router bgp 51 vrf VrfReg1 |
| 436 |
# log-neighbor-changes |
| 437 |
# timers 60 180 |
| 438 |
# ! |
| 439 |
# address-family ipv4 unicast |
| 440 |
# maximum-paths 1 |
| 441 |
# maximum-paths ibgp 1 |
| 442 |
# network 3.3.3.3/16 |
| 443 |
# aggregate-address 5.5.5.5/5 as-set summary-only route-map rmap-1 |
| 444 |
# dampening |
| 445 |
# import vrf route-map rmap-1 |
| 446 |
# import vrf default |
| 447 |
# ! |
| 448 |
# router bgp 51 |
| 449 |
# router-id 111.2.2.41 |
| 450 |
# timers 60 180 |
| 451 |
# ! |
| 452 |
# address-family ipv6 unicast |
| 453 |
# ! |
| 454 |
# address-family l2vpn evpn |
| 455 |
# |
| 456 |
|
| 457 |
- name: Delete All BGP address family configurations |
| 458 |
dellemc.enterprise_sonic.sonic_bgp_af: |
| 459 |
config: |
| 460 |
state: deleted |
| 461 |
|
| 462 |
|
| 463 |
# After state: |
| 464 |
# ------------ |
| 465 |
# |
| 466 |
# sonic# show running-configuration bgp |
| 467 |
# ! |
| 468 |
# router bgp 51 vrf VrfReg1 |
| 469 |
# log-neighbor-changes |
| 470 |
# timers 60 180 |
| 471 |
# ! |
| 472 |
# router bgp 51 |
| 473 |
# router-id 111.2.2.41 |
| 474 |
# timers 60 180 |
| 475 |
# |
| 476 |
|
| 477 |
# Using "merged" state |
| 478 |
# |
| 479 |
# Before state: |
| 480 |
# ------------- |
| 481 |
# |
| 482 |
# sonic# show running-configuration bgp |
| 483 |
# ! |
| 484 |
# router bgp 51 vrf VrfReg1 |
| 485 |
# log-neighbor-changes |
| 486 |
# timers 60 180 |
| 487 |
# ! |
| 488 |
# router bgp 51 |
| 489 |
# router-id 111.2.2.41 |
| 490 |
# timers 60 180 |
| 491 |
# ! |
| 492 |
# address-family l2vpn evpn |
| 493 |
# dup-addr-detection |
| 494 |
# |
| 495 |
|
| 496 |
- name: Merge provided BGP address family configuration on the device. |
| 497 |
dellemc.enterprise_sonic.sonic_bgp_af: |
| 498 |
config: |
| 499 |
- bgp_as: 51 |
| 500 |
address_family: |
| 501 |
afis: |
| 502 |
- afi: l2vpn |
| 503 |
safi: evpn |
| 504 |
advertise_pip: true |
| 505 |
advertise_pip_ip: "3.3.3.3" |
| 506 |
advertise_pip_peer_ip: "4.4.4.4" |
| 507 |
advertise_svi_ip: true |
| 508 |
advertise_all_vni: false |
| 509 |
advertise_default_gw: false |
| 510 |
dup_addr_detection: |
| 511 |
freeze: permanent |
| 512 |
max_moves: 10 |
| 513 |
time: 600 |
| 514 |
route_advertise_list: |
| 515 |
- advertise_afi: ipv4 |
| 516 |
route_map: bb |
| 517 |
rd: "1.1.1.1:11" |
| 518 |
rt_in: |
| 519 |
- "12:12" |
| 520 |
rt_out: |
| 521 |
- "13:13" |
| 522 |
vnis: |
| 523 |
- vni_number: 1 |
| 524 |
advertise_default_gw: true |
| 525 |
advertise_svi_ip: true |
| 526 |
rd: "5.5.5.5:55" |
| 527 |
rt_in: |
| 528 |
- "88:88" |
| 529 |
rt_out: |
| 530 |
- "77:77" |
| 531 |
- afi: ipv4 |
| 532 |
safi: unicast |
| 533 |
network: |
| 534 |
- 2.2.2.2/16 |
| 535 |
- 192.168.10.1/32 |
| 536 |
dampening: true |
| 537 |
aggregate_address_config: |
| 538 |
- prefix: 1.1.1.1/1 |
| 539 |
as_set: true |
| 540 |
policy_name: bb |
| 541 |
summary_only: true |
| 542 |
- afi: ipv6 |
| 543 |
safi: unicast |
| 544 |
max_path: |
| 545 |
ebgp: 4 |
| 546 |
ibgp: 5 |
| 547 |
redistribute: |
| 548 |
- metric: "21" |
| 549 |
protocol: connected |
| 550 |
route_map: bb |
| 551 |
- metric: "27" |
| 552 |
protocol: ospf |
| 553 |
route_map: aa |
| 554 |
- metric: "26" |
| 555 |
protocol: static |
| 556 |
route_map: bb |
| 557 |
- bgp_as: 51 |
| 558 |
vrf_name: VrfReg1 |
| 559 |
address_family: |
| 560 |
afis: |
| 561 |
- afi: ipv4 |
| 562 |
safi: unicast |
| 563 |
import: |
| 564 |
vrf: |
| 565 |
vrf_list: |
| 566 |
- default |
| 567 |
route_map: rmap-1 |
| 568 |
state: merged |
| 569 |
|
| 570 |
# After state: |
| 571 |
# ------------ |
| 572 |
# |
| 573 |
# sonic# show running-configuration bgp |
| 574 |
# ! |
| 575 |
# router bgp 51 vrf VrfReg1 |
| 576 |
# log-neighbor-changes |
| 577 |
# timers 60 180 |
| 578 |
# ! |
| 579 |
# address-family ipv4 unicast |
| 580 |
# maximum-paths 1 |
| 581 |
# maximum-paths ibgp 1 |
| 582 |
# import vrf route-map rmap-1 |
| 583 |
# import vrf default |
| 584 |
# ! |
| 585 |
# router bgp 51 |
| 586 |
# router-id 111.2.2.41 |
| 587 |
# timers 60 180 |
| 588 |
# ! |
| 589 |
# address-family ipv4 unicast |
| 590 |
# network 2.2.2.2/16 |
| 591 |
# network 192.168.10.1/32 |
| 592 |
# aggregate-address 1.1.1.1/1 as-set summary-only route-map bb |
| 593 |
# dampening |
| 594 |
# ! |
| 595 |
# address-family ipv6 unicast |
| 596 |
# redistribute connected route-map bb metric 21 |
| 597 |
# redistribute ospf route-map aa metric 27 |
| 598 |
# redistribute static route-map bb metric 26 |
| 599 |
# maximum-paths 4 |
| 600 |
# maximum-paths ibgp 5 |
| 601 |
# ! |
| 602 |
# address-family l2vpn evpn |
| 603 |
# advertise-svi-ip |
| 604 |
# advertise ipv4 unicast route-map bb |
| 605 |
# rd 1.1.1.1:11 |
| 606 |
# route-target import 12:12 |
| 607 |
# route-target import 13:13 |
| 608 |
# dup-addr-detection max-moves 10 time 600 |
| 609 |
# dup-addr-detection freeze permanent |
| 610 |
# advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4 |
| 611 |
# ! |
| 612 |
# vni 1 |
| 613 |
# advertise-default-gw |
| 614 |
# advertise-svi-ip |
| 615 |
# rd 5.5.5.5:55 |
| 616 |
# route-target import 88:88 |
| 617 |
# route-target export 77:77 |
| 618 |
# |
| 619 |
|
| 620 |
# Using "replaced" state |
| 621 |
# |
| 622 |
# Before state: |
| 623 |
# ------------- |
| 624 |
# |
| 625 |
# sonic# show running-configuration bgp |
| 626 |
# ! |
| 627 |
# router bgp 51 vrf VrfReg1 |
| 628 |
# log-neighbor-changes |
| 629 |
# timers 60 180 |
| 630 |
# ! |
| 631 |
# address-family ipv4 unicast |
| 632 |
# maximum-paths 1 |
| 633 |
# maximum-paths ibgp 1 |
| 634 |
# network 3.3.3.3/16 |
| 635 |
# dampening |
| 636 |
# ! |
| 637 |
# router bgp 51 vrf VrfReg2 |
| 638 |
# log-neighbor-changes |
| 639 |
# timers 60 180 |
| 640 |
# ! |
| 641 |
# address-family ipv4 unicast |
| 642 |
# maximum-paths 1 |
| 643 |
# maximum-paths ibgp 1 |
| 644 |
# import vrf route-map rmap-1 |
| 645 |
# import vrf default |
| 646 |
# ! |
| 647 |
# router bgp 51 |
| 648 |
# router-id 111.2.2.41 |
| 649 |
# log-neighbor-changes |
| 650 |
# timers 60 180 |
| 651 |
# ! |
| 652 |
# address-family ipv4 unicast |
| 653 |
# redistribute connected route-map bb metric 21 |
| 654 |
# redistribute ospf route-map bb metric 27 |
| 655 |
# maximum-paths 1 |
| 656 |
# maximum-paths ibgp 1 |
| 657 |
# network 2.2.2.2/16 |
| 658 |
# network 192.168.10.1/32 |
| 659 |
# aggregate-address 5.5.5.5/5 as-set summary-only route-map bb |
| 660 |
# dampening |
| 661 |
# ! |
| 662 |
# address-family ipv6 unicast |
| 663 |
# redistribute static route-map aa metric 26 |
| 664 |
# maximum-paths 4 |
| 665 |
# maximum-paths ibgp 5 |
| 666 |
# ! |
| 667 |
# address-family l2vpn evpn |
| 668 |
# advertise-all-vni |
| 669 |
# advertise-svi-ip |
| 670 |
# advertise ipv4 unicast route-map bb |
| 671 |
# rd 1.1.1.1:11 |
| 672 |
# route-target import 12:12 |
| 673 |
# route-target export 13:13 |
| 674 |
# advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4 |
| 675 |
# no dup-addr-detection |
| 676 |
# ! |
| 677 |
# vni 1 |
| 678 |
# advertise-default-gw |
| 679 |
# advertise-svi-ip |
| 680 |
# rd 5.5.5.5:55 |
| 681 |
# route-target import 88:88 |
| 682 |
# route-target export 77:77 |
| 683 |
# |
| 684 |
|
| 685 |
- name: Replace device configuration of address families of specified BGP AS with provided configuration. |
| 686 |
dellemc.enterprise_sonic.sonic_bgp_af: |
| 687 |
config: |
| 688 |
- bgp_as: 51 |
| 689 |
address_family: |
| 690 |
afis: |
| 691 |
- afi: l2vpn |
| 692 |
safi: evpn |
| 693 |
advertise_pip: true |
| 694 |
advertise_pip_ip: "3.3.3.3" |
| 695 |
advertise_pip_peer_ip: "4.4.4.4" |
| 696 |
advertise_svi_ip: true |
| 697 |
advertise_all_vni: true |
| 698 |
advertise_default_gw: false |
| 699 |
route_advertise_list: |
| 700 |
- advertise_afi: ipv4 |
| 701 |
route_map: bb |
| 702 |
rd: "1.1.1.1:11" |
| 703 |
rt_in: |
| 704 |
- "22:22" |
| 705 |
rt_out: |
| 706 |
- "13:13" |
| 707 |
vnis: |
| 708 |
- vni_number: 5 |
| 709 |
advertise_default_gw: true |
| 710 |
advertise_svi_ip: true |
| 711 |
rd: "10.10.10.10:55" |
| 712 |
rt_in: |
| 713 |
- "88:88" |
| 714 |
rt_out: |
| 715 |
- "77:77" |
| 716 |
- afi: ipv4 |
| 717 |
safi: unicast |
| 718 |
network: |
| 719 |
- 2.2.2.2/16 |
| 720 |
- 192.168.10.1/32 |
| 721 |
dampening: true |
| 722 |
redistribute: |
| 723 |
- protocol: connected |
| 724 |
- protocol: ospf |
| 725 |
metric: 30 |
| 726 |
aggregate-address-config: |
| 727 |
- prefix: '5.5.5.5/5' |
| 728 |
as_set: true |
| 729 |
- bgp_as: 51 |
| 730 |
vrf_name: VrfReg2 |
| 731 |
address_family: |
| 732 |
afis: |
| 733 |
- afi: ipv4 |
| 734 |
safi: unicast |
| 735 |
import: |
| 736 |
vrf: |
| 737 |
vrf_list: |
| 738 |
- VrfReg1 |
| 739 |
route_map: rmap-reg1 |
| 740 |
state: replaced |
| 741 |
|
| 742 |
# After state: |
| 743 |
# ------------ |
| 744 |
# |
| 745 |
# sonic# show running-configuration bgp |
| 746 |
# ! |
| 747 |
# router bgp 51 vrf VrfReg1 |
| 748 |
# log-neighbor-changes |
| 749 |
# timers 60 180 |
| 750 |
# ! |
| 751 |
# address-family ipv4 unicast |
| 752 |
# maximum-paths 1 |
| 753 |
# maximum-paths ibgp 1 |
| 754 |
# network 3.3.3.3/16 |
| 755 |
# dampening |
| 756 |
# ! |
| 757 |
# router bgp 51 vrf VrfReg2 |
| 758 |
# log-neighbor-changes |
| 759 |
# timers 60 180 |
| 760 |
# ! |
| 761 |
# address-family ipv4 unicast |
| 762 |
# maximum-paths 1 |
| 763 |
# maximum-paths ibgp 1 |
| 764 |
# import vrf route-map rmap-reg1 |
| 765 |
# import vrf VrfReg1 |
| 766 |
# ! |
| 767 |
# router bgp 51 |
| 768 |
# router-id 111.2.2.41 |
| 769 |
# log-neighbor-changes |
| 770 |
# timers 60 180 |
| 771 |
# ! |
| 772 |
# address-family ipv4 unicast |
| 773 |
# redistribute connected |
| 774 |
# redistribute ospf metric 30 |
| 775 |
# maximum-paths 1 |
| 776 |
# maximum-paths ibgp 1 |
| 777 |
# network 2.2.2.2/16 |
| 778 |
# network 192.168.10.1/32 |
| 779 |
# aggregate-address 5.5.5.5/5 as-set |
| 780 |
# dampening |
| 781 |
# ! |
| 782 |
# address-family ipv6 unicast |
| 783 |
# redistribute static route-map aa metric 26 |
| 784 |
# maximum-paths 4 |
| 785 |
# maximum-paths ibgp 5 |
| 786 |
# ! |
| 787 |
# address-family l2vpn evpn |
| 788 |
# advertise-all-vni |
| 789 |
# advertise-svi-ip |
| 790 |
# advertise ipv4 unicast route-map bb |
| 791 |
# rd 1.1.1.1:11 |
| 792 |
# route-target import 22:22 |
| 793 |
# route-target export 13:13 |
| 794 |
# dup-addr-detection |
| 795 |
# advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4 |
| 796 |
# ! |
| 797 |
# vni 5 |
| 798 |
# advertise-default-gw |
| 799 |
# advertise-svi-ip |
| 800 |
# rd 10.10.10.10:55 |
| 801 |
# route-target import 88:88 |
| 802 |
# route-target export 77:77 |
| 803 |
# |
| 804 |
|
| 805 |
# Using "overridden" state |
| 806 |
# |
| 807 |
# Before state: |
| 808 |
# ------------- |
| 809 |
# |
| 810 |
# sonic# show running-configuration bgp |
| 811 |
# ! |
| 812 |
# router bgp 51 vrf VrfReg1 |
| 813 |
# log-neighbor-changes |
| 814 |
# timers 60 180 |
| 815 |
# ! |
| 816 |
# address-family ipv4 unicast |
| 817 |
# maximum-paths 1 |
| 818 |
# maximum-paths ibgp 1 |
| 819 |
# network 3.3.3.3/16 |
| 820 |
# dampening |
| 821 |
# import vrf route-map rmap-1 |
| 822 |
# import vrf default |
| 823 |
# ! |
| 824 |
# router bgp 51 |
| 825 |
# router-id 111.2.2.41 |
| 826 |
# log-neighbor-changes |
| 827 |
# timers 60 180 |
| 828 |
# ! |
| 829 |
# address-family ipv4 unicast |
| 830 |
# redistribute connected route-map bb metric 21 |
| 831 |
# redistribute ospf route-map bb metric 27 |
| 832 |
# maximum-paths 1 |
| 833 |
# maximum-paths ibgp 1 |
| 834 |
# network 2.2.2.2/16 |
| 835 |
# network 192.168.10.1/32 |
| 836 |
# dampening |
| 837 |
# ! |
| 838 |
# address-family ipv6 unicast |
| 839 |
# redistribute static route-map aa metric 26 |
| 840 |
# maximum-paths 4 |
| 841 |
# maximum-paths ibgp 5 |
| 842 |
# ! |
| 843 |
# address-family l2vpn evpn |
| 844 |
# advertise-all-vni |
| 845 |
# advertise-svi-ip |
| 846 |
# advertise ipv4 unicast route-map bb |
| 847 |
# rd 1.1.1.1:11 |
| 848 |
# route-target import 12:12 |
| 849 |
# route-target export 13:13 |
| 850 |
# dup-addr-detection max-moves 10 time 600 |
| 851 |
# dup-addr-detection freeze permanent |
| 852 |
# advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4 |
| 853 |
# ! |
| 854 |
# vni 1 |
| 855 |
# advertise-default-gw |
| 856 |
# advertise-svi-ip |
| 857 |
# rd 5.5.5.5:55 |
| 858 |
# route-target import 88:88 |
| 859 |
# route-target export 77:77 |
| 860 |
# |
| 861 |
|
| 862 |
- name: Override device configuration of BGP address families with provided configuration. |
| 863 |
dellemc.enterprise_sonic.sonic_bgp_af: |
| 864 |
config: |
| 865 |
- bgp_as: 51 |
| 866 |
address_family: |
| 867 |
afis: |
| 868 |
- afi: l2vpn |
| 869 |
safi: evpn |
| 870 |
advertise_pip: true |
| 871 |
advertise_pip_ip: "3.3.3.3" |
| 872 |
advertise_pip_peer_ip: "4.4.4.4" |
| 873 |
advertise_svi_ip: true |
| 874 |
advertise_all_vni: true |
| 875 |
advertise_default_gw: false |
| 876 |
dup_addr_detection: |
| 877 |
freeze: '600' |
| 878 |
route_advertise_list: |
| 879 |
- advertise_afi: ipv4 |
| 880 |
route_map: bb |
| 881 |
rd: "1.1.1.1:11" |
| 882 |
rt_in: |
| 883 |
- "22:22" |
| 884 |
rt_out: |
| 885 |
- "13:13" |
| 886 |
vnis: |
| 887 |
- vni_number: 5 |
| 888 |
advertise_default_gw: true |
| 889 |
advertise_svi_ip: true |
| 890 |
rd: "10.10.10.10:55" |
| 891 |
rt_in: |
| 892 |
- "88:88" |
| 893 |
rt_out: |
| 894 |
- "77:77" |
| 895 |
- afi: ipv4 |
| 896 |
safi: unicast |
| 897 |
network: |
| 898 |
- 2.2.2.2/16 |
| 899 |
- 192.168.10.1/32 |
| 900 |
dampening: true |
| 901 |
redistribute: |
| 902 |
- protocol: connected |
| 903 |
- protocol: ospf |
| 904 |
metric: 30 |
| 905 |
aggregate_address_config: |
| 906 |
- prefix: 4.4.4.4/4 |
| 907 |
as_set: true |
| 908 |
policy_name: bb |
| 909 |
summary_only: true |
| 910 |
state: overridden |
| 911 |
|
| 912 |
# After state: |
| 913 |
# ------------ |
| 914 |
# |
| 915 |
# sonic# show running-configuration bgp |
| 916 |
# ! |
| 917 |
# router bgp 51 vrf VrfReg1 |
| 918 |
# log-neighbor-changes |
| 919 |
# timers 60 180 |
| 920 |
# ! |
| 921 |
# router bgp 51 |
| 922 |
# router-id 111.2.2.41 |
| 923 |
# log-neighbor-changes |
| 924 |
# timers 60 180 |
| 925 |
# ! |
| 926 |
# address-family ipv4 unicast |
| 927 |
# redistribute connected |
| 928 |
# redistribute ospf metric 30 |
| 929 |
# maximum-paths 1 |
| 930 |
# maximum-paths ibgp 1 |
| 931 |
# network 2.2.2.2/16 |
| 932 |
# network 192.168.10.1/32 |
| 933 |
# aggregate-address 4.4.4.4/4 as-set summary-only route-map bb |
| 934 |
# dampening |
| 935 |
# ! |
| 936 |
# address-family l2vpn evpn |
| 937 |
# advertise-all-vni |
| 938 |
# advertise-svi-ip |
| 939 |
# advertise ipv4 unicast route-map bb |
| 940 |
# rd 1.1.1.1:11 |
| 941 |
# route-target import 22:22 |
| 942 |
# route-target export 13:13 |
| 943 |
# dup-addr-detection |
| 944 |
# dup-addr-detection freeze 600 |
| 945 |
# advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4 |
| 946 |
# ! |
| 947 |
# vni 5 |
| 948 |
# advertise-default-gw |
| 949 |
# advertise-svi-ip |
| 950 |
# rd 10.10.10.10:55 |
| 951 |
# route-target import 88:88 |
| 952 |
# route-target export 77:77 |
| 953 |
# |
| 954 |
""" |
| 955 |
|
| 956 |
RETURN = """ |
| 957 |
before: |
| 958 |
description: The configuration prior to the module invocation. |
| 959 |
returned: always |
| 960 |
type: list |
| 961 |
sample: > |
| 962 |
The configuration returned is always in the same format |
| 963 |
as the parameters above. |
| 964 |
after: |
| 965 |
description: The resulting configuration module invocation. |
| 966 |
returned: when changed |
| 967 |
type: list |
| 968 |
sample: > |
| 969 |
The configuration returned always in the same format |
| 970 |
as the parameters above. |
| 971 |
commands: |
| 972 |
description: The set of commands pushed to the remote device. |
| 973 |
returned: always |
| 974 |
type: list |
| 975 |
sample: ['command 1', 'command 2', 'command 3'] |
| 976 |
""" |
| 977 |
|
| 978 |
|
| 979 |
from ansible.module_utils.basic import AnsibleModule |
| 980 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.bgp_af.bgp_af import Bgp_afArgs |
| 981 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.bgp_af.bgp_af import Bgp_af |
| 982 |
|
| 983 |
|
| 984 |
def main(): |
| 985 |
""" |
| 986 |
Main entry point for module execution |
| 987 |
|
| 988 |
:returns: the result form module invocation |
| 989 |
""" |
| 990 |
module = AnsibleModule(argument_spec=Bgp_afArgs.argument_spec, |
| 991 |
supports_check_mode=True) |
| 992 |
|
| 993 |
result = Bgp_af(module).execute_module() |
| 994 |
module.exit_json(**result) |
| 995 |
|
| 996 |
|
| 997 |
if __name__ == '__main__': |
| 998 |
main() |