cloudstack: cs_instance: add domain and account
This commit is contained in:
parent
67f954e35e
commit
4d210048ee
1 changed files with 57 additions and 12 deletions
|
@ -106,6 +106,16 @@ options:
|
|||
required: false
|
||||
default: []
|
||||
aliases: [ 'security_group' ]
|
||||
domain:
|
||||
description:
|
||||
- Domain the instance is related to.
|
||||
required: false
|
||||
default: null
|
||||
account:
|
||||
description:
|
||||
- Account the instance is related to.
|
||||
required: false
|
||||
default: null
|
||||
project:
|
||||
description:
|
||||
- Name of the project the instance to be deployed in.
|
||||
|
@ -252,6 +262,16 @@ ssh_key:
|
|||
returned: success
|
||||
type: string
|
||||
sample: key@work
|
||||
domain:
|
||||
description: Domain the instance is related to.
|
||||
returned: success
|
||||
type: string
|
||||
sample: example domain
|
||||
account:
|
||||
description: Account the instance is related to.
|
||||
returned: success
|
||||
type: string
|
||||
sample: example account
|
||||
project:
|
||||
description: Name of project the instance is related to.
|
||||
returned: success
|
||||
|
@ -352,8 +372,15 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|||
if template and iso:
|
||||
self.module.fail_json(msg="Template are ISO are mutually exclusive.")
|
||||
|
||||
args = {}
|
||||
args['account'] = self.get_account('name')
|
||||
args['domainid'] = self.get_domain('id')
|
||||
args['projectid'] = self.get_project('id')
|
||||
args['zoneid'] = self.get_zone('id')
|
||||
|
||||
if template:
|
||||
templates = self.cs.listTemplates(templatefilter='executable')
|
||||
args['templatefilter'] = 'executable'
|
||||
templates = self.cs.listTemplates(**args)
|
||||
if templates:
|
||||
for t in templates['template']:
|
||||
if template in [ t['displaytext'], t['name'], t['id'] ]:
|
||||
|
@ -361,7 +388,8 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|||
self.module.fail_json(msg="Template '%s' not found" % template)
|
||||
|
||||
elif iso:
|
||||
isos = self.cs.listIsos()
|
||||
args['isofilter'] = 'executable'
|
||||
isos = self.cs.listIsos(**args)
|
||||
if isos:
|
||||
for i in isos['iso']:
|
||||
if iso in [ i['displaytext'], i['name'], i['id'] ]:
|
||||
|
@ -375,7 +403,10 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|||
if not disk_offering:
|
||||
return None
|
||||
|
||||
disk_offerings = self.cs.listDiskOfferings()
|
||||
args = {}
|
||||
args['domainid'] = self.get_domain('id')
|
||||
|
||||
disk_offerings = self.cs.listDiskOfferings(**args)
|
||||
if disk_offerings:
|
||||
for d in disk_offerings['diskoffering']:
|
||||
if disk_offering in [ d['displaytext'], d['name'], d['id'] ]:
|
||||
|
@ -388,9 +419,12 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|||
if not instance:
|
||||
instance_name = self.module.params.get('name')
|
||||
|
||||
args = {}
|
||||
args['projectid'] = self.get_project_id()
|
||||
args['zoneid'] = self.get_zone_id()
|
||||
args = {}
|
||||
args['account'] = self.get_account('name')
|
||||
args['domainid'] = self.get_domain('id')
|
||||
args['projectid'] = self.get_project('id')
|
||||
args['zoneid'] = self.get_zone('id')
|
||||
|
||||
instances = self.cs.listVirtualMachines(**args)
|
||||
if instances:
|
||||
for v in instances['virtualmachine']:
|
||||
|
@ -405,9 +439,12 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|||
if not network_names:
|
||||
return None
|
||||
|
||||
args = {}
|
||||
args['zoneid'] = self.get_zone_id()
|
||||
args['projectid'] = self.get_project_id()
|
||||
args = {}
|
||||
args['account'] = self.get_account('name')
|
||||
args['domainid'] = self.get_domain('id')
|
||||
args['projectid'] = self.get_project('id')
|
||||
args['zoneid'] = self.get_zone('id')
|
||||
|
||||
networks = self.cs.listNetworks(**args)
|
||||
if not networks:
|
||||
self.module.fail_json(msg="No networks available")
|
||||
|
@ -458,9 +495,11 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|||
|
||||
args = {}
|
||||
args['templateid'] = self.get_template_or_iso_id()
|
||||
args['zoneid'] = self.get_zone_id()
|
||||
args['zoneid'] = self.get_zone('id')
|
||||
args['serviceofferingid'] = self.get_service_offering_id()
|
||||
args['projectid'] = self.get_project_id()
|
||||
args['account'] = self.get_account('name')
|
||||
args['domainid'] = self.get_domain('id')
|
||||
args['projectid'] = self.get_project('id')
|
||||
args['diskofferingid'] = self.get_disk_offering_id()
|
||||
args['networkids'] = self.get_network_ids()
|
||||
args['hypervisor'] = self.get_hypervisor()
|
||||
|
@ -503,7 +542,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|||
args_ssh_key = {}
|
||||
args_ssh_key['id'] = instance['id']
|
||||
args_ssh_key['keypair'] = self.module.params.get('ssh_key')
|
||||
args_ssh_key['projectid'] = self.get_project_id()
|
||||
args_ssh_key['projectid'] = self.get_project('id')
|
||||
|
||||
if self._has_changed(args_service_offering, instance) or \
|
||||
self._has_changed(args_instance_update, instance) or \
|
||||
|
@ -668,6 +707,10 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|||
self.result['display_name'] = instance['displayname']
|
||||
if 'group' in instance:
|
||||
self.result['group'] = instance['group']
|
||||
if 'domain' in instance:
|
||||
self.result['domain'] = instance['domain']
|
||||
if 'account' in instance:
|
||||
self.result['account'] = instance['account']
|
||||
if 'project' in instance:
|
||||
self.result['project'] = instance['project']
|
||||
if 'publicip' in instance:
|
||||
|
@ -732,6 +775,8 @@ def main():
|
|||
hypervisor = dict(default=None),
|
||||
security_groups = dict(type='list', aliases=[ 'security_group' ], default=[]),
|
||||
affinity_groups = dict(type='list', aliases=[ 'affinity_group' ], default=[]),
|
||||
domain = dict(default=None),
|
||||
account = dict(default=None),
|
||||
project = dict(default=None),
|
||||
user_data = dict(default=None),
|
||||
zone = dict(default=None),
|
||||
|
|
Loading…
Reference in a new issue