From 96ebfd78aff742986e1e13860f307bcda566c47c Mon Sep 17 00:00:00 2001 From: Miouge1 Date: Sun, 17 Sep 2017 15:19:58 +0200 Subject: [PATCH] os_image: Add checksum based glance image manipulation (#27107) * Add checksum based glance image manipulation * Update os_image.py * Move to 2.5 --- lib/ansible/modules/cloud/openstack/os_image.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/openstack/os_image.py b/lib/ansible/modules/cloud/openstack/os_image.py index 9df1a45cecc..2bbc98bc46d 100644 --- a/lib/ansible/modules/cloud/openstack/os_image.py +++ b/lib/ansible/modules/cloud/openstack/os_image.py @@ -44,6 +44,12 @@ options: - The Id of the image required: false default: None + checksum: + version_added: "2.5" + description: + - The checksum of the image + required: false + default: None disk_format: description: - The format of the disk that is getting uploaded @@ -138,6 +144,7 @@ def main(): argument_spec = openstack_full_argument_spec( name = dict(required=True), id = dict(default=None), + checksum = dict(default=None), disk_format = dict(default='qcow2', choices=['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', 'vdi', 'iso', 'vhdx', 'ploop']), container_format = dict(default='bare', choices=['ami', 'aki', 'ari', 'bare', 'ovf', 'ova', 'docker']), owner = dict(default=None), @@ -160,7 +167,10 @@ def main(): cloud = shade.openstack_cloud(**module.params) changed = False - image = cloud.get_image(name_or_id=module.params['name']) + if module.params['checksum']: + image = cloud.get_image(name_or_id=None,filters={'checksum': module.params['checksum']}) + else: + image = cloud.get_image(name_or_id=module.params['name']) if module.params['state'] == 'present': if not image: