From 1d0df46475e6194eedaa52622e778e0fee5c7378 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Mon, 11 Apr 2016 20:02:03 +0200 Subject: [PATCH] cloudstack: cs_template: fix state=extracted * url arg is optional but we enforced it * url is in a required together, but args only relevant while registering --- cloud/cloudstack/cs_template.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cloud/cloudstack/cs_template.py b/cloud/cloudstack/cs_template.py index 537d83e3c2e..e53c8e286e4 100644 --- a/cloud/cloudstack/cs_template.py +++ b/cloud/cloudstack/cs_template.py @@ -470,6 +470,12 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack): def register_template(self): + required_params = [ + 'format', + 'url', + 'hypervisor', + ] + self.module.fail_on_missing_params(required_params=required_params) template = self.get_template() if not template: self.result['changed'] = True @@ -537,9 +543,6 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack): args['mode'] = self.module.params.get('mode') args['zoneid'] = self.get_zone(key='id') - if not args['url']: - self.module.fail_json(msg="Missing required arguments: url") - self.result['changed'] = True if not self.module.check_mode: @@ -613,14 +616,9 @@ def main(): poll_async = dict(type='bool', default=True), )) - required_together = cs_required_together() - required_together.extend([ - ['format', 'url', 'hypervisor'], - ]) - module = AnsibleModule( argument_spec=argument_spec, - required_together=required_together, + required_together=cs_required_together(), mutually_exclusive = ( ['url', 'vm'], ['zone', 'cross_zones'],