fix ios_interface test (#32372)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2017-10-31 11:58:22 +05:30 committed by GitHub
parent 071f86afc6
commit 8453398dd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,25 @@
---
- debug: msg="START ios_interface cli/intent.yaml"
- name: Run show version
ios_command:
commands: show version
authorize: yes
register: show_version_result
- name: Set test interface to GigabitEthernet0/2 if we are on Cisco IOS
set_fact: test_interface=GigabitEthernet0/2
when: "'Cisco IOS' in show_version_result.stdout[0]"
- name: Set test interface to GigabitEthernet2 if we are on Cisco IOS-XE
set_fact: test_interface=GigabitEthernet2
when: "'Cisco IOS-XE' in show_version_result.stdout[0]"
- name: Check intent arguments
ios_interface:
name: GigabitEthernet0/2
name: "{{ test_interface }}"
state: up
tx_rate: ge(0)
rx_rate: le(0)
@ -16,7 +32,7 @@
- name: Check intent arguments (failed condition)
ios_interface:
name: GigabitEthernet0/2
name: "{{ test_interface }}"
state: down
tx_rate: gt(0)
rx_rate: lt(0)
@ -33,7 +49,7 @@
- name: Config + intent
ios_interface:
name: GigabitEthernet0/2
name: "{{ test_interface }}"
enabled: False
state: down
authorize: yes
@ -45,7 +61,7 @@
- name: Config + intent (fail)
ios_interface:
name: GigabitEthernet0/2
name: "{{ test_interface }}"
enabled: False
authorize: yes
state: up
@ -57,41 +73,50 @@
- "result.failed == true"
- "'state eq(up)' in result.failed_conditions"
- name: Check neighbors intent arguments
ios_interface:
name: Gi0/0
neighbors:
- port: eth0
host: netdev
- name: Register show neighbors detail
ios_command:
commands:
- show lldp neighbors
authorize: yes
register: result
register: show_lldp_neighbors_result
- assert:
that:
- "result.failed == false"
- block:
- name: Check neighbors intent arguments
ios_interface:
name: Gi0/0
neighbors:
- port: eth0
host: netdev
authorize: yes
register: result
- name: Check neighbors intent arguments (failed condition)
ios_interface:
name: Gi0/0
neighbors:
- port: dummy_port
host: dummy_host
authorize: yes
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == false"
- assert:
that:
- "result.failed == true"
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
- name: Check neighbors intent arguments (failed condition)
ios_interface:
name: Gi0/0
neighbors:
- port: dummy_port
host: dummy_host
authorize: yes
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
when: '"netdev" in show_lldp_neighbors_result.stdout'
- name: Aggregate config + intent (pass)
ios_interface:
aggregate:
- name: GigabitEthernet0/2
enabled: True
state: up
- name: "{{ test_interface }}"
enabled: True
state: up
authorize: yes
ignore_errors: yes
register: result
@ -100,36 +125,38 @@
that:
- "result.failed == false"
- name: Aggregate neighbors intent (pass)
ios_interface:
aggregate:
- name: Gi0/0
neighbors:
- port: eth0
host: netdev
authorize: yes
ignore_errors: yes
register: result
- block:
- name: Aggregate neighbors intent (pass)
ios_interface:
aggregate:
- name: Gi0/0
neighbors:
- port: eth0
host: netdev
authorize: yes
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == false"
- assert:
that:
- "result.failed == false"
- name: Aggregate neighbors intent (fail)
ios_interface:
aggregate:
- name: Gi0/0
neighbors:
- port: eth0
host: netdev
- port: dummy_port
host: dummy_host
authorize: yes
ignore_errors: yes
register: result
- name: Aggregate neighbors intent (fail)
ios_interface:
aggregate:
- name: Gi0/0
neighbors:
- port: eth0
host: netdev
- port: dummy_port
host: dummy_host
authorize: yes
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
- assert:
that:
- "result.failed == true"
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
when: "'netdev' in show_lldp_neighbors_result.stdout"