From 4d26762b341feb0488ce19b87d9e2f4bc2459726 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 8 Jun 2016 18:01:29 +0200 Subject: [PATCH] cloudstack: cs_affinitygroup: overhaul code style --- .../cloud/cloudstack/cs_affinitygroup.py | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_affinitygroup.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_affinitygroup.py index 68600813914..1eb852edfe0 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_affinitygroup.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_affinitygroup.py @@ -115,21 +115,20 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack): } self.affinity_group = None - def get_affinity_group(self): if not self.affinity_group: - args = {} - args['account'] = self.get_account('name') - args['domainid'] = self.get_domain('id') - args['name'] = self.module.params.get('name') - + args = { + 'projectid': self.get_project(key='id'), + 'account': self.get_account(key='name'), + 'domainid': self.get_domain(key='id'), + 'name': self.module.params.get('name'), + } affinity_groups = self.cs.listAffinityGroups(**args) if affinity_groups: self.affinity_group = affinity_groups['affinitygroup'][0] return self.affinity_group - def get_affinity_type(self): affinity_type = self.module.params.get('affinty_type') @@ -143,19 +142,19 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack): return a['type'] self.module.fail_json(msg="affinity group type '%s' not found" % affinity_type) - def create_affinity_group(self): affinity_group = self.get_affinity_group() if not affinity_group: self.result['changed'] = True - args = {} - args['name'] = self.module.params.get('name') - args['type'] = self.get_affinity_type() - args['description'] = self.module.params.get('description') - args['account'] = self.get_account('name') - args['domainid'] = self.get_domain('id') - + args = { + 'name': self.module.params.get('name'), + 'type': self.get_affinity_type(), + 'description': self.module.params.get('description'), + 'projectid': self.get_project(key='id'), + 'account': self.get_account(key='name'), + 'domainid': self.get_domain(key='id'), + } if not self.module.check_mode: res = self.cs.createAffinityGroup(**args) @@ -167,17 +166,17 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack): affinity_group = self._poll_job(res, 'affinitygroup') return affinity_group - def remove_affinity_group(self): affinity_group = self.get_affinity_group() if affinity_group: self.result['changed'] = True - args = {} - args['name'] = self.module.params.get('name') - args['account'] = self.get_account('name') - args['domainid'] = self.get_domain('id') - + args = { + 'name': self.module.params.get('name'), + 'projectid': self.get_project(key='id'), + 'account': self.get_account(key='name'), + 'domainid': self.get_domain(key='id'), + } if not self.module.check_mode: res = self.cs.deleteAffinityGroup(**args) @@ -186,20 +185,21 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack): poll_async = self.module.params.get('poll_async') if res and poll_async: - res = self._poll_job(res, 'affinitygroup') + self._poll_job(res, 'affinitygroup') return affinity_group def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( - name = dict(required=True), - affinty_type = dict(default=None), - description = dict(default=None), - state = dict(choices=['present', 'absent'], default='present'), - domain = dict(default=None), - account = dict(default=None), - poll_async = dict(choices=BOOLEANS, default=True), + name=dict(required=True), + affinty_type=dict(default=None), + description=dict(default=None), + state=dict(choices=['present', 'absent'], default='present'), + domain=dict(default=None), + account=dict(default=None), + project=dict(default=None), + poll_async=dict(type='bool', default=True), )) module = AnsibleModule(