cloudstack: fix pep8 cs_affinitygroup
parent
9fe3891d65
commit
e3f75227bc
|
@ -128,8 +128,13 @@ account:
|
||||||
sample: example account
|
sample: example account
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# import cloudstack common
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.cloudstack import *
|
from ansible.module_utils.cloudstack import (
|
||||||
|
AnsibleCloudStack,
|
||||||
|
CloudStackException,
|
||||||
|
cs_argument_spec,
|
||||||
|
cs_required_together
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
|
@ -166,7 +171,7 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
||||||
for a in affinity_types['affinityGroupType']:
|
for a in affinity_types['affinityGroupType']:
|
||||||
if a['type'] == affinity_type:
|
if a['type'] == affinity_type:
|
||||||
return a['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):
|
def create_affinity_group(self):
|
||||||
affinity_group = self.get_affinity_group()
|
affinity_group = self.get_affinity_group()
|
||||||
|
@ -219,12 +224,12 @@ def main():
|
||||||
argument_spec = cs_argument_spec()
|
argument_spec = cs_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
name=dict(required=True),
|
name=dict(required=True),
|
||||||
affinty_type=dict(default=None),
|
affinty_type=dict(),
|
||||||
description=dict(default=None),
|
description=dict(),
|
||||||
state=dict(choices=['present', 'absent'], default='present'),
|
state=dict(choices=['present', 'absent'], default='present'),
|
||||||
domain=dict(default=None),
|
domain=dict(),
|
||||||
account=dict(default=None),
|
account=dict(),
|
||||||
project=dict(default=None),
|
project=dict(),
|
||||||
poll_async=dict(type='bool', default=True),
|
poll_async=dict(type='bool', default=True),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -250,7 +255,6 @@ def main():
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
---
|
---
|
||||||
- name: setup
|
- name: setup
|
||||||
cs_affinitygroup: name={{ cs_resource_prefix }}_ag state=absent
|
cs_affinitygroup:
|
||||||
|
name: "{{ cs_resource_prefix }}_ag"
|
||||||
|
state: absent
|
||||||
register: ag
|
register: ag
|
||||||
- name: verify setup
|
- name: verify setup
|
||||||
assert:
|
assert:
|
||||||
|
@ -8,7 +10,7 @@
|
||||||
- ag|success
|
- ag|success
|
||||||
|
|
||||||
- name: test fail if missing name
|
- name: test fail if missing name
|
||||||
action: cs_affinitygroup
|
cs_affinitygroup:
|
||||||
register: ag
|
register: ag
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
- name: verify results of fail if missing name
|
- name: verify results of fail if missing name
|
||||||
|
@ -17,6 +19,18 @@
|
||||||
- ag|failed
|
- ag|failed
|
||||||
- "ag.msg == 'missing required arguments: name'"
|
- "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
|
- name: test present affinity group in check mode
|
||||||
cs_affinitygroup: name={{ cs_resource_prefix }}_ag
|
cs_affinitygroup: name={{ cs_resource_prefix }}_ag
|
||||||
register: ag
|
register: ag
|
||||||
|
|
Loading…
Reference in New Issue