diff options
author | GomathiselviS <gomathiselvi@gmail.com> | 2020-02-12 11:12:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-12 11:12:12 -0500 |
commit | 4ec1437212b2fb3c313e44ed5a76b105f2151622 (patch) | |
tree | e8beb4505b0c930885755026ab0f94b20c7d877b | |
parent | cd146b836e032df785ecd9eb711c6ef23c2228b8 (diff) | |
download | ansible-4ec1437212b2fb3c313e44ed5a76b105f2151622.tar.gz |
Fix to - eos_vlans using state parameter replaced is giving odd behavior (#67318)
* Added fix for bug # 54400
* Adding files for RM static_routes
* Added Integration tests
* Revert "Added fix for bug # 54400"
This reverts commit bf42db42697d64abbfea4e546f890637d4a5175b.
* Revert "Adding files for RM static_routes"
This reverts commit dafdd92d4327cfc6dfcebb1e977454b2f77a1daa.
* Revert "Added Integration tests"
This reverts commit 129dc87682bba9292105fc3b642fdf3930ce79fd.
* Adding files for RM static_routes
* Added Integration tests
* Corrected lint errors
* Added fix for bug # 54400
* Revert "Added fix for bug # 54400"
This reverts commit bf42db42697d64abbfea4e546f890637d4a5175b.
* Revert "Adding files for RM static_routes"
This reverts commit dafdd92d4327cfc6dfcebb1e977454b2f77a1daa.
* Revert "Added Integration tests"
This reverts commit 129dc87682bba9292105fc3b642fdf3930ce79fd.
* fix to bug #67313
* fixing rebase issue
* fixing rebase issue
* addressed review comments
* addressed review comments
-rw-r--r-- | lib/ansible/module_utils/network/eos/config/vlans/vlans.py | 9 | ||||
-rw-r--r-- | test/integration/targets/eos_vlans/tests/cli/replaced.yaml | 1 | ||||
-rw-r--r-- | test/units/modules/network/eos/test_eos_vlans.py | 6 |
3 files changed, 9 insertions, 7 deletions
diff --git a/lib/ansible/module_utils/network/eos/config/vlans/vlans.py b/lib/ansible/module_utils/network/eos/config/vlans/vlans.py index 99cb37cd07..c2a701637d 100644 --- a/lib/ansible/module_utils/network/eos/config/vlans/vlans.py +++ b/lib/ansible/module_utils/network/eos/config/vlans/vlans.py @@ -208,16 +208,17 @@ def generate_commands(vlan_id, to_set, to_remove): if "vlan_id" in to_remove: return ["no vlan {0}".format(vlan_id)] + for key in to_remove: + if key in to_set.keys(): + continue + commands.append("no {0}".format(key)) + for key, value in to_set.items(): if key == "vlan_id" or value is None: continue commands.append("{0} {1}".format(key, value)) - for key in to_remove: - commands.append("no {0}".format(key)) - if commands: commands.insert(0, "vlan {0}".format(vlan_id)) - return commands diff --git a/test/integration/targets/eos_vlans/tests/cli/replaced.yaml b/test/integration/targets/eos_vlans/tests/cli/replaced.yaml index ca502ff156..13d68274d2 100644 --- a/test/integration/targets/eos_vlans/tests/cli/replaced.yaml +++ b/test/integration/targets/eos_vlans/tests/cli/replaced.yaml @@ -5,6 +5,7 @@ config: - vlan_id: 20 state: suspend + name: twentyreplaced other_config: - vlan_id: 10 name: ten diff --git a/test/units/modules/network/eos/test_eos_vlans.py b/test/units/modules/network/eos/test_eos_vlans.py index 5bdc878305..63f4d38d14 100644 --- a/test/units/modules/network/eos/test_eos_vlans.py +++ b/test/units/modules/network/eos/test_eos_vlans.py @@ -102,12 +102,12 @@ class TestEosVlansModule(TestEosModule): self.execute_show_command.return_value = [] set_module_args(dict( config=[dict( - vlan_id=30, - name="thirty", + vlan_id=10, + name="tenreplaced", state="suspend" )], state="replaced" )) - commands = ['vlan 30', 'name thirty', 'state suspend'] + commands = ['vlan 10', 'name tenreplaced', 'state suspend'] self.execute_module(changed=True, commands=commands) def test_eos_vlan_replaced_idempotent(self): |