mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
ovirt_vms: Search template also by cluster (#44161)
This commit is contained in:
@@ -916,7 +916,9 @@ class VmsModule(BaseModule):
|
|||||||
template = None
|
template = None
|
||||||
templates_service = self._connection.system_service().templates_service()
|
templates_service = self._connection.system_service().templates_service()
|
||||||
if self.param('template'):
|
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'):
|
if self.param('template_version'):
|
||||||
templates = [
|
templates = [
|
||||||
t for t in templates
|
t for t in templates
|
||||||
@@ -924,9 +926,10 @@ class VmsModule(BaseModule):
|
|||||||
]
|
]
|
||||||
if not templates:
|
if not templates:
|
||||||
raise ValueError(
|
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'),
|
||||||
self.param('template_version')
|
self.param('template_version'),
|
||||||
|
self.param('cluster')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
template = sorted(templates, key=lambda t: t.version.version_number, reverse=True)[0]
|
template = sorted(templates, key=lambda t: t.version.version_number, reverse=True)[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user