Skip to content

Commit

Permalink
Merge pull request #14 from agx/find-os
Browse files Browse the repository at this point in the history
Search for title instead of just name
  • Loading branch information
Nosmoht committed Apr 12, 2016
2 parents 7b0396d + 6b92850 commit b4ef4cd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions foreman_config_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def equal_dict_lists(l1, l2, compare_key='name'):
return s1.issubset(s2) and s2.issubset(s1)


def get_resources(resource_type, resource_func, resource_specs):
def get_resources(resource_type, resource_func, resource_specs, search_field='name'):
result = list()
if not resource_specs:
return result
Expand All @@ -130,7 +130,7 @@ def get_resources(resource_type, resource_func, resource_specs):
for key in item:
search_data[key] = item[key]
else:
search_data['name'] = item
search_data[search_field] = item
try:
resource = resource_func(data=search_data)
if not resource:
Expand Down Expand Up @@ -212,7 +212,8 @@ def ensure():
if not snippet:
data['operatingsystems'] = get_resources(resource_type='operatingsystem',
resource_func=theforeman.search_operatingsystem,
resource_specs=operatingsystems)
resource_specs=operatingsystems,
search_field='title')

if not config_template:
try:
Expand Down

0 comments on commit b4ef4cd

Please sign in to comment.