Fix inventory script for Foreman where group by pattern are not prope… (#25173)

* Fix inventory script for Foreman where group by pattern are not properly safe-guarded.

* Fix pep8 error about tab mixed with blanks.
This commit is contained in:
Eric L 2017-05-31 22:35:28 +02:00 committed by Brian Coca
parent b7662f7e5b
commit eb53f3c129

View file

@ -262,12 +262,9 @@ class ForemanInventory(object):
# Ansible groups by parameters in host groups and Foreman host # Ansible groups by parameters in host groups and Foreman host
# attributes. # attributes.
groupby = copy.copy(params) groupby = dict()
for k, v in host.items(): for k, v in params.items():
if isinstance(v, str): groupby[k] = self.to_safe(str(v))
groupby[k] = self.to_safe(v)
elif isinstance(v, int):
groupby[k] = v
# The name of the ansible groups is given by group_patterns: # The name of the ansible groups is given by group_patterns:
for pattern in self.group_patterns: for pattern in self.group_patterns: