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

dcnm_vrf fix issues #351, #356, #357 #354

Open
wants to merge 51 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
40d93d6
Tentative fix for Issue #351
allenrobel Dec 3, 2024
0b17715
dcnm_vrf: to_bool() fix to return correct value, or call fail_json()
allenrobel Dec 3, 2024
6e32f42
dcnm_image_policy: fix for issue #347 (#348)
allenrobel Dec 3, 2024
244929b
dcnm_fabric: hardening (#349)
allenrobel Dec 3, 2024
5f67187
dcnm_vrf: remove bool() casts, more...
allenrobel Dec 4, 2024
9508840
dcnm_vrf: More refactoring and simplifying
allenrobel Dec 4, 2024
098d17f
Rename var for readability
allenrobel Dec 4, 2024
be41882
Rename var for readability
allenrobel Dec 4, 2024
13e076e
dcnm_vrf: Avoid code duplication
allenrobel Dec 5, 2024
6a6de04
Remove TODO comment
allenrobel Dec 5, 2024
12f9e53
dcnm_vrf: leverage get_vrf_lite_objects() everywhere
allenrobel Dec 5, 2024
bbbf285
Appease pylint f-string complaints, more...
allenrobel Dec 5, 2024
da54fa1
test_log_v2.py: Temporarily disable unit tests
allenrobel Dec 5, 2024
c8c578b
Appease pylint
allenrobel Dec 5, 2024
14da7d7
Fix pep8 too-many-blank-lines
allenrobel Dec 5, 2024
1e028a2
Remove python 3.9 incompatible type hint
allenrobel Dec 5, 2024
ee179b5
Re-enable test_log_v2.py unit tests and "fix" UT errors
allenrobel Dec 5, 2024
0c980b3
Appease linters
allenrobel Dec 5, 2024
5b8c1c3
Merge branch 'develop' into dcnm-vrf-fix-issue-351
allenrobel Dec 6, 2024
b401ab8
Update another conditional
allenrobel Dec 6, 2024
978b0d2
dcnm_vrf: dict_values_differ() use generic names
allenrobel Dec 6, 2024
75a24d5
dcnm_vrf: Address mwiebe review comments
allenrobel Dec 6, 2024
f747767
Address mwiebe coments part 2
allenrobel Dec 6, 2024
dbfe057
dcnm_vrf: Protect dictionary access
allenrobel Dec 6, 2024
cc804e0
dcnm_vrf: Refactor push_to_remote, validate_input
allenrobel Dec 7, 2024
78f9e0d
appease linters
allenrobel Dec 7, 2024
e861626
Appease linters
allenrobel Dec 7, 2024
3a1a514
More refactoring
allenrobel Dec 7, 2024
fed3a70
Fix typo
allenrobel Dec 7, 2024
930dbec
dcnm_vrf: fix IT files, minor cleanup
allenrobel Dec 8, 2024
d83d4fc
Fix UT failures
allenrobel Dec 8, 2024
832a3e8
Appease pylint
allenrobel Dec 8, 2024
cf27b33
Cleanup IT deleted, query, merged
allenrobel Dec 8, 2024
72bfc10
Update playbooks/roles
allenrobel Dec 8, 2024
5749eda
Move dynamic_inventory.py into playbooks/files
allenrobel Dec 8, 2024
acb3890
Appease ansible sanity
allenrobel Dec 8, 2024
0bc26be
Appease linters
allenrobel Dec 8, 2024
b78e996
dcnm_vrf: Updates to integration tests
allenrobel Dec 10, 2024
ca7bea8
Appease linters
allenrobel Dec 10, 2024
8fb0907
Fix unprotected dictionary access
allenrobel Dec 10, 2024
509c335
Update integration tests
allenrobel Dec 10, 2024
b61fd0b
dcnm_vrf/dcnm_tests.yaml - Include all vars
allenrobel Dec 11, 2024
a565a46
Update Usage section and assign additional fabric_* vars
allenrobel Dec 11, 2024
001931e
IT: interface var naming change
allenrobel Dec 11, 2024
ecd1849
IT: Update scale.yaml
allenrobel Dec 12, 2024
a0f44c3
dcnm_vrf: IT dynamic_inventory.py small modifications
allenrobel Dec 12, 2024
41a8fd7
dcnm_vrf: fix for #356, and for an undeploy case, simplify, more...
allenrobel Dec 15, 2024
c30cfd4
dcnm_vrf: Fix for issue #357
allenrobel Dec 16, 2024
d754e3e
dcnm_vrf IT: Update task titles, print results
allenrobel Dec 16, 2024
75334e0
Merge branch 'develop' into dcnm-vrf-fix-issue-351
allenrobel Dec 16, 2024
e92c1e2
IT: Update comment for workaround.
allenrobel Dec 17, 2024
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
195 changes: 195 additions & 0 deletions playbooks/files/dynamic_inventory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
#!/usr/bin/env python
#
# Copyright (c) 2024 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, division, print_function
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!


__metaclass__ = type
__copyright__ = "Copyright (c) 2024 Cisco and/or its affiliates."
__author__ = "Allen Robel"

import json
from os import environ

"""
# Summary

Dynamic inventory for DCNM Collection integration tests.
Copy link
Collaborator

@mikewiebe mikewiebe Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea to use this dynamic_inventory file (eventually) for all of the integration tests? I suspect we will need to use a common naming convention across all of our tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind the question about how to run it... I see the instructions in the diffs below.

Inventory is built from environment variables.

# Usage

See README.md in the top-level of this repository and define the environment
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you adding more information to our README.md? I don't see any updates to it

Copy link
Collaborator Author

@allenrobel allenrobel Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. This is a holdover from when this was a separate repository. I'll modify to remove this reference.

EDIT: Added detailed usage to the Usage section of dynamic_inventory.py

variables described there appropriately for your environment.
"""
nd_role = environ.get("ND_ROLE", "dcnm_vrf")
nd_testcase = environ.get("ND_TESTCASE", "query")

fabric_1 = environ.get("ND_FABRIC_1")
nd_ip4 = environ.get("ND_IP4")
nd_password = environ.get("ND_PASSWORD")
nd_username = environ.get("ND_USERNAME", "admin")
nxos_password = environ.get("NXOS_PASSWORD")
nxos_username = environ.get("NXOS_USERNAME", "admin")

# Base set of switches
bgw_1 = environ.get("ND_BGW_1_IP4", "10.1.1.211")
bgw_2 = environ.get("ND_BGW_2_IP4", "10.1.1.212")
leaf_1 = environ.get("ND_LEAF_1_IP4", "10.1.1.106")
leaf_2 = environ.get("ND_LEAF_2_IP4", "10.1.1.107")
leaf_3 = environ.get("ND_LEAF_3_IP4", "10.1.1.108")
leaf_4 = environ.get("ND_LEAF_4_IP4", "10.1.1.109")
spine_1 = environ.get("ND_SPINE_1_IP4", "10.1.1.112")
spine_2 = environ.get("ND_SPINE_2_IP4", "10.1.1.113")

# Base set of interfaces
interface_1 = environ.get("ND_INTERFACE_1", "Ethernet1/1")
interface_2 = environ.get("ND_INTERFACE_2", "Ethernet1/2")
interface_3 = environ.get("ND_INTERFACE_3", "Ethernet1/3")

if nd_role == "dcnm_vrf":
# VXLAN/EVPN Fabric Name
# fabric_1
# - all tests
# switch_1
# - all tests
# - vrf capable
switch_1 = spine_1
# switch_2
# - all tests
# - vrf-lite capable
switch_2 = spine_2
# switch_3
# - merged
# - NOT vrf-lite capable
switch_3 = leaf_3
# interface_1
# - no tests
# interface_2
# - all tests
# - switch_2 VRF LITE extensions
# interface_3
# - merged
# - switch_3 non-vrf-lite capable switch
# - overridden
# - Removed from test due to unrelated IP POOL errors.
# - It appears that fabric would need to have SUBNET
# resource added?
#
elif nd_role == "vrf_lite":
# VXLAN/EVPN Fabric Name
# Uses fabric_1
# switch_1: vrf-lite capable
switch_1 = spine_1
# switch_2: vrf-lite capable
switch_2 = spine_2
# switch_3: vrf-lite capable
switch_3 = bgw_1
else:
switch_1 = leaf_1
switch_2 = spine_1
switch_3 = bgw_1

# output is printed to STDOUT, where ansible-playbook -i reads it.
# If you change any vars above, be sure to add them below.
# We'll clean this up as the integration test vars are standardized.

output = {
"_meta": {"hostvars": {}},
"all": {
"children": ["ungrouped", "dcnm", "ndfc", "nxos"],
"vars": {
"ansible_httpapi_use_ssl": "true",
"ansible_httpapi_validate_certs": "false",
"ansible_password": nd_password,
"ansible_python_interpreter": "python",
"ansible_user": nd_username,
"fabric_1": fabric_1,
"bgw1": bgw_1,
"bgw2": bgw_2,
"leaf1": leaf_1,
"leaf2": leaf_2,
"leaf_1": leaf_1,
"leaf_2": leaf_2,
"leaf3": leaf_3,
"leaf4": leaf_4,
"nxos_username": nxos_username,
"nxos_password": nxos_password,
"switch_password": nxos_password,
"switch_username": nxos_username,
"spine1": spine_1,
"spine2": spine_2,
"switch1": switch_1,
"switch2": switch_2,
"switch_1": switch_1,
"switch_2": switch_2,
"switch_3": switch_3,
"interface_1": interface_1,
"interface_2": interface_2,
"interface_3": interface_3,
"testcase": nd_testcase,
},
},
"dcnm": {
"hosts": [nd_ip4],
"vars": {
"ansible_connection": "ansible.netcommon.httpapi",
"ansible_network_os": "cisco.dcnm.dcnm",
},
},
"ndfc": {
"hosts": [nd_ip4],
"vars": {
"ansible_connection": "ansible.netcommon.httpapi",
"ansible_network_os": "cisco.dcnm.dcnm",
},
},
"nxos": {
"children": [
"bgw1",
"bgw2",
"leaf_1",
"leaf_2",
"leaf1",
"leaf2",
"leaf3",
"leaf4",
"spine1",
"spine2",
"switch1",
"switch2",
],
"vars": {
"ansible_become": "true",
"ansible_become_method": "enable",
"ansible_connection": "ansible.netcommon.httpapi",
"ansible_network_os": "cisco.nxos.nxos",
},
},
"bgw1": {"hosts": [bgw_1]},
"bgw2": {"hosts": [bgw_2]},
"leaf_1": {"hosts": [leaf_1]},
"leaf_2": {"hosts": [leaf_2]},
"leaf1": {"hosts": [leaf_1]},
"leaf2": {"hosts": [leaf_2]},
"leaf3": {"hosts": [leaf_3]},
"leaf4": {"hosts": [leaf_4]},
"spine1": {"hosts": [spine_1]},
"spine2": {"hosts": [spine_2]},
"switch1": {"hosts": [switch_1]},
"switch2": {"hosts": [switch_2]},
}

print(json.dumps(output))
15 changes: 15 additions & 0 deletions playbooks/roles/dcnm_vrf/dcnm_hosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
all:
vars:
ansible_user: "admin"
ansible_password: "password-ndfc"
switch_password: "password-switch"
ansible_python_interpreter: python
ansible_httpapi_validate_certs: False
ansible_httpapi_use_ssl: True
children:
ndfc:
vars:
ansible_connection: ansible.netcommon.httpapi
ansible_network_os: cisco.dcnm.dcnm
hosts:
192.168.1.1:
39 changes: 39 additions & 0 deletions playbooks/roles/dcnm_vrf/dcnm_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# This playbook can be used to execute integration tests for
# the roles located in:
#
# REPO_ROOT/tests/integration/targets/dcnm_vrf/tests/dcnm/*.yaml
#
# Either:
# 1. Modify the following:
# - The vars section below with details for your testing setup.
# - dcnm_hosts.yaml in this directory
#
# 2. Run the tests
# ansible-playbook dcnm_tests.yaml -i dcnm_hosts.yaml
#
# OR:
# 1. Modify ../dynamic_inventory.py to align with your setup
# This must contain the vars mentioned below and controller
# info from dcnm_hosts.yaml (modified for your setup)
# 2. Run the tests
# ansible-playbook dcnm_tests.yaml -i ../files/dynamic_inventory.py
#
# NOTES:
- hosts: dcnm
gather_facts: no
connection: ansible.netcommon.httpapi
# Uncomment and modify if not using dynamic_inventory.py
# vars:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the full set of vars that are required by the vrf integration tests?

Copy link
Collaborator Author

@allenrobel allenrobel Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I've updated it to include all the vars.

# test_fabric: f1
# switch_1: 10.1.1.2
# switch_2: 10.1.1.3
# switch_3: 10.1.1.4
# interface_1: Ethernet1/2
## Uncomment ONE of the following testcases
# testcase: deleted
# testcase: merged
# testcase: query

roles:
- dcnm_vrf
Loading
Loading