From c419dabe12cbcdcc909f613d8544156b64866dc4 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Fri, 11 Sep 2015 19:04:41 +0200 Subject: [PATCH] cloudstack: cs_account re-factor error handling state=present --- cloud/cloudstack/cs_account.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/cloud/cloudstack/cs_account.py b/cloud/cloudstack/cs_account.py index b8c2f0f54ef..2ffecf06fcf 100644 --- a/cloud/cloudstack/cs_account.py +++ b/cloud/cloudstack/cs_account.py @@ -277,21 +277,16 @@ class AnsibleCloudStackAccount(AnsibleCloudStack): def present_account(self): missing_params = [] - if not self.module.params.get('email'): - missing_params.append('email') - - if not self.module.params.get('username'): - missing_params.append('username') - - if not self.module.params.get('password'): - missing_params.append('password') - - if not self.module.params.get('first_name'): - missing_params.append('first_name') - - if not self.module.params.get('last_name'): - missing_params.append('last_name') - + missing_params = [] + for required_params in [ + 'email', + 'username', + 'password', + 'first_name', + 'last_name', + ]: + if not self.module.params.get(required_params): + missing_params.append(required_params) if missing_params: self.module.fail_json(msg="missing required arguments: %s" % ','.join(missing_params))