From 2c99cbc8746735381eec6e4ee3f5ae8b9e7d7971 Mon Sep 17 00:00:00 2001 From: Dave Thelen Date: Wed, 1 Nov 2017 12:48:52 -0400 Subject: [PATCH] eos_eapi: adding the desired state config to the new vrf fixes #32111 (#32112) * adding the desired state config to the new vrf fixes #32111 * fix default vrf initial configured * add unit test --- lib/ansible/modules/network/eos/eos_eapi.py | 10 ++++++++-- test/units/modules/network/eos/test_eos_eapi.py | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/eos/eos_eapi.py b/lib/ansible/modules/network/eos/eos_eapi.py index c3ae14f3339..541b104a87d 100644 --- a/lib/ansible/modules/network/eos/eos_eapi.py +++ b/lib/ansible/modules/network/eos/eos_eapi.py @@ -260,11 +260,17 @@ def map_obj_to_commands(updates, module, warnings): else: add('protocol unix-socket') + if needs_update('state') and not needs_update('vrf'): + if want['state'] == 'stopped': + add('shutdown') + elif want['state'] == 'started': + add('no shutdown') + if needs_update('vrf'): add('vrf %s' % want['vrf']) - - if needs_update('state'): + # switching operational vrfs here + # need to add the desired state as well if want['state'] == 'stopped': add('shutdown') elif want['state'] == 'started': diff --git a/test/units/modules/network/eos/test_eos_eapi.py b/test/units/modules/network/eos/test_eos_eapi.py index 5ef9a3b14f2..dfb4e83f4a1 100644 --- a/test/units/modules/network/eos/test_eos_eapi.py +++ b/test/units/modules/network/eos/test_eos_eapi.py @@ -134,6 +134,11 @@ class TestEosEapiModule(TestEosModule): commands = ['management api http-commands', 'vrf test', 'no shutdown'] self.start_unconfigured(changed=True, commands=commands) + def test_eos_eapi_change_from_default_vrf(self): + set_module_args(dict(vrf='test')) + commands = ['management api http-commands', 'vrf test', 'no shutdown'] + self.start_configured(changed=True, commands=commands) + def test_eos_eapi_vrf_missing(self): set_module_args(dict(vrf='missing')) self.start_unconfigured(failed=True)