mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-07-07 02:58:54 +00:00
Refactoring code of cnos_portchannel as cnos_linkagg in tune with other vendors. (#49467)
* Refactoring code of cnos_portchannel as cnos_linkagg in tune with other vendors.
This commit is contained in:
parent
287a42eba0
commit
dd004321d4
16 changed files with 783 additions and 825 deletions
2
test/integration/targets/cnos_linkagg/aliases
Normal file
2
test/integration/targets/cnos_linkagg/aliases
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# No Lenovo Switch simulator yet, so not enabled
|
||||
unsupported
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# You have to paste this dummy information in /etc/ansible/hosts
|
||||
# Notes:
|
||||
# - Comments begin with the '#' character
|
||||
# - Blank lines are ignored
|
||||
# - Groups of hosts are delimited by [header] elements
|
||||
# - You can enter hostnames or ip addresses
|
||||
# - A hostname/ip can be a member of multiple groups
|
||||
#
|
||||
# In the /etc/ansible/hosts file u have to enter [cnos_portchannel_sample] tag
|
||||
# Following you should specify IP Adresses details
|
||||
# Please change <username> and <password> with appropriate value for your switch.
|
||||
|
||||
[cnos_linkagg_sample]
|
||||
10.241.107.39 ansible_network_os=cnos ansible_ssh_user=<username> ansible_ssh_pass=<password>
|
||||
3
test/integration/targets/cnos_linkagg/defaults/main.yaml
Normal file
3
test/integration/targets/cnos_linkagg/defaults/main.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
||||
22
test/integration/targets/cnos_linkagg/tasks/cli.yaml
Normal file
22
test/integration/targets/cnos_linkagg/tasks/cli.yaml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
- 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 }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: run test case (connection=local)
|
||||
include: "{{ test_case_to_run }} ansible_connection=local"
|
||||
with_first_found: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
2
test/integration/targets/cnos_linkagg/tasks/main.yaml
Normal file
2
test/integration/targets/cnos_linkagg/tasks/main.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
169
test/integration/targets/cnos_linkagg/tests/cli/basic.yaml
Normal file
169
test/integration/targets/cnos_linkagg/tests/cli/basic.yaml
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
---
|
||||
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
|
||||
- block:
|
||||
|
||||
- name: setup - remove config used in test(part1)
|
||||
cnos_config:
|
||||
lines:
|
||||
- no interface port-channel 20
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: setup - remove config used in test(part2)
|
||||
cnos_config:
|
||||
lines:
|
||||
- no interface port-channel 5
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: setup - remove config used in test(part3)
|
||||
cnos_config:
|
||||
lines:
|
||||
- no channel-group
|
||||
provider: "{{ cli }}"
|
||||
parents: "{{ item }}"
|
||||
loop:
|
||||
- interface Ethernet1/33
|
||||
- interface Ethernet1/44
|
||||
|
||||
- name: create linkagg
|
||||
cnos_linkagg: &create
|
||||
group: 20
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'interface port-channel 20' in result.commands"
|
||||
|
||||
- name: create linkagg(Idempotence)
|
||||
cnos_linkagg: *create
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: set link aggregation group to members
|
||||
cnos_linkagg: &configure_member
|
||||
group: 20
|
||||
mode: active
|
||||
members:
|
||||
- Ethernet1/33
|
||||
- Ethernet1/44
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'interface Ethernet1/33' in result.commands"
|
||||
- "'channel-group 20 mode active' in result.commands"
|
||||
- "'interface Ethernet1/44' in result.commands"
|
||||
- "'channel-group 20 mode active' in result.commands"
|
||||
|
||||
- name: set link aggregation group to members(Idempotence)
|
||||
cnos_linkagg: *configure_member
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: remove link aggregation group from member
|
||||
cnos_linkagg: &remove_member
|
||||
group: 20
|
||||
mode: active
|
||||
members:
|
||||
- Ethernet1/33
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'interface Ethernet1/44' in result.commands"
|
||||
- "'no channel-group' in result.commands"
|
||||
|
||||
- name: remove link aggregation group from member(Idempotence)
|
||||
cnos_linkagg: *remove_member
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: remove linkagg
|
||||
cnos_linkagg: &remove
|
||||
group: 20
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'no interface port-channel 20' in result.commands"
|
||||
|
||||
- name: remove linkagg(Idempotence)
|
||||
cnos_linkagg: *remove
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: create aggregate of linkagg definitions
|
||||
cnos_linkagg: &create_agg
|
||||
aggregate:
|
||||
- { group: 5 }
|
||||
- { group: 20, mode: active, members: ['Ethernet1/33'] }
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'interface port-channel 5' in result.commands"
|
||||
- "'interface port-channel 20' in result.commands"
|
||||
- "'interface Ethernet1/33' in result.commands"
|
||||
- "'channel-group 20 mode active' in result.commands"
|
||||
|
||||
- name: create aggregate of linkagg definitions(Idempotence)
|
||||
cnos_linkagg: *create_agg
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown(part1)
|
||||
cnos_config:
|
||||
lines:
|
||||
- no interface port-channel 20
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: teardown(part2)
|
||||
cnos_config:
|
||||
lines:
|
||||
- no interface port-channel 5
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: teardown(part3)
|
||||
cnos_config:
|
||||
lines:
|
||||
- no channel-group
|
||||
provider: "{{ cli }}"
|
||||
parents: "{{ item }}"
|
||||
loop:
|
||||
- interface Ethernet1/33
|
||||
- interface Ethernet1/44
|
||||
|
||||
|
||||
- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}"
|
||||
9
test/integration/targets/cnos_linkagg/vars/main.yaml
Normal file
9
test/integration/targets/cnos_linkagg/vars/main.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
cli:
|
||||
host: "{{ inventory_hostname }}"
|
||||
port: 22
|
||||
username: admin
|
||||
password: admin
|
||||
timeout: 30
|
||||
authorize: True
|
||||
auth_pass:
|
||||
Loading…
Add table
Add a link
Reference in a new issue