Use latest available template (#31780)

* Use latest available template

Documentation states:
template_version: version number of the template to be used for VM. By default the latest available version of the template is used.

This was not true because if parameter was not specified, template[0] is choosen, without checking if is the latest. Now, sorting + selecting the latest selects the one with the latest version number.

* Sort in reverse order, style cleanup

Applied fixes from comment
pull/4420/head
Luca Lorenzetto 2017-10-26 15:12:34 +02:00 committed by ansibot
parent 4f01ad41bd
commit ea05035be2
1 changed files with 1 additions and 1 deletions

View File

@ -607,7 +607,7 @@ class VmsModule(BaseModule):
self.param('template_version')
)
)
template = templates[0]
template = sorted(templates, key=lambda t: t.version.version_number, reverse=True)[0]
return template