Fix vrf parsing in eos_vrf and eos_eapi module (#35791)

* Fix vrf parsing in eos_vrf and eos_eapi module

Fixes #30250

Fix logic to parse vrf when interface value in `show vrf`
command output spans on multiple lines

* Add idempotent test case
This commit is contained in:
Ganesh Nalawade 2018-02-12 12:33:22 +05:30 committed by GitHub
commit 6a223d5576
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 103 additions and 26 deletions

View file

@ -2,27 +2,18 @@
- name: setup - remove vrf
eos_vrf:
name: test
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
- name: setup - remove vrf
eos_vrf:
name: test2
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
- name: setup - remove vrf
eos_vrf:
name: test3
name: "{{ item }}"
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
with_items:
- test
- test1
- test2
- test3
- test4
- test5
- name: Create vrf
eos_vrf:
@ -133,6 +124,66 @@
# Ensure sessions contains epoc. Will fail after 18th May 2033
- "'session_name' not in result.commands"
- name: Add multiple interfaces to vrf
eos_vrf:
name: test1
rd: 1:202
state: present
authorize: yes
interfaces:
- loopback10
- loopback11
- loopback12
- loopback13
- loopback14
- loopback15
- loopback1000
provider: "{{ cli }}"
become: yes
register: result
- assert:
that:
- "result.changed == true"
- "'interface loopback10' in result.commands"
- "'vrf forwarding test1' in result.commands"
- "'interface loopback11' in result.commands"
- "'vrf forwarding test1' in result.commands"
- "'interface loopback12' in result.commands"
- "'vrf forwarding test1' in result.commands"
- "'interface loopback13' in result.commands"
- "'vrf forwarding test1' in result.commands"
- "'interface loopback14' in result.commands"
- "'vrf forwarding test1' in result.commands"
- "'interface loopback15' in result.commands"
- "'vrf forwarding test1' in result.commands"
- "'interface loopback1000' in result.commands"
- "'vrf forwarding test1' in result.commands"
- "'ansible_1' in result.session_name"
- name: Add multiple interfaces to vrf (idempotent)
eos_vrf:
name: test1
rd: 1:202
state: present
authorize: yes
interfaces:
- loopback10
- loopback11
- loopback12
- loopback13
- loopback14
- loopback15
- loopback1000
provider: "{{ cli }}"
become: yes
register: result
- assert:
that:
- "result.changed == false"
- "result.commands | length == 0"
- name: Create aggregate of VRFs
eos_vrf:
aggregate:
@ -216,6 +267,7 @@
- name: Delete aggregate of VRFs
eos_vrf:
aggregate:
- { name: test1 }
- { name: test2 }
- { name: test3 }
- { name: test4 }
@ -228,6 +280,7 @@
- name: Delete VRFs again (idempotent)
eos_vrf:
aggregate:
- { name: test1 }
- { name: test2 }
- { name: test3 }
- { name: test4 }