diff --git a/lib/ansible/module_utils/network/common/network.py b/lib/ansible/module_utils/network/common/network.py index e76d31e9837..315a663762e 100644 --- a/lib/ansible/module_utils/network/common/network.py +++ b/lib/ansible/module_utils/network/common/network.py @@ -30,12 +30,23 @@ import json from ansible.module_utils._text import to_text, to_native from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, missing_required_lib from ansible.module_utils.connection import Connection, ConnectionError from ansible.module_utils.network.common.netconf import NetconfConnection from ansible.module_utils.network.common.parsing import Cli from ansible.module_utils.six import iteritems +try: + from ansible.module_utils.network.eos import eos + HAS_EOS = True +except ImportError: + HAS_EOS = False + +try: + from ansible.module_utils.network.nxos import nxos + HAS_NXOS = True +except ImportError: + HAS_NXOS = False NET_TRANSPORT_ARGS = dict( host=dict(required=True), @@ -212,7 +223,17 @@ def get_resource_connection(module): capabilities = get_capabilities(module) network_api = capabilities.get('network_api') - if network_api in ('cliconf', 'nxapi', 'eapi', 'exosapi'): + if network_api == 'eapi': + if HAS_EOS: + module._connection = eos.get_connection(module) + else: + module.fail_json(msg=missing_required_lib("collection arista.eos")) + elif network_api == 'nxapi': + if HAS_NXOS: + module._connection = nxos.get_connection(module) + else: + module.fail_json(msg=missing_required_lib("collection cisco.nxos")) + elif network_api in ('cliconf', 'exosapi'): module._connection = Connection(module._socket_path) elif network_api == 'netconf': module._connection = NetconfConnection(module._socket_path) diff --git a/lib/ansible/module_utils/network/eos/eos.py b/lib/ansible/module_utils/network/eos/eos.py index 22c675153e1..6721c0e54cd 100644 --- a/lib/ansible/module_utils/network/eos/eos.py +++ b/lib/ansible/module_utils/network/eos/eos.py @@ -418,6 +418,9 @@ class HttpApi: self._session_support = self._connection.supports_sessions() return self._session_support + def get(self, command, **kwargs): + return self._connection.send_request(command) + def run_commands(self, commands, check_rc=True): """Runs list of commands on remote device and returns results """ @@ -511,7 +514,7 @@ class HttpApi: """ return self.edit_config(config, commit, replace) - def edit_config(self, config, commit=False, replace=False): + def edit_config(self, config, commit=True, replace=False): """Loads the configuration onto the remote devices If the device doesn't support configuration sessions, this will diff --git a/lib/ansible/module_utils/network/eos/facts/legacy/base.py b/lib/ansible/module_utils/network/eos/facts/legacy/base.py index 50bb82e8499..6093dedd094 100644 --- a/lib/ansible/module_utils/network/eos/facts/legacy/base.py +++ b/lib/ansible/module_utils/network/eos/facts/legacy/base.py @@ -130,6 +130,13 @@ class Interfaces(FactsBase): self.facts['all_ipv6_addresses'] = list() data = self.responses[0] + if not isinstance(data, dict): + # EAPI kills the whole request on an error. + self.COMMANDS.pop() + super(Interfaces, self).populate() + self.responses.append(None) + data = self.responses[0] + self.facts['interfaces'] = self.populate_interfaces(data) data = self.responses[1] diff --git a/lib/ansible/module_utils/network/eos/facts/vlans/vlans.py b/lib/ansible/module_utils/network/eos/facts/vlans/vlans.py index 0e01b6c216d..63d21b169b5 100644 --- a/lib/ansible/module_utils/network/eos/facts/vlans/vlans.py +++ b/lib/ansible/module_utils/network/eos/facts/vlans/vlans.py @@ -63,8 +63,7 @@ class VlansFacts(object): if obj: objs.extend(obj) - ansible_facts['ansible_network_resources'].pop('vlans', None) - facts = {} + facts = {'vlans': []} if objs: params = utils.validate_config(self.argument_spec, {'config': objs}) facts['vlans'] = [utils.remove_empties(cfg) for cfg in params['config']] diff --git a/lib/ansible/utils/jsonrpc.py b/lib/ansible/utils/jsonrpc.py index e48c979d4c5..0a97c610547 100644 --- a/lib/ansible/utils/jsonrpc.py +++ b/lib/ansible/utils/jsonrpc.py @@ -39,7 +39,7 @@ class JsonRpcServer(object): break if not rpc_method: - error = self.method_not_found() + error = self.method_not_found(rpc_method) response = json.dumps(error) else: try: diff --git a/test/integration/targets/eos_interfaces/tasks/cli.yaml b/test/integration/targets/eos_interfaces/tasks/cli.yaml new file mode 100644 index 00000000000..475fe831549 --- /dev/null +++ b/test/integration/targets/eos_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000000..34ce8f63470 --- /dev/null +++ b/test/integration/targets/eos_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_interfaces/tasks/main.yaml b/test/integration/targets/eos_interfaces/tasks/main.yaml index 068963b4c34..970e74171ea 100644 --- a/test/integration/targets/eos_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_interfaces/tests/common/deleted.yaml similarity index 100% rename from test/integration/targets/eos_interfaces/tests/cli/deleted.yaml rename to test/integration/targets/eos_interfaces/tests/common/deleted.yaml diff --git a/test/integration/targets/eos_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_interfaces/tests/common/merged.yaml similarity index 100% rename from test/integration/targets/eos_interfaces/tests/cli/merged.yaml rename to test/integration/targets/eos_interfaces/tests/common/merged.yaml diff --git a/test/integration/targets/eos_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_interfaces/tests/common/overridden.yaml similarity index 100% rename from test/integration/targets/eos_interfaces/tests/cli/overridden.yaml rename to test/integration/targets/eos_interfaces/tests/common/overridden.yaml diff --git a/test/integration/targets/eos_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_interfaces/tests/common/replaced.yaml similarity index 100% rename from test/integration/targets/eos_interfaces/tests/cli/replaced.yaml rename to test/integration/targets/eos_interfaces/tests/common/replaced.yaml diff --git a/test/integration/targets/eos_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_interfaces/tests/common/reset_config.yml similarity index 96% rename from test/integration/targets/eos_interfaces/tests/cli/reset_config.yml rename to test/integration/targets/eos_interfaces/tests/common/reset_config.yml index 06135829553..7932f9f9487 100644 --- a/test/integration/targets/eos_interfaces/tests/cli/reset_config.yml +++ b/test/integration/targets/eos_interfaces/tests/common/reset_config.yml @@ -1,7 +1,7 @@ --- - name: Reset initial config - cli_config: - config: | + eos_config: + lines: | interface Ethernet1 description "Interface 1" no shutdown diff --git a/test/integration/targets/eos_l2_interfaces/tasks/cli.yaml b/test/integration/targets/eos_l2_interfaces/tasks/cli.yaml new file mode 100644 index 00000000000..92c7271ce9e --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- block: + - name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli + + always: + - name: Clean up test state + include: "{{ role_path }}/tests/common/cleanup.yml ansible_connection=network_cli" diff --git a/test/integration/targets/eos_l2_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_l2_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000000..f67b3d7214d --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tasks/eapi.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- block: + - name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi + + always: + - name: Clean up test state + include: "{{ role_path }}/tests/common/cleanup.yml ansible_connection=httpapi" diff --git a/test/integration/targets/eos_l2_interfaces/tasks/main.yaml b/test/integration/targets/eos_l2_interfaces/tasks/main.yaml index 35abc8e876f..970e74171ea 100644 --- a/test/integration/targets/eos_l2_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_l2_interfaces/tasks/main.yaml @@ -1,22 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- block: - - name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli - - always: - - name: Clean up test state - include: "{{ role_path }}/tests/cli/cleanup.yml ansible_connection=network_cli" +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/cleanup.yml b/test/integration/targets/eos_l2_interfaces/tests/common/cleanup.yml similarity index 77% rename from test/integration/targets/eos_l2_interfaces/tests/cli/cleanup.yml rename to test/integration/targets/eos_l2_interfaces/tests/common/cleanup.yml index d71a6a9db4d..7a6f44dd04f 100644 --- a/test/integration/targets/eos_l2_interfaces/tests/cli/cleanup.yml +++ b/test/integration/targets/eos_l2_interfaces/tests/common/cleanup.yml @@ -1,12 +1,12 @@ --- - name: Remove all vlans - cli_config: - config: no vlan 1-4094 + eos_config: + lines: no vlan 1-4094 become: yes - name: Completely remove vlans from interfaces - cli_config: - config: | + eos_config: + lines: | interface {{ item }} no switchport mode no switchport access vlan diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml similarity index 100% rename from test/integration/targets/eos_l2_interfaces/tests/cli/deleted.yaml rename to test/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_l2_interfaces/tests/common/merged.yaml similarity index 100% rename from test/integration/targets/eos_l2_interfaces/tests/cli/merged.yaml rename to test/integration/targets/eos_l2_interfaces/tests/common/merged.yaml diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml similarity index 100% rename from test/integration/targets/eos_l2_interfaces/tests/cli/overridden.yaml rename to test/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml similarity index 100% rename from test/integration/targets/eos_l2_interfaces/tests/cli/replaced.yaml rename to test/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_l2_interfaces/tests/common/reset_config.yml similarity index 96% rename from test/integration/targets/eos_l2_interfaces/tests/cli/reset_config.yml rename to test/integration/targets/eos_l2_interfaces/tests/common/reset_config.yml index f4474ce1b7d..cc43075cfdd 100644 --- a/test/integration/targets/eos_l2_interfaces/tests/cli/reset_config.yml +++ b/test/integration/targets/eos_l2_interfaces/tests/common/reset_config.yml @@ -1,7 +1,7 @@ --- - name: Reset state - cli_config: - config: | + eos_config: + lines: | interface Ethernet1 switchport access vlan 20 no switchport trunk native vlan diff --git a/test/integration/targets/eos_l3_interfaces/tasks/cli.yaml b/test/integration/targets/eos_l3_interfaces/tasks/cli.yaml new file mode 100644 index 00000000000..475fe831549 --- /dev/null +++ b/test/integration/targets/eos_l3_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_l3_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_l3_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000000..acddad170e2 --- /dev/null +++ b/test/integration/targets/eos_l3_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_l3_interfaces/tasks/main.yaml b/test/integration/targets/eos_l3_interfaces/tasks/main.yaml index 82d196e4edc..970e74171ea 100644 --- a/test/integration/targets/eos_l3_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_l3_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - register: test_cases - delegate_to: localhost - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml similarity index 100% rename from test/integration/targets/eos_l3_interfaces/tests/cli/deleted.yaml rename to test/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_l3_interfaces/tests/common/merged.yaml similarity index 100% rename from test/integration/targets/eos_l3_interfaces/tests/cli/merged.yaml rename to test/integration/targets/eos_l3_interfaces/tests/common/merged.yaml diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml similarity index 100% rename from test/integration/targets/eos_l3_interfaces/tests/cli/overridden.yaml rename to test/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml similarity index 100% rename from test/integration/targets/eos_l3_interfaces/tests/cli/replaced.yaml rename to test/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_l3_interfaces/tests/common/reset_config.yml similarity index 96% rename from test/integration/targets/eos_l3_interfaces/tests/cli/reset_config.yml rename to test/integration/targets/eos_l3_interfaces/tests/common/reset_config.yml index 3efc086a4b0..f74d1f521c4 100644 --- a/test/integration/targets/eos_l3_interfaces/tests/cli/reset_config.yml +++ b/test/integration/targets/eos_l3_interfaces/tests/common/reset_config.yml @@ -1,7 +1,7 @@ --- - name: Reset state - cli_config: - config: | + eos_config: + lines: | interface Ethernet1 ip address 192.0.2.12/24 ip address 203.0.113.27/31 secondary diff --git a/test/integration/targets/eos_lacp_interfaces/tasks/cli.yaml b/test/integration/targets/eos_lacp_interfaces/tasks/cli.yaml new file mode 100644 index 00000000000..475fe831549 --- /dev/null +++ b/test/integration/targets/eos_lacp_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000000..34ce8f63470 --- /dev/null +++ b/test/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_lacp_interfaces/tasks/main.yaml b/test/integration/targets/eos_lacp_interfaces/tasks/main.yaml index 068963b4c34..970e74171ea 100644 --- a/test/integration/targets/eos_lacp_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_lacp_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml similarity index 100% rename from test/integration/targets/eos_lacp_interfaces/tests/cli/deleted.yaml rename to test/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml similarity index 100% rename from test/integration/targets/eos_lacp_interfaces/tests/cli/merged.yaml rename to test/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml similarity index 100% rename from test/integration/targets/eos_lacp_interfaces/tests/cli/overridden.yaml rename to test/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml similarity index 100% rename from test/integration/targets/eos_lacp_interfaces/tests/cli/replaced.yaml rename to test/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_lacp_interfaces/tests/common/reset_config.yml similarity index 95% rename from test/integration/targets/eos_lacp_interfaces/tests/cli/reset_config.yml rename to test/integration/targets/eos_lacp_interfaces/tests/common/reset_config.yml index 45caea1f4a6..b4e68513657 100644 --- a/test/integration/targets/eos_lacp_interfaces/tests/cli/reset_config.yml +++ b/test/integration/targets/eos_lacp_interfaces/tests/common/reset_config.yml @@ -1,7 +1,7 @@ --- - name: Reset initial config - cli_config: - config: | + eos_config: + lines: | interface Ethernet1 lacp port-priority 30 lacp rate normal diff --git a/test/integration/targets/eos_lag_interfaces/tasks/cli.yaml b/test/integration/targets/eos_lag_interfaces/tasks/cli.yaml new file mode 100644 index 00000000000..475fe831549 --- /dev/null +++ b/test/integration/targets/eos_lag_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_lag_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_lag_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000000..34ce8f63470 --- /dev/null +++ b/test/integration/targets/eos_lag_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_lag_interfaces/tasks/main.yaml b/test/integration/targets/eos_lag_interfaces/tasks/main.yaml index 82d196e4edc..970e74171ea 100644 --- a/test/integration/targets/eos_lag_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_lag_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - register: test_cases - delegate_to: localhost - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_lag_interfaces/tests/common/deleted.yaml similarity index 100% rename from test/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml rename to test/integration/targets/eos_lag_interfaces/tests/common/deleted.yaml diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_lag_interfaces/tests/common/merged.yaml similarity index 100% rename from test/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml rename to test/integration/targets/eos_lag_interfaces/tests/common/merged.yaml diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_lag_interfaces/tests/common/overridden.yaml similarity index 100% rename from test/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml rename to test/integration/targets/eos_lag_interfaces/tests/common/overridden.yaml diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_lag_interfaces/tests/common/replaced.yaml similarity index 100% rename from test/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml rename to test/integration/targets/eos_lag_interfaces/tests/common/replaced.yaml diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_lag_interfaces/tests/common/reset_config.yml similarity index 94% rename from test/integration/targets/eos_lag_interfaces/tests/cli/reset_config.yml rename to test/integration/targets/eos_lag_interfaces/tests/common/reset_config.yml index ba7cf513a2e..31ef2098669 100644 --- a/test/integration/targets/eos_lag_interfaces/tests/cli/reset_config.yml +++ b/test/integration/targets/eos_lag_interfaces/tests/common/reset_config.yml @@ -1,7 +1,7 @@ --- - name: Reset state - cli_config: - config: | + eos_config: + lines: | interface Ethernet1 channel-group 5 mode on interface Ethernet2 diff --git a/test/integration/targets/eos_lldp_global/tasks/cli.yaml b/test/integration/targets/eos_lldp_global/tasks/cli.yaml new file mode 100644 index 00000000000..475fe831549 --- /dev/null +++ b/test/integration/targets/eos_lldp_global/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_lldp_global/tasks/eapi.yaml b/test/integration/targets/eos_lldp_global/tasks/eapi.yaml new file mode 100644 index 00000000000..34ce8f63470 --- /dev/null +++ b/test/integration/targets/eos_lldp_global/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_lldp_global/tasks/main.yaml b/test/integration/targets/eos_lldp_global/tasks/main.yaml index 068963b4c34..970e74171ea 100644 --- a/test/integration/targets/eos_lldp_global/tasks/main.yaml +++ b/test/integration/targets/eos_lldp_global/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_lldp_global/tests/cli/deleted.yaml b/test/integration/targets/eos_lldp_global/tests/common/deleted.yaml similarity index 100% rename from test/integration/targets/eos_lldp_global/tests/cli/deleted.yaml rename to test/integration/targets/eos_lldp_global/tests/common/deleted.yaml diff --git a/test/integration/targets/eos_lldp_global/tests/cli/merged.yaml b/test/integration/targets/eos_lldp_global/tests/common/merged.yaml similarity index 100% rename from test/integration/targets/eos_lldp_global/tests/cli/merged.yaml rename to test/integration/targets/eos_lldp_global/tests/common/merged.yaml diff --git a/test/integration/targets/eos_lldp_global/tests/cli/replaced.yaml b/test/integration/targets/eos_lldp_global/tests/common/replaced.yaml similarity index 100% rename from test/integration/targets/eos_lldp_global/tests/cli/replaced.yaml rename to test/integration/targets/eos_lldp_global/tests/common/replaced.yaml diff --git a/test/integration/targets/eos_lldp_global/tests/cli/reset_config.yml b/test/integration/targets/eos_lldp_global/tests/common/reset_config.yml similarity index 95% rename from test/integration/targets/eos_lldp_global/tests/cli/reset_config.yml rename to test/integration/targets/eos_lldp_global/tests/common/reset_config.yml index 4e5fd337461..441edf3891d 100644 --- a/test/integration/targets/eos_lldp_global/tests/cli/reset_config.yml +++ b/test/integration/targets/eos_lldp_global/tests/common/reset_config.yml @@ -1,7 +1,7 @@ --- - name: Reset initial config - cli_config: - config: | + eos_config: + lines: | lldp timer 3000 lldp holdtime 100 lldp reinit 5 diff --git a/test/integration/targets/eos_lldp_interfaces/tasks/cli.yaml b/test/integration/targets/eos_lldp_interfaces/tasks/cli.yaml new file mode 100644 index 00000000000..475fe831549 --- /dev/null +++ b/test/integration/targets/eos_lldp_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000000..34ce8f63470 --- /dev/null +++ b/test/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_lldp_interfaces/tasks/main.yaml b/test/integration/targets/eos_lldp_interfaces/tasks/main.yaml index 068963b4c34..970e74171ea 100644 --- a/test/integration/targets/eos_lldp_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_lldp_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml similarity index 100% rename from test/integration/targets/eos_lldp_interfaces/tests/cli/deleted.yaml rename to test/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml similarity index 100% rename from test/integration/targets/eos_lldp_interfaces/tests/cli/merged.yaml rename to test/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml similarity index 100% rename from test/integration/targets/eos_lldp_interfaces/tests/cli/overridden.yaml rename to test/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml similarity index 100% rename from test/integration/targets/eos_lldp_interfaces/tests/cli/replaced.yaml rename to test/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_lldp_interfaces/tests/common/reset_config.yml similarity index 94% rename from test/integration/targets/eos_lldp_interfaces/tests/cli/reset_config.yml rename to test/integration/targets/eos_lldp_interfaces/tests/common/reset_config.yml index 99688d8478c..c2085aef61f 100644 --- a/test/integration/targets/eos_lldp_interfaces/tests/cli/reset_config.yml +++ b/test/integration/targets/eos_lldp_interfaces/tests/common/reset_config.yml @@ -1,7 +1,7 @@ --- - name: Reset initial config - cli_config: - config: | + eos_config: + lines: | interface Ethernet1 no lldp receive lldp transmit diff --git a/test/integration/targets/eos_vlans/tasks/cli.yaml b/test/integration/targets/eos_vlans/tasks/cli.yaml new file mode 100644 index 00000000000..475fe831549 --- /dev/null +++ b/test/integration/targets/eos_vlans/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_vlans/tasks/eapi.yaml b/test/integration/targets/eos_vlans/tasks/eapi.yaml new file mode 100644 index 00000000000..34ce8f63470 --- /dev/null +++ b/test/integration/targets/eos_vlans/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_vlans/tasks/main.yaml b/test/integration/targets/eos_vlans/tasks/main.yaml index 068963b4c34..970e74171ea 100644 --- a/test/integration/targets/eos_vlans/tasks/main.yaml +++ b/test/integration/targets/eos_vlans/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_vlans/tests/cli/deleted.yaml b/test/integration/targets/eos_vlans/tests/common/deleted.yaml similarity index 100% rename from test/integration/targets/eos_vlans/tests/cli/deleted.yaml rename to test/integration/targets/eos_vlans/tests/common/deleted.yaml diff --git a/test/integration/targets/eos_vlans/tests/cli/idempotent.yaml b/test/integration/targets/eos_vlans/tests/common/idempotent.yaml similarity index 100% rename from test/integration/targets/eos_vlans/tests/cli/idempotent.yaml rename to test/integration/targets/eos_vlans/tests/common/idempotent.yaml diff --git a/test/integration/targets/eos_vlans/tests/cli/merged.yaml b/test/integration/targets/eos_vlans/tests/common/merged.yaml similarity index 100% rename from test/integration/targets/eos_vlans/tests/cli/merged.yaml rename to test/integration/targets/eos_vlans/tests/common/merged.yaml diff --git a/test/integration/targets/eos_vlans/tests/cli/overridden.yaml b/test/integration/targets/eos_vlans/tests/common/overridden.yaml similarity index 100% rename from test/integration/targets/eos_vlans/tests/cli/overridden.yaml rename to test/integration/targets/eos_vlans/tests/common/overridden.yaml diff --git a/test/integration/targets/eos_vlans/tests/cli/replaced.yaml b/test/integration/targets/eos_vlans/tests/common/replaced.yaml similarity index 100% rename from test/integration/targets/eos_vlans/tests/cli/replaced.yaml rename to test/integration/targets/eos_vlans/tests/common/replaced.yaml diff --git a/test/integration/targets/eos_vlans/tests/cli/reset_config.yml b/test/integration/targets/eos_vlans/tests/common/reset_config.yml similarity index 78% rename from test/integration/targets/eos_vlans/tests/cli/reset_config.yml rename to test/integration/targets/eos_vlans/tests/common/reset_config.yml index 513a1199b1a..38736d88b5e 100644 --- a/test/integration/targets/eos_vlans/tests/cli/reset_config.yml +++ b/test/integration/targets/eos_vlans/tests/common/reset_config.yml @@ -1,12 +1,17 @@ --- - name: Reset initial config - cli_config: - config: | + eos_config: + before: no vlan 1-4094 + defaults: yes + match: exact + lines: | vlan 10 name ten + state active vlan 20 name twenty + state active become: yes - eos_facts: