Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minor_change] Fix BGP peer rn on non-infra peers (DCNE-294) #717

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/modules/aci_l3out_bgp_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def main():

bgp_peer_profile_dict = dict(
aci_class=aci_class,
aci_rn="infraPeerP-[{0}]".format(peer_ip) if bgp_infra_peer else "peerP-{0}".format(peer_ip),
aci_rn="infraPeerP-[{0}]".format(peer_ip) if bgp_infra_peer else "peerP-[{0}]".format(peer_ip),
edudppaz marked this conversation as resolved.
Show resolved Hide resolved
module_object=peer_ip,
target_filter={"addr": peer_ip},
)
Expand Down
367 changes: 367 additions & 0 deletions tests/integration/targets/aci_l3out_bgp_peer/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Test code for the ACI modules
# Copyright: (c) 2021, Tim Cragg (@timcragg)
# Copyright: (c) 2023, Akini ROss (@akinross)
# Copyright: (c) 2025, Eduardo Pozo (@edudppaz)


# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
Expand Down Expand Up @@ -1499,7 +1500,373 @@
- remove_vpc_bgp_peer.current == []
- remove_vpc_bgp_peer.previous.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]"
- remove_vpc_bgp_peer.previous.0.bgpPeerP.attributes.addr == "192.168.50.2"
# ADD dynamic BGP peer (prefix) to ethernet port
- name: add dynamic BGP peer (prefix) to ethernet port (version >= 4)
cisco.aci.aci_l3out_bgp_peer:
edudppaz marked this conversation as resolved.
Show resolved Hide resolved
<<: *aci_info
tenant: ansible_tenant
l3out: ansible_l3out
node_profile: ansible_node_profile
interface_profile: ansible_interface_profile
pod_id: 1
node_id: 201
path_ep: eth1/15
peer_ip: 192.168.50.0/24
remote_asn: 65456
bgp_controls:
- nh-self
- send-com
- send-ext-com
peer_controls:
- bfd
address_type_controls:
- af-ucast
ttl: 2
local_as_number_config: "replace-as"
state: present
register: add_dyn_bgp_peer
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: add dynamic BGP peer (prefix) to ethernet port (version < 4)
edudppaz marked this conversation as resolved.
Show resolved Hide resolved
cisco.aci.aci_l3out_bgp_peer:
<<: *aci_info
tenant: ansible_tenant
l3out: ansible_l3out
node_profile: ansible_node_profile
interface_profile: ansible_interface_profile
pod_id: 1
node_id: 201
path_ep: eth1/15
peer_ip: 192.168.50.0/24
remote_asn: 65456
bgp_controls:
- nh-self
- send-com
- send-ext-com
peer_controls:
- bfd
ttl: 2
state: present
register: add_dyn_bgp_peer_32
when: version.current.0.topSystem.attributes.version is version('4', '<')

- name: verify dynamic BGP peer (prefix) has been created with correct attributes (version >= 4)
ansible.builtin.assert:
that:
- add_dyn_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.0/24]"
- add_dyn_bgp_peer.current.0.bgpPeerP.attributes.addr == "192.168.50.0/24"
- add_dyn_bgp_peer.current.0.bgpPeerP.attributes.addrTCtrl == "af-ucast"
- add_dyn_bgp_peer.current.0.bgpPeerP.attributes.adminSt == "enabled"
- add_dyn_bgp_peer.current.0.bgpPeerP.attributes.ctrl == "nh-self,send-com,send-ext-com"
- add_dyn_bgp_peer.current.0.bgpPeerP.attributes.peerCtrl == "bfd"
- add_dyn_bgp_peer.current.0.bgpPeerP.attributes.ttl == "2"
- add_dyn_bgp_peer.current.0.bgpPeerP.attributes.annotation == 'orchestrator:ansible'
- add_dyn_bgp_peer.current.0.bgpPeerP.children.0.bgpLocalAsnP.attributes.asnPropagate == "replace-as"
- add_dyn_bgp_peer.current.0.bgpPeerP.children.0.bgpLocalAsnP.attributes.localAsn == "0"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify dynamic BGP peer (prefix) has been created with correct attributes (version < 4)
ansible.builtin.assert:
that:
- add_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.0/24]"
- add_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.addr == "192.168.50.0/24"
- add_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.ctrl == "nh-self,send-com,send-ext-com"
- add_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.peerCtrl == "bfd"
- add_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.ttl == "2"
- add_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.annotation == 'orchestrator:ansible'
when: version.current.0.topSystem.attributes.version is version('4', '<')

- name: verify remote AS object has been created correctly
edudppaz marked this conversation as resolved.
Show resolved Hide resolved
ansible.builtin.assert:
that:
- add_dyn_bgp_peer.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65456"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify remote AS object has been created correctly
ansible.builtin.assert:
that:
- add_dyn_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456"
when: version.current.0.topSystem.attributes.version is version('4', '<')

# ADD dynamic BGP peer (prefix) again to check idempotence
- name: add dynamic BGP peer (prefix) to ethernet port again (version >= 4)
cisco.aci.aci_l3out_bgp_peer:
<<: *aci_info
tenant: ansible_tenant
l3out: ansible_l3out
node_profile: ansible_node_profile
interface_profile: ansible_interface_profile
pod_id: 1
node_id: 201
path_ep: eth1/15
peer_ip: 192.168.50.0/24
remote_asn: 65456
bgp_controls:
- nh-self
- send-com
- send-ext-com
peer_controls:
- bfd
address_type_controls:
- af-ucast
ttl: 2
state: present
register: add_dyn_bgp_peer_again
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: add dynamic BGP peer (prefix) to ethernet port again (version < 4)
cisco.aci.aci_l3out_bgp_peer:
<<: *aci_info
tenant: ansible_tenant
l3out: ansible_l3out
node_profile: ansible_node_profile
interface_profile: ansible_interface_profile
pod_id: 1
node_id: 201
path_ep: eth1/15
peer_ip: 192.168.50.0/24
remote_asn: 65456
bgp_controls:
- nh-self
- send-com
- send-ext-com
peer_controls:
- bfd
ttl: 2
state: present
register: add_dyn_bgp_peer_again_32
when: version.current.0.topSystem.attributes.version is version('4', '<')

- name: verify dynamic BGP peer (prefix) has been created with correct attributes (version >= 4)
ansible.builtin.assert:
that:
- add_dyn_bgp_peer_again is not changed
- add_dyn_bgp_peer_again.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.0/24]"
- add_dyn_bgp_peer_again.current.0.bgpPeerP.attributes.addr == "192.168.50.0/24"
- add_dyn_bgp_peer_again.current.0.bgpPeerP.attributes.addrTCtrl == "af-ucast"
- add_dyn_bgp_peer_again.current.0.bgpPeerP.attributes.adminSt == "enabled"
- add_dyn_bgp_peer_again.current.0.bgpPeerP.attributes.ctrl == "nh-self,send-com,send-ext-com"
- add_dyn_bgp_peer_again.current.0.bgpPeerP.attributes.peerCtrl == "bfd"
- add_dyn_bgp_peer_again.current.0.bgpPeerP.attributes.ttl == "2"
edudppaz marked this conversation as resolved.
Show resolved Hide resolved
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify dynamic BGP peer (prefix) has been created with correct attributes (version < 4)
ansible.builtin.assert:
that:
- add_dyn_bgp_peer_again_32 is not changed
- add_dyn_bgp_peer_again_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.0/24]"
- add_dyn_bgp_peer_again_32.current.0.bgpPeerP.attributes.addr == "192.168.50.0/24"
- add_dyn_bgp_peer_again_32.current.0.bgpPeerP.attributes.ctrl == "nh-self,send-com,send-ext-com"
- add_dyn_bgp_peer_again_32.current.0.bgpPeerP.attributes.peerCtrl == "bfd"
- add_dyn_bgp_peer_again_32.current.0.bgpPeerP.attributes.ttl == "2"
when: version.current.0.topSystem.attributes.version is version('4', '<')

- name: verify remote AS object is still correct (version >= 4)
ansible.builtin.assert:
that:
- add_dyn_bgp_peer_again.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65456"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify remote AS object his still correct (version < 4)
ansible.builtin.assert:
that:
- add_dyn_bgp_peer_again_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456"
when: version.current.0.topSystem.attributes.version is version('4', '<')

# MODIFY dynamic BGP peer (prefix)
- name: update dynamic BGP peer (prefix) (version >= 4)
cisco.aci.aci_l3out_bgp_peer:
<<: *aci_info
tenant: ansible_tenant
l3out: ansible_l3out
node_profile: ansible_node_profile
interface_profile: ansible_interface_profile
pod_id: 1
node_id: 201
path_ep: eth1/15
peer_ip: 192.168.50.0/24
remote_asn: 65457
bgp_controls:
- allow-self-as
- as-override
peer_controls:
- dis-conn-check
private_asn_controls:
- remove-exclusive
address_type_controls:
- af-ucast
- af-mcast
weight: 50
allow_self_as_count: 3
ttl: 4
admin_state: disabled
local_as_number: 101
local_as_number_config: "dual-as"
state: present
register: update_dyn_bgp_peer
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: update dynamic BGP peer (prefix) (version < 4)
cisco.aci.aci_l3out_bgp_peer:
<<: *aci_info
tenant: ansible_tenant
l3out: ansible_l3out
node_profile: ansible_node_profile
interface_profile: ansible_interface_profile
pod_id: 1
node_id: 201
path_ep: eth1/15
peer_ip: 192.168.50.0/24
remote_asn: 65457
bgp_controls:
- allow-self-as
- as-override
peer_controls:
- dis-conn-check
private_asn_controls:
- remove-exclusive
weight: 50
allow_self_as_count: 3
ttl: 4
state: present
register: update_dyn_bgp_peer_32
when: version.current.0.topSystem.attributes.version is version('4', '<')

- name: verify dynamic BGP peer (prefix) has been updated with correct attributes (version >= 4)
ansible.builtin.assert:
that:
- update_dyn_bgp_peer is changed
- update_dyn_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.0/24]"
- update_dyn_bgp_peer.current.0.bgpPeerP.attributes.addr == "192.168.50.0/24"
- update_dyn_bgp_peer.current.0.bgpPeerP.attributes.addrTCtrl == "af-mcast,af-ucast"
- update_dyn_bgp_peer.current.0.bgpPeerP.attributes.adminSt == "disabled"
- update_dyn_bgp_peer.current.0.bgpPeerP.attributes.ctrl == "allow-self-as,as-override"
- update_dyn_bgp_peer.current.0.bgpPeerP.attributes.peerCtrl == "dis-conn-check"
- update_dyn_bgp_peer.current.0.bgpPeerP.attributes.ttl == "4"
- update_dyn_bgp_peer.current.0.bgpPeerP.attributes.allowedSelfAsCnt == "3"
- update_dyn_bgp_peer.current.0.bgpPeerP.attributes.privateASctrl == "remove-exclusive"
- update_dyn_bgp_peer.current.0.bgpPeerP.children.0.bgpLocalAsnP.attributes.asnPropagate == "dual-as"
- update_dyn_bgp_peer.current.0.bgpPeerP.children.0.bgpLocalAsnP.attributes.localAsn == "101"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify dynamic BGP peer (prefix) has been updated with correct attributes (version < 4)
ansible.builtin.assert:
that:
- update_dyn_bgp_peer_32 is changed
- update_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.0/24]"
- update_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.addr == "192.168.50.0/24"
- update_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.ctrl == "allow-self-as,as-override"
- update_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.peerCtrl == "dis-conn-check"
- update_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.ttl == "4"
- update_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.allowedSelfAsCnt == "3"
- update_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.privateASctrl == "remove-exclusive"
when: version.current.0.topSystem.attributes.version is version('4', '<')

- name: verify remote AS object has been updated correctly (version >= 4)
ansible.builtin.assert:
that:
- update_dyn_bgp_peer.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65457"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify remote AS object has been updated correctly (version < 4)
ansible.builtin.assert:
that:
- update_dyn_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457"
when: version.current.0.topSystem.attributes.version is version('4', '<')

# QUERY dynamic BGP peer (prefix)
- name: query dynamic BGP peer (prefix) (version >= 4)
cisco.aci.aci_l3out_bgp_peer:
<<: *aci_info
tenant: ansible_tenant
l3out: ansible_l3out
node_profile: ansible_node_profile
interface_profile: ansible_interface_profile
pod_id: 1
node_id: 201
path_ep: eth1/15
peer_ip: 192.168.50.0/24
state: query
register: query_dyn_bgp_peer
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: query dynamic BGP peer (prefix) (version < 4)
cisco.aci.aci_l3out_bgp_peer:
<<: *aci_info
tenant: ansible_tenant
l3out: ansible_l3out
node_profile: ansible_node_profile
interface_profile: ansible_interface_profile
pod_id: 1
node_id: 201
path_ep: eth1/15
peer_ip: 192.168.50.0/24
state: query
register: query_dyn_bgp_peer_32
when: version.current.0.topSystem.attributes.version is version('4', '<')

- name: verify dynamic BGP peer (prefix) attributes (version >= 4)
ansible.builtin.assert:
that:
- query_dyn_bgp_peer is not changed
- query_dyn_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.0/24]"
- query_dyn_bgp_peer.current.0.bgpPeerP.attributes.addr == "192.168.50.0/24"
- query_dyn_bgp_peer.current.0.bgpPeerP.attributes.addrTCtrl == "af-mcast,af-ucast"
- query_dyn_bgp_peer.current.0.bgpPeerP.attributes.adminSt == "disabled"
- query_dyn_bgp_peer.current.0.bgpPeerP.attributes.ctrl == "allow-self-as,as-override"
- query_dyn_bgp_peer.current.0.bgpPeerP.attributes.peerCtrl == "dis-conn-check"
- query_dyn_bgp_peer.current.0.bgpPeerP.attributes.ttl == "4"
- query_dyn_bgp_peer.current.0.bgpPeerP.attributes.allowedSelfAsCnt == "3"
- query_dyn_bgp_peer.current.0.bgpPeerP.attributes.privateASctrl == "remove-exclusive"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify dynamic BGP peer (prefix) attributes (version < 4)
ansible.builtin.assert:
that:
- query_dyn_bgp_peer_32 is not changed
- query_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.0/24]"
- query_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.addr == "192.168.50.0/24"
- query_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.ctrl == "allow-self-as,as-override"
- query_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.peerCtrl == "dis-conn-check"
- query_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.ttl == "4"
- query_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.allowedSelfAsCnt == "3"
- query_dyn_bgp_peer_32.current.0.bgpPeerP.attributes.privateASctrl == "remove-exclusive"
when: version.current.0.topSystem.attributes.version is version('4', '<')

- name: verify BGP remote AS (version >= 4)
ansible.builtin.assert:
that:
- query_dyn_bgp_peer.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65457"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify BGP remote AS (version < 4)
ansible.builtin.assert:
that:
- query_dyn_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457"
when: version.current.0.topSystem.attributes.version is version('4', '<')

# DELETE dynamic BGP peer (prefix)
- name: delete dynamic BGP peer (prefix)
edudppaz marked this conversation as resolved.
Show resolved Hide resolved
cisco.aci.aci_l3out_bgp_peer:
<<: *aci_info
tenant: ansible_tenant
l3out: ansible_l3out
node_profile: ansible_node_profile
interface_profile: ansible_interface_profile
pod_id: 1
node_id: 201
path_ep: eth1/15
peer_ip: 192.168.50.0/24
state: absent
register: remove_dyn_bgp_peer

- name: verify remove_dyn_bgp_peer
ansible.builtin.assert:
that:
- remove_dyn_bgp_peer is changed
- remove_dyn_bgp_peer.current == []
- remove_dyn_bgp_peer.previous.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.0/24]"
- remove_dyn_bgp_peer.previous.0.bgpPeerP.attributes.addr == "192.168.50.0/24"
# Create BGP Peer with password
- name: Create BGP Peer with password
aci_l3out_bgp_peer: &bgp_peer_with_password
Expand Down
Loading