Merge pull request #3302 from rcarrillocruz/allow_domain_name_os_user
Allow passing domain name on os_user
This commit is contained in:
commit
c10daa5d80
1 changed files with 16 additions and 0 deletions
|
@ -175,6 +175,22 @@ def main():
|
||||||
module.fail_json(msg='Default project %s is not valid' % default_project)
|
module.fail_json(msg='Default project %s is not valid' % default_project)
|
||||||
project_id = project['id']
|
project_id = project['id']
|
||||||
|
|
||||||
|
if domain:
|
||||||
|
opcloud = shade.operator_cloud(**module.params)
|
||||||
|
try:
|
||||||
|
# We assume admin is passing domain id
|
||||||
|
dom = opcloud.get_domain(domain)['id']
|
||||||
|
domain = dom
|
||||||
|
except:
|
||||||
|
# If we fail, maybe admin is passing a domain name.
|
||||||
|
# Note that domains have unique names, just like id.
|
||||||
|
try:
|
||||||
|
dom = opcloud.search_domains(filters={'name': domain})[0]['id']
|
||||||
|
domain = dom
|
||||||
|
except:
|
||||||
|
# Ok, let's hope the user is non-admin and passing a sane id
|
||||||
|
pass
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if user is None:
|
if user is None:
|
||||||
user = cloud.create_user(
|
user = cloud.create_user(
|
||||||
|
|
Loading…
Reference in a new issue