cloudstack: cs_cluster: overhaul code style
This commit is contained in:
parent
4d26762b34
commit
03d3baa164
1 changed files with 33 additions and 38 deletions
|
@ -229,6 +229,7 @@ pod:
|
|||
# import cloudstack common
|
||||
from ansible.module_utils.cloudstack import *
|
||||
|
||||
|
||||
class AnsibleCloudStackCluster(AnsibleCloudStack):
|
||||
|
||||
def __init__(self, module):
|
||||
|
@ -245,29 +246,27 @@ class AnsibleCloudStackCluster(AnsibleCloudStack):
|
|||
}
|
||||
self.cluster = None
|
||||
|
||||
|
||||
def _get_common_cluster_args(self):
|
||||
args = {}
|
||||
args['clustername'] = self.module.params.get('name')
|
||||
args['hypervisor'] = self.module.params.get('hypervisor')
|
||||
args['clustertype'] = self.module.params.get('cluster_type')
|
||||
|
||||
args = {
|
||||
'clustername': self.module.params.get('name'),
|
||||
'hypervisor': self.module.params.get('hypervisor'),
|
||||
'clustertype': self.module.params.get('cluster_type'),
|
||||
}
|
||||
state = self.module.params.get('state')
|
||||
if state in ['enabled', 'disabled']:
|
||||
args['allocationstate'] = state.capitalize()
|
||||
return args
|
||||
|
||||
|
||||
def get_pod(self, key=None):
|
||||
args = {}
|
||||
args['name'] = self.module.params.get('pod')
|
||||
args['zoneid'] = self.get_zone(key='id')
|
||||
args = {
|
||||
'name': self.module.params.get('pod'),
|
||||
'zoneid': self.get_zone(key='id'),
|
||||
}
|
||||
pods = self.cs.listPods(**args)
|
||||
if pods:
|
||||
return self._get_by_key(key, pods['pod'][0])
|
||||
self.module.fail_json(msg="Pod %s not found in zone %s." % (self.module.params.get('pod'), self.get_zone(key='name')))
|
||||
|
||||
|
||||
def get_cluster(self):
|
||||
if not self.cluster:
|
||||
args = {}
|
||||
|
@ -289,7 +288,6 @@ class AnsibleCloudStackCluster(AnsibleCloudStack):
|
|||
self.cluster['clustername'] = self.cluster['name']
|
||||
return self.cluster
|
||||
|
||||
|
||||
def present_cluster(self):
|
||||
cluster = self.get_cluster()
|
||||
if cluster:
|
||||
|
@ -298,7 +296,6 @@ class AnsibleCloudStackCluster(AnsibleCloudStack):
|
|||
cluster = self._create_cluster()
|
||||
return cluster
|
||||
|
||||
|
||||
def _create_cluster(self):
|
||||
required_params = [
|
||||
'cluster_type',
|
||||
|
@ -337,7 +334,6 @@ class AnsibleCloudStackCluster(AnsibleCloudStack):
|
|||
cluster = res['cluster']
|
||||
return cluster
|
||||
|
||||
|
||||
def _update_cluster(self):
|
||||
cluster = self.get_cluster()
|
||||
|
||||
|
@ -354,15 +350,14 @@ class AnsibleCloudStackCluster(AnsibleCloudStack):
|
|||
cluster = res['cluster']
|
||||
return cluster
|
||||
|
||||
|
||||
def absent_cluster(self):
|
||||
cluster = self.get_cluster()
|
||||
if cluster:
|
||||
self.result['changed'] = True
|
||||
|
||||
args = {}
|
||||
args['id'] = cluster['id']
|
||||
|
||||
args = {
|
||||
'id': cluster['id'],
|
||||
}
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.deleteCluster(**args)
|
||||
if 'errortext' in res:
|
||||
|
|
Loading…
Reference in a new issue