Skip to content

Commit

Permalink
ovirt_affinity_lables_facts: Raise error when host/vm not found (ansi…
Browse files Browse the repository at this point in the history
  • Loading branch information
machacekondra authored and ansibot committed Jul 3, 2018
1 parent faa8328 commit 0a6ab23
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ansible/modules/cloud/ovirt/ovirt_affinity_label_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
create_connection,
get_dict_of_struct,
ovirt_facts_full_argument_spec,
search_by_name,
)


Expand Down Expand Up @@ -127,6 +128,8 @@ def main():
])
if module.params['host']:
hosts_service = connection.system_service().hosts_service()
if search_by_name(hosts_service, module.params['host']) is None:
raise Exception("Host '%s' was not found." % module.params['host'])
labels.extend([
label
for label in all_labels
Expand All @@ -135,6 +138,8 @@ def main():
])
if module.params['vm']:
vms_service = connection.system_service().vms_service()
if search_by_name(vms_service, module.params['vm']) is None:
raise Exception("Vm '%s' was not found." % module.params['vm'])
labels.extend([
label
for label in all_labels
Expand Down

0 comments on commit 0a6ab23

Please sign in to comment.