summaryrefslogtreecommitdiff
path: root/lib/ansible/module_utils/network/ios
diff options
context:
space:
mode:
authorSumit Jaiswal <sjaiswal@redhat.com>2019-09-04 15:51:05 +0530
committerToshio Kuratomi <a.badger@gmail.com>2019-09-04 12:06:58 -0700
commit58fda1632f394d5f5885a311c86ac68201e143fd (patch)
tree1e0475bffa0837ee5192f26430df1c5f4ebd229a /lib/ansible/module_utils/network/ios
parentfa3d52729cd7e4d0e5f1d63dc8035e6a41038181 (diff)
downloadansible-58fda1632f394d5f5885a311c86ac68201e143fd.tar.gz
Fixes IOS L3 intermittent zuul failure (#61682)
* fix ios l3 intermittent failure * fix self * dict to ordered dict * fix diff_again fn Signed-off-by: Sumit Jaiswal <sjaiswal@redhat.com> * remove orderdict as its expensive Signed-off-by: Sumit Jaiswal <sjaiswal@redhat.com> * update verify fn Signed-off-by: Sumit Jaiswal <sjaiswal@redhat.com> (cherry picked from commit 2672dc9694f3fe80c7a817f81554a6c8561b065b)
Diffstat (limited to 'lib/ansible/module_utils/network/ios')
-rw-r--r--lib/ansible/module_utils/network/ios/config/l3_interfaces/l3_interfaces.py38
-rw-r--r--lib/ansible/module_utils/network/ios/utils/utils.py2
2 files changed, 39 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/network/ios/config/l3_interfaces/l3_interfaces.py b/lib/ansible/module_utils/network/ios/config/l3_interfaces/l3_interfaces.py
index 03bbf6b6c5..84e2e4a01a 100644
--- a/lib/ansible/module_utils/network/ios/config/l3_interfaces/l3_interfaces.py
+++ b/lib/ansible/module_utils/network/ios/config/l3_interfaces/l3_interfaces.py
@@ -204,6 +204,42 @@ class L3_Interfaces(ConfigBase):
return commands
+ def verify_diff_again(self, want, have):
+ """
+ Verify the IPV4 difference again as sometimes due to
+ change in order of set, set difference may result into change,
+ when there's actually no difference between want and have
+ :param want: want_dict IPV4
+ :param have: have_dict IPV4
+ :return: diff
+ """
+ diff = False
+ for each in want:
+ each_want = dict(each)
+ for every in have:
+ every_have = dict(every)
+ if each_want.get('address') != every_have.get('address') and \
+ each_want.get('secondary') != every_have.get('secondary') and \
+ len(each_want.keys()) == len(every_have.keys()):
+ diff = True
+ break
+ elif each_want.get('dhcp_client') != every_have.get('dhcp_client') and each_want.get(
+ 'dhcp_client') is not None:
+ diff = True
+ break
+ elif each_want.get('dhcp_hostname') != every_have.get('dhcp_hostname') and each_want.get(
+ 'dhcp_hostname') is not None:
+ diff = True
+ break
+ elif each_want.get('address') != every_have.get('address') and len(each_want.keys()) == len(
+ every_have.keys()):
+ diff = True
+ break
+ if diff:
+ break
+
+ return diff
+
def _set_config(self, want, have, module):
# Set the interface config based on the want and have config
commands = []
@@ -225,6 +261,8 @@ class L3_Interfaces(ConfigBase):
# Get the diff b/w want and have IPV4
if have.get('ipv4'):
ipv4 = tuple(set(dict(want_dict).get('ipv4')) - set(dict(have_dict).get('ipv4')))
+ if ipv4:
+ ipv4 = ipv4 if self.verify_diff_again(dict(want_dict).get('ipv4'), dict(have_dict).get('ipv4')) else ()
else:
diff = want_dict - have_dict
ipv4 = dict(diff).get('ipv4')
diff --git a/lib/ansible/module_utils/network/ios/utils/utils.py b/lib/ansible/module_utils/network/ios/utils/utils.py
index f9a4b9c0ff..9c30c1bdbd 100644
--- a/lib/ansible/module_utils/network/ios/utils/utils.py
+++ b/lib/ansible/module_utils/network/ios/utils/utils.py
@@ -30,7 +30,7 @@ def add_command_to_config_list(interface, cmd, commands):
def dict_to_set(sample_dict):
# Generate a set with passed dictionary for comparison
- test_dict = {}
+ test_dict = dict()
if isinstance(sample_dict, dict):
for k, v in iteritems(sample_dict):
if v is not None: