Fix grains.get_or_set_hash to work with multiple entries under same key

This commit is contained in:
Anton Chernev 2015-04-01 14:36:47 +01:00
parent 20d8f757dd
commit 81746bcaee

View File

@ -514,9 +514,12 @@ def get_or_set_hash(name,
val = ''.join([random.SystemRandom().choice(chars) for _ in range(length)])
if ':' in name:
name, rest = name.split(':', 1)
root, rest = name.split(':', 1)
curr = get(root, _infinitedict())
val = _dict_from_path(rest, val)
setval(name, val)
curr.update(val)
setval(root, curr)
else:
setval(name, val)
return get(name)