Merge pull request #2388 from resmo/for-ansible-2.2

[2.2] cloudstack related changes for Ansible 2.2
This commit is contained in:
René Moser 2016-06-13 19:41:43 +02:00 committed by GitHub
commit e596ad9294
29 changed files with 176 additions and 504 deletions

View file

@ -172,12 +172,6 @@ domain:
sample: ROOT
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -196,28 +190,26 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
'domain_admin': 2,
}
def get_account_type(self):
account_type = self.module.params.get('account_type')
return self.account_types[account_type]
def get_account(self):
if not self.account:
args = {}
args['listall'] = True
args['domainid'] = self.get_domain('id')
args = {
'listall': True,
'domainid': self.get_domain(key='id'),
}
accounts = self.cs.listAccounts(**args)
if accounts:
account_name = self.module.params.get('name')
for a in accounts['account']:
if account_name in [ a['name'] ]:
if account_name == a['name']:
self.account = a
break
return self.account
def enable_account(self):
account = self.get_account()
if not account:
@ -225,10 +217,11 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
if account['state'].lower() != 'enabled':
self.result['changed'] = True
args = {}
args['id'] = account['id']
args['account'] = self.module.params.get('name')
args['domainid'] = self.get_domain('id')
args = {
'id': account['id'],
'account': self.module.params.get('name'),
'domainid': self.get_domain(key='id')
}
if not self.module.check_mode:
res = self.cs.enableAccount(**args)
if 'errortext' in res:
@ -236,15 +229,12 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
account = res['account']
return account
def lock_account(self):
return self.lock_or_disable_account(lock=True)
def disable_account(self):
return self.lock_or_disable_account()
def lock_or_disable_account(self, lock=False):
account = self.get_account()
if not account:
@ -254,14 +244,15 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
if lock and account['state'].lower() == 'disabled':
account = self.enable_account()
if lock and account['state'].lower() != 'locked' \
or not lock and account['state'].lower() != 'disabled':
if (lock and account['state'].lower() != 'locked' or
not lock and account['state'].lower() != 'disabled'):
self.result['changed'] = True
args = {}
args['id'] = account['id']
args['account'] = self.module.params.get('name')
args['domainid'] = self.get_domain('id')
args['lock'] = lock
args = {
'id': account['id'],
'account': self.module.params.get('name'),
'domainid': self.get_domain(key='id'),
'lock': lock,
}
if not self.module.check_mode:
account = self.cs.disableAccount(**args)
@ -270,42 +261,36 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
account = self._poll_job(account, 'account')
account = self.poll_job(account, 'account')
return account
def present_account(self):
missing_params = []
missing_params = []
for required_params in [
required_params = [
'email',
'username',
'password',
'first_name',
'last_name',
]:
if not self.module.params.get(required_params):
missing_params.append(required_params)
if missing_params:
self.module.fail_json(msg="missing required arguments: %s" % ','.join(missing_params))
]
self.module.fail_on_missing_params(required_params=required_params)
account = self.get_account()
if not account:
self.result['changed'] = True
args = {}
args['account'] = self.module.params.get('name')
args['domainid'] = self.get_domain('id')
args['accounttype'] = self.get_account_type()
args['networkdomain'] = self.module.params.get('network_domain')
args['username'] = self.module.params.get('username')
args['password'] = self.module.params.get('password')
args['firstname'] = self.module.params.get('first_name')
args['lastname'] = self.module.params.get('last_name')
args['email'] = self.module.params.get('email')
args['timezone'] = self.module.params.get('timezone')
args = {
'account': self.module.params.get('name'),
'domainid': self.get_domain(key='id'),
'accounttype': self.get_account_type(),
'networkdomain': self.module.params.get('network_domain'),
'username': self.module.params.get('username'),
'password': self.module.params.get('password'),
'firstname': self.module.params.get('first_name'),
'lastname': self.module.params.get('last_name'),
'email': self.module.params.get('email'),
'timezone': self.module.params.get('timezone')
}
if not self.module.check_mode:
res = self.cs.createAccount(**args)
if 'errortext' in res:
@ -313,7 +298,6 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
account = res['account']
return account
def absent_account(self):
account = self.get_account()
if account:
@ -327,15 +311,14 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'account')
self.poll_job(res, 'account')
return account
def get_result(self, account):
super(AnsibleCloudStackAccount, self).get_result(account)
if account:
if 'accounttype' in account:
for key,value in self.account_types.items():
for key, value in self.account_types.items():
if value == account['accounttype']:
self.result['account_type'] = key
break
@ -345,18 +328,18 @@ class AnsibleCloudStackAccount(AnsibleCloudStack):
def main():
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
state = dict(choices=['present', 'absent', 'enabled', 'disabled', 'locked', 'unlocked'], default='present'),
account_type = dict(choices=['user', 'root_admin', 'domain_admin'], default='user'),
network_domain = dict(default=None),
domain = dict(default='ROOT'),
email = dict(default=None),
first_name = dict(default=None),
last_name = dict(default=None),
username = dict(default=None),
password = dict(default=None, no_log=True),
timezone = dict(default=None),
poll_async = dict(type='bool', default=True),
name=dict(required=True),
state=dict(choices=['present', 'absent', 'enabled', 'disabled', 'locked', 'unlocked'], default='present'),
account_type=dict(choices=['user', 'root_admin', 'domain_admin'], default='user'),
network_domain=dict(default=None),
domain=dict(default='ROOT'),
email=dict(default=None),
first_name=dict(default=None),
last_name=dict(default=None),
username=dict(default=None),
password=dict(default=None, no_log=True),
timezone=dict(default=None),
poll_async=dict(type='bool', default=True),
))
module = AnsibleModule(
@ -365,9 +348,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_acc = AnsibleCloudStackAccount(module)

View file

@ -123,12 +123,6 @@ account:
sample: example account
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -142,22 +136,20 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
}
self.affinity_group = None
def get_affinity_group(self):
if not self.affinity_group:
args = {}
args['projectid'] = self.get_project(key='id')
args['account'] = self.get_account('name')
args['domainid'] = self.get_domain('id')
args['name'] = self.module.params.get('name')
args = {
'projectid': self.get_project(key='id'),
'account': self.get_account(key='name'),
'domainid': self.get_domain(key='id'),
'name': self.module.params.get('name'),
}
affinity_groups = self.cs.listAffinityGroups(**args)
if affinity_groups:
self.affinity_group = affinity_groups['affinitygroup'][0]
return self.affinity_group
def get_affinity_type(self):
affinity_type = self.module.params.get('affinty_type')
@ -171,20 +163,19 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
return a['type']
self.module.fail_json(msg="affinity group type '%s' not found" % affinity_type)
def create_affinity_group(self):
affinity_group = self.get_affinity_group()
if not affinity_group:
self.result['changed'] = True
args = {}
args['name'] = self.module.params.get('name')
args['type'] = self.get_affinity_type()
args['description'] = self.module.params.get('description')
args['projectid'] = self.get_project(key='id')
args['account'] = self.get_account('name')
args['domainid'] = self.get_domain('id')
args = {
'name': self.module.params.get('name'),
'type': self.get_affinity_type(),
'description': self.module.params.get('description'),
'projectid': self.get_project(key='id'),
'account': self.get_account(key='name'),
'domainid': self.get_domain(key='id'),
}
if not self.module.check_mode:
res = self.cs.createAffinityGroup(**args)
@ -193,21 +184,20 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
affinity_group = self._poll_job(res, 'affinitygroup')
affinity_group = self.poll_job(res, 'affinitygroup')
return affinity_group
def remove_affinity_group(self):
affinity_group = self.get_affinity_group()
if affinity_group:
self.result['changed'] = True
args = {}
args['name'] = self.module.params.get('name')
args['projectid'] = self.get_project(key='id')
args['account'] = self.get_account('name')
args['domainid'] = self.get_domain('id')
args = {
'name': self.module.params.get('name'),
'projectid': self.get_project(key='id'),
'account': self.get_account(key='name'),
'domainid': self.get_domain(key='id'),
}
if not self.module.check_mode:
res = self.cs.deleteAffinityGroup(**args)
@ -216,21 +206,21 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'affinitygroup')
self.poll_job(res, 'affinitygroup')
return affinity_group
def main():
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
affinty_type = dict(default=None),
description = dict(default=None),
state = dict(choices=['present', 'absent'], default='present'),
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
poll_async = dict(type='bool', default=True),
name=dict(required=True),
affinty_type=dict(default=None),
description=dict(default=None),
state=dict(choices=['present', 'absent'], default='present'),
domain=dict(default=None),
account=dict(default=None),
project=dict(default=None),
poll_async=dict(type='bool', default=True),
))
module = AnsibleModule(
@ -239,9 +229,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_ag = AnsibleCloudStackAffinityGroup(module)

View file

@ -226,15 +226,10 @@ pod:
sample: pod01
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
class AnsibleCloudStackCluster(AnsibleCloudStack):
def __init__(self, module):
@ -251,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']:
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 = {}
@ -295,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:
@ -304,7 +296,6 @@ class AnsibleCloudStackCluster(AnsibleCloudStack):
cluster = self._create_cluster()
return cluster
def _create_cluster(self):
required_params = [
'cluster_type',
@ -343,7 +334,6 @@ class AnsibleCloudStackCluster(AnsibleCloudStack):
cluster = res['cluster']
return cluster
def _update_cluster(self):
cluster = self.get_cluster()
@ -360,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:
@ -379,25 +368,25 @@ class AnsibleCloudStackCluster(AnsibleCloudStack):
def main():
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name = dict(required=True),
zone = dict(default=None),
pod = dict(default=None),
cluster_type = dict(choices=['CloudManaged', 'ExternalManaged'], default=None),
hypervisor = dict(choices=CS_HYPERVISORS, default=None),
state = dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'),
url = dict(default=None),
username = dict(default=None),
password = dict(default=None, no_log=True),
guest_vswitch_name = dict(default=None),
guest_vswitch_type = dict(choices=['vmwaresvs', 'vmwaredvs'], default=None),
public_vswitch_name = dict(default=None),
public_vswitch_type = dict(choices=['vmwaresvs', 'vmwaredvs'], default=None),
vms_ip_address = dict(default=None),
vms_username = dict(default=None),
vms_password = dict(default=None, no_log=True),
ovm3_cluster = dict(default=None),
ovm3_pool = dict(default=None),
ovm3_vip = dict(default=None),
name=dict(required=True),
zone=dict(default=None),
pod=dict(default=None),
cluster_type=dict(choices=['CloudManaged', 'ExternalManaged'], default=None),
hypervisor=dict(choices=CS_HYPERVISORS, default=None),
state=dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'),
url=dict(default=None),
username=dict(default=None),
password=dict(default=None, no_log=True),
guest_vswitch_name=dict(default=None),
guest_vswitch_type=dict(choices=['vmwaresvs', 'vmwaredvs'], default=None),
public_vswitch_name=dict(default=None),
public_vswitch_type=dict(choices=['vmwaresvs', 'vmwaredvs'], default=None),
vms_ip_address=dict(default=None),
vms_username=dict(default=None),
vms_password=dict(default=None, no_log=True),
ovm3_cluster=dict(default=None),
ovm3_pool=dict(default=None),
ovm3_vip=dict(default=None),
))
module = AnsibleModule(
@ -406,9 +395,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_cluster = AnsibleCloudStackCluster(module)

View file

@ -148,12 +148,6 @@ storage:
sample: storage01
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -278,9 +272,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_configuration = AnsibleCloudStackConfiguration(module)
configuration = acs_configuration.present_configuration()

View file

@ -106,12 +106,6 @@ network_domain:
sample: example.local
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -207,7 +201,7 @@ class AnsibleCloudStackDomain(AnsibleCloudStack):
args['id'] = domain['id']
args['networkdomain'] = self.module.params.get('network_domain')
if self._has_changed(args, domain):
if self.has_changed(args, domain):
self.result['changed'] = True
if not self.module.check_mode:
res = self.cs.updateDomain(**args)
@ -233,7 +227,7 @@ class AnsibleCloudStackDomain(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'domain')
res = self.poll_job(res, 'domain')
return domain
@ -254,9 +248,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_dom = AnsibleCloudStackDomain(module)

View file

@ -210,12 +210,6 @@ network:
sample: my_network
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -337,7 +331,7 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
firewall_rule = self._poll_job(res, 'firewallrule')
firewall_rule = self.poll_job(res, 'firewallrule')
return firewall_rule
@ -361,7 +355,7 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'firewallrule')
res = self.poll_job(res, 'firewallrule')
return firewall_rule
@ -413,9 +407,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_fw = AnsibleCloudStackFirewall(module)

View file

@ -396,12 +396,6 @@ instance_name:
import base64
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -672,7 +666,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
return instance
@ -682,7 +676,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
args_service_offering['id'] = instance['id']
if self.module.params.get('service_offering'):
args_service_offering['serviceofferingid'] = self.get_service_offering_id()
service_offering_changed = self._has_changed(args_service_offering, instance)
service_offering_changed = self.has_changed(args_service_offering, instance)
# Instance data
args_instance_update = {}
@ -693,7 +687,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
args_instance_update['group'] = self.module.params.get('group')
if self.module.params.get('display_name'):
args_instance_update['displayname'] = self.module.params.get('display_name')
instance_changed = self._has_changed(args_instance_update, instance)
instance_changed = self.has_changed(args_instance_update, instance)
# SSH key data
args_ssh_key = {}
@ -701,7 +695,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
args_ssh_key['projectid'] = self.get_project(key='id')
if self.module.params.get('ssh_key'):
args_ssh_key['keypair'] = self.module.params.get('ssh_key')
ssh_key_changed = self._has_changed(args_ssh_key, instance)
ssh_key_changed = self.has_changed(args_ssh_key, instance)
security_groups_changed = self.security_groups_has_changed()
@ -721,7 +715,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
# Ensure VM has stopped
instance = self.stop_instance()
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
self.instance = instance
# Change service offering
@ -748,7 +742,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
if 'errortext' in instance:
self.module.fail_json(msg="Failed: '%s'" % instance['errortext'])
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
self.instance = instance
# Start VM again if it was running before
@ -781,7 +775,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(res, 'virtualmachine')
instance = self.poll_job(res, 'virtualmachine')
return instance
@ -804,7 +798,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'virtualmachine')
res = self.poll_job(res, 'virtualmachine')
return instance
@ -825,7 +819,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
return instance
@ -846,7 +840,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
return instance
@ -864,7 +858,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(instance, 'virtualmachine')
instance = self.poll_job(instance, 'virtualmachine')
elif instance['state'].lower() in [ 'stopping', 'stopped' ]:
instance = self.start_instance()
@ -885,7 +879,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
instance = self._poll_job(res, 'virtualmachine')
instance = self.poll_job(res, 'virtualmachine')
return instance
@ -962,9 +956,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_instance = AnsibleCloudStackInstance(module)

View file

@ -178,12 +178,6 @@ cloudstack_instance.instance_name:
import base64
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -270,9 +264,6 @@ def main():
supports_check_mode=False,
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
cs_instance_facts = AnsibleCloudStackInstanceFacts(module=module).run()
cs_facts_result = dict(changed=False, ansible_facts=cs_instance_facts)
module.exit_json(**cs_facts_result)

View file

@ -102,12 +102,6 @@ project:
sample: example project
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -185,9 +179,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_ig = AnsibleCloudStackInstanceGroup(module)

View file

@ -127,13 +127,6 @@ domain:
sample: example domain
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -209,7 +202,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'ipaddress')
res = self.poll_job(res, 'ipaddress')
ip_address = res
return ip_address
@ -228,7 +221,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack):
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
self._poll_job(res, 'ipaddress')
self.poll_job(res, 'ipaddress')
return ip_address
@ -252,9 +245,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_ip_address = AnsibleCloudStackIPAddress(module)

View file

@ -197,12 +197,6 @@ project:
sample: example project
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -319,9 +313,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_iso = AnsibleCloudStackIso(module)

View file

@ -217,12 +217,6 @@ state:
sample: "Add"
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -333,7 +327,7 @@ class AnsibleCloudStackLBRule(AnsibleCloudStack):
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'loadbalancer')
res = self.poll_job(res, 'loadbalancer')
return rule
@ -364,9 +358,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_lb_rule = AnsibleCloudStackLBRule(module)

View file

@ -200,12 +200,6 @@ state:
sample: "Add"
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -344,9 +338,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_lb_rule_member = AnsibleCloudStackLBRuleMember(module)

View file

@ -318,12 +318,6 @@ network_offering:
sample: DefaultIsolatedNetworkOfferingWithSourceNatService
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -428,7 +422,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
args = self._get_args()
args['id'] = network['id']
if self._has_changed(args, network):
if self.has_changed(args, network):
self.result['changed'] = True
if not self.module.check_mode:
network = self.cs.updateNetwork(**args)
@ -438,7 +432,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if network and poll_async:
network = self._poll_job(network, 'network')
network = self.poll_job(network, 'network')
return network
@ -496,7 +490,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if network and poll_async:
network = self._poll_job(network, 'network')
network = self.poll_job(network, 'network')
return network
@ -516,7 +510,7 @@ class AnsibleCloudStackNetwork(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'network')
res = self.poll_job(res, 'network')
return network
@ -560,9 +554,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_network = AnsibleCloudStackNetwork(module)

View file

@ -150,12 +150,6 @@ zone:
sample: ch-gva-2
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -286,9 +280,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_pod = AnsibleCloudStackPod(module)
state = module.params.get('state')

View file

@ -203,12 +203,6 @@ vm_guest_ip:
sample: 10.101.65.152
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -233,33 +227,6 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
'privateendport': 'private_end_port',
}
self.portforwarding_rule = None
self.vm_default_nic = None
def get_vm_guest_ip(self):
vm_guest_ip = self.module.params.get('vm_guest_ip')
default_nic = self.get_vm_default_nic()
if not vm_guest_ip:
return default_nic['ipaddress']
for secondary_ip in default_nic['secondaryip']:
if vm_guest_ip == secondary_ip['ipaddress']:
return vm_guest_ip
self.module.fail_json(msg="Secondary IP '%s' not assigned to VM" % vm_guest_ip)
def get_vm_default_nic(self):
if self.vm_default_nic:
return self.vm_default_nic
nics = self.cs.listNics(virtualmachineid=self.get_vm(key='id'))
if nics:
for n in nics['nic']:
if n['isdefault']:
self.vm_default_nic = n
return self.vm_default_nic
self.module.fail_json(msg="No default IP address of VM '%s' found" % self.module.params.get('vm'))
def get_portforwarding_rule(self):
@ -311,7 +278,7 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
portforwarding_rule = self.cs.createPortForwardingRule(**args)
poll_async = self.module.params.get('poll_async')
if poll_async:
portforwarding_rule = self._poll_job(portforwarding_rule, 'portforwardingrule')
portforwarding_rule = self.poll_job(portforwarding_rule, 'portforwardingrule')
return portforwarding_rule
@ -326,7 +293,7 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
args['ipaddressid'] = self.get_ip_address(key='id')
args['virtualmachineid'] = self.get_vm(key='id')
if self._has_changed(args, portforwarding_rule):
if self.has_changed(args, portforwarding_rule):
self.result['changed'] = True
if not self.module.check_mode:
# API broken in 4.2.1?, workaround using remove/create instead of update
@ -335,7 +302,7 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
portforwarding_rule = self.cs.createPortForwardingRule(**args)
poll_async = self.module.params.get('poll_async')
if poll_async:
portforwarding_rule = self._poll_job(portforwarding_rule, 'portforwardingrule')
portforwarding_rule = self.poll_job(portforwarding_rule, 'portforwardingrule')
return portforwarding_rule
@ -351,7 +318,7 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack):
res = self.cs.deletePortForwardingRule(**args)
poll_async = self.module.params.get('poll_async')
if poll_async:
self._poll_job(res, 'portforwardingrule')
self.poll_job(res, 'portforwardingrule')
return portforwarding_rule
@ -391,9 +358,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_pf = AnsibleCloudStackPortforwarding(module)
state = module.params.get('state')

View file

@ -53,6 +53,13 @@ options:
- Account the project is related to.
required: false
default: null
tags:
description:
- List of tags. Tags are a list of dictionaries having keys C(key) and C(value).
- "If you want to delete all tags, set a empty list e.g. C(tags: [])."
required: false
default: null
version_added: "2.2"
poll_async:
description:
- Poll async jobs until job has finished.
@ -66,6 +73,9 @@ EXAMPLES = '''
- local_action:
module: cs_project
name: web
tags:
- { key: admin, value: john }
- { key: foo, value: bar }
# Rename a project
- local_action:
@ -131,12 +141,6 @@ tags:
sample: '[ { "key": "foo", "value": "bar" } ]'
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -167,6 +171,10 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
project = self.create_project(project)
else:
project = self.update_project(project)
if project:
project = self.ensure_tags(resource=project, resource_type='project')
# refresh resource
self.project = project
return project
@ -175,7 +183,7 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
args['id'] = project['id']
args['displaytext'] = self.get_or_fallback('display_text', 'name')
if self._has_changed(args, project):
if self.has_changed(args, project):
self.result['changed'] = True
if not self.module.check_mode:
project = self.cs.updateProject(**args)
@ -185,7 +193,7 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if project and poll_async:
project = self._poll_job(project, 'project')
project = self.poll_job(project, 'project')
return project
@ -206,15 +214,12 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if project and poll_async:
project = self._poll_job(project, 'project')
project = self.poll_job(project, 'project')
return project
def state_project(self, state=None):
project = self.get_project()
if not project:
self.module.fail_json(msg="No project named '%s' found." % self.module.params('name'))
def state_project(self, state='active'):
project = self.present_project()
if project['state'].lower() != state:
self.result['changed'] = True
@ -233,7 +238,7 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if project and poll_async:
project = self._poll_job(project, 'project')
project = self.poll_job(project, 'project')
return project
@ -253,7 +258,7 @@ class AnsibleCloudStackProject(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'project')
res = self.poll_job(res, 'project')
return project
@ -267,6 +272,7 @@ def main():
domain = dict(default=None),
account = dict(default=None),
poll_async = dict(type='bool', default=True),
tags=dict(type='list', aliases=['tag'], default=None),
))
module = AnsibleModule(
@ -275,9 +281,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_project = AnsibleCloudStackProject(module)

View file

@ -115,12 +115,6 @@ project:
sample: example project
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -206,9 +200,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_resource_limit = AnsibleCloudStackResourceLimit(module)
resource_limit = acs_resource_limit.update_resource_limit()

View file

@ -160,12 +160,6 @@ account:
sample: admin
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -233,7 +227,7 @@ class AnsibleCloudStackRouter(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
router = self._poll_job(res, 'router')
router = self.poll_job(res, 'router')
return router
def stop_router(self):
@ -254,7 +248,7 @@ class AnsibleCloudStackRouter(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
router = self._poll_job(res, 'router')
router = self.poll_job(res, 'router')
return router
def reboot_router(self):
@ -274,7 +268,7 @@ class AnsibleCloudStackRouter(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
router = self._poll_job(res, 'router')
router = self.poll_job(res, 'router')
return router
def absent_router(self):
@ -293,7 +287,7 @@ class AnsibleCloudStackRouter(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
self._poll_job(res, 'router')
self.poll_job(res, 'router')
return router
@ -358,9 +352,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_router = AnsibleCloudStackRouter(module)

View file

@ -113,12 +113,6 @@ account:
sample: example account
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -203,9 +197,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_sg = AnsibleCloudStackSecurityGroup(module)

View file

@ -181,12 +181,6 @@ end_port:
sample: 80
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -329,7 +323,7 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
security_group = self._poll_job(res, 'securitygroup')
security_group = self.poll_job(res, 'securitygroup')
key = sg_type + "rule" # ingressrule / egressrule
if key in security_group:
rule = security_group[key][0]
@ -360,7 +354,7 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'securitygroup')
res = self.poll_job(res, 'securitygroup')
return rule
@ -405,9 +399,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_sg_rule = AnsibleCloudStackSecurityGroupRule(module)

View file

@ -99,13 +99,6 @@ private_key:
sample: "-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQCkeFYjI+4k8bWfIRMzp4pCzhlopNydbbwRu824P5ilD4ATWMUG\nvEtuCQ2Mp5k5Bma30CdYHgh2/SbxC5RxXSUKTUJtTKpoJUy8PAhb1nn9dnfkC2oU\naRVi9NRUgypTIZxMpgooHOxvAzWxbZCyh1W+91Ld3FNaGxTLqTgeevY84wIDAQAB\nAoGAcwQwgLyUwsNB1vmjWwE0QEmvHS4FlhZyahhi4hGfZvbzAxSWHIK7YUT1c8KU\n9XsThEIN8aJ3GvcoL3OAqNKRnoNb14neejVHkYRadhxqc0GVN6AUIyCqoEMpvhFI\nQrinM572ORzv5ffRjCTbvZcYlW+sqFKNo5e8pYIB8TigpFECQQDu7bg9vkvg8xPs\nkP1K+EH0vsR6vUfy+m3euXjnbJtiP7RoTkZk0JQMOmexgy1qQhISWT0e451wd62v\nJ7M0trl5AkEAsDivJnMIlCCCypwPN4tdNUYpe9dtidR1zLmb3SA7wXk5xMUgLZI9\ncWPjBCMt0KKShdDhQ+hjXAyKQLF7iAPuOwJABjdHCMwvmy2XwhrPjCjDRoPEBtFv\n0sFzJE08+QBZVogDwIbwy+SlRWArnHGmN9J6N+H8dhZD3U4vxZPJ1MBAOQJBAJxO\nCv1dt1Q76gbwmYa49LnWO+F+2cgRTVODpr5iYt5fOmBQQRRqzFkRMkFvOqn+KVzM\nQ6LKM6dn8BEl295vLhUCQQCVDWzoSk3GjL3sOjfAUTyAj8VAXM69llaptxWWySPM\nE9pA+8rYmHfohYFx7FD5/KWCO+sfmxTNB48X0uwyE8tO\n-----END RSA PRIVATE KEY-----\n"
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
try:
import sshpubkeys
has_lib_sshpubkeys = True
@ -221,9 +214,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
if not has_lib_sshpubkeys:
module.fail_json(msg="python library sshpubkeys required: pip install sshpubkeys")

View file

@ -146,13 +146,6 @@ domain:
sample: example domain
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -167,35 +160,6 @@ class AnsibleCloudStackStaticNat(AnsibleCloudStack):
'ipaddress': 'ip_address',
'vmipaddress': 'vm_guest_ip',
}
self.vm_default_nic = None
# TODO: move it to cloudstack utils, also used in cs_portforward
def get_vm_guest_ip(self):
vm_guest_ip = self.module.params.get('vm_guest_ip')
default_nic = self.get_vm_default_nic()
if not vm_guest_ip:
return default_nic['ipaddress']
for secondary_ip in default_nic['secondaryip']:
if vm_guest_ip == secondary_ip['ipaddress']:
return vm_guest_ip
self.module.fail_json(msg="Secondary IP '%s' not assigned to VM" % vm_guest_ip)
# TODO: move it to cloudstack utils, also used in cs_portforward
def get_vm_default_nic(self):
if self.vm_default_nic:
return self.vm_default_nic
nics = self.cs.listNics(virtualmachineid=self.get_vm(key='id'))
if nics:
for n in nics['nic']:
if n['isdefault']:
self.vm_default_nic = n
return self.vm_default_nic
self.module.fail_json(msg="No default IP address of VM '%s' found" % self.module.params.get('vm'))
def create_static_nat(self, ip_address):
@ -224,13 +188,13 @@ class AnsibleCloudStackStaticNat(AnsibleCloudStack):
# make an alias, so we can use _has_changed()
ip_address['vmguestip'] = ip_address['vmipaddress']
if self._has_changed(args, ip_address):
if self.has_changed(args, ip_address, ['vmguestip', 'virtualmachineid']):
self.result['changed'] = True
if not self.module.check_mode:
res = self.cs.disableStaticNat(ipaddressid=ip_address['id'])
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
self._poll_job(res, 'staticnat')
self.poll_job(res, 'staticnat')
res = self.cs.enableStaticNat(**args)
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
@ -260,7 +224,7 @@ class AnsibleCloudStackStaticNat(AnsibleCloudStack):
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:
self._poll_job(res, 'staticnat')
self.poll_job(res, 'staticnat')
return ip_address
@ -285,9 +249,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_static_nat = AnsibleCloudStackStaticNat(module)

View file

@ -375,12 +375,6 @@ project:
sample: Production
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -482,7 +476,7 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
template = self._poll_job(template, 'template')
template = self.poll_job(template, 'template')
return template
@ -570,7 +564,7 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
template = self._poll_job(template, 'template')
template = self.poll_job(template, 'template')
return template
@ -593,7 +587,7 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
res = self._poll_job(res, 'template')
res = self.poll_job(res, 'template')
return template
@ -643,9 +637,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_tpl = AnsibleCloudStackTemplate(module)

View file

@ -197,12 +197,6 @@ domain:
sample: ROOT
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -303,7 +297,7 @@ class AnsibleCloudStackUser(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if poll_async:
user = self._poll_job(user, 'user')
user = self.poll_job(user, 'user')
return user
@ -424,9 +418,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_acc = AnsibleCloudStackUser(module)

View file

@ -162,12 +162,6 @@ project:
sample: Production
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -215,7 +209,7 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
snapshot = self._poll_job(res, 'vmsnapshot')
snapshot = self.poll_job(res, 'vmsnapshot')
return snapshot
@ -232,7 +226,7 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'vmsnapshot')
res = self.poll_job(res, 'vmsnapshot')
return snapshot
@ -249,7 +243,7 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
poll_async = self.module.params.get('poll_async')
if res and poll_async:
res = self._poll_job(res, 'vmsnapshot')
res = self.poll_job(res, 'vmsnapshot')
return snapshot
self.module.fail_json(msg="snapshot not found, could not revert VM")
@ -282,9 +276,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_vmsnapshot = AnsibleCloudStackVmSnapshot(module)

View file

@ -230,12 +230,6 @@ device_id:
sample: 1
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -469,9 +463,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_vol = AnsibleCloudStackVolume(module)

View file

@ -226,12 +226,6 @@ tags:
sample: [ { "key": "foo", "value": "bar" } ]
'''
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -386,9 +380,6 @@ def main():
supports_check_mode=True
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
try:
acs_zone = AnsibleCloudStackZone(module)

View file

@ -138,12 +138,6 @@ cloudstack_zone.tags:
import base64
try:
from cs import CloudStack, CloudStackException, read_config
has_lib_cs = True
except ImportError:
has_lib_cs = False
# import cloudstack common
from ansible.module_utils.cloudstack import *
@ -197,9 +191,6 @@ def main():
supports_check_mode=False,
)
if not has_lib_cs:
module.fail_json(msg="python library cs required: pip install cs")
cs_zone_facts = AnsibleCloudStackZoneFacts(module=module).run()
cs_facts_result = dict(changed=False, ansible_facts=cs_zone_facts)
module.exit_json(**cs_facts_result)