-
Notifications
You must be signed in to change notification settings - Fork 38
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
allenrobel
wants to merge
51
commits into
develop
Choose a base branch
from
dcnm-vrf-fix-issue-351
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
40d93d6
Tentative fix for Issue #351
allenrobel 0b17715
dcnm_vrf: to_bool() fix to return correct value, or call fail_json()
allenrobel 6e32f42
dcnm_image_policy: fix for issue #347 (#348)
allenrobel 244929b
dcnm_fabric: hardening (#349)
allenrobel 5f67187
dcnm_vrf: remove bool() casts, more...
allenrobel 9508840
dcnm_vrf: More refactoring and simplifying
allenrobel 098d17f
Rename var for readability
allenrobel be41882
Rename var for readability
allenrobel 13e076e
dcnm_vrf: Avoid code duplication
allenrobel 6a6de04
Remove TODO comment
allenrobel 12f9e53
dcnm_vrf: leverage get_vrf_lite_objects() everywhere
allenrobel bbbf285
Appease pylint f-string complaints, more...
allenrobel da54fa1
test_log_v2.py: Temporarily disable unit tests
allenrobel c8c578b
Appease pylint
allenrobel 14da7d7
Fix pep8 too-many-blank-lines
allenrobel 1e028a2
Remove python 3.9 incompatible type hint
allenrobel ee179b5
Re-enable test_log_v2.py unit tests and "fix" UT errors
allenrobel 0c980b3
Appease linters
allenrobel 5b8c1c3
Merge branch 'develop' into dcnm-vrf-fix-issue-351
allenrobel b401ab8
Update another conditional
allenrobel 978b0d2
dcnm_vrf: dict_values_differ() use generic names
allenrobel 75a24d5
dcnm_vrf: Address mwiebe review comments
allenrobel f747767
Address mwiebe coments part 2
allenrobel dbfe057
dcnm_vrf: Protect dictionary access
allenrobel cc804e0
dcnm_vrf: Refactor push_to_remote, validate_input
allenrobel 78f9e0d
appease linters
allenrobel e861626
Appease linters
allenrobel 3a1a514
More refactoring
allenrobel fed3a70
Fix typo
allenrobel 930dbec
dcnm_vrf: fix IT files, minor cleanup
allenrobel d83d4fc
Fix UT failures
allenrobel 832a3e8
Appease pylint
allenrobel cf27b33
Cleanup IT deleted, query, merged
allenrobel 72bfc10
Update playbooks/roles
allenrobel 5749eda
Move dynamic_inventory.py into playbooks/files
allenrobel acb3890
Appease ansible sanity
allenrobel 0bc26be
Appease linters
allenrobel b78e996
dcnm_vrf: Updates to integration tests
allenrobel ca7bea8
Appease linters
allenrobel 8fb0907
Fix unprotected dictionary access
allenrobel 509c335
Update integration tests
allenrobel b61fd0b
dcnm_vrf/dcnm_tests.yaml - Include all vars
allenrobel a565a46
Update Usage section and assign additional fabric_* vars
allenrobel 001931e
IT: interface var naming change
allenrobel ecd1849
IT: Update scale.yaml
allenrobel a0f44c3
dcnm_vrf: IT dynamic_inventory.py small modifications
allenrobel 41a8fd7
dcnm_vrf: fix for #356, and for an undeploy case, simplify, more...
allenrobel c30cfd4
dcnm_vrf: Fix for issue #357
allenrobel d754e3e
dcnm_vrf IT: Update task titles, print results
allenrobel 75334e0
Merge branch 'develop' into dcnm-vrf-fix-issue-351
allenrobel e92c1e2
IT: Update comment for workaround.
allenrobel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
#!/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 | ||
|
||
__metaclass__ = type | ||
__copyright__ = "Copyright (c) 2024 Cisco and/or its affiliates." | ||
__author__ = "Allen Robel" | ||
|
||
import json | ||
from os import environ | ||
|
||
""" | ||
# Summary | ||
|
||
Optional dynamic inventory for the ansible-dcnm repository | ||
integration tests. This inventory is built from environment | ||
variables. | ||
|
||
## Usage | ||
|
||
### Mandatory general variables | ||
|
||
The following general environment variables are related | ||
to credentials, controller reachability, and role/testcase | ||
assignment. These should be considered mandatory; though | ||
the NXOS_* variables are not strictly needed unless called | ||
for by the specific role/testcase. | ||
|
||
Values below are examples, and should be modified for your | ||
setup and the roles/testcases you are running. | ||
|
||
```bash | ||
export ND_ROLE=dcnm_vrf # The role to run | ||
export ND_TESTCASE=query # The testcase to run | ||
export ND_IP4=10.1.1.1 # Controller IPv4 address | ||
export ND_PASSWORD=MyPassword # Controller password | ||
export ND_USERNAME=admin # Controller username | ||
export NXOS_PASSWORD=MyPassword # Switch password | ||
export NXOS_USERNAME=admin # Switch username | ||
``` | ||
|
||
### Fabrics | ||
|
||
We can add more fabrics later as the need arises... | ||
|
||
```bash | ||
export ND_FABRIC_1=MyFabric1 # Assigned to var fabric_1 | ||
export ND_FABRIC_2=MyFabric2 # Assigned to var fabric_2 | ||
export ND_FABRIC_3=MyFabric3 # Assigned to var fabric_3 | ||
|
||
``` | ||
|
||
### Interfaces | ||
|
||
Interface usage varies by testcase. See individual | ||
testcase YAML files for details regarding each test's | ||
usage. | ||
|
||
#### Interface naming convention | ||
|
||
##### Environment variables | ||
|
||
ND_INTERFACE_[A][b] | ||
|
||
Where: | ||
|
||
A - The number of the switch to which the interface belongs | ||
b - An incrementing lower-case letter in range a-z | ||
|
||
###### Examples: | ||
|
||
```bash | ||
export ND_INTERFACE_1a=Ethernet1/1 | ||
export ND_INTERFACE_2a=Ethernet1/1 | ||
export ND_INTERFACE_2b=Ethernet1/2 | ||
export ND_INTERFACE_3a=Ethernet2/4 | ||
``` | ||
|
||
Above: | ||
|
||
- switch_1 has one interface; Ethernet1/1 | ||
- switch_2 two interfaces; Ethernet1/1 and Ethernet1/2 | ||
- switch_3 has one interface; Ethernet2/4 | ||
|
||
##### Test case variables | ||
|
||
Interface variables within test cases follow the same convention | ||
as above, but are lowercase, and remove the leading ND_. | ||
|
||
###### Examples | ||
|
||
interface_1a - 1st interface on switch_1 | ||
interface_1b - 2st interface on switch_1 | ||
etc... | ||
|
||
""" | ||
nd_role = environ.get("ND_ROLE", "dcnm_vrf") | ||
nd_testcase = environ.get("ND_TESTCASE", "query") | ||
|
||
fabric_1 = environ.get("ND_FABRIC_1") | ||
fabric_2 = environ.get("ND_FABRIC_1") | ||
fabric_3 = 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") | ||
|
||
# Placeholders if you'd rather directly set each of | ||
# the switch vars instead of setting the switch vars | ||
# from the switch roles above. | ||
switch_1 = environ.get("ND_SWITCH_1_IP4", "10.1.1.112") | ||
switch_2 = environ.get("ND_SWITCH_2_IP4", "10.1.1.113") | ||
switch_3 = environ.get("ND_SWITCH_3_IP4", "10.1.1.108") | ||
|
||
# Base set of interfaces | ||
interface_1a = environ.get("ND_INTERFACE_1a", "Ethernet1/1") | ||
interface_2a = environ.get("ND_INTERFACE_2a", "Ethernet1/1") | ||
interface_2b = environ.get("ND_INTERFACE_2b", "Ethernet1/2") | ||
interface_3a = environ.get("ND_INTERFACE_3a", "Ethernet1/3") | ||
|
||
if nd_role == "dcnm_vrf": | ||
pass | ||
# VXLAN/EVPN Fabric Name | ||
# fabric_1 | ||
# - all tests | ||
# switch_1 | ||
# - all tests | ||
# - vrf capable | ||
# switch_2 | ||
# - all tests | ||
# - vrf-lite capable | ||
# switch_3 | ||
# - merged | ||
# - NOT vrf-lite capable | ||
# interface_1a | ||
# - no tests | ||
# interface_2a | ||
# - [deleted, merged, overridden, query, replaced, vrf_lite] | ||
# - switch_2 VRF LITE extensions | ||
# interface_2b | ||
# - [vrf_lite] | ||
# - switch_2 VRF LITE extensions | ||
# interface_3a | ||
# - [merged, vrf_lite] | ||
# - switch_3 non-vrf-lite capable switch | ||
# | ||
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 capable | ||
switch_3 = bgw_1 | ||
elif nd_role == "scale": | ||
pass | ||
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, | ||
"testcase": nd_testcase, | ||
"fabric_1": fabric_1, | ||
"fabric_2": fabric_2, | ||
"fabric_3": fabric_3, | ||
"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_1a": interface_1a, | ||
"interface_2a": interface_2a, | ||
"interface_2b": interface_2b, | ||
"interface_3a": interface_3a, | ||
}, | ||
}, | ||
"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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
# 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 ../../files/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 | ||
# | ||
# | ||
- hosts: dcnm | ||
gather_facts: no | ||
connection: ansible.netcommon.httpapi | ||
# Uncomment and modify if not using dynamic_inventory.py | ||
# See the individual test yaml files for a description of | ||
# how each var below is used in each test. Some tests, | ||
# for example, do not use interface_1. | ||
# vars: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! I've updated it to include all the vars. |
||
# fabric_1: f1 | ||
# switch_1: 10.1.1.2 | ||
# switch_2: 10.1.1.3 | ||
# switch_3: 10.1.1.4 | ||
# interface_1: Ethernet1/1 | ||
# interface_2: Ethernet1/2 | ||
# interface_3: Ethernet1/3 | ||
## Uncomment ONE of the following testcases | ||
# testcase: deleted | ||
# testcase: merged | ||
# testcase: query | ||
|
||
roles: | ||
- dcnm_vrf |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this!