Add integration tests and fix nxos providers (#26913)

* fix issues with python3.x

* Add integration testa and fix for nxos_evpn_vni

* add nxos_evpn_vni to nxos.yaml

* fix get_vtp_config()

* add new integration tests

* fix rollback

* add integration test files
pull/27378/head
saichint 7 years ago committed by Nathaniel Case
parent cee9b08e70
commit 9b9a8749da

@ -297,9 +297,10 @@ def main():
else:
candidate = CustomNetworkConfig(indent=3)
candidate.add(commands, parents=parents)
candidate = candidate.items_text()
load_config(module, candidate)
results['changed'] = True
results['commands'] = candidate.items_text()
results['commands'] = candidate
else:
results['commands'] = []
module.exit_json(**results)

@ -83,12 +83,20 @@ from ansible.module_utils.basic import AnsibleModule
def checkpoint(filename, module):
commands = ['terminal dont-ask', 'checkpoint file %s' % filename]
commands = [{
'command': 'terminal dont-ask',
'output': 'text', }, {
'command': 'checkpoint file %s' % filename,
'output': 'text',
}]
run_commands(module, commands)
def rollback(filename, module):
commands = ['rollback running-config file %s' % filename]
commands = [{
'command': 'rollback running-config file %s' % filename,
'output': 'text',
}]
run_commands(module, commands)

@ -104,12 +104,14 @@ from ansible.module_utils.basic import AnsibleModule
def execute_show_command(command, module):
transport = module.params['transport']
if transport == 'cli':
if 'show run' not in command:
command += ' | json'
cmds = [command]
if 'show run' not in command:
output = 'json'
else:
output = 'text'
cmds = [{
'command': command,
'output': output,
}]
body = run_commands(module, cmds)
return body
@ -222,7 +224,6 @@ def main():
check_args(module, warnings)
results = dict(changed=False, warnings=warnings)
vrf = module.params['vrf']
admin_state = module.params['admin_state'].lower()
description = module.params['description']

@ -101,23 +101,24 @@ changed:
'''
import re
from ansible.module_utils.nxos import get_config, load_config, run_commands
from ansible.module_utils.nxos import load_config, run_commands
from ansible.module_utils.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
WARNINGS = []
def execute_show_command(command, module, command_type='cli_show'):
if module.params['transport'] == 'cli':
if 'show run' not in command:
command += ' | json'
cmds = [command]
body = run_commands(module, cmds)
elif module.params['transport'] == 'nxapi':
cmds = [command]
body = run_commands(module, cmds)
def execute_show_command(command, module, command_type='cli_show'):
if 'show run' not in command:
output = 'json'
else:
output = 'text'
cmds = [{
'command': command,
'output': output,
}]
body = run_commands(module, cmds)
return body
@ -174,9 +175,6 @@ def get_interface_info(interface, module):
if not interface.startswith('loopback'):
interface = interface.capitalize()
interface_type = get_interface_type(interface)
intf_module = re.split('\d+', interface)[0]
intf_name = interface_type + interface.split(intf_module)[1]
command = 'show run | section interface.{0}'.format(interface)
vrf_regex = ".*vrf\s+member\s+(?P<vrf>\S+).*"
@ -227,7 +225,6 @@ def main():
warnings = list()
check_args(module, warnings)
vrf = module.params['vrf']
interface = module.params['interface'].lower()
state = module.params['state']
@ -305,4 +302,3 @@ def main():
if __name__ == '__main__':
main()

@ -137,21 +137,22 @@ changed:
type: boolean
sample: true
'''
import re
from ansible.module_utils.nxos import get_config, load_config, run_commands
from ansible.module_utils.nxos import load_config, run_commands
from ansible.module_utils.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
def execute_show_command(command, module, command_type='cli_show'):
if module.params['transport'] == 'cli':
command += ' | json'
cmds = [command]
body = run_commands(module, cmds)
elif module.params['transport'] == 'nxapi':
cmds = [command]
body = run_commands(module, cmds)
def execute_show_command(command, module):
if 'show run' not in command:
output = 'json'
else:
output = 'text'
cmds = [{
'command': command,
'output': output,
}]
body = run_commands(module, cmds)
return body
@ -167,7 +168,6 @@ def apply_key_map(key_map, table):
new_dict[new_key] = value
return new_dict
def get_interface_type(interface):
if interface.upper().startswith('ET'):
return 'ethernet'
@ -223,7 +223,7 @@ def get_interface_mode(interface, intf_type, module):
def get_vrr_status(group, module, interface):
command = 'show run all | section interface.{0}$'.format(interface)
body = execute_show_command(command, module, command_type='cli_show_ascii')[0]
body = execute_show_command(command, module)[0]
vrf_index = None
admin_state = 'shutdown'
@ -373,7 +373,6 @@ def main():
warnings = list()
check_args(module, warnings)
state = module.params['state']
interface = module.params['interface'].lower()
group = module.params['group']
@ -451,4 +450,3 @@ def main():
if __name__ == '__main__':
main()

@ -86,22 +86,22 @@ changed:
'''
from ansible.module_utils.nxos import get_config, load_config, run_commands
from ansible.module_utils.nxos import load_config, run_commands
from ansible.module_utils.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
import re
def execute_show_command(command, module, command_type='cli_show'):
if module.params['transport'] == 'cli':
if 'status' not in command:
command += ' | json'
cmds = [command]
body = run_commands(module, cmds)
elif module.params['transport'] == 'nxapi':
cmds = [command]
body = run_commands(module, cmds)
if 'status' not in command:
output = 'json'
else:
output = 'text'
cmds = [{
'command': command,
'output': output,
}]
body = run_commands(module, cmds)
return body
@ -117,9 +117,8 @@ def flatten_list(command_lists):
def get_vtp_config(module):
command = 'show vtp status'
body = execute_show_command(
command, module, command_type='cli_show_ascii')[0]
command, module)[0]
vtp_parsed = {}
if body:
@ -169,7 +168,6 @@ def main():
warnings = list()
check_args(module, warnings)
domain = module.params['domain']
existing = get_vtp_config(module)
@ -209,4 +207,3 @@ def main():
if __name__ == '__main__':
main()

@ -103,22 +103,22 @@ changed:
sample: true
'''
from ansible.module_utils.nxos import get_config, load_config, run_commands
from ansible.module_utils.nxos import load_config, run_commands
from ansible.module_utils.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
import re
def execute_show_command(command, module, command_type='cli_show'):
if module.params['transport'] == 'cli':
if 'show run' not in command:
command += ' | json'
cmds = [command]
body = run_commands(module, cmds)
elif module.params['transport'] == 'nxapi':
cmds = [command]
body = run_commands(module, cmds)
if 'status' not in command:
output = 'json'
else:
output = 'text'
cmds = [{
'command': command,
'output': output,
}]
body = run_commands(module, cmds)
return body
@ -149,7 +149,7 @@ def get_vtp_config(module):
command = 'show vtp status'
body = execute_show_command(
command, module, command_type='cli_show_ascii')[0]
command, module)[0]
vtp_parsed = {}
if body:
@ -201,7 +201,6 @@ def main():
warnings = list()
check_args(module, warnings)
vtp_password = module.params['vtp_password'] or None
state = module.params['state']
@ -266,4 +265,3 @@ def main():
if __name__ == '__main__':
main()

@ -81,7 +81,7 @@ changed:
type: boolean
sample: true
'''
from ansible.module_utils.nxos import get_config, load_config, run_commands
from ansible.module_utils.nxos import load_config, run_commands
from ansible.module_utils.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
@ -91,15 +91,15 @@ import re
def execute_show_command(command, module, command_type='cli_show'):
if module.params['transport'] == 'cli':
if 'status' not in command:
command += ' | json'
cmds = [command]
body = run_commands(module, cmds)
elif module.params['transport'] == 'nxapi':
cmds = [command]
body = run_commands(module, cmds)
if 'status' not in command:
output = 'json'
else:
output = 'text'
cmds = [{
'command': command,
'output': output,
}]
body = run_commands(module, cmds)
return body
@ -115,9 +115,8 @@ def flatten_list(command_lists):
def get_vtp_config(module):
command = 'show vtp status'
body = execute_show_command(
command, module, command_type='cli_show_ascii')[0]
command, module)[0]
vtp_parsed = {}
if body:
@ -167,7 +166,6 @@ def main():
warnings = list()
check_args(module, warnings)
version = module.params['version']
existing = get_vtp_config(module)
@ -207,4 +205,3 @@ def main():
if __name__ == '__main__':
main()

@ -60,6 +60,15 @@
failed_modules: "{{ failed_modules }} + [ 'nxos_nxapi' ]"
test_failed: true
- block:
- include_role:
name: nxos_evpn_vni
when: "limit_to in ['*', 'nxos_evpn_vni']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_evpn_vni' ]"
test_failed: true
- block:
- include_role:
name: nxos_evpn_global
@ -141,6 +150,69 @@
failed_modules: "{{ failed_modules }} + [ 'nxos_acl_interface' ]"
test_failed: true
- block:
- include_role:
name: nxos_vrf
when: "limit_to in ['*', 'nxos_vrf']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_vrf' ]"
test_failed: true
- block:
- include_role:
name: nxos_vrf_interface
when: "limit_to in ['*', 'nxos_vrf_interface']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_vrf_interface' ]"
test_failed: true
- block:
- include_role:
name: nxos_vrrp
when: "limit_to in ['*', 'nxos_vrrp']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_vrrp' ]"
test_failed: true
- block:
- include_role:
name: nxos_vtp_domain
when: "limit_to in ['*', 'nxos_vtp_domain']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_vtp_domain' ]"
test_failed: true
- block:
- include_role:
name: nxos_vtp_password
when: "limit_to in ['*', 'nxos_vtp_password']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_vtp_password' ]"
test_failed: true
- block:
- include_role:
name: nxos_vtp_version
when: "limit_to in ['*', 'nxos_vtp_version']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_vtp_version' ]"
test_failed: true
- block:
- include_role:
name: nxos_rollback
when: "limit_to in ['*', 'nxos_rollback']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_rollback' ]"
test_failed: true
- block:
- include_role:
name: nxos_logging

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

@ -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,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { 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,74 @@
---
- debug: msg="START TRANSPORT:CLI nxos_evpn_vni sanity test"
- name: "Setup"
nxos_config: &remove_evpn
lines: no nv overlay evpn
provider: "{{ cli }}"
match: none
ignore_errors: yes
- block:
- name: "Enable feature BGP"
nxos_feature:
feature: bgp
state: enabled
provider: "{{ cli }}"
- name: "Enable nv overlay evpn"
nxos_config:
lines: nv overlay evpn
provider: "{{ cli }}"
match: none
- name: "Configure nxos_evpn_vni"
nxos_evpn_vni: &evpn_vni
vni: 6000
route_distinguisher: "60:10"
route_target_import:
- "5000:10"
- "4100:100"
route_target_export: auto
provider: "{{ cli }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_evpn_vni: *evpn_vni
register: result
- assert: &false
that:
- "result.changed == false"
- name: "remove nxos_evpn_vni"
nxos_evpn_vni: &rvni
vni: 6000
state: absent
provider: "{{ cli }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_evpn_vni: *rvni
register: result
- assert: *false
always:
- name: "Remove nv overlay evpn"
nxos_config: *remove_evpn
ignore_errors: yes
- name: "Disable feature bgp"
nxos_feature:
feature: bgp
state: disabled
provider: "{{ cli }}"
ignore_errors: yes
- debug: msg="END TRANSPORT:CLI nxos_evpn_vni sanity test"

@ -0,0 +1,74 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_evpn_vni sanity test"
- name: "Setup"
nxos_config: &remove_evpn
lines: no nv overlay evpn
provider: "{{ nxapi }}"
match: none
ignore_errors: yes
- block:
- name: "Enable feature BGP"
nxos_feature:
feature: bgp
state: enabled
provider: "{{ nxapi }}"
- name: "Enable nv overlay evpn"
nxos_config:
lines: nv overlay evpn
provider: "{{ nxapi }}"
match: none
- name: "Configure nxos_evpn_vni"
nxos_evpn_vni: &evpn_vni
vni: 6000
route_distinguisher: "60:10"
route_target_import:
- "5000:10"
- "4100:100"
route_target_export: auto
provider: "{{ nxapi }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_evpn_vni: *evpn_vni
register: result
- assert: &false
that:
- "result.changed == false"
- name: "remove nxos_evpn_vni"
nxos_evpn_vni: &rvni
vni: 6000
state: absent
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_evpn_vni: *rvni
register: result
- assert: *false
always:
- name: "Remove nv overlay evpn"
nxos_config: *remove_evpn
ignore_errors: yes
- name: "Disable feature bgp"
nxos_feature:
feature: bgp
state: disabled
provider: "{{ nxapi }}"
ignore_errors: yes
- debug: msg="END TRANSPORT:NXAPI nxos_evpn_vni sanity test"

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

@ -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,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { 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,29 @@
---
- debug: msg="START TRANSPORT:CLI nxos_rollback sanity test"
- name: delete existing checkpoint file
nxos_config: &delete
commands:
- terminal dont-ask
- delete backup.cfg
match: none
provider: "{{ cli }}"
ignore_errors: yes
- name: Create checkpoint file
nxos_rollback:
checkpoint_file: backup.cfg
timeout: 300
provider: "{{ cli }}"
- name: rollback to the previously created checkpoint file
nxos_rollback:
rollback_to: backup.cfg
timeout: 300
provider: "{{ cli }}"
- name: cleanup checkpoint file
nxos_config: *delete
ignore_errors: yes
- debug: msg="END TRANSPORT:CLI nxos_rollback sanity test"

@ -0,0 +1,29 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_rollback sanity test"
- name: delete existing checkpoint file
nxos_config: &delete
commands:
- terminal dont-ask
- delete backup.cfg
match: none
provider: "{{ nxapi }}"
ignore_errors: yes
- name: Create checkpoint file
nxos_rollback:
checkpoint_file: backup.cfg
timeout: 300
provider: "{{ nxapi }}"
- name: rollback to the previously created checkpoint file
nxos_rollback:
rollback_to: backup.cfg
timeout: 300
provider: "{{ nxapi }}"
- name: cleanup checkpoint file
nxos_config: *delete
ignore_errors: yes
- debug: msg="END TRANSPORT:NXAPI nxos_rollback sanity test"

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

@ -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,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { 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,15 @@
---
- debug: msg="START TRANSPORT:CLI nxos_vrf sanity test"
- name: Ensure ntc VRF exists on switch
nxos_vrf:
vrf: ntc
provider: "{{ cli }}"
- name: Ensure ntc VRF does not exist on switch
nxos_vrf:
vrf: ntc
state: absent
provider: "{{ cli }}"
- debug: msg="END TRANSPORT:CLI nxos_vrf sanity test"

@ -0,0 +1,15 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_vrf sanity test"
- name: Ensure ntc VRF exists on switch
nxos_vrf:
vrf: ntc
provider: "{{ nxapi }}"
- name: Ensure ntc VRF does not exist on switch
nxos_vrf:
vrf: ntc
state: absent
provider: "{{ nxapi }}"
- debug: msg="END TRANSPORT:NXAPI nxos_vrf sanity test"

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

@ -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,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { 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,39 @@
---
- debug: msg="START TRANSPORT:CLI nxos_vrf_interface sanity test"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- block:
- name: put interface in L3
nxos_config:
commands:
- no switchport
parents:
- "interface {{ intname }}"
match: none
provider: "{{ cli }}"
- name: Ensure vrf ntc exists on interface
nxos_vrf_interface:
vrf: ntc
interface: "{{ intname }}"
state: present
provider: "{{ cli }}"
- name: Ensure ntc VRF does not exist on interface
nxos_vrf_interface:
vrf: ntc
interface: "{{ intname }}"
state: absent
provider: "{{ cli }}"
always:
- name: put interface in default mode
nxos_config:
lines: "default interface {{ intname }}"
provider: "{{ cli }}"
match: none
ignore_errors: yes
- debug: msg="END TRANSPORT:CLI nxos_vrf_interface sanity test"

@ -0,0 +1,39 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_vrf_interface sanity test"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- block:
- name: put interface in L3
nxos_config:
commands:
- no switchport
parents:
- "interface {{ intname }}"
match: none
provider: "{{ nxapi }}"
- name: Ensure vrf ntc exists on interface
nxos_vrf_interface:
vrf: ntc
interface: "{{ intname }}"
state: present
provider: "{{ nxapi }}"
- name: Ensure ntc VRF does not exist on interface
nxos_vrf_interface:
vrf: ntc
interface: "{{ intname }}"
state: absent
provider: "{{ nxapi }}"
always:
- name: put interface in default mode
nxos_config:
lines: "default interface {{ intname }}"
provider: "{{ nxapi }}"
match: none
ignore_errors: yes
- debug: msg="END TRANSPORT:NXAPI nxos_vrf_interface sanity test"

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

@ -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,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { 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,72 @@
---
- debug: msg="START TRANSPORT:CLI nxos_vrrp sanity test"
- block:
- name: "Enable interface-vlan"
nxos_feature:
feature: interface-vlan
state: enabled
provider: "{{ cli }}"
- name: "Enable vrrp"
nxos_feature:
feature: vrrp
state: enabled
provider: "{{ cli }}"
- name: "create int vlan 10"
nxos_interface:
interface: "vlan 10"
state: present
provider: "{{ cli }}"
- name: Ensure vrrp group 100 and vip 10.1.100.1 is on vlan10
nxos_vrrp:
interface: vlan10
group: 100
vip: 10.1.100.1
provider: "{{ cli }}"
- name: Ensure removal of the vrrp group config
# vip is required to ensure the user knows what they are removing
nxos_vrrp: &remove
interface: vlan10
group: 100
vip: 10.1.100.1
state: absent
provider: "{{ cli }}"
- pause:
seconds: 30
- name: Re-config with more params
nxos_vrrp:
interface: vlan10
group: 100
vip: 10.1.100.1
preempt: false
priority: 130
authentication: AUTHKEY
provider: "{{ cli }}"
always:
- name: remove vrrp
nxos_vrrp: *remove
ignore_errors: yes
- name: "Disable interface-vlan"
nxos_config:
commands:
- no feature interface-vlan
provider: "{{ cli }}"
match: none
ignore_errors: yes
- name: "Disable vrrp"
nxos_feature:
feature: vrrp
state: disabled
provider: "{{ cli }}"
ignore_errors: yes
- debug: msg="END TRANSPORT:CLI nxos_vrrp sanity test"

@ -0,0 +1,70 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_vrrp sanity test"
- block:
- name: "Enable interface-vlan"
nxos_feature:
feature: interface-vlan
state: enabled
provider: "{{ nxapi }}"
- name: "Enable vrrp"
nxos_feature:
feature: vrrp
state: enabled
provider: "{{ nxapi }}"
- name: "create int vlan 10"
nxos_config:
commands:
- interface vlan 10
match: none
provider: "{{ nxapi }}"
- name: Ensure vrrp group 100 and vip 10.1.100.1 is on vlan10
nxos_vrrp:
interface: vlan10
group: 100
vip: 10.1.100.1
provider: "{{ nxapi }}"
- name: Ensure removal of the vrrp group config
# vip is required to ensure the user knows what they are removing
nxos_vrrp: &remove
interface: vlan10
group: 100
vip: 10.1.100.1
state: absent
provider: "{{ nxapi }}"
- name: Re-config with more params
nxos_vrrp:
interface: vlan10
group: 100
vip: 10.1.100.1
preempt: false
priority: 130
authentication: AUTHKEY
provider: "{{ nxapi }}"
always:
- name: remove vrrp
nxos_vrrp: *remove
ignore_errors: yes
- name: "Disable interface-vlan"
nxos_config:
commands:
- no feature interface-vlan
provider: "{{ nxapi }}"
match: none
ignore_errors: yes
- name: "Disable vrrp"
nxos_feature:
feature: vrrp
state: disabled
provider: "{{ nxapi }}"
ignore_errors: yes
- debug: msg="END TRANSPORT:NXAPI nxos_vrrp sanity test"

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

@ -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,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { 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,23 @@
---
- debug: msg="START TRANSPORT:CLI nxos_vtp_domain sanity test"
- block:
- name: enable feature vtp
nxos_feature:
feature: vtp
state: enabled
provider: "{{ cli }}"
- name: configure vtp domain
nxos_vtp_domain:
domain: ntc
provider: "{{ cli }}"
always:
- name: disable feature vtp
nxos_feature:
feature: vtp
state: disabled
provider: "{{ cli }}"
- debug: msg="END TRANSPORT:CLI nxos_vtp_domain sanity test"

@ -0,0 +1,23 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_vtp_domain sanity test"
- block:
- name: enable feature vtp
nxos_feature:
feature: vtp
state: enabled
provider: "{{ nxapi }}"
- name: configure vtp domain
nxos_vtp_domain:
domain: ntc
provider: "{{ nxapi }}"
always:
- name: disable feature vtp
nxos_feature:
feature: vtp
state: disabled
provider: "{{ nxapi }}"
- debug: msg="END TRANSPORT:NXAPI nxos_vtp_domain sanity test"

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

@ -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,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { 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,30 @@
---
- debug: msg="START TRANSPORT:CLI nxos_vtp_password sanity test"
- block:
- name: enable feature vtp
nxos_feature:
feature: vtp
state: enabled
provider: "{{ cli }}"
- name: configure vtp password
nxos_vtp_password:
password: ntc
state: present
provider: "{{ cli }}"
- name: remove vtp password
nxos_vtp_password:
password: ntc
state: absent
provider: "{{ cli }}"
always:
- name: disable feature vtp
nxos_feature:
feature: vtp
state: disabled
provider: "{{ cli }}"
- debug: msg="END TRANSPORT:CLI nxos_vtp_password sanity test"

@ -0,0 +1,30 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_vtp_password sanity test"
- block:
- name: enable feature vtp
nxos_feature:
feature: vtp
state: enabled
provider: "{{ nxapi }}"
- name: configure vtp password
nxos_vtp_password:
password: ntc
state: present
provider: "{{ nxapi }}"
- name: remove vtp password
nxos_vtp_password:
password: ntc
state: absent
provider: "{{ nxapi }}"
always:
- name: disable feature vtp
nxos_feature:
feature: vtp
state: disabled
provider: "{{ nxapi }}"
- debug: msg="END TRANSPORT:NXAPI nxos_vtp_password sanity test"

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

@ -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,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { 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,23 @@
---
- debug: msg="START TRANSPORT:CLI nxos_vtp_version sanity test"
- block:
- name: enable feature vtp
nxos_feature:
feature: vtp
state: enabled
provider: "{{ cli }}"
- name: configure vtp version
nxos_vtp_version:
version: 2
provider: "{{ cli }}"
always:
- name: disable feature vtp
nxos_feature:
feature: vtp
state: disabled
provider: "{{ cli }}"
- debug: msg="END TRANSPORT:CLI nxos_vtp_version sanity test"

@ -0,0 +1,23 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_vtp_version sanity test"
- block:
- name: enable feature vtp
nxos_feature:
feature: vtp
state: enabled
provider: "{{ nxapi }}"
- name: configure vtp version
nxos_vtp_version:
version: 2
provider: "{{ nxapi }}"
always:
- name: disable feature vtp
nxos_feature:
feature: vtp
state: disabled
provider: "{{ nxapi }}"
- debug: msg="END TRANSPORT:NXAPI nxos_vtp_version sanity test"

@ -47,6 +47,8 @@ class TestNxosVrfModule(TestNxosModule):
output = list()
for command in commands:
if isinstance(command, dict):
command = command['command']
filename = str(command).split(' | ')[0].replace(' ', '_')
output.append(load_fixture('nxos_vrf', filename))
return output

Loading…
Cancel
Save