Skip to content

Commit

Permalink
cloudstack: fix pep8 cs_pod
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo committed May 28, 2017
1 parent 3ef37e8 commit 9cbae80
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 35 deletions.
68 changes: 34 additions & 34 deletions lib/ansible/modules/cloud/cloudstack/cs_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,37 +155,42 @@
sample: ch-gva-2
'''

# 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 AnsibleCloudStackPod(AnsibleCloudStack):

def __init__(self, module):
super(AnsibleCloudStackPod, self).__init__(module)
self.returns = {
'endip': 'end_ip',
'startip': 'start_ip',
'gateway': 'gateway',
'netmask': 'netmask',
'allocationstate': 'allocation_state',
'endip': 'end_ip',
'startip': 'start_ip',
'gateway': 'gateway',
'netmask': 'netmask',
'allocationstate': 'allocation_state',
}
self.pod = None


def _get_common_pod_args(self):
args = {}
args['name'] = self.module.params.get('name')
args['zoneid'] = self.get_zone(key='id')
args['startip'] = self.module.params.get('start_ip')
args['endip'] = self.module.params.get('end_ip')
args['netmask'] = self.module.params.get('netmask')
args['gateway'] = self.module.params.get('gateway')
args = {
'name': self.module.params.get('name'),
'zoneid': self.get_zone(key='id'),
'startip': self.module.params.get('start_ip'),
'endip': self.module.params.get('end_ip'),
'netmask': self.module.params.get('netmask'),
'gateway': self.module.params.get('gateway')
}
state = self.module.params.get('state')
if state in [ 'enabled', 'disabled']:
if state in ['enabled', 'disabled']:
args['allocationstate'] = state.capitalize()
return args


def get_pod(self):
if not self.pod:
args = {}
Expand All @@ -206,7 +211,6 @@ def get_pod(self):
self.pod = pods['pod'][0]
return self.pod


def present_pod(self):
pod = self.get_pod()
if pod:
Expand All @@ -215,7 +219,6 @@ def present_pod(self):
pod = self._create_pod()
return pod


def _create_pod(self):
required_params = [
'start_ip',
Expand All @@ -234,7 +237,6 @@ def _create_pod(self):
pod = res['pod']
return pod


def _update_pod(self):
pod = self.get_pod()
args = self._get_common_pod_args()
Expand All @@ -250,15 +252,14 @@ def _update_pod(self):
pod = res['pod']
return pod


def absent_pod(self):
pod = self.get_pod()
if pod:
self.result['changed'] = True

args = {}
args['id'] = pod['id']

args = {
'id': pod['id']
}
if not self.module.check_mode:
res = self.cs.deletePod(**args)
if 'errortext' in res:
Expand All @@ -269,14 +270,14 @@ def absent_pod(self):
def main():
argument_spec = cs_argument_spec()
argument_spec.update(dict(
id = dict(default=None),
name = dict(required=True),
gateway = dict(default=None),
netmask = dict(default=None),
start_ip = dict(default=None),
end_ip = dict(default=None),
zone = dict(default=None),
state = dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'),
id=dict(),
name=dict(required=True),
gateway=dict(),
netmask=dict(),
start_ip=dict(),
end_ip=dict(),
zone=dict(),
state=dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'),
))

module = AnsibleModule(
Expand All @@ -300,7 +301,6 @@ def main():

module.exit_json(**result)

# import module snippets
from ansible.module_utils.basic import *

if __name__ == '__main__':
main()
1 change: 0 additions & 1 deletion test/sanity/pep8/legacy-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_iso.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_project.py
lib/ansible/modules/cloud/cloudstack/cs_router.py
Expand Down

0 comments on commit 9cbae80

Please sign in to comment.