fix connection gets overridden by network_cli for transport nxapi,eapi net_* modules (#34778)

* fix connection gets overridden by network_cli for transport nxapi,eapi net_* modules

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Define functions in individual action plugins to avoid code duplication

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Add net_* eos tests for eapi

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* update plugin code
This commit is contained in:
Trishna Guha
2018-01-15 13:16:41 +05:30
committed by GitHub
parent c04cd8642d
commit 48ecbb8fb9
13 changed files with 338 additions and 57 deletions

View File

@@ -0,0 +1,36 @@
---
- debug: msg="START eos eapi/net_banner.yaml on connection={{ ansible_connection }}"
# Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful.
- name: Remove previous motd banner (setup)
eos_config:
lines: no banner motd
authorize: yes
provider: "{{ eapi }}"
- name: create motd
net_banner:
banner: motd
text: this is my motd banner configure by net_banner
state: present
authorize: yes
provider: "{{ eapi }}"
register: result
- assert:
that:
- "result.changed == true"
- "result.commands.0.cmd == 'banner motd'"
- "result.commands.0.input == 'this is my motd banner configure by net_banner'"
# Ensure sessions contains epoc. Will fail after 18th May 2033
- "'ansible_1' in result.session_name"
- name: Remove previous motd banner (teardown)
eos_config:
lines: no banner motd
authorize: yes
provider: "{{ eapi }}"
- debug: msg="END eos eapi/net_banner.yaml on connection={{ ansible_connection }}"

View File

@@ -0,0 +1,53 @@
---
- debug: msg="START eos eapi/net_interface.yaml on connection={{ ansible_connection }}"
# Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful.
- name: Set test interface
set_fact:
test_interface_1: ethernet1
- name: Configure interface (setup)
net_interface:
name: "{{ test_interface_1 }}"
description: test-interface-1
mtu: 1800
state: present
authorize: yes
provider: "{{ eapi }}"
register: result
- name: Configure interface description using platform agnostic module
net_interface:
name: "{{ test_interface_1 }}"
description: test-interface-initial
state: present
authorize: yes
provider: "{{ eapi }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface_1 }}" in result.commands'
- '"description test-interface-initial" in result.commands'
- name: Confgure interface parameters
net_interface:
name: "{{ test_interface_1 }}"
description: test-interface
mtu: 2000
state: present
authorize: yes
provider: "{{ eapi }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface_1 }}" in result.commands'
- '"description test-interface" in result.commands'
- '"mtu 2000" in result.commands'
- debug: msg="END eos eapi/net_interface.yaml on connection={{ ansible_connection }}"

View File

@@ -0,0 +1,42 @@
---
- debug: msg="START eos eapi/net_l3_interface.yaml on connection={{ ansible_connection }}"
# Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful.
- name: Set test interface
set_fact:
test_interface_1: ethernet1
- name: Delete interface ipv4 and ipv6 address(setup)
net_l3_interface:
name: "{{ test_interface_1 }}"
state: absent
authorize: yes
provider: "{{ eapi }}"
register: result
- name: Configure interface ipv4 address using platform agnostic module
net_l3_interface:
name: "{{ test_interface_1 }}"
ipv4: 192.108.0.1/24
state: present
authorize: yes
provider: "{{ eapi }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface_1 }}" in result.commands'
- '"ip address 192.108.0.1/24" in result.commands'
- name: Delete interface ipv4 and ipv6 address(teardown)
net_l3_interface:
name: "{{ test_interface_1 }}"
state: absent
authorize: yes
provider: "{{ eapi }}"
register: result
- debug: msg="END eos eapi/net_l3_interface.yaml on connection={{ ansible_connection }}"

View File

@@ -0,0 +1,39 @@
---
- debug: msg="START eos eapi/net_logging.yaml on connection={{ ansible_connection }}"
# Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful.
- name: Delete/disable host logging- setup
net_logging:
dest: host
name: 172.16.0.1
state: absent
authorize: yes
provider: "{{ eapi }}"
register: result
- name: Set up host logging using platform agnostic module
net_logging:
dest: host
name: 172.16.0.1
state: present
authorize: yes
provider: "{{ eapi }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"logging host 172.16.0.1" in result.commands'
- name: Delete/disable host logging- teardown
net_logging:
dest: host
name: 172.16.0.1
state: absent
authorize: yes
provider: "{{ eapi }}"
register: result
- debug: msg="END eos eapi/net_logging.yaml on connection={{ ansible_connection }}"

View File

@@ -0,0 +1,37 @@
---
- debug: msg="START eos eapi/net_system.yaml on connection={{ ansible_connection }}"
# Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful.
- name: setup
eos_config:
lines:
- no ip domain-list ansible.com
- no ip domain-list redhat.com
match: none
provider: "{{ eapi }}"
- name: configure domain_list using platform agnostic module
net_system:
domain_list:
- ansible.com
- redhat.com
provider: "{{ eapi }}"
register: result
- assert:
that:
- result.changed == true
- "'ip domain-list ansible.com' in result.commands"
- "'ip domain-list redhat.com' in result.commands"
- name: teardown
eos_config:
lines:
- no ip domain-list ansible.com
- no ip domain-list redhat.com
match: none
provider: "{{ eapi }}"
- debug: msg="END eos eapi/net_system.yaml on connection={{ ansible_connection }}"

View File

@@ -1,4 +1,8 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_logging basic test"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- name: Set up console logging
nxos_logging:
dest: console
@@ -88,3 +92,5 @@
- 'result.changed == true'
- '"no logging logfile" in result.commands'
- '"no logging level daemon" in result.commands'
- debug: msg="END connection={{ ansible_connection }} nxos_logging basic test"

View File

@@ -1,5 +1,7 @@
---
- debug: msg="START nxos common/net_logging.yaml on connection={{ ansible_connection }}"
- debug: msg="START connection={{ ansible_connection }} nxos common/net_logging.yaml"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
# Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful.
@@ -33,4 +35,5 @@
provider: "{{ connection }}"
register: result
- debug: msg="END nxos common/net_logging.yaml on connection={{ ansible_connection }}"
- debug: msg="END connection={{ ansible_connection }} nxos common/net_logging.yaml"

View File

@@ -0,0 +1,38 @@
---
- debug: msg="START nxos nxapi/net_system.yaml on connection={{ ansible_connection }}"
- debug: msg="Using provider={{ connection.transport }}"
# Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful.
- name: setup
nxos_config:
lines:
- no ip domain-list ansible.com
- no ip domain-list redhat.com
match: none
provider: "{{ nxapi }}"
- name: configure domain_list using platform agnostic module
net_system:
domain_search:
- ansible.com
- redhat.com
provider: "{{ nxapi }}"
register: result
- assert:
that:
- result.changed == true
- "'ip domain-list ansible.com' in result.commands"
- "'ip domain-list redhat.com' in result.commands"
- name: setup
nxos_config:
lines:
- no ip domain-list ansible.com
- no ip domain-list redhat.com
match: none
provider: "{{ nxapi }}"
- debug: msg="END nxos nxapi/net_system.yaml on connection={{ ansible_connection }}"

View File

@@ -1,4 +1,8 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_user basic test"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- name: Remove old entries of user
nxos_user:
aggregate:
@@ -51,3 +55,5 @@
that:
- 'result.changed == true'
- '"no username" in result.commands[0]'
- debug: msg="END connection={{ ansible_connection }} nxos_user basic test"

View File

@@ -1,12 +1,14 @@
---
- debug: msg="START nxos common/net_user.yaml on connection={{ ansible_connection }}"
- debug: msg="START connection={{ ansible_connection }} nxos common/net_user.yaml"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
# Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful.
- name: Remove old entries of user - setup
- name: "Remove old entries of user - setup"
net_user:
- name: ansibletest1
name: ansibletest1
state: absent
provider: "{{ connection }}"
@@ -27,8 +29,8 @@
- name: teardown
net_user:
- name: ansibletest1
name: ansibletest1
state: absent
provider: "{{ connection }}"
- debug: msg="END nxos common/net_user.yaml on connection={{ ansible_connection }}"
- debug: msg="END connection={{ ansible_connection }} nxos common/net_user.yaml"