From df581eb74959dc99fabcc3ac223fa94973bcf5b1 Mon Sep 17 00:00:00 2001 From: Ondra Machacek Date: Wed, 15 Aug 2018 14:22:49 +0200 Subject: [PATCH] ovirt_vms: Search template also by cluster (#44161) --- lib/ansible/modules/cloud/ovirt/ovirt_vms.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py index 4d069dd541..6031ebb2fc 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py @@ -916,7 +916,9 @@ class VmsModule(BaseModule): template = None templates_service = self._connection.system_service().templates_service() if self.param('template'): - templates = templates_service.list(search='name=%s' % self.param('template')) + templates = templates_service.list( + search='name=%s and cluster=%s' % (self.param('template'), self.param('cluster')) + ) if self.param('template_version'): templates = [ t for t in templates @@ -924,9 +926,10 @@ class VmsModule(BaseModule): ] if not templates: raise ValueError( - "Template with name '%s' and version '%s' was not found'" % ( + "Template with name '%s' and version '%s' in cluster '%s' was not found'" % ( self.param('template'), - self.param('template_version') + self.param('template_version'), + self.param('cluster') ) ) template = sorted(templates, key=lambda t: t.version.version_number, reverse=True)[0]