cloudstack: fix pep8 cs_pod
This commit is contained in:
parent
3ef37e88fe
commit
9cbae80c3b
2 changed files with 34 additions and 35 deletions
|
@ -155,8 +155,14 @@ zone:
|
||||||
sample: ch-gva-2
|
sample: ch-gva-2
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# 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 AnsibleCloudStackPod(AnsibleCloudStack):
|
class AnsibleCloudStackPod(AnsibleCloudStack):
|
||||||
|
|
||||||
|
@ -171,21 +177,20 @@ class AnsibleCloudStackPod(AnsibleCloudStack):
|
||||||
}
|
}
|
||||||
self.pod = None
|
self.pod = None
|
||||||
|
|
||||||
|
|
||||||
def _get_common_pod_args(self):
|
def _get_common_pod_args(self):
|
||||||
args = {}
|
args = {
|
||||||
args['name'] = self.module.params.get('name')
|
'name': self.module.params.get('name'),
|
||||||
args['zoneid'] = self.get_zone(key='id')
|
'zoneid': self.get_zone(key='id'),
|
||||||
args['startip'] = self.module.params.get('start_ip')
|
'startip': self.module.params.get('start_ip'),
|
||||||
args['endip'] = self.module.params.get('end_ip')
|
'endip': self.module.params.get('end_ip'),
|
||||||
args['netmask'] = self.module.params.get('netmask')
|
'netmask': self.module.params.get('netmask'),
|
||||||
args['gateway'] = self.module.params.get('gateway')
|
'gateway': self.module.params.get('gateway')
|
||||||
|
}
|
||||||
state = self.module.params.get('state')
|
state = self.module.params.get('state')
|
||||||
if state in ['enabled', 'disabled']:
|
if state in ['enabled', 'disabled']:
|
||||||
args['allocationstate'] = state.capitalize()
|
args['allocationstate'] = state.capitalize()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def get_pod(self):
|
def get_pod(self):
|
||||||
if not self.pod:
|
if not self.pod:
|
||||||
args = {}
|
args = {}
|
||||||
|
@ -206,7 +211,6 @@ class AnsibleCloudStackPod(AnsibleCloudStack):
|
||||||
self.pod = pods['pod'][0]
|
self.pod = pods['pod'][0]
|
||||||
return self.pod
|
return self.pod
|
||||||
|
|
||||||
|
|
||||||
def present_pod(self):
|
def present_pod(self):
|
||||||
pod = self.get_pod()
|
pod = self.get_pod()
|
||||||
if pod:
|
if pod:
|
||||||
|
@ -215,7 +219,6 @@ class AnsibleCloudStackPod(AnsibleCloudStack):
|
||||||
pod = self._create_pod()
|
pod = self._create_pod()
|
||||||
return pod
|
return pod
|
||||||
|
|
||||||
|
|
||||||
def _create_pod(self):
|
def _create_pod(self):
|
||||||
required_params = [
|
required_params = [
|
||||||
'start_ip',
|
'start_ip',
|
||||||
|
@ -234,7 +237,6 @@ class AnsibleCloudStackPod(AnsibleCloudStack):
|
||||||
pod = res['pod']
|
pod = res['pod']
|
||||||
return pod
|
return pod
|
||||||
|
|
||||||
|
|
||||||
def _update_pod(self):
|
def _update_pod(self):
|
||||||
pod = self.get_pod()
|
pod = self.get_pod()
|
||||||
args = self._get_common_pod_args()
|
args = self._get_common_pod_args()
|
||||||
|
@ -250,15 +252,14 @@ class AnsibleCloudStackPod(AnsibleCloudStack):
|
||||||
pod = res['pod']
|
pod = res['pod']
|
||||||
return pod
|
return pod
|
||||||
|
|
||||||
|
|
||||||
def absent_pod(self):
|
def absent_pod(self):
|
||||||
pod = self.get_pod()
|
pod = self.get_pod()
|
||||||
if pod:
|
if pod:
|
||||||
self.result['changed'] = True
|
self.result['changed'] = True
|
||||||
|
|
||||||
args = {}
|
args = {
|
||||||
args['id'] = pod['id']
|
'id': pod['id']
|
||||||
|
}
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.cs.deletePod(**args)
|
res = self.cs.deletePod(**args)
|
||||||
if 'errortext' in res:
|
if 'errortext' in res:
|
||||||
|
@ -269,13 +270,13 @@ class AnsibleCloudStackPod(AnsibleCloudStack):
|
||||||
def main():
|
def main():
|
||||||
argument_spec = cs_argument_spec()
|
argument_spec = cs_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
id = dict(default=None),
|
id=dict(),
|
||||||
name=dict(required=True),
|
name=dict(required=True),
|
||||||
gateway = dict(default=None),
|
gateway=dict(),
|
||||||
netmask = dict(default=None),
|
netmask=dict(),
|
||||||
start_ip = dict(default=None),
|
start_ip=dict(),
|
||||||
end_ip = dict(default=None),
|
end_ip=dict(),
|
||||||
zone = dict(default=None),
|
zone=dict(),
|
||||||
state=dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'),
|
state=dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -300,7 +301,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()
|
||||||
|
|
|
@ -170,7 +170,6 @@ lib/ansible/modules/cloud/cloudstack/cs_instance_facts.py
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_instancegroup.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_pod.py
|
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_portforward.py
|
lib/ansible/modules/cloud/cloudstack/cs_portforward.py
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_project.py
|
lib/ansible/modules/cloud/cloudstack/cs_project.py
|
||||||
lib/ansible/modules/cloud/cloudstack/cs_router.py
|
lib/ansible/modules/cloud/cloudstack/cs_router.py
|
||||||
|
|
Loading…
Reference in a new issue