summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Nalawade <ganesh634@gmail.com>2017-11-01 23:02:51 +0530
committerGitHub <noreply@github.com>2017-11-01 23:02:51 +0530
commitbc01b5d9812ce1f2943769d4b9f2880d3195ee6b (patch)
tree9d993553a94ae17a7cda8246ba174cc7f20ded71
parentb8ee3bb24fd3079c527785a14366bdcd4ddbcdab (diff)
downloadansible-bc01b5d9812ce1f2943769d4b9f2880d3195ee6b.tar.gz
eos_eapi: adding the desired state config to the new vrf fixes #32111 (#32112) (#32452)
* adding the desired state config to the new vrf fixes #32111 * fix default vrf initial configured * add unit test * Update CHANGELOG (cherry picked from commit 2c99cbc8746735381eec6e4ee3f5ae8b9e7d7971)
-rw-r--r--CHANGELOG.md2
-rw-r--r--lib/ansible/modules/network/eos/eos_eapi.py10
-rw-r--r--test/units/modules/network/eos/test_eos_eapi.py5
3 files changed, 14 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6c5b20746..fbba26e0c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -113,7 +113,7 @@ Ansible Changes By Release
* Fix ios_logging module issue where facility is being deleted along with host:
(https://github.com/ansible/ansible/pull/32234)
* Fix wrong prompt issue for network modules (https://github.com/ansible/ansible/pull/32426)
-
+* Fix eos_eapi to enable non-default vrfs if the default vrf is already configured (https://github.com/ansible/ansible/pull/32112)
<a id="2.4.1"></a>
diff --git a/lib/ansible/modules/network/eos/eos_eapi.py b/lib/ansible/modules/network/eos/eos_eapi.py
index c3ae14f333..541b104a87 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 5ef9a3b14f..dfb4e83f4a 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)