Skip to content

Commit

Permalink
[bgp_address_family] fix remote_as (#933)
Browse files Browse the repository at this point in the history
* fix remote_as bgp_address_family

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add a changelog

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
KB-perByte and pre-commit-ci[bot] authored Oct 5, 2023
1 parent f8cc93a commit 77b65ad
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/bgp_add_fam_route_maps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- ios_bgp_address_family - fix rendering of remote_as configuration with period.
4 changes: 2 additions & 2 deletions docs/cisco.ios.ios_bgp_address_family_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3101,7 +3101,7 @@ Parameters
<b>number</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
<span style="color: purple">string</span>
</div>
</td>
<td>
Expand Down Expand Up @@ -4026,7 +4026,7 @@ Parameters
<b>remote_as</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
<span style="color: purple">string</span>
</div>
</td>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class Bgp_address_familyArgs(object): # pylint: disable=R0903
"type": "dict",
"options": {
"set": {"type": "bool"},
"number": {"type": "int"},
"number": {"type": "str"},
"dual_as": {"type": "bool"},
"no_prepend": {
"type": "dict",
Expand Down Expand Up @@ -439,7 +439,7 @@ class Bgp_address_familyArgs(object): # pylint: disable=R0903
"out": {"type": "bool"},
},
},
"remote_as": {"type": "int"},
"remote_as": {"type": "str"},
"remove_private_as": {
"type": "dict",
"options": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ def _bgp_add_fam_list_to_dict(self, tmp_data):
# slow_peer to slow_peer_options
if neib.get("slow_peer"): # only one slow_peer is allowed
neib["slow_peer_options"] = neib.pop("slow_peer")[0]
# we can skip deprecating these by handling the int to str conversion here
# int to float is not considered considering the size of as numbers
if neib.get("remote_as"):
neib["remote_as"] = str(neib.get("remote_as"))
if neib.get("local_as") and neib.get("local_as", {}).get("number"):
neib["local_as"]["number"] = str(neib["local_as"]["number"])
# make dict neighbors dict
tmp[neib[p_key[k]]] = neib
_af["neighbors"] = tmp
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/ios_bgp_address_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
description:
- AS number used as local AS
- Please refer vendor documentation for valid values
type: int
type: str
dual_as:
description: Accept either real AS or local AS from the ebgp peer
type: bool
Expand Down Expand Up @@ -769,7 +769,7 @@
description:
- Specify a BGP neighbor
- AS of remote neighbor
type: int
type: str
remove_private_as:
description: Remove private AS number from outbound updates
type: dict
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/modules/network/ios/test_ios_bgp_address_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_ios_bgp_address_family_merged(self):
neighbors=[
dict(
neighbor_address="198.51.100.1",
remote_as=65100,
remote_as="65.11",
route_maps=[dict(name="test-route-out", out="true")],
prefix_lists=[dict(name="AS65100-PREFIX-OUT", out="true")],
),
Expand All @@ -144,7 +144,7 @@ def test_ios_bgp_address_family_merged(self):
"bgp aggregate-timer 20",
"bgp dmzlink-bw",
"bgp scan-time 10",
"neighbor 198.51.100.1 remote-as 65100",
"neighbor 198.51.100.1 remote-as 65.11",
"neighbor 198.51.100.1 route-map test-route-out out",
"network 192.0.1.1 route-map test_route",
"default-metric 10",
Expand Down Expand Up @@ -228,7 +228,7 @@ def test_ios_bgp_address_family_merged_idempotent(self):
network 198.51.110.10 mask 255.255.255.255 backdoor
aggregate-address 192.0.2.1 255.255.255.255 as-confed-set
neighbor 198.51.100.1 remote-as 10
neighbor 198.51.100.1 local-as 20
neighbor 198.51.100.1 local-as 10.64760
neighbor 198.51.100.1 activate
neighbor 198.51.100.1 next-hop-self all
neighbor 198.51.100.1 aigp send cost-community 100 poi igp-cost transitive
Expand Down Expand Up @@ -321,7 +321,7 @@ def test_ios_bgp_address_family_merged_idempotent(self):
},
},
},
"local_as": {"number": 20, "set": True},
"local_as": {"number": "10.64760", "set": True},
"neighbor_address": "198.51.100.1",
"nexthop_self": {"all": True},
"prefix_lists": [{"name": "AS65100-PREFIX-OUT", "out": True}],
Expand Down Expand Up @@ -1163,8 +1163,8 @@ def test_ios_bgp_address_family_parsed(self):
],
"neighbors": [
{
"remote_as": 10,
"local_as": {"set": True, "number": 20},
"remote_as": "10",
"local_as": {"set": True, "number": "20"},
"activate": True,
"neighbor_address": "198.51.100.1",
"nexthop_self": {"all": True},
Expand Down

0 comments on commit 77b65ad

Please sign in to comment.