diff --git a/lib/ansible/modules/network/nxos/nxos_evpn_vni.py b/lib/ansible/modules/network/nxos/nxos_evpn_vni.py index b540a46ccab..c0bbf26ae98 100644 --- a/lib/ansible/modules/network/nxos/nxos_evpn_vni.py +++ b/lib/ansible/modules/network/nxos/nxos_evpn_vni.py @@ -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) diff --git a/lib/ansible/modules/network/nxos/nxos_rollback.py b/lib/ansible/modules/network/nxos/nxos_rollback.py index 6b6e4122f88..e7911e4442f 100644 --- a/lib/ansible/modules/network/nxos/nxos_rollback.py +++ b/lib/ansible/modules/network/nxos/nxos_rollback.py @@ -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) diff --git a/lib/ansible/modules/network/nxos/nxos_vrf.py b/lib/ansible/modules/network/nxos/nxos_vrf.py index 3f1362bbb9e..50ecdbbe48d 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf.py @@ -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'] diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py index 0ef121cd8a2..a7c9b4e7d38 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py @@ -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\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() - diff --git a/lib/ansible/modules/network/nxos/nxos_vrrp.py b/lib/ansible/modules/network/nxos/nxos_vrrp.py index dd472f50f9e..287e9554120 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrrp.py +++ b/lib/ansible/modules/network/nxos/nxos_vrrp.py @@ -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() - diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_domain.py b/lib/ansible/modules/network/nxos/nxos_vtp_domain.py index 2893b8b2c19..a77498a5b0d 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_domain.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_domain.py @@ -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() - diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_password.py b/lib/ansible/modules/network/nxos/nxos_vtp_password.py index 1d93e532369..f7e161475ac 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_password.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_password.py @@ -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() - diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_version.py b/lib/ansible/modules/network/nxos/nxos_vtp_version.py index 9307c2a04e4..70af78424e5 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_version.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_version.py @@ -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() - diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml index 512d116b703..a7c509cdee0 100644 --- a/test/integration/nxos.yaml +++ b/test/integration/nxos.yaml @@ -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 diff --git a/test/integration/targets/nxos_evpn_vni/defaults/main.yaml b/test/integration/targets/nxos_evpn_vni/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_evpn_vni/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_evpn_vni/meta/main.yml b/test/integration/targets/nxos_evpn_vni/meta/main.yml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_evpn_vni/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_evpn_vni/tasks/cli.yaml b/test/integration/targets/nxos_evpn_vni/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_evpn_vni/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_evpn_vni/tasks/main.yaml b/test/integration/targets/nxos_evpn_vni/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_evpn_vni/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml b/test/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_evpn_vni/tasks/nxapi.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_evpn_vni/tests/cli/sanity.yaml b/test/integration/targets/nxos_evpn_vni/tests/cli/sanity.yaml new file mode 100644 index 00000000000..d2b963cb5bb --- /dev/null +++ b/test/integration/targets/nxos_evpn_vni/tests/cli/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_evpn_vni/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_evpn_vni/tests/nxapi/sanity.yaml new file mode 100644 index 00000000000..83123c493ad --- /dev/null +++ b/test/integration/targets/nxos_evpn_vni/tests/nxapi/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_rollback/defaults/main.yaml b/test/integration/targets/nxos_rollback/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_rollback/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_rollback/meta/main.yml b/test/integration/targets/nxos_rollback/meta/main.yml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_rollback/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_rollback/tasks/cli.yaml b/test/integration/targets/nxos_rollback/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_rollback/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_rollback/tasks/main.yaml b/test/integration/targets/nxos_rollback/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_rollback/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_rollback/tasks/nxapi.yaml b/test/integration/targets/nxos_rollback/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_rollback/tasks/nxapi.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_rollback/tests/cli/sanity.yaml b/test/integration/targets/nxos_rollback/tests/cli/sanity.yaml new file mode 100644 index 00000000000..a03a52631e6 --- /dev/null +++ b/test/integration/targets/nxos_rollback/tests/cli/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_rollback/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_rollback/tests/nxapi/sanity.yaml new file mode 100644 index 00000000000..248568a9647 --- /dev/null +++ b/test/integration/targets/nxos_rollback/tests/nxapi/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vrf/defaults/main.yaml b/test/integration/targets/nxos_vrf/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_vrf/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_vrf/meta/main.yml b/test/integration/targets/nxos_vrf/meta/main.yml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_vrf/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_vrf/tasks/cli.yaml b/test/integration/targets/nxos_vrf/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_vrf/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_vrf/tasks/main.yaml b/test/integration/targets/nxos_vrf/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_vrf/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_vrf/tasks/nxapi.yaml b/test/integration/targets/nxos_vrf/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_vrf/tasks/nxapi.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_vrf/tests/cli/sanity.yaml b/test/integration/targets/nxos_vrf/tests/cli/sanity.yaml new file mode 100644 index 00000000000..8b02508be07 --- /dev/null +++ b/test/integration/targets/nxos_vrf/tests/cli/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vrf/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vrf/tests/nxapi/sanity.yaml new file mode 100644 index 00000000000..ca7bab19599 --- /dev/null +++ b/test/integration/targets/nxos_vrf/tests/nxapi/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vrf_interface/defaults/main.yaml b/test/integration/targets/nxos_vrf_interface/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_vrf_interface/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_vrf_interface/meta/main.yml b/test/integration/targets/nxos_vrf_interface/meta/main.yml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_vrf_interface/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_vrf_interface/tasks/cli.yaml b/test/integration/targets/nxos_vrf_interface/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_vrf_interface/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_vrf_interface/tasks/main.yaml b/test/integration/targets/nxos_vrf_interface/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_vrf_interface/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml b/test/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_vrf_interface/tasks/nxapi.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_vrf_interface/tests/cli/sanity.yaml b/test/integration/targets/nxos_vrf_interface/tests/cli/sanity.yaml new file mode 100644 index 00000000000..d7abe2b6f7f --- /dev/null +++ b/test/integration/targets/nxos_vrf_interface/tests/cli/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vrf_interface/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vrf_interface/tests/nxapi/sanity.yaml new file mode 100644 index 00000000000..162d000406a --- /dev/null +++ b/test/integration/targets/nxos_vrf_interface/tests/nxapi/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vrrp/defaults/main.yaml b/test/integration/targets/nxos_vrrp/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_vrrp/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_vrrp/meta/main.yml b/test/integration/targets/nxos_vrrp/meta/main.yml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_vrrp/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_vrrp/tasks/cli.yaml b/test/integration/targets/nxos_vrrp/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_vrrp/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_vrrp/tasks/main.yaml b/test/integration/targets/nxos_vrrp/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_vrrp/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_vrrp/tasks/nxapi.yaml b/test/integration/targets/nxos_vrrp/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_vrrp/tasks/nxapi.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_vrrp/tests/cli/sanity.yaml b/test/integration/targets/nxos_vrrp/tests/cli/sanity.yaml new file mode 100644 index 00000000000..dc82e8caaff --- /dev/null +++ b/test/integration/targets/nxos_vrrp/tests/cli/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vrrp/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vrrp/tests/nxapi/sanity.yaml new file mode 100644 index 00000000000..afdd9af64e4 --- /dev/null +++ b/test/integration/targets/nxos_vrrp/tests/nxapi/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vtp_domain/defaults/main.yaml b/test/integration/targets/nxos_vtp_domain/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_vtp_domain/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_vtp_domain/meta/main.yml b/test/integration/targets/nxos_vtp_domain/meta/main.yml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_vtp_domain/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_vtp_domain/tasks/cli.yaml b/test/integration/targets/nxos_vtp_domain/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_vtp_domain/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_vtp_domain/tasks/main.yaml b/test/integration/targets/nxos_vtp_domain/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_vtp_domain/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml b/test/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_vtp_domain/tasks/nxapi.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_vtp_domain/tests/cli/sanity.yaml b/test/integration/targets/nxos_vtp_domain/tests/cli/sanity.yaml new file mode 100644 index 00000000000..5454ddebad5 --- /dev/null +++ b/test/integration/targets/nxos_vtp_domain/tests/cli/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vtp_domain/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vtp_domain/tests/nxapi/sanity.yaml new file mode 100644 index 00000000000..377fae6976a --- /dev/null +++ b/test/integration/targets/nxos_vtp_domain/tests/nxapi/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vtp_password/defaults/main.yaml b/test/integration/targets/nxos_vtp_password/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_vtp_password/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_vtp_password/meta/main.yml b/test/integration/targets/nxos_vtp_password/meta/main.yml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_vtp_password/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_vtp_password/tasks/cli.yaml b/test/integration/targets/nxos_vtp_password/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_vtp_password/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_vtp_password/tasks/main.yaml b/test/integration/targets/nxos_vtp_password/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_vtp_password/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_vtp_password/tasks/nxapi.yaml b/test/integration/targets/nxos_vtp_password/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_vtp_password/tasks/nxapi.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_vtp_password/tests/cli/sanity.yaml b/test/integration/targets/nxos_vtp_password/tests/cli/sanity.yaml new file mode 100644 index 00000000000..f96cb146c7a --- /dev/null +++ b/test/integration/targets/nxos_vtp_password/tests/cli/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vtp_password/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vtp_password/tests/nxapi/sanity.yaml new file mode 100644 index 00000000000..8851b213bee --- /dev/null +++ b/test/integration/targets/nxos_vtp_password/tests/nxapi/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vtp_version/defaults/main.yaml b/test/integration/targets/nxos_vtp_version/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_vtp_version/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_vtp_version/meta/main.yml b/test/integration/targets/nxos_vtp_version/meta/main.yml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_vtp_version/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_vtp_version/tasks/cli.yaml b/test/integration/targets/nxos_vtp_version/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_vtp_version/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_vtp_version/tasks/main.yaml b/test/integration/targets/nxos_vtp_version/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_vtp_version/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_vtp_version/tasks/nxapi.yaml b/test/integration/targets/nxos_vtp_version/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_vtp_version/tasks/nxapi.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_vtp_version/tests/cli/sanity.yaml b/test/integration/targets/nxos_vtp_version/tests/cli/sanity.yaml new file mode 100644 index 00000000000..6655cacc000 --- /dev/null +++ b/test/integration/targets/nxos_vtp_version/tests/cli/sanity.yaml @@ -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" diff --git a/test/integration/targets/nxos_vtp_version/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vtp_version/tests/nxapi/sanity.yaml new file mode 100644 index 00000000000..475f6eab20d --- /dev/null +++ b/test/integration/targets/nxos_vtp_version/tests/nxapi/sanity.yaml @@ -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" diff --git a/test/units/modules/network/nxos/test_nxos_vrf.py b/test/units/modules/network/nxos/test_nxos_vrf.py index 71a984f105d..71b072476e3 100644 --- a/test/units/modules/network/nxos/test_nxos_vrf.py +++ b/test/units/modules/network/nxos/test_nxos_vrf.py @@ -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