cloudstack: fix pep8 cs_affinitygroup

This commit is contained in:
Rene Moser 2017-05-28 01:08:03 +02:00 committed by René Moser
parent 9fe3891d65
commit e3f75227bc
2 changed files with 30 additions and 12 deletions

View file

@ -128,8 +128,13 @@ account:
sample: example account
'''
# import cloudstack common
from ansible.module_utils.cloudstack import *
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.cloudstack import (
AnsibleCloudStack,
CloudStackException,
cs_argument_spec,
cs_required_together
)
class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
@ -166,7 +171,7 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
for a in affinity_types['affinityGroupType']:
if a['type'] == affinity_type:
return a['type']
self.module.fail_json(msg="affinity group type '%s' not found" % affinity_type)
self.module.fail_json(msg="affinity group type not found: %s" % affinity_type)
def create_affinity_group(self):
affinity_group = self.get_affinity_group()
@ -219,12 +224,12 @@ def main():
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name=dict(required=True),
affinty_type=dict(default=None),
description=dict(default=None),
affinty_type=dict(),
description=dict(),
state=dict(choices=['present', 'absent'], default='present'),
domain=dict(default=None),
account=dict(default=None),
project=dict(default=None),
domain=dict(),
account=dict(),
project=dict(),
poll_async=dict(type='bool', default=True),
))
@ -250,7 +255,6 @@ def main():
module.exit_json(**result)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__':
main()

View file

@ -1,6 +1,8 @@
---
- name: setup
cs_affinitygroup: name={{ cs_resource_prefix }}_ag state=absent
cs_affinitygroup:
name: "{{ cs_resource_prefix }}_ag"
state: absent
register: ag
- name: verify setup
assert:
@ -8,7 +10,7 @@
- ag|success
- name: test fail if missing name
action: cs_affinitygroup
cs_affinitygroup:
register: ag
ignore_errors: true
- name: verify results of fail if missing name
@ -17,6 +19,18 @@
- ag|failed
- "ag.msg == 'missing required arguments: name'"
- name: test fail unknown affinity type
cs_affinitygroup:
name: "{{ cs_resource_prefix }}_ag"
affinty_type: unexistent affinity type
register: ag
ignore_errors: true
- name: verify test fail unknown affinity type
assert:
that:
- ag|failed
- "ag.msg == 'affinity group type not found: unexistent affinity type'"
- name: test present affinity group in check mode
cs_affinitygroup: name={{ cs_resource_prefix }}_ag
register: ag