Browse Source

Merge "Add support domain-scoped token for CLI"

changes/41/675941/1
Zuul Gerrit Code Review 6 months ago
parent
commit
9c5f68cf97
3 changed files with 29 additions and 5 deletions
  1. +2
    -0
      doc/source/CLI.rst
  2. +4
    -1
      src/bin/shipyard_client/shipyard_client/api_client/base_client.py
  3. +23
    -4
      src/bin/shipyard_client/shipyard_client/cli/commands.py

+ 2
- 0
doc/source/CLI.rst View File

@@ -32,6 +32,8 @@ variables that will be used are as follows:

- OS_PROJECT_DOMAIN_NAME ("default" if not specified)
- OS_USER_DOMAIN_NAME ("default" if not specified)
- OS_DOMAIN_NAME
- OS_AUTH_TOKEN
- OS_PROJECT_NAME
- OS_USERNAME
- OS_PASSWORD


+ 4
- 1
src/bin/shipyard_client/shipyard_client/api_client/base_client.py View File

@@ -150,7 +150,10 @@ class BaseClient(metaclass=abc.ABCMeta):
def _get_ks_session(self):
self.logger.debug('Accessing keystone for keystone session')
try:
auth = v3.Password(**self.context.keystone_auth)
if self.context.keystone_auth.get("token"):
auth = v3.Token(**self.context.keystone_auth)
else:
auth = v3.Password(**self.context.keystone_auth)
return session.Session(auth=auth)
except AuthorizationFailure as e:
self.logger.error('Could not authorize against keystone: %s',


+ 23
- 4
src/bin/shipyard_client/shipyard_client/cli/commands.py View File

@@ -46,10 +46,16 @@ from shipyard_client.cli.input_checks import check_control_action, check_id
type=click.Choice(['format', 'raw', 'cli']),
default='cli')
# Supported Environment Variables
@click.option('--os-auth-token',
envvar='OS_AUTH_TOKEN',
required=False)
@click.option('--os-project-domain-name',
envvar='OS_PROJECT_DOMAIN_NAME',
required=False,
default='default')
@click.option('--os-domain-name',
envvar='OS_DOMAIN_NAME',
required=False)
@click.option('--os-user-domain-name',
envvar='OS_USER_DOMAIN_NAME',
required=False,
@@ -68,9 +74,9 @@ from shipyard_client.cli.input_checks import check_control_action, check_id
type=click.IntRange(0, 5),
default=1)
@click.pass_context
def shipyard(ctx, context_marker, debug, os_project_domain_name,
os_user_domain_name, os_project_name, os_username, os_password,
os_auth_url, output_format, verbosity):
def shipyard(ctx, context_marker, debug, os_auth_token, os_project_domain_name,
os_user_domain_name, os_domain_name, os_project_name, os_username,
os_password, os_auth_url, output_format, verbosity):
"""
COMMAND: shipyard \n
DESCRIPTION: The base shipyard command supports options that determine
@@ -95,7 +101,6 @@ def shipyard(ctx, context_marker, debug, os_project_domain_name,
logger.debug('logging for cli initialized')

auth_vars = {
'project_domain_name': os_project_domain_name,
'user_domain_name': os_user_domain_name,
'project_name': os_project_name,
'username': os_username,
@@ -103,6 +108,20 @@ def shipyard(ctx, context_marker, debug, os_project_domain_name,
'auth_url': os_auth_url
}

if os_auth_token:
auth_vars = {
'token': os_auth_token,
'auth_url': os_auth_url
}

# Domain-scoped params
if os_domain_name:
auth_vars['domain_name'] = os_domain_name
auth_vars['project_domain_name'] = None
# Project-scoped params
else:
auth_vars['project_domain_name'] = os_project_domain_name

ctx.obj['API_PARAMETERS'] = {
'auth_vars': auth_vars,
'context_marker': str(context_marker) if context_marker else None,


Loading…
Cancel
Save