cloudstack: cs_instancegroup: fix pep8 (#26534)
This commit is contained in:
parent
804f40f7a5
commit
3050856f2a
2 changed files with 25 additions and 25 deletions
|
@ -107,8 +107,13 @@ project:
|
||||||
sample: example project
|
sample: example project
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# 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 AnsibleCloudStackInstanceGroup(AnsibleCloudStack):
|
class AnsibleCloudStackInstanceGroup(AnsibleCloudStack):
|
||||||
|
@ -117,38 +122,36 @@ class AnsibleCloudStackInstanceGroup(AnsibleCloudStack):
|
||||||
super(AnsibleCloudStackInstanceGroup, self).__init__(module)
|
super(AnsibleCloudStackInstanceGroup, self).__init__(module)
|
||||||
self.instance_group = None
|
self.instance_group = None
|
||||||
|
|
||||||
|
|
||||||
def get_instance_group(self):
|
def get_instance_group(self):
|
||||||
if self.instance_group:
|
if self.instance_group:
|
||||||
return self.instance_group
|
return self.instance_group
|
||||||
|
|
||||||
name = self.module.params.get('name')
|
name = self.module.params.get('name')
|
||||||
|
|
||||||
args = {}
|
args = {
|
||||||
args['account'] = self.get_account('name')
|
'account': self.get_account('name'),
|
||||||
args['domainid'] = self.get_domain('id')
|
'domainid': self.get_domain('id'),
|
||||||
args['projectid'] = self.get_project('id')
|
'projectid': self.get_project('id'),
|
||||||
|
}
|
||||||
instance_groups = self.cs.listInstanceGroups(**args)
|
instance_groups = self.cs.listInstanceGroups(**args)
|
||||||
if instance_groups:
|
if instance_groups:
|
||||||
for g in instance_groups['instancegroup']:
|
for g in instance_groups['instancegroup']:
|
||||||
if name in [ g['name'], g['id'] ]:
|
if name in [g['name'], g['id']]:
|
||||||
self.instance_group = g
|
self.instance_group = g
|
||||||
break
|
break
|
||||||
return self.instance_group
|
return self.instance_group
|
||||||
|
|
||||||
|
|
||||||
def present_instance_group(self):
|
def present_instance_group(self):
|
||||||
instance_group = self.get_instance_group()
|
instance_group = self.get_instance_group()
|
||||||
if not instance_group:
|
if not instance_group:
|
||||||
self.result['changed'] = True
|
self.result['changed'] = True
|
||||||
|
|
||||||
args = {}
|
args = {
|
||||||
args['name'] = self.module.params.get('name')
|
'name': self.module.params.get('name'),
|
||||||
args['account'] = self.get_account('name')
|
'account': self.get_account('name'),
|
||||||
args['domainid'] = self.get_domain('id')
|
'domainid': self.get_domain('id'),
|
||||||
args['projectid'] = self.get_project('id')
|
'projectid': self.get_project('id'),
|
||||||
|
}
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.cs.createInstanceGroup(**args)
|
res = self.cs.createInstanceGroup(**args)
|
||||||
if 'errortext' in res:
|
if 'errortext' in res:
|
||||||
|
@ -156,7 +159,6 @@ class AnsibleCloudStackInstanceGroup(AnsibleCloudStack):
|
||||||
instance_group = res['instancegroup']
|
instance_group = res['instancegroup']
|
||||||
return instance_group
|
return instance_group
|
||||||
|
|
||||||
|
|
||||||
def absent_instance_group(self):
|
def absent_instance_group(self):
|
||||||
instance_group = self.get_instance_group()
|
instance_group = self.get_instance_group()
|
||||||
if instance_group:
|
if instance_group:
|
||||||
|
@ -171,11 +173,11 @@ class AnsibleCloudStackInstanceGroup(AnsibleCloudStack):
|
||||||
def main():
|
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),
|
||||||
state = dict(default='present', choices=['present', 'absent']),
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
domain = dict(default=None),
|
domain=dict(),
|
||||||
account = dict(default=None),
|
account=dict(),
|
||||||
project = dict(default=None),
|
project=dict(),
|
||||||
))
|
))
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
@ -200,7 +202,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()
|
||||||
|
|
|
@ -87,7 +87,6 @@ lib/ansible/modules/cloud/cloudscale/cloudscale_server.py
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_configuration.py
|
lib/ansible/modules/cloud/cloudstack/cs_configuration.py
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_instance.py
|
lib/ansible/modules/cloud/cloudstack/cs_instance.py
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py
|
lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_instancegroup.py
|
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_iso.py
|
lib/ansible/modules/cloud/cloudstack/cs_iso.py
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_nic.py
|
lib/ansible/modules/cloud/cloudstack/cs_nic.py
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_portforward.py
|
lib/ansible/modules/cloud/cloudstack/cs_portforward.py
|
||||||
|
|
Loading…
Reference in a new issue