mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
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:
@@ -213,7 +213,15 @@ def validate_local_http_port(value, module):
|
||||
|
||||
def validate_vrf(value, module):
|
||||
out = run_commands(module, ['show vrf'])
|
||||
configured_vrfs = re.findall(r'^\s+(\w+)(?=\s)', out[0], re.M)
|
||||
configured_vrfs = []
|
||||
lines = out[0].strip().splitlines()[3:]
|
||||
for l in lines:
|
||||
if not l:
|
||||
continue
|
||||
splitted_line = re.split(r'\s{2,}', l.strip())
|
||||
if len(splitted_line) > 2:
|
||||
configured_vrfs.append(splitted_line[0])
|
||||
|
||||
configured_vrfs.append('default')
|
||||
if value not in configured_vrfs:
|
||||
module.fail_json(msg='vrf `%s` is not configured on the system' % value)
|
||||
|
||||
Reference in New Issue
Block a user