From 3f158a4688ff391e895078b9a62cd37a1536d934 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sat, 17 Aug 2013 17:56:19 +0200 Subject: [PATCH] image_id is not required to delete a vm from openstack Since deletion do not check the type of image or anything, and since that's tedious to keep track of the image_id and just adding noise to add image_id for nothing, this commit just relax the requirement. --- library/cloud/nova_compute | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/cloud/nova_compute b/library/cloud/nova_compute index 90583ee3f1..3252f49dc9 100644 --- a/library/cloud/nova_compute +++ b/library/cloud/nova_compute @@ -213,7 +213,7 @@ def main(): auth_url = dict(default='http://127.0.0.1:35357/v2.0/'), region_name = dict(default=None), name = dict(required=True), - image_id = dict(required=True), + image_id = dict(default=None), flavor_id = dict(default=1), key_name = dict(default=None), security_groups = dict(default='default'), @@ -234,8 +234,11 @@ def main(): except Exception as e: module.fail_json( msg = "Error in authenticating to nova: %s" % e.message) if module.params['state'] == 'present': - _get_server_state(module, nova) - _create_server(module, nova) + if not module.params['image_id']: + module.fail_json( msg = "Parameter 'image_id' is required if state == 'present'") + else: + _get_server_state(module, nova) + _create_server(module, nova) if module.params['state'] == 'absent': _get_server_state(module, nova) _delete_server(module, nova)