Skip to content

Commit

Permalink
fixes an issue with dict_merge in network utils (#41107)
Browse files Browse the repository at this point in the history
This change address a problem where the dict_merge function would fail
due to the value being a nested dict.  This will now recursively pass
the value back through the dict_merge function.
Merge to devel #41107

(cherry picked from commit 2a4be27)

Update changelog

Fix review comments
  • Loading branch information
privateip authored and abadger committed Dec 5, 2018
1 parent a928ea4 commit 799f8e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/49474-network_utils_dict_merge_fix.yaml
@@ -0,0 +1,3 @@
---
bugfixes:
- fixes an issue with dict_merge in network utils (https://github.com/ansible/ansible/pull/49474)
6 changes: 5 additions & 1 deletion lib/ansible/module_utils/network/common/utils.py
Expand Up @@ -34,6 +34,7 @@
from struct import pack
from socket import inet_aton, inet_ntoa

from ansible.module_utils.common._collections_compat import Mapping
from ansible.module_utils.six import iteritems, string_types
from ansible.module_utils.six.moves import zip
from ansible.module_utils.basic import AnsibleFallbackNotFound
Expand Down Expand Up @@ -275,7 +276,10 @@ def dict_merge(base, other):
if key in other:
item = other.get(key)
if item is not None:
combined[key] = dict_merge(value, other[key])
if isinstance(other[key], Mapping):
combined[key] = dict_merge(value, other[key])
else:
combined[key] = other[key]
else:
combined[key] = item
else:
Expand Down

0 comments on commit 799f8e9

Please sign in to comment.