mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix nxos_overlay_global networking modules (#28943)
This commit is contained in:
parent
a09a231be7
commit
7292dd20ed
14 changed files with 293 additions and 13 deletions
|
@ -95,24 +95,23 @@ def get_commands(module, existing, proposed, candidate):
|
||||||
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed)
|
||||||
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing)
|
||||||
|
|
||||||
for key, value in proposed_commands.items():
|
for key, proposed in proposed_commands.items():
|
||||||
if value == 'default':
|
|
||||||
existing_value = existing_commands.get(key)
|
existing_value = existing_commands.get(key)
|
||||||
if existing_value:
|
if proposed == 'default' and existing_value:
|
||||||
commands.append('no {0} {1}'.format(key, existing_value))
|
commands.append('no {0} {1}'.format(key, existing_value))
|
||||||
else:
|
elif 'anycast-gateway-mac' in key and proposed != 'default':
|
||||||
if 'anycast-gateway-mac' in key:
|
proposed = normalize_mac(proposed, module)
|
||||||
value = normalize_mac(value, module)
|
existing_value = normalize_mac(existing_value, module)
|
||||||
existing_value = existing_commands.get(key)
|
if proposed != existing_value:
|
||||||
if existing_value and value != existing_value:
|
command = '{0} {1}'.format(key, proposed)
|
||||||
command = '{0} {1}'.format(key, value)
|
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
if commands:
|
if commands:
|
||||||
candidate.add(commands, parents=[])
|
candidate.add(commands, parents=[])
|
||||||
|
|
||||||
|
|
||||||
def normalize_mac(proposed_mac, module):
|
def normalize_mac(proposed_mac, module):
|
||||||
|
if proposed_mac is None:
|
||||||
|
return ''
|
||||||
try:
|
try:
|
||||||
if '-' in proposed_mac:
|
if '-' in proposed_mac:
|
||||||
splitted_mac = proposed_mac.split('-')
|
splitted_mac = proposed_mac.split('-')
|
||||||
|
|
|
@ -345,6 +345,14 @@
|
||||||
when: "limit_to in ['*', 'nxos_bgp_neighbor_af']"
|
when: "limit_to in ['*', 'nxos_bgp_neighbor_af']"
|
||||||
rescue:
|
rescue:
|
||||||
- set_fact: test_failed=true
|
- set_fact: test_failed=true
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- include_role:
|
||||||
|
name: nxos_overlay_global
|
||||||
|
when: "limit_to in ['*', 'nxos_overlay_global']"
|
||||||
|
rescue:
|
||||||
|
- set_fact: test_failed=true
|
||||||
|
|
||||||
###########
|
###########
|
||||||
- debug: var=failed_modules
|
- debug: var=failed_modules
|
||||||
when: test_failed
|
when: test_failed
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
nxos_interface:
|
nxos_interface:
|
||||||
interface: Loopback1
|
interface: Loopback1
|
||||||
state: present
|
state: present
|
||||||
|
description: 'Configured by Ansible - Layer3'
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
nxos_interface:
|
nxos_interface:
|
||||||
interface: Loopback1
|
interface: Loopback1
|
||||||
state: present
|
state: present
|
||||||
|
description: 'Configured by Ansible - Layer3'
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- prepare_nxos_tests
|
15
test/integration/targets/nxos_overlay_global/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_overlay_global/tasks/cli.yaml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
- name: collect all cli test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/cli"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: run test case
|
||||||
|
include: "{{ test_case_to_run }}"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
# Use block to ensure that both cli and nxapi tests
|
||||||
|
# will run even if there are failures or errors.
|
||||||
|
- block:
|
||||||
|
- { include: cli.yaml, tags: ['cli'] }
|
||||||
|
always:
|
||||||
|
- { include: nxapi.yaml, tags: ['nxapi'] }
|
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
- name: collect all nxapi test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/nxapi"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: enable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- feature nxapi
|
||||||
|
- nxapi http port 80
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
|
- name: run test case
|
||||||
|
include: "{{ test_case_to_run }}"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: disable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- no feature nxapi
|
||||||
|
provider: "{{ cli }}"
|
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
- name: "Unconfigure VDC setting limit-resource module-type f3"
|
||||||
|
nxos_config:
|
||||||
|
commands:
|
||||||
|
- 'terminal dont-ask ; vdc {{ vdcid }} ; no limit-resource module-type f3'
|
||||||
|
match: none
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Previous command is asynchronous and can take a while. Allow time for it to complete
|
||||||
|
pause:
|
||||||
|
seconds: 45
|
||||||
|
|
||||||
|
- name: "Configure VDC setting allocate interface unallocated-interfaces"
|
||||||
|
nxos_config: &allocate
|
||||||
|
commands:
|
||||||
|
- 'terminal dont-ask ; vdc {{ vdcid }} ; allocate interface unallocated-interfaces'
|
||||||
|
match: none
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Previous command is asynchronous can take a while. Allow time for it to complete
|
||||||
|
pause:
|
||||||
|
seconds: 45
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
- name: "Get default vdc id"
|
||||||
|
nxos_command:
|
||||||
|
commands: ['show vdc current-vdc | json']
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: vdcout
|
||||||
|
|
||||||
|
- set_fact: vdcid="{{ vdcout.stdout_lines[0].name }}"
|
||||||
|
|
||||||
|
- name: "Configure VDC setting limit-resource module-type f3"
|
||||||
|
nxos_config:
|
||||||
|
commands:
|
||||||
|
- "terminal dont-ask ; vdc {{ vdcid }} ; limit-resource module-type f3"
|
||||||
|
match: none
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Previous command is asynchronous and can take a while. Allow time for it to complete
|
||||||
|
pause:
|
||||||
|
seconds: 45
|
||||||
|
|
||||||
|
- name: "Configure VDC setting allocate interface unallocated-interfaces"
|
||||||
|
nxos_config: &allocate
|
||||||
|
commands:
|
||||||
|
- "terminal dont-ask ; vdc {{ vdcid }} ; allocate interface unallocated-interfaces"
|
||||||
|
match: none
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Previous command is asynchronous and can take a while. Allow time for it to complete
|
||||||
|
pause:
|
||||||
|
seconds: 45
|
||||||
|
|
||||||
|
- name: "Configure Additional N7K requiste features"
|
||||||
|
nxos_config:
|
||||||
|
commands:
|
||||||
|
- feature-set fabric
|
||||||
|
- feature fabric forwarding
|
||||||
|
match: none
|
||||||
|
provider: "{{ connection }}"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ cli }}"
|
||||||
|
|
||||||
|
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"
|
|
@ -0,0 +1,104 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_overlay_global sanity test"
|
||||||
|
|
||||||
|
- set_fact: overlay_global_supported="false"
|
||||||
|
- set_fact: overlay_global_supported="true"
|
||||||
|
when: platform | search("N35NG|N7K|^N9K$") or
|
||||||
|
(platform | match("N9k-F") and imagetag | version_compare('F3', 'ne'))
|
||||||
|
|
||||||
|
- debug: msg="Platform {{ platform }} running Image version {{ image_version }} supports nxos_overlay_global"
|
||||||
|
when: overlay_global_supported
|
||||||
|
|
||||||
|
# Setup Block
|
||||||
|
- block:
|
||||||
|
- name: "Enable nv overlay evpn"
|
||||||
|
nxos_evpn_global: &enable_evpn
|
||||||
|
nv_overlay_evpn: true
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
- name: "Apply N7K specific setup config"
|
||||||
|
include: targets/nxos_overlay_global/tasks/platform/n7k/setup.yaml
|
||||||
|
when: platform | match('N7K')
|
||||||
|
|
||||||
|
- name: "Configure Additional N7K requiste features"
|
||||||
|
nxos_config:
|
||||||
|
commands:
|
||||||
|
- feature-set fabric
|
||||||
|
- feature fabric forwarding
|
||||||
|
match: none
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
when: platform | match('N7K')
|
||||||
|
|
||||||
|
- name: "Remove possibly existing mac"
|
||||||
|
nxos_overlay_global:
|
||||||
|
anycast_gateway_mac: "default"
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
when: overlay_global_supported
|
||||||
|
|
||||||
|
# Test execution block
|
||||||
|
- block:
|
||||||
|
|
||||||
|
- name: Configure overlay global
|
||||||
|
nxos_overlay_global: &configure
|
||||||
|
anycast_gateway_mac: "b.b.b"
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &true
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: "Check Idempotence"
|
||||||
|
nxos_overlay_global: *configure
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &false
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
|
||||||
|
- name: Update anycast gateway mac
|
||||||
|
nxos_overlay_global: &update
|
||||||
|
anycast_gateway_mac: "a.a.a"
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Check Idempotence"
|
||||||
|
nxos_overlay_global: *update
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
|
||||||
|
- name: Remove anycast gateway mac
|
||||||
|
nxos_overlay_global: &remove
|
||||||
|
anycast_gateway_mac: "default"
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Check Idempotence"
|
||||||
|
nxos_overlay_global: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
when: overlay_global_supported
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: "Apply N7K specific cleanup config"
|
||||||
|
include: targets/nxos_overlay_global/tasks/platform/n7k/cleanup.yaml
|
||||||
|
when: platform | match('N7K')
|
||||||
|
|
||||||
|
- name: "Disable nv overlay evpn"
|
||||||
|
nxos_evpn_global: &disable_evpn
|
||||||
|
nv_overlay_evpn: false
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
when: overlay_global_supported
|
||||||
|
|
||||||
|
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_overlay_global sanity test"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ nxapi }}"
|
||||||
|
|
||||||
|
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"
|
|
@ -48,6 +48,15 @@
|
||||||
- set_fact: nxos_int2="{{ intdataraw[2].interface }}"
|
- set_fact: nxos_int2="{{ intdataraw[2].interface }}"
|
||||||
- set_fact: nxos_int3="{{ intdataraw[3].interface }}"
|
- set_fact: nxos_int3="{{ intdataraw[3].interface }}"
|
||||||
|
|
||||||
|
# Get image version information for this device
|
||||||
|
- name: "Gather image version info"
|
||||||
|
nxos_command:
|
||||||
|
commands: ['sh version | json']
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: nxos_version_output
|
||||||
|
|
||||||
|
- set_fact: image_version="{{ nxos_version_output.stdout[0]['kickstart_ver_str'] }}"
|
||||||
|
|
||||||
# Get platform information for this device
|
# Get platform information for this device
|
||||||
#
|
#
|
||||||
# Usage in integration test playbook:
|
# Usage in integration test playbook:
|
||||||
|
@ -62,6 +71,7 @@
|
||||||
register: nxos_inventory_output
|
register: nxos_inventory_output
|
||||||
|
|
||||||
- set_fact: platform="{{ nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'][0]['productid'].split('-')[0] }}"
|
- set_fact: platform="{{ nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'][0]['productid'].split('-')[0] }}"
|
||||||
|
- set_fact: chassis_type="{{ nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'][0]['productid'].split('-')[1] }}"
|
||||||
|
|
||||||
# Check if platform is fretta
|
# Check if platform is fretta
|
||||||
- set_fact: fretta={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'FM-R' in row['productid'] %}"true"{% endfor %}
|
- set_fact: fretta={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'FM-R' in row['productid'] %}"true"{% endfor %}
|
||||||
|
@ -74,3 +84,34 @@
|
||||||
# Check if platform is titanium
|
# Check if platform is titanium
|
||||||
- set_fact: titanium={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'NX-OSv' in row['desc']%}"true"{% endfor %}
|
- set_fact: titanium={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'NX-OSv' in row['desc']%}"true"{% endfor %}
|
||||||
when: platform | match("N7K")
|
when: platform | match("N7K")
|
||||||
|
|
||||||
|
# Set platform to N35 for N3k-35xx
|
||||||
|
- set_fact: platform="N35"
|
||||||
|
when: (chassis_type | search("C35"))
|
||||||
|
|
||||||
|
# Set platform to N35NG for N3k-35xx running image version
|
||||||
|
# 7.0(3)I7 or later. NG(Next Gen)
|
||||||
|
- set_fact: platform="N35NG"
|
||||||
|
when: (chassis_type | search("C35")) and image_version | search("7.0\(3\)I7")
|
||||||
|
|
||||||
|
# Create matrix of simple keys based on platform
|
||||||
|
# and image version for use within test playbooks.
|
||||||
|
- set_fact: imagetag=""
|
||||||
|
- set_fact: imagetag="I2"
|
||||||
|
when: image_version | search("7.0\(3\)I2")
|
||||||
|
- set_fact: imagetag="I3"
|
||||||
|
when: image_version | search("7.0\(3\)I3")
|
||||||
|
- set_fact: imagetag="I4"
|
||||||
|
when: image_version | search("7.0\(3\)I4")
|
||||||
|
- set_fact: imagetag="I5"
|
||||||
|
when: image_version | search("7.0\(3\)I5")
|
||||||
|
- set_fact: imagetag="I6"
|
||||||
|
when: image_version | search("7.0\(3\)I6")
|
||||||
|
- set_fact: imagetag="I7"
|
||||||
|
when: image_version | search("7.0\(3\)I7")
|
||||||
|
- set_fact: imagetag="F1"
|
||||||
|
when: image_version | search("7.0\(3\)F1")
|
||||||
|
- set_fact: imagetag="F2"
|
||||||
|
when: image_version | search("7.0\(3\)F2")
|
||||||
|
- set_fact: imagetag="F3"
|
||||||
|
when: image_version | search("7.0\(3\)F3")
|
||||||
|
|
Loading…
Reference in a new issue