From a48a7eecc81ae5be83ab10d99fdd60437822084f Mon Sep 17 00:00:00 2001 From: Lukas Bednar Date: Thu, 10 Aug 2017 14:32:25 +0200 Subject: [PATCH] ovirt_templates: added option to name imported disk as a template (#27902) * ovirt_templates: added option to name imported disk as a template * ovirt_templates: added version_added to new attribute * ovirt_templates: added alias for image_name and example * added alias glance_image_disk_name for image_name * example how to import image from glance as template * improve description of template_image_disk_name --- .../modules/cloud/ovirt/ovirt_templates.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py index 695800a7df9..b1174cd028c 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py @@ -72,6 +72,13 @@ options: description: - "When C(state) is I(imported) and C(image_provider) is used this parameter specifies the name of disk to be imported as template." + aliases: ['glance_image_disk_name'] + template_image_disk_name: + description: + - "When C(state) is I(imported) and C(image_provider) is used this parameter specifies the new name for imported disk, + if omitted then I(image_disk) name is used by default. + This parameter is used only in case of importing disk image from Glance domain." + version_added: "2.4" storage_domain: description: - "When C(state) is I(imported) this parameter specifies the name of the destination data storage domain. @@ -116,6 +123,16 @@ EXAMPLES = ''' name: mytemplate storage_domain: mystorage cluster: mycluster + +# Import image from Glance s a template +- ovirt_templates: + state: imported + name: mytemplate + image_disk: "centos7" + template_image_disk_name: centos7_from_glance + image_provider: "glance_domain" + storage_domain: mystorage + cluster: mycluster ''' RETURN = ''' @@ -228,7 +245,8 @@ def main(): storage_domain=dict(default=None), exclusive=dict(type='bool'), image_provider=dict(default=None), - image_disk=dict(default=None), + image_disk=dict(default=None, aliases=['glance_image_disk_name']), + template_image_disk_name=dict(default=None), ) module = AnsibleModule( argument_spec=argument_spec, @@ -279,7 +297,7 @@ def main(): if module.params['image_provider']: kwargs.update( disk=otypes.Disk( - name=module.params['image_disk'] + name=module.params['template_image_disk_name'] or module.params['image_disk'] ), template=otypes.Template( name=module.params['name'],