Merge pull request #497 from resmo/for-ansible
cloudstack: various improvements and cleanups
This commit is contained in:
commit
1b750d6540
11 changed files with 144 additions and 81 deletions
|
@ -97,7 +97,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# create an account in domain 'CUSTOMERS'
|
||||
local_action:
|
||||
module: cs_account
|
||||
|
@ -366,7 +365,7 @@ def main():
|
|||
timezone = dict(default=None),
|
||||
poll_async = dict(choices=BOOLEANS, default=True),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -401,6 +400,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -47,6 +47,16 @@ options:
|
|||
required: false
|
||||
default: 'present'
|
||||
choices: [ 'present', 'absent' ]
|
||||
domain:
|
||||
description:
|
||||
- Domain the affinity group is related to.
|
||||
required: false
|
||||
default: null
|
||||
account:
|
||||
description:
|
||||
- Account the affinity group is related to.
|
||||
required: false
|
||||
default: null
|
||||
poll_async:
|
||||
description:
|
||||
- Poll async jobs until job has finished.
|
||||
|
@ -56,7 +66,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# Create a affinity group
|
||||
- local_action:
|
||||
module: cs_affinitygroup
|
||||
|
@ -104,20 +113,21 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
|||
|
||||
def __init__(self, module):
|
||||
AnsibleCloudStack.__init__(self, module)
|
||||
self.result = {
|
||||
'changed': False,
|
||||
}
|
||||
self.affinity_group = None
|
||||
|
||||
|
||||
def get_affinity_group(self):
|
||||
if not self.affinity_group:
|
||||
affinity_group_name = self.module.params.get('name')
|
||||
affinity_group = self.module.params.get('name')
|
||||
|
||||
affinity_groups = self.cs.listAffinityGroups()
|
||||
args = {}
|
||||
args['account'] = self.get_account('name')
|
||||
args['domainid'] = self.get_domain('id')
|
||||
|
||||
affinity_groups = self.cs.listAffinityGroups(**args)
|
||||
if affinity_groups:
|
||||
for a in affinity_groups['affinitygroup']:
|
||||
if a['name'] == affinity_group_name:
|
||||
if affinity_group in [ a['name'], a['id'] ]:
|
||||
self.affinity_group = a
|
||||
break
|
||||
return self.affinity_group
|
||||
|
@ -142,10 +152,12 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
|||
if not affinity_group:
|
||||
self.result['changed'] = True
|
||||
|
||||
args = {}
|
||||
args['name'] = self.module.params.get('name')
|
||||
args['type'] = self.get_affinity_type()
|
||||
args = {}
|
||||
args['name'] = self.module.params.get('name')
|
||||
args['type'] = self.get_affinity_type()
|
||||
args['description'] = self.module.params.get('description')
|
||||
args['account'] = self.get_account('name')
|
||||
args['domainid'] = self.get_domain('id')
|
||||
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.createAffinityGroup(**args)
|
||||
|
@ -156,7 +168,6 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
|||
poll_async = self.module.params.get('poll_async')
|
||||
if res and poll_async:
|
||||
affinity_group = self._poll_job(res, 'affinitygroup')
|
||||
|
||||
return affinity_group
|
||||
|
||||
|
||||
|
@ -165,8 +176,10 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
|||
if affinity_group:
|
||||
self.result['changed'] = True
|
||||
|
||||
args = {}
|
||||
args['name'] = self.module.params.get('name')
|
||||
args = {}
|
||||
args['name'] = self.module.params.get('name')
|
||||
args['account'] = self.get_account('name')
|
||||
args['domainid'] = self.get_domain('id')
|
||||
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.deleteAffinityGroup(**args)
|
||||
|
@ -177,7 +190,6 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
|||
poll_async = self.module.params.get('poll_async')
|
||||
if res and poll_async:
|
||||
res = self._poll_job(res, 'affinitygroup')
|
||||
|
||||
return affinity_group
|
||||
|
||||
|
||||
|
@ -189,6 +201,10 @@ class AnsibleCloudStackAffinityGroup(AnsibleCloudStack):
|
|||
self.result['description'] = affinity_group['description']
|
||||
if 'type' in affinity_group:
|
||||
self.result['affinity_type'] = affinity_group['type']
|
||||
if 'domain' in affinity_group:
|
||||
self.result['domain'] = affinity_group['domain']
|
||||
if 'account' in affinity_group:
|
||||
self.result['account'] = affinity_group['account']
|
||||
return self.result
|
||||
|
||||
|
||||
|
@ -199,9 +215,11 @@ def main():
|
|||
affinty_type = dict(default=None),
|
||||
description = dict(default=None),
|
||||
state = dict(choices=['present', 'absent'], default='present'),
|
||||
domain = dict(default=None),
|
||||
account = dict(default=None),
|
||||
poll_async = dict(choices=BOOLEANS, default=True),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -225,6 +243,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -88,7 +88,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# Allow inbound port 80/tcp from 1.2.3.4 to 4.3.2.1
|
||||
- local_action:
|
||||
module: cs_firewall
|
||||
|
@ -171,9 +170,6 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
|||
|
||||
def __init__(self, module):
|
||||
AnsibleCloudStack.__init__(self, module)
|
||||
self.result = {
|
||||
'changed': False,
|
||||
}
|
||||
self.firewall_rule = None
|
||||
|
||||
|
||||
|
@ -303,7 +299,7 @@ def main():
|
|||
account = dict(default=None),
|
||||
project = dict(default=None),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -331,6 +327,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -164,7 +164,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# Create a instance on CloudStack from an ISO
|
||||
# NOTE: Names of offerings and ISOs depending on the CloudStack configuration.
|
||||
- local_action:
|
||||
|
@ -537,7 +536,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|||
args_instance_update['group'] = self.module.params.get('group')
|
||||
args_instance_update['displayname'] = self.get_display_name()
|
||||
args_instance_update['userdata'] = self.get_user_data()
|
||||
args_instance_update['ostypeid'] = self.get_os_type_id()
|
||||
args_instance_update['ostypeid'] = self.get_os_type('id')
|
||||
|
||||
args_ssh_key = {}
|
||||
args_ssh_key['id'] = instance['id']
|
||||
|
@ -785,7 +784,7 @@ def main():
|
|||
tags = dict(type='list', aliases=[ 'tag' ], default=None),
|
||||
poll_async = dict(choices=BOOLEANS, default=True),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -826,6 +825,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -56,7 +56,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# Create an instance group
|
||||
- local_action:
|
||||
module: cs_instancegroup
|
||||
|
@ -197,7 +196,7 @@ def main():
|
|||
account = dict(default=None),
|
||||
project = dict(default=None),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -221,6 +220,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -73,6 +73,16 @@ options:
|
|||
- Register the ISO to be bootable. Only used if C(state) is present.
|
||||
required: false
|
||||
default: true
|
||||
domain:
|
||||
description:
|
||||
- Domain the ISO is related to.
|
||||
required: false
|
||||
default: null
|
||||
account:
|
||||
description:
|
||||
- Account the ISO is related to.
|
||||
required: false
|
||||
default: null
|
||||
project:
|
||||
description:
|
||||
- Name of the project the ISO to be registered in.
|
||||
|
@ -99,7 +109,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# Register an ISO if ISO name does not already exist.
|
||||
- local_action:
|
||||
module: cs_iso
|
||||
|
@ -169,6 +178,21 @@ created:
|
|||
returned: success
|
||||
type: string
|
||||
sample: 2015-03-29T14:57:06+0200
|
||||
domain:
|
||||
description: Domain the ISO is related to.
|
||||
returned: success
|
||||
type: string
|
||||
sample: example domain
|
||||
account:
|
||||
description: Account the ISO is related to.
|
||||
returned: success
|
||||
type: string
|
||||
sample: example account
|
||||
project:
|
||||
description: Project the ISO is related to.
|
||||
returned: success
|
||||
type: string
|
||||
sample: example project
|
||||
'''
|
||||
|
||||
try:
|
||||
|
@ -185,20 +209,26 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
|||
|
||||
def __init__(self, module):
|
||||
AnsibleCloudStack.__init__(self, module)
|
||||
self.result = {
|
||||
'changed': False,
|
||||
}
|
||||
self.iso = None
|
||||
|
||||
def register_iso(self):
|
||||
iso = self.get_iso()
|
||||
if not iso:
|
||||
args = {}
|
||||
args['zoneid'] = self.get_zone_id()
|
||||
args['projectid'] = self.get_project_id()
|
||||
|
||||
args['bootable'] = self.module.params.get('bootable')
|
||||
args['ostypeid'] = self.get_os_type_id()
|
||||
args = {}
|
||||
args['zoneid'] = self.get_zone('id')
|
||||
args['domainid'] = self.get_domain('id')
|
||||
args['account'] = self.get_account('name')
|
||||
args['projectid'] = self.get_project('id')
|
||||
args['bootable'] = self.module.params.get('bootable')
|
||||
args['ostypeid'] = self.get_os_type('id')
|
||||
args['name'] = self.module.params.get('name')
|
||||
args['displaytext'] = self.module.params.get('name')
|
||||
args['checksum'] = self.module.params.get('checksum')
|
||||
args['isdynamicallyscalable'] = self.module.params.get('is_dynamically_scalable')
|
||||
args['isfeatured'] = self.module.params.get('is_featured')
|
||||
args['ispublic'] = self.module.params.get('is_public')
|
||||
|
||||
if args['bootable'] and not args['ostypeid']:
|
||||
self.module.fail_json(msg="OS type 'os_type' is requried if 'bootable=true'.")
|
||||
|
||||
|
@ -206,13 +236,6 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
|||
if not args['url']:
|
||||
self.module.fail_json(msg="URL is requried.")
|
||||
|
||||
args['name'] = self.module.params.get('name')
|
||||
args['displaytext'] = self.module.params.get('name')
|
||||
args['checksum'] = self.module.params.get('checksum')
|
||||
args['isdynamicallyscalable'] = self.module.params.get('is_dynamically_scalable')
|
||||
args['isfeatured'] = self.module.params.get('is_featured')
|
||||
args['ispublic'] = self.module.params.get('is_public')
|
||||
|
||||
self.result['changed'] = True
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.registerIso(**args)
|
||||
|
@ -222,11 +245,14 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
|||
|
||||
def get_iso(self):
|
||||
if not self.iso:
|
||||
args = {}
|
||||
args['isready'] = self.module.params.get('is_ready')
|
||||
args['isofilter'] = self.module.params.get('iso_filter')
|
||||
args['projectid'] = self.get_project_id()
|
||||
args['zoneid'] = self.get_zone_id()
|
||||
|
||||
args = {}
|
||||
args['isready'] = self.module.params.get('is_ready')
|
||||
args['isofilter'] = self.module.params.get('iso_filter')
|
||||
args['domainid'] = self.get_domain('id')
|
||||
args['account'] = self.get_account('name')
|
||||
args['projectid'] = self.get_project('id')
|
||||
args['zoneid'] = self.get_zone('id')
|
||||
|
||||
# if checksum is set, we only look on that.
|
||||
checksum = self.module.params.get('checksum')
|
||||
|
@ -249,10 +275,12 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
|||
iso = self.get_iso()
|
||||
if iso:
|
||||
self.result['changed'] = True
|
||||
args = {}
|
||||
args['id'] = iso['id']
|
||||
args['projectid'] = self.get_project_id()
|
||||
args['zoneid'] = self.get_zone_id()
|
||||
|
||||
args = {}
|
||||
args['id'] = iso['id']
|
||||
args['projectid'] = self.get_project('id')
|
||||
args['zoneid'] = self.get_zone('id')
|
||||
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.deleteIso(**args)
|
||||
return iso
|
||||
|
@ -274,17 +302,25 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
|||
self.result['is_ready'] = iso['isready']
|
||||
if 'created' in iso:
|
||||
self.result['created'] = iso['created']
|
||||
if 'project' in iso:
|
||||
self.result['project'] = iso['project']
|
||||
if 'domain' in iso:
|
||||
self.result['domain'] = iso['domain']
|
||||
if 'account' in iso:
|
||||
self.result['account'] = iso['account']
|
||||
return self.result
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
name = dict(required=True, default=None),
|
||||
name = dict(required=True),
|
||||
url = dict(default=None),
|
||||
os_type = dict(default=None),
|
||||
zone = dict(default=None),
|
||||
iso_filter = dict(default='self', choices=[ 'featured', 'self', 'selfexecutable','sharedexecutable','executable', 'community' ]),
|
||||
domain = dict(default=None),
|
||||
account = dict(default=None),
|
||||
project = dict(default=None),
|
||||
checksum = dict(default=None),
|
||||
is_ready = dict(choices=BOOLEANS, default=False),
|
||||
|
@ -293,7 +329,7 @@ def main():
|
|||
is_dynamically_scalable = dict(choices=BOOLEANS, default=False),
|
||||
state = dict(choices=['present', 'absent'], default='present'),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -317,6 +353,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -106,7 +106,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# 1.2.3.4:80 -> web01:8080
|
||||
- local_action:
|
||||
module: cs_portforward
|
||||
|
@ -144,7 +143,6 @@ EXAMPLES = '''
|
|||
public_port: 22
|
||||
private_port: 22
|
||||
state: absent
|
||||
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
|
@ -402,7 +400,7 @@ def main():
|
|||
project = dict(default=None),
|
||||
poll_async = dict(choices=BOOLEANS, default=True),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -425,6 +423,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -51,7 +51,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# Create a security group
|
||||
- local_action:
|
||||
module: cs_securitygroup
|
||||
|
@ -94,9 +93,6 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
|||
|
||||
def __init__(self, module):
|
||||
AnsibleCloudStack.__init__(self, module)
|
||||
self.result = {
|
||||
'changed': False,
|
||||
}
|
||||
self.security_group = None
|
||||
|
||||
|
||||
|
@ -104,7 +100,7 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
|||
if not self.security_group:
|
||||
sg_name = self.module.params.get('name')
|
||||
args = {}
|
||||
args['projectid'] = self.get_project_id()
|
||||
args['projectid'] = self.get_project('id')
|
||||
sgs = self.cs.listSecurityGroups(**args)
|
||||
if sgs:
|
||||
for s in sgs['securitygroup']:
|
||||
|
@ -121,7 +117,7 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
|||
|
||||
args = {}
|
||||
args['name'] = self.module.params.get('name')
|
||||
args['projectid'] = self.get_project_id()
|
||||
args['projectid'] = self.get_project('id')
|
||||
args['description'] = self.module.params.get('description')
|
||||
|
||||
if not self.module.check_mode:
|
||||
|
@ -140,7 +136,7 @@ class AnsibleCloudStackSecurityGroup(AnsibleCloudStack):
|
|||
|
||||
args = {}
|
||||
args['name'] = self.module.params.get('name')
|
||||
args['projectid'] = self.get_project_id()
|
||||
args['projectid'] = self.get_project('id')
|
||||
|
||||
if not self.module.check_mode:
|
||||
res = self.cs.deleteSecurityGroup(**args)
|
||||
|
@ -167,7 +163,7 @@ def main():
|
|||
state = dict(choices=['present', 'absent'], default='present'),
|
||||
project = dict(default=None),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -191,6 +187,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -194,9 +194,6 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
|||
|
||||
def __init__(self, module):
|
||||
AnsibleCloudStack.__init__(self, module)
|
||||
self.result = {
|
||||
'changed': False,
|
||||
}
|
||||
|
||||
|
||||
def _tcp_udp_match(self, rule, protocol, start_port, end_port):
|
||||
|
@ -271,7 +268,7 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
|||
security_group_name = self.module.params.get('security_group')
|
||||
args = {}
|
||||
args['securitygroupname'] = security_group_name
|
||||
args['projectid'] = self.get_project_id()
|
||||
args['projectid'] = self.get_project('id')
|
||||
sgs = self.cs.listSecurityGroups(**args)
|
||||
if not sgs or 'securitygroup' not in sgs:
|
||||
self.module.fail_json(msg="security group '%s' not found" % security_group_name)
|
||||
|
@ -301,7 +298,7 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
|||
args['endport'] = self.get_end_port()
|
||||
args['icmptype'] = self.module.params.get('icmp_type')
|
||||
args['icmpcode'] = self.module.params.get('icmp_code')
|
||||
args['projectid'] = self.get_project_id()
|
||||
args['projectid'] = self.get_project('id')
|
||||
args['securitygroupid'] = security_group['id']
|
||||
|
||||
rule = None
|
||||
|
@ -401,7 +398,7 @@ def main():
|
|||
project = dict(default=None),
|
||||
poll_async = dict(choices=BOOLEANS, default=True),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -431,6 +428,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -63,7 +63,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# create a new private / public key pair:
|
||||
- local_action: cs_sshkeypair name=linus@example.com
|
||||
register: key
|
||||
|
@ -114,9 +113,6 @@ class AnsibleCloudStackSshKey(AnsibleCloudStack):
|
|||
|
||||
def __init__(self, module):
|
||||
AnsibleCloudStack.__init__(self, module)
|
||||
self.result = {
|
||||
'changed': False,
|
||||
}
|
||||
self.ssh_key = None
|
||||
|
||||
|
||||
|
@ -219,7 +215,7 @@ def main():
|
|||
project = dict(default=None),
|
||||
state = dict(choices=['present', 'absent'], default='present'),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -249,6 +245,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
|
@ -81,7 +81,6 @@ extends_documentation_fragment: cloudstack
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
---
|
||||
# Create a VM snapshot of disk and memory before an upgrade
|
||||
- local_action:
|
||||
module: cs_vmsnapshot
|
||||
|
@ -175,9 +174,6 @@ class AnsibleCloudStackVmSnapshot(AnsibleCloudStack):
|
|||
|
||||
def __init__(self, module):
|
||||
AnsibleCloudStack.__init__(self, module)
|
||||
self.result = {
|
||||
'changed': False,
|
||||
}
|
||||
|
||||
|
||||
def get_snapshot(self):
|
||||
|
@ -292,7 +288,7 @@ def main():
|
|||
project = dict(default=None),
|
||||
poll_async = dict(choices=BOOLEANS, default=True),
|
||||
api_key = dict(default=None),
|
||||
api_secret = dict(default=None),
|
||||
api_secret = dict(default=None, no_log=True),
|
||||
api_url = dict(default=None),
|
||||
api_http_method = dict(default='get'),
|
||||
),
|
||||
|
@ -318,6 +314,9 @@ def main():
|
|||
except CloudStackException, e:
|
||||
module.fail_json(msg='CloudStackException: %s' % str(e))
|
||||
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Exception: %s' % str(e))
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
|
|
Loading…
Reference in a new issue