summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloud/cloudstack/cs_account.py4
-rw-r--r--cloud/cloudstack/cs_affinitygroup.py4
-rw-r--r--cloud/cloudstack/cs_domain.py6
-rw-r--r--cloud/cloudstack/cs_firewall.py4
-rw-r--r--cloud/cloudstack/cs_instance.py34
-rw-r--r--cloud/cloudstack/cs_instancegroup.py2
-rw-r--r--cloud/cloudstack/cs_ip_address.py4
-rw-r--r--cloud/cloudstack/cs_iso.py10
-rw-r--r--cloud/cloudstack/cs_loadbalancer_rule.py6
-rw-r--r--cloud/cloudstack/cs_loadbalancer_rule_member.py4
-rw-r--r--cloud/cloudstack/cs_network.py6
-rw-r--r--cloud/cloudstack/cs_portforward.py6
-rw-r--r--cloud/cloudstack/cs_project.py4
-rw-r--r--cloud/cloudstack/cs_securitygroup.py2
-rw-r--r--cloud/cloudstack/cs_securitygroup_rule.py4
-rw-r--r--cloud/cloudstack/cs_sshkeypair.py2
-rw-r--r--cloud/cloudstack/cs_staticnat.py4
-rw-r--r--cloud/cloudstack/cs_template.py24
-rw-r--r--cloud/cloudstack/cs_user.py4
-rw-r--r--cloud/cloudstack/cs_vmsnapshot.py6
20 files changed, 68 insertions, 72 deletions
diff --git a/cloud/cloudstack/cs_account.py b/cloud/cloudstack/cs_account.py
index 839f6e53..80ab6748 100644
--- a/cloud/cloudstack/cs_account.py
+++ b/cloud/cloudstack/cs_account.py
@@ -356,7 +356,7 @@ def main():
username = dict(default=None),
password = dict(default=None),
timezone = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -390,7 +390,7 @@ def main():
result = acs_acc.get_result(account)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_affinitygroup.py b/cloud/cloudstack/cs_affinitygroup.py
index b1dc075c..77323315 100644
--- a/cloud/cloudstack/cs_affinitygroup.py
+++ b/cloud/cloudstack/cs_affinitygroup.py
@@ -233,7 +233,7 @@ def main():
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -256,7 +256,7 @@ def main():
result = acs_ag.get_result(affinity_group)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_domain.py b/cloud/cloudstack/cs_domain.py
index 0d8b7dea..0d041d73 100644
--- a/cloud/cloudstack/cs_domain.py
+++ b/cloud/cloudstack/cs_domain.py
@@ -244,8 +244,8 @@ def main():
path = dict(required=True),
state = dict(choices=['present', 'absent'], default='present'),
network_domain = dict(default=None),
- clean_up = dict(choices=BOOLEANS, default=False),
- poll_async = dict(choices=BOOLEANS, default=True),
+ clean_up = dict(type='bool', default=False),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -268,7 +268,7 @@ def main():
result = acs_dom.get_result(domain)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_firewall.py b/cloud/cloudstack/cs_firewall.py
index 9834dd67..7a6bfb6c 100644
--- a/cloud/cloudstack/cs_firewall.py
+++ b/cloud/cloudstack/cs_firewall.py
@@ -414,7 +414,7 @@ def main():
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
required_together = cs_required_together()
@@ -450,7 +450,7 @@ def main():
result = acs_fw.get_result(fw_rule)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_instance.py b/cloud/cloudstack/cs_instance.py
index 852be68a..88076fa1 100644
--- a/cloud/cloudstack/cs_instance.py
+++ b/cloud/cloudstack/cs_instance.py
@@ -44,7 +44,6 @@ options:
state:
description:
- State of the instance.
- - C(restored) added in version 2.1.
required: false
default: 'present'
choices: [ 'deployed', 'started', 'stopped', 'restarted', 'restored', 'destroyed', 'expunged', 'present', 'absent' ]
@@ -827,23 +826,19 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
def restore_instance(self):
instance = self.get_instance()
-
- if not instance:
- instance = self.deploy_instance()
- return instance
-
self.result['changed'] = True
+ # in check mode intance may not be instanciated
+ if instance:
+ args = {}
+ args['templateid'] = self.get_template_or_iso(key='id')
+ args['virtualmachineid'] = instance['id']
+ res = self.cs.restoreVirtualMachine(**args)
+ if 'errortext' in res:
+ self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
- args = {}
- args['templateid'] = self.get_template_or_iso(key='id')
- args['virtualmachineid'] = instance['id']
- res = self.cs.restoreVirtualMachine(**args)
- if 'errortext' in res:
- self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
-
- poll_async = self.module.params.get('poll_async')
- if poll_async:
- instance = self._poll_job(res, 'virtualmachine')
+ poll_async = self.module.params.get('poll_async')
+ if poll_async:
+ instance = self._poll_job(res, 'virtualmachine')
return instance
@@ -897,9 +892,9 @@ def main():
user_data = dict(default=None),
zone = dict(default=None),
ssh_key = dict(default=None),
- force = dict(choices=BOOLEANS, default=False),
+ force = dict(type='bool', default=False),
tags = dict(type='list', aliases=[ 'tag' ], default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
required_together = cs_required_together()
@@ -931,6 +926,7 @@ def main():
instance = acs_instance.expunge_instance()
elif state in ['restored']:
+ acs_instance.present_instance()
instance = acs_instance.restore_instance()
elif state in ['present', 'deployed']:
@@ -953,7 +949,7 @@ def main():
result = acs_instance.get_result(instance)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_instancegroup.py b/cloud/cloudstack/cs_instancegroup.py
index 4ffda0ed..bece7901 100644
--- a/cloud/cloudstack/cs_instancegroup.py
+++ b/cloud/cloudstack/cs_instancegroup.py
@@ -199,7 +199,7 @@ def main():
result = acs_ig.get_result(instance_group)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_ip_address.py b/cloud/cloudstack/cs_ip_address.py
index 1be597fd..c5a65d62 100644
--- a/cloud/cloudstack/cs_ip_address.py
+++ b/cloud/cloudstack/cs_ip_address.py
@@ -233,7 +233,7 @@ def main():
account = dict(default=None),
network = dict(default=None),
project = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -256,7 +256,7 @@ def main():
result = acs_ip_address.get_result(ip_address)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_iso.py b/cloud/cloudstack/cs_iso.py
index 98a06f6c..5508fdd2 100644
--- a/cloud/cloudstack/cs_iso.py
+++ b/cloud/cloudstack/cs_iso.py
@@ -306,10 +306,10 @@ def main():
account = dict(default=None),
project = dict(default=None),
checksum = dict(default=None),
- is_ready = dict(choices=BOOLEANS, default=False),
- bootable = dict(choices=BOOLEANS, default=True),
- is_featured = dict(choices=BOOLEANS, default=False),
- is_dynamically_scalable = dict(choices=BOOLEANS, default=False),
+ is_ready = dict(type='bool', default=False),
+ bootable = dict(type='bool', default=True),
+ is_featured = dict(type='bool', default=False),
+ is_dynamically_scalable = dict(type='bool', default=False),
state = dict(choices=['present', 'absent'], default='present'),
))
@@ -333,7 +333,7 @@ def main():
result = acs_iso.get_result(iso)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_loadbalancer_rule.py b/cloud/cloudstack/cs_loadbalancer_rule.py
index 713aaad0..aec04cf7 100644
--- a/cloud/cloudstack/cs_loadbalancer_rule.py
+++ b/cloud/cloudstack/cs_loadbalancer_rule.py
@@ -355,12 +355,12 @@ def main():
ip_address = dict(required=True, aliases=['public_ip']),
cidr = dict(default=None),
project = dict(default=None),
- open_firewall = dict(choices=BOOLEANS, default=False),
+ open_firewall = dict(type='bool', default=False),
tags = dict(type='list', aliases=['tag'], default=None),
zone = dict(default=None),
domain = dict(default=None),
account = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -383,7 +383,7 @@ def main():
result = acs_lb_rule.get_result(rule)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_loadbalancer_rule_member.py b/cloud/cloudstack/cs_loadbalancer_rule_member.py
index f0738830..757c0067 100644
--- a/cloud/cloudstack/cs_loadbalancer_rule_member.py
+++ b/cloud/cloudstack/cs_loadbalancer_rule_member.py
@@ -335,7 +335,7 @@ def main():
domain = dict(default=None),
project = dict(default=None),
account = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -358,7 +358,7 @@ def main():
result = acs_lb_rule_member.get_result(rule)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_network.py b/cloud/cloudstack/cs_network.py
index 6dea3dd3..fa1c7a68 100644
--- a/cloud/cloudstack/cs_network.py
+++ b/cloud/cloudstack/cs_network.py
@@ -539,14 +539,14 @@ def main():
vlan = dict(default=None),
vpc = dict(default=None),
isolated_pvlan = dict(default=None),
- clean_up = dict(type='bool', choices=BOOLEANS, default=False),
+ clean_up = dict(type='bool', default=False),
network_domain = dict(default=None),
state = dict(choices=['present', 'absent', 'restarted' ], default='present'),
acl_type = dict(choices=['account', 'domain'], default='account'),
project = dict(default=None),
domain = dict(default=None),
account = dict(default=None),
- poll_async = dict(type='bool', choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
required_together = cs_required_together()
required_together.extend([
@@ -578,7 +578,7 @@ def main():
result = acs_network.get_result(network)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_portforward.py b/cloud/cloudstack/cs_portforward.py
index 4d091f68..9932dcb0 100644
--- a/cloud/cloudstack/cs_portforward.py
+++ b/cloud/cloudstack/cs_portforward.py
@@ -376,14 +376,14 @@ def main():
private_port = dict(type='int', required=True),
private_end_port = dict(type='int', default=None),
state = dict(choices=['present', 'absent'], default='present'),
- open_firewall = dict(choices=BOOLEANS, default=False),
+ open_firewall = dict(type='bool', default=False),
vm_guest_ip = dict(default=None),
vm = dict(default=None),
zone = dict(default=None),
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -405,7 +405,7 @@ def main():
result = acs_pf.get_result(pf_rule)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_project.py b/cloud/cloudstack/cs_project.py
index 504fefc6..6b37923d 100644
--- a/cloud/cloudstack/cs_project.py
+++ b/cloud/cloudstack/cs_project.py
@@ -266,7 +266,7 @@ def main():
state = dict(choices=['present', 'absent', 'active', 'suspended' ], default='present'),
domain = dict(default=None),
account = dict(default=None),
- poll_async = dict(type='bool', choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -293,7 +293,7 @@ def main():
result = acs_project.get_result(project)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_securitygroup.py b/cloud/cloudstack/cs_securitygroup.py
index 255d306c..d0319059 100644
--- a/cloud/cloudstack/cs_securitygroup.py
+++ b/cloud/cloudstack/cs_securitygroup.py
@@ -180,7 +180,7 @@ def main():
result = acs_sg.get_result(sg)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_securitygroup_rule.py b/cloud/cloudstack/cs_securitygroup_rule.py
index 69e04ee7..a088c6c2 100644
--- a/cloud/cloudstack/cs_securitygroup_rule.py
+++ b/cloud/cloudstack/cs_securitygroup_rule.py
@@ -384,7 +384,7 @@ def main():
end_port = dict(type='int', default=None),
state = dict(choices=['present', 'absent'], default='present'),
project = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
required_together = cs_required_together()
required_together.extend([
@@ -417,7 +417,7 @@ def main():
result = acs_sg_rule.get_result(sg_rule)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_sshkeypair.py b/cloud/cloudstack/cs_sshkeypair.py
index 7e665cd6..7794303f 100644
--- a/cloud/cloudstack/cs_sshkeypair.py
+++ b/cloud/cloudstack/cs_sshkeypair.py
@@ -241,7 +241,7 @@ def main():
result = acs_sshkey.get_result(ssh_key)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_staticnat.py b/cloud/cloudstack/cs_staticnat.py
index c8fba548..f6b5d3f9 100644
--- a/cloud/cloudstack/cs_staticnat.py
+++ b/cloud/cloudstack/cs_staticnat.py
@@ -269,7 +269,7 @@ def main():
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -292,7 +292,7 @@ def main():
result = acs_static_nat.get_result(ip_address)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_template.py b/cloud/cloudstack/cs_template.py
index 94803aeb..dc043425 100644
--- a/cloud/cloudstack/cs_template.py
+++ b/cloud/cloudstack/cs_template.py
@@ -537,29 +537,29 @@ def main():
vm = dict(default=None),
snapshot = dict(default=None),
os_type = dict(default=None),
- is_ready = dict(type='bool', choices=BOOLEANS, default=False),
- is_public = dict(type='bool', choices=BOOLEANS, default=True),
- is_featured = dict(type='bool', choices=BOOLEANS, default=False),
- is_dynamically_scalable = dict(type='bool', choices=BOOLEANS, default=False),
- is_extractable = dict(type='bool', choices=BOOLEANS, default=False),
- is_routing = dict(type='bool', choices=BOOLEANS, default=False),
+ is_ready = dict(type='bool', default=False),
+ is_public = dict(type='bool', default=True),
+ is_featured = dict(type='bool', default=False),
+ is_dynamically_scalable = dict(type='bool', default=False),
+ is_extractable = dict(type='bool', default=False),
+ is_routing = dict(type='bool', default=False),
checksum = dict(default=None),
template_filter = dict(default='self', choices=['featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community']),
hypervisor = dict(choices=['KVM', 'VMware', 'BareMetal', 'XenServer', 'LXC', 'HyperV', 'UCS', 'OVM', 'Simulator'], default=None),
- requires_hvm = dict(type='bool', choices=BOOLEANS, default=False),
- password_enabled = dict(type='bool', choices=BOOLEANS, default=False),
+ requires_hvm = dict(type='bool', default=False),
+ password_enabled = dict(type='bool', default=False),
template_tag = dict(default=None),
- sshkey_enabled = dict(type='bool', choices=BOOLEANS, default=False),
+ sshkey_enabled = dict(type='bool', default=False),
format = dict(choices=['QCOW2', 'RAW', 'VHD', 'OVA'], default=None),
details = dict(default=None),
bits = dict(type='int', choices=[ 32, 64 ], default=64),
state = dict(choices=['present', 'absent'], default='present'),
- cross_zones = dict(type='bool', choices=BOOLEANS, default=False),
+ cross_zones = dict(type='bool', default=False),
zone = dict(default=None),
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
- poll_async = dict(type='bool', choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
required_together = cs_required_together()
@@ -595,7 +595,7 @@ def main():
result = acs_tpl.get_result(tpl)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_user.py b/cloud/cloudstack/cs_user.py
index e6fe1c1f..a0be4634 100644
--- a/cloud/cloudstack/cs_user.py
+++ b/cloud/cloudstack/cs_user.py
@@ -415,7 +415,7 @@ def main():
last_name = dict(default=None),
password = dict(default=None),
timezone = dict(default=None),
- poll_async = dict(choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
module = AnsibleModule(
@@ -449,7 +449,7 @@ def main():
result = acs_acc.get_result(user)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)
diff --git a/cloud/cloudstack/cs_vmsnapshot.py b/cloud/cloudstack/cs_vmsnapshot.py
index 43e561bb..bec9e513 100644
--- a/cloud/cloudstack/cs_vmsnapshot.py
+++ b/cloud/cloudstack/cs_vmsnapshot.py
@@ -263,12 +263,12 @@ def main():
vm = dict(required=True),
description = dict(default=None),
zone = dict(default=None),
- snapshot_memory = dict(choices=BOOLEANS, default=False),
+ snapshot_memory = dict(type='bool', default=False),
state = dict(choices=['present', 'absent', 'revert'], default='present'),
domain = dict(default=None),
account = dict(default=None),
project = dict(default=None),
- poll_async = dict(type='bool', choices=BOOLEANS, default=True),
+ poll_async = dict(type='bool', default=True),
))
required_together = cs_required_together()
@@ -298,7 +298,7 @@ def main():
result = acs_vmsnapshot.get_result(snapshot)
- except CloudStackException, e:
+ except CloudStackException as e:
module.fail_json(msg='CloudStackException: %s' % str(e))
module.exit_json(**result)