|
|
@ -73,6 +73,16 @@ options:
|
|
|
|
- Register the ISO to be bootable. Only used if C(state) is present.
|
|
|
|
- Register the ISO to be bootable. Only used if C(state) is present.
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
default: true
|
|
|
|
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:
|
|
|
|
project:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Name of the project the ISO to be registered in.
|
|
|
|
- Name of the project the ISO to be registered in.
|
|
|
@ -99,7 +109,6 @@ extends_documentation_fragment: cloudstack
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
EXAMPLES = '''
|
|
|
|
---
|
|
|
|
|
|
|
|
# Register an ISO if ISO name does not already exist.
|
|
|
|
# Register an ISO if ISO name does not already exist.
|
|
|
|
- local_action:
|
|
|
|
- local_action:
|
|
|
|
module: cs_iso
|
|
|
|
module: cs_iso
|
|
|
@ -169,6 +178,21 @@ created:
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: 2015-03-29T14:57:06+0200
|
|
|
|
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:
|
|
|
|
try:
|
|
|
@ -185,20 +209,26 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, module):
|
|
|
|
def __init__(self, module):
|
|
|
|
AnsibleCloudStack.__init__(self, module)
|
|
|
|
AnsibleCloudStack.__init__(self, module)
|
|
|
|
self.result = {
|
|
|
|
|
|
|
|
'changed': False,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
self.iso = None
|
|
|
|
self.iso = None
|
|
|
|
|
|
|
|
|
|
|
|
def register_iso(self):
|
|
|
|
def register_iso(self):
|
|
|
|
iso = self.get_iso()
|
|
|
|
iso = self.get_iso()
|
|
|
|
if not 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 = {}
|
|
|
|
args['ostypeid'] = self.get_os_type_id()
|
|
|
|
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']:
|
|
|
|
if args['bootable'] and not args['ostypeid']:
|
|
|
|
self.module.fail_json(msg="OS type 'os_type' is requried if 'bootable=true'.")
|
|
|
|
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']:
|
|
|
|
if not args['url']:
|
|
|
|
self.module.fail_json(msg="URL is requried.")
|
|
|
|
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
|
|
|
|
self.result['changed'] = True
|
|
|
|
if not self.module.check_mode:
|
|
|
|
if not self.module.check_mode:
|
|
|
|
res = self.cs.registerIso(**args)
|
|
|
|
res = self.cs.registerIso(**args)
|
|
|
@ -222,11 +245,14 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
|
|
|
|
|
|
|
|
|
|
|
def get_iso(self):
|
|
|
|
def get_iso(self):
|
|
|
|
if not self.iso:
|
|
|
|
if not self.iso:
|
|
|
|
args = {}
|
|
|
|
|
|
|
|
args['isready'] = self.module.params.get('is_ready')
|
|
|
|
args = {}
|
|
|
|
args['isofilter'] = self.module.params.get('iso_filter')
|
|
|
|
args['isready'] = self.module.params.get('is_ready')
|
|
|
|
args['projectid'] = self.get_project_id()
|
|
|
|
args['isofilter'] = self.module.params.get('iso_filter')
|
|
|
|
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['zoneid'] = self.get_zone('id')
|
|
|
|
|
|
|
|
|
|
|
|
# if checksum is set, we only look on that.
|
|
|
|
# if checksum is set, we only look on that.
|
|
|
|
checksum = self.module.params.get('checksum')
|
|
|
|
checksum = self.module.params.get('checksum')
|
|
|
@ -249,10 +275,12 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
|
|
|
iso = self.get_iso()
|
|
|
|
iso = self.get_iso()
|
|
|
|
if iso:
|
|
|
|
if iso:
|
|
|
|
self.result['changed'] = True
|
|
|
|
self.result['changed'] = True
|
|
|
|
args = {}
|
|
|
|
|
|
|
|
args['id'] = iso['id']
|
|
|
|
args = {}
|
|
|
|
args['projectid'] = self.get_project_id()
|
|
|
|
args['id'] = iso['id']
|
|
|
|
args['zoneid'] = self.get_zone_id()
|
|
|
|
args['projectid'] = self.get_project('id')
|
|
|
|
|
|
|
|
args['zoneid'] = self.get_zone('id')
|
|
|
|
|
|
|
|
|
|
|
|
if not self.module.check_mode:
|
|
|
|
if not self.module.check_mode:
|
|
|
|
res = self.cs.deleteIso(**args)
|
|
|
|
res = self.cs.deleteIso(**args)
|
|
|
|
return iso
|
|
|
|
return iso
|
|
|
@ -274,17 +302,25 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
|
|
|
|
self.result['is_ready'] = iso['isready']
|
|
|
|
self.result['is_ready'] = iso['isready']
|
|
|
|
if 'created' in iso:
|
|
|
|
if 'created' in iso:
|
|
|
|
self.result['created'] = iso['created']
|
|
|
|
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
|
|
|
|
return self.result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec = dict(
|
|
|
|
argument_spec = dict(
|
|
|
|
name = dict(required=True, default=None),
|
|
|
|
name = dict(required=True),
|
|
|
|
url = dict(default=None),
|
|
|
|
url = dict(default=None),
|
|
|
|
os_type = dict(default=None),
|
|
|
|
os_type = dict(default=None),
|
|
|
|
zone = dict(default=None),
|
|
|
|
zone = dict(default=None),
|
|
|
|
iso_filter = dict(default='self', choices=[ 'featured', 'self', 'selfexecutable','sharedexecutable','executable', 'community' ]),
|
|
|
|
iso_filter = dict(default='self', choices=[ 'featured', 'self', 'selfexecutable','sharedexecutable','executable', 'community' ]),
|
|
|
|
|
|
|
|
domain = dict(default=None),
|
|
|
|
|
|
|
|
account = dict(default=None),
|
|
|
|
project = dict(default=None),
|
|
|
|
project = dict(default=None),
|
|
|
|
checksum = dict(default=None),
|
|
|
|
checksum = dict(default=None),
|
|
|
|
is_ready = dict(choices=BOOLEANS, default=False),
|
|
|
|
is_ready = dict(choices=BOOLEANS, default=False),
|
|
|
@ -293,7 +329,7 @@ def main():
|
|
|
|
is_dynamically_scalable = dict(choices=BOOLEANS, default=False),
|
|
|
|
is_dynamically_scalable = dict(choices=BOOLEANS, default=False),
|
|
|
|
state = dict(choices=['present', 'absent'], default='present'),
|
|
|
|
state = dict(choices=['present', 'absent'], default='present'),
|
|
|
|
api_key = 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_url = dict(default=None),
|
|
|
|
api_http_method = dict(default='get'),
|
|
|
|
api_http_method = dict(default='get'),
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -317,6 +353,9 @@ def main():
|
|
|
|
except CloudStackException, e:
|
|
|
|
except CloudStackException, e:
|
|
|
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
|
|
|
module.fail_json(msg='CloudStackException: %s' % str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except Exception, e:
|
|
|
|
|
|
|
|
module.fail_json(msg='Exception: %s' % str(e))
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(**result)
|
|
|
|
module.exit_json(**result)
|
|
|
|
|
|
|
|
|
|
|
|
# import module snippets
|
|
|
|
# import module snippets
|
|
|
|