cloudstack: cs_iso code style and cleanup

reviewable/pr18780/r1
Rene Moser 10 years ago
parent de1f642efd
commit 46cb5627dc

@ -214,6 +214,7 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
def register_iso(self): def register_iso(self):
iso = self.get_iso() iso = self.get_iso()
if not iso: if not iso:
args = {} args = {}
args['zoneid'] = self.get_zone('id') args['zoneid'] = self.get_zone('id')
args['domainid'] = self.get_domain('id') args['domainid'] = self.get_domain('id')
@ -221,13 +222,6 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
args['projectid'] = self.get_project('id') args['projectid'] = self.get_project('id')
args['bootable'] = self.module.params.get('bootable') args['bootable'] = self.module.params.get('bootable')
args['ostypeid'] = self.get_os_type('id') args['ostypeid'] = self.get_os_type('id')
if args['bootable'] and not args['ostypeid']:
self.module.fail_json(msg="OS type 'os_type' is requried if 'bootable=true'.")
args['url'] = self.module.params.get('url')
if not args['url']:
self.module.fail_json(msg="URL is requried.")
args['name'] = self.module.params.get('name') args['name'] = self.module.params.get('name')
args['displaytext'] = self.module.params.get('name') args['displaytext'] = self.module.params.get('name')
args['checksum'] = self.module.params.get('checksum') args['checksum'] = self.module.params.get('checksum')
@ -235,6 +229,13 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
args['isfeatured'] = self.module.params.get('is_featured') args['isfeatured'] = self.module.params.get('is_featured')
args['ispublic'] = self.module.params.get('is_public') 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'.")
args['url'] = self.module.params.get('url')
if not args['url']:
self.module.fail_json(msg="URL is requried.")
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)
@ -244,6 +245,7 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
def get_iso(self): def get_iso(self):
if not self.iso: if not self.iso:
args = {} args = {}
args['isready'] = self.module.params.get('is_ready') args['isready'] = self.module.params.get('is_ready')
args['isofilter'] = self.module.params.get('iso_filter') args['isofilter'] = self.module.params.get('iso_filter')
@ -273,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 = {}
args['id'] = iso['id'] args['id'] = iso['id']
args['projectid'] = self.get_project('id') args['projectid'] = self.get_project('id')
args['zoneid'] = self.get_zone('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
@ -310,7 +314,7 @@ class AnsibleCloudStackIso(AnsibleCloudStack):
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),

Loading…
Cancel
Save