mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
New module: Add support for Arista EOS vlan (network/eos/eos_vlan) (#25355)
* WIP Add eos_vlan module * Fix docstrings * Fix pep8 issues * Add active/suspend states logic * Add integration tests for eos_vlan * Fix map_config_to_obj on EAPI * Sixify iteritems * Add platform agnostic net_vlan integration tests
This commit is contained in:
parent
745f72916f
commit
b3e8c48d4b
16 changed files with 482 additions and 0 deletions
2
test/integration/targets/eos_vlan/defaults/main.yaml
Normal file
2
test/integration/targets/eos_vlan/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
2
test/integration/targets/eos_vlan/meta/main.yml
Normal file
2
test/integration/targets/eos_vlan/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_eos_tests
|
15
test/integration/targets/eos_vlan/tasks/cli.yaml
Normal file
15
test/integration/targets/eos_vlan/tasks/cli.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
33
test/integration/targets/eos_vlan/tasks/eapi.yaml
Normal file
33
test/integration/targets/eos_vlan/tasks/eapi.yaml
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
- name: collect all eapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/eapi"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" #"
|
||||
|
||||
- name: enable eapi
|
||||
eos_eapi:
|
||||
enable_http: yes
|
||||
enable_https: yes
|
||||
enable_local_http: yes
|
||||
enable_socket: yes
|
||||
provider: "{{ cli }}"
|
||||
# authorize: yes
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: disable eapi
|
||||
eos_eapi:
|
||||
enable_http: no
|
||||
enable_https: no
|
||||
enable_local_http: no
|
||||
enable_socket: no
|
||||
provider: "{{ cli }}"
|
||||
# authorize: yes
|
3
test/integration/targets/eos_vlan/tasks/main.yaml
Normal file
3
test/integration/targets/eos_vlan/tasks/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: eapi.yaml, tags: ['eapi'] }
|
68
test/integration/targets/eos_vlan/tests/cli/basic.yaml
Normal file
68
test/integration/targets/eos_vlan/tests/cli/basic.yaml
Normal file
|
@ -0,0 +1,68 @@
|
|||
---
|
||||
|
||||
- name: setup - remove vlan
|
||||
eos_vlan:
|
||||
vlan_id: 4000
|
||||
name: test-vlan
|
||||
state: absent
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Create vlan
|
||||
eos_vlan:
|
||||
vlan_id: 4000
|
||||
name: test-vlan
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- debug:
|
||||
msg: "{{ result }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'vlan 4000' in result.commands"
|
||||
- "'name test-vlan' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
- name: Create vlan again (idempotent)
|
||||
eos_vlan:
|
||||
vlan_id: 4000
|
||||
name: test-vlan
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "result.session_name is not defined"
|
||||
|
||||
- name: Change vlan name and state
|
||||
eos_vlan:
|
||||
vlan_id: 4000
|
||||
name: test-vlan2
|
||||
state: suspend
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'vlan 4000' in result.commands"
|
||||
- "'name test-vlan2' in result.commands"
|
||||
- "'state suspend' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
|
||||
# FIXME add in tests for everything defined in docs
|
||||
# FIXME Test state:absent + test:
|
||||
# FIXME Without powers ensure "privileged mode required"
|
68
test/integration/targets/eos_vlan/tests/eapi/basic.yaml
Normal file
68
test/integration/targets/eos_vlan/tests/eapi/basic.yaml
Normal file
|
@ -0,0 +1,68 @@
|
|||
---
|
||||
|
||||
- name: setup - remove vlan
|
||||
eos_vlan:
|
||||
vlan_id: 4000
|
||||
name: test-vlan
|
||||
state: absent
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- name: Create vlan
|
||||
eos_vlan:
|
||||
vlan_id: 4000
|
||||
name: test-vlan
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- debug:
|
||||
msg: "{{ result }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'vlan 4000' in result.commands"
|
||||
- "'name test-vlan' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
- name: Create vlan again (idempotent)
|
||||
eos_vlan:
|
||||
vlan_id: 4000
|
||||
name: test-vlan
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "result.session_name is not defined"
|
||||
|
||||
- name: Change vlan name and state
|
||||
eos_vlan:
|
||||
vlan_id: 4000
|
||||
name: test-vlan2
|
||||
state: suspend
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'vlan 4000' in result.commands"
|
||||
- "'name test-vlan2' in result.commands"
|
||||
- "'state suspend' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
|
||||
# FIXME add in tests for everything defined in docs
|
||||
# FIXME Test state:absent + test:
|
||||
# FIXME Without powers ensure "privileged mode required"
|
Loading…
Add table
Add a link
Reference in a new issue