Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 2.9: Fix nxos_vrf purge breaking with empty aggregate #66367

Merged
merged 1 commit into from Jan 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/66004_fix_nxos_vrf.yaml
@@ -0,0 +1,3 @@
---
bugfixes:
- Fix issue where purge breaks with empty aggregate (https://github.com/ansible/ansible/pull/66004).
20 changes: 12 additions & 8 deletions lib/ansible/modules/network/nxos/nxos_vrf.py
Expand Up @@ -237,11 +237,13 @@ def map_obj_to_commands(updates, module):
admin_state = w['admin_state']
vni = w['vni']
interfaces = w.get('interfaces') or []
state = w['state']
if purge:
state = "absent"
else:
state = w['state']
del w['state']

obj_in_have = search_obj_in_list(name, have)

if state == 'absent' and obj_in_have:
commands.append('no vrf context {0}'.format(name))

Expand Down Expand Up @@ -344,12 +346,14 @@ def map_obj_to_commands(updates, module):


def validate_vrf(name, module):
if name == 'default':
module.fail_json(msg='cannot use default as name of a VRF')
elif len(name) > 32:
module.fail_json(msg='VRF name exceeded max length of 32', name=name)
else:
return name
if name:
name = name.strip()
if name == 'default':
module.fail_json(msg='cannot use default as name of a VRF')
elif len(name) > 32:
module.fail_json(msg='VRF name exceeded max length of 32', name=name)
else:
return name


def map_params_to_obj(module):
Expand Down