From 8165ce6144f319ed64531bfc3770d438a3a5bbfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ola=20Nystr=C3=B6m?= Date: Sun, 15 Dec 2019 08:05:51 +0100 Subject: [PATCH] add prefix-list to ios_bgp af-mode (#62705) * adding prefix-list to ios_bgp * adding prefix-list to ios_bgp * Fix copy-paste bug in test * Adding neigbor 10.10.20.20 to global neighbor pool * Added prefix_list_in and _out to documentation * Rewrite bgp prefix_list test * Bugfix in yaml data * More test, assert neighbor 10.10.20.20 --- .../ios/providers/cli/config/bgp/neighbors.py | 10 ++++++++++ lib/ansible/modules/network/ios/ios_bgp.py | 10 +++++++++- .../targets/ios_bgp/tests/cli/basic.yaml | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/network/ios/providers/cli/config/bgp/neighbors.py b/lib/ansible/module_utils/network/ios/providers/cli/config/bgp/neighbors.py index 62da3d988a0..2cee73382a4 100644 --- a/lib/ansible/module_utils/network/ios/providers/cli/config/bgp/neighbors.py +++ b/lib/ansible/module_utils/network/ios/providers/cli/config/bgp/neighbors.py @@ -184,3 +184,13 @@ class AFNeighbors(CliProvider): cmd = 'neighbor %s maximum-prefix %s' % (item['neighbor'], item['maximum_prefix']) if not config or cmd not in config: return cmd + + def _render_prefix_list_in(self, item, config=None): + cmd = 'neighbor %s prefix-list %s in' % (item['neighbor'], item['prefix_list_in']) + if not config or cmd not in config: + return cmd + + def _render_prefix_list_out(self, item, config=None): + cmd = 'neighbor %s prefix-list %s out' % (item['neighbor'], item['prefix_list_out']) + if not config or cmd not in config: + return cmd diff --git a/lib/ansible/modules/network/ios/ios_bgp.py b/lib/ansible/modules/network/ios/ios_bgp.py index 604033486fe..88fe29a12cb 100644 --- a/lib/ansible/modules/network/ios/ios_bgp.py +++ b/lib/ansible/modules/network/ios/ios_bgp.py @@ -222,6 +222,12 @@ options: - Maximum number of prefixes to accept from this peer. - The range is from 1 to 2147483647. type: int + prefix_list_in: + description: + - Name of ip prefix-list to apply to incoming prefixes. + prefix_list_out: + description: + - Name of ip prefix-list to apply to outgoing prefixes. operation: description: - Specifies the operation to be performed on the BGP process configured on the device. @@ -388,7 +394,9 @@ def main(): 'next_hop_self': dict(type='bool'), 'route_reflector_client': dict(type='bool'), 'route_server_client': dict(type='bool'), - 'maximum_prefix': dict(type='int') + 'maximum_prefix': dict(type='int'), + 'prefix_list_in': dict(), + 'prefix_list_out': dict() } address_family_spec = { diff --git a/test/integration/targets/ios_bgp/tests/cli/basic.yaml b/test/integration/targets/ios_bgp/tests/cli/basic.yaml index 8dd0bfe3ab0..9d6713530ae 100644 --- a/test/integration/targets/ios_bgp/tests/cli/basic.yaml +++ b/test/integration/targets/ios_bgp/tests/cli/basic.yaml @@ -142,6 +142,11 @@ remote_as: 64511 description: EBGP_NBR_1 local_as: 64497 + + - neighbor: 10.10.20.20 + remote_as: 65012 + description: BGP_NBR_2 + ebgp_multihop: 100 register: result - assert: @@ -150,6 +155,8 @@ - "'neighbor 203.0.113.10 remote-as 64511' in result.commands" - "'neighbor 203.0.113.10 description EBGP_NBR_1' in result.commands" - "'neighbor 203.0.113.10 local-as 64497' in result.commands" + - "'neighbor 10.10.20.20 remote-as 65012' in result.commands" + - "'neighbor 10.10.20.20 description BGP_NBR_2' in result.commands" - "'no neighbor 192.0.2.10' in result.commands" - name: Configure BGP neighbors with operation replace (idempotent) @@ -236,6 +243,11 @@ - neighbor: 192.0.2.15 activate: yes route_reflector_client: True + + - neighbor: 10.10.20.20 + activate: yes + prefix_list_in: incoming-prefixes + prefix_list_out: outgoing-prefixes register: result - assert: @@ -248,6 +260,9 @@ - "'neighbor 203.0.113.10 advertisement-interval 120' in result.commands" - "'neighbor 192.0.2.15 activate' in result.commands" - "'neighbor 192.0.2.15 route-reflector-client' in result.commands" + - "'neighbor 10.10.20.20 activate' in result.commands" + - "'neighbor 10.10.20.20 prefix-list incoming-prefixes in' in result.commands" + - "'neighbor 10.10.20.20 prefix-list outgoing-prefixes out' in result.commands" - name: Configure BGP neighbors under address family mode (idempotent) ios_bgp: *af_nbr