1
0
Fork 0
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:
Anil Kumar Muraleedharan 2018-12-05 21:33:42 +05:30 committed by Nathaniel Case
parent 287a42eba0
commit dd004321d4
16 changed files with 783 additions and 825 deletions

View file

@ -0,0 +1,2 @@
# No Lenovo Switch simulator yet, so not enabled
unsupported

View file

@ -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>

View file

@ -0,0 +1,3 @@
---
testcase: "*"
test_items: []

View 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

View file

@ -0,0 +1,2 @@
---
- { include: cli.yaml, tags: ['cli'] }

View 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 }}"

View file

@ -0,0 +1,9 @@
---
cli:
host: "{{ inventory_hostname }}"
port: 22
username: admin
password: admin
timeout: 30
authorize: True
auth_pass: