enable ONE auth file authentication (#49331)
This commit is contained in:
parent
b2e5c75131
commit
c1a30c743e
1 changed files with 9 additions and 3 deletions
|
@ -52,6 +52,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- Password of the user to login into OpenNebula RPC server. If not set
|
- Password of the user to login into OpenNebula RPC server. If not set
|
||||||
- then the value of the C(ONE_PASSWORD) environment variable is used.
|
- then the value of the C(ONE_PASSWORD) environment variable is used.
|
||||||
|
- if both I(api_username) or I(api_password) are not set, then it will try
|
||||||
|
- authenticate with ONE auth file. Default path is "~/.one/one_auth".
|
||||||
|
- Set environment variable C(ONE_AUTH) to override this path.
|
||||||
template_name:
|
template_name:
|
||||||
description:
|
description:
|
||||||
- Name of VM template to use to create a new instace
|
- Name of VM template to use to create a new instace
|
||||||
|
@ -1220,8 +1223,8 @@ def get_connection_info(module):
|
||||||
if not password:
|
if not password:
|
||||||
password = os.environ.get('ONE_PASSWORD')
|
password = os.environ.get('ONE_PASSWORD')
|
||||||
|
|
||||||
if not(url and username and password):
|
if not url:
|
||||||
module.fail_json(msg="One or more connection parameters (api_url, api_username, api_password) were not specified")
|
module.fail_json(msg="Opennebula API url (api_url) is not specified")
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
auth_params = namedtuple('auth', ('url', 'username', 'password'))
|
auth_params = namedtuple('auth', ('url', 'username', 'password'))
|
||||||
|
@ -1309,7 +1312,10 @@ def main():
|
||||||
count_labels = params.get('count_labels')
|
count_labels = params.get('count_labels')
|
||||||
disk_saveas = params.get('disk_saveas')
|
disk_saveas = params.get('disk_saveas')
|
||||||
|
|
||||||
client = oca.Client(auth.username + ':' + auth.password, auth.url)
|
if not (auth.username and auth.password):
|
||||||
|
client = oca.Client(None, auth.url)
|
||||||
|
else:
|
||||||
|
client = oca.Client(auth.username + ':' + auth.password, auth.url)
|
||||||
|
|
||||||
if attributes:
|
if attributes:
|
||||||
attributes = dict((key.upper(), value) for key, value in attributes.items())
|
attributes = dict((key.upper(), value) for key, value in attributes.items())
|
||||||
|
|
Loading…
Reference in a new issue