Change CLIAuth arg names
Change the argument names used for common Keystone authentication per the updated http://wiki.openstack.org/CLIAuth: --auth_url -> --os_auth_url --password -> --os_password --username -> --os_username --tenant_name -> os_tenant_name --region_name -> os_region_name All old args are depricated but available for backward compatibility. Fixes bug 954531 Change-Id: Ic67c447e4e4b8d793f587c789cecd149446194f3
This commit is contained in:
parent
f90aa8c91a
commit
cc72d6dfe2
62
README.rst
62
README.rst
@ -39,37 +39,39 @@ Command-line API
|
||||
Installing this package gets you a shell command, ``nova``, that you
|
||||
can use to interact with any Rackspace compatible API (including OpenStack).
|
||||
|
||||
You'll need to provide your OpenStack username and API key. You can do this
|
||||
with the ``--username``, ``--password`` and ``--projectid`` params, but it's
|
||||
easier to just set them as environment variables::
|
||||
You'll need to provide your OpenStack username and password. You can do this
|
||||
with the ``--os_username``, ``--os_password`` and ``--os_tenant_name``
|
||||
params, but it's easier to just set them as environment variables::
|
||||
|
||||
export NOVA_USERNAME=openstack
|
||||
export NOVA_PASSWORD=yadayada
|
||||
export NOVA_PROJECT_ID=myproject
|
||||
export OS_USERNAME=openstack
|
||||
export OS_PASSWORD=yadayada
|
||||
export OS_TENANT_NAME=myproject
|
||||
|
||||
You will also need to define the authentication url with ``--url`` and the
|
||||
version of the API with ``--version``. Or set them as an environment
|
||||
You will also need to define the authentication url with ``--os_auth_url``
|
||||
and the version of the API with ``--version``. Or set them as an environment
|
||||
variables as well::
|
||||
|
||||
export NOVA_URL=http://example.com:8774/v1.1/
|
||||
export OS_AUTH_URL=http://example.com:8774/v1.1/
|
||||
export NOVA_VERSION=1.1
|
||||
|
||||
If you are using Keystone, you need to set the NOVA_URL to the keystone
|
||||
endpoint::
|
||||
|
||||
export NOVA_URL=http://example.com:5000/v2.0/
|
||||
export OS_AUTH_URL=http://example.com:5000/v2.0/
|
||||
|
||||
Since Keystone can return multiple regions in the Service Catalog, you
|
||||
can specify the one you want with ``--region_name`` (or
|
||||
``export NOVA_REGION_NAME``). It defaults to the first in the list returned.
|
||||
can specify the one you want with ``--os_region_name`` (or
|
||||
``export OS_REGION_NAME``). It defaults to the first in the list returned.
|
||||
|
||||
You'll find complete documentation on the shell by running
|
||||
``nova help``::
|
||||
|
||||
usage: nova [--username USERNAME] [--password PASSWORD] [--projectid PROJECTID]
|
||||
[--url URL] [--version VERSION] [--region_name NAME]
|
||||
[--endpoint_name NAME]
|
||||
<subcommand> ...
|
||||
usage: nova [--debug] [--os_username OS_USERNAME] [--os_password OS_PASSWORD]
|
||||
[--os_tenant_name OS_TENANT_NAME] [--os_auth_url OS_AUTH_URL]
|
||||
[--os_region_name OS_REGION_NAME] [--service_type SERVICE_TYPE]
|
||||
[--service_name SERVICE_NAME] [--endpoint_type ENDPOINT_TYPE]
|
||||
[--version VERSION]
|
||||
<subcommand> ...
|
||||
|
||||
Command-line interface to the OpenStack Nova API.
|
||||
|
||||
@ -171,18 +173,26 @@ You'll find complete documentation on the shell by running
|
||||
x509-create-cert Create x509 cert for a user in tenant
|
||||
x509-get-root-cert Fetches the x509 root cert.
|
||||
|
||||
|
||||
Optional arguments:
|
||||
--username USERNAME Defaults to env[NOVA_USERNAME].
|
||||
--password PASSWORD Defaults to env[NOVA_PASSWORD].
|
||||
--projectid PROJECTID Defaults to env[NOVA_PROJECT_ID].
|
||||
--url AUTH_URL Defaults to env[NOVA_URL] or
|
||||
https://auth.api.rackspacecloud.com/v1.0
|
||||
if undefined.
|
||||
--debug Print debugging output
|
||||
--os_username OS_USERNAME
|
||||
Defaults to env[OS_USERNAME].
|
||||
--os_password OS_PASSWORD
|
||||
Defaults to env[OS_PASSWORD].
|
||||
--os_tenant_name OS_TENANT_NAME
|
||||
Defaults to env[OS_TENANT_NAME].
|
||||
--os_auth_url OS_AUTH_URL
|
||||
Defaults to env[OS_AUTH_URL].
|
||||
--os_region_name OS_REGION_NAME
|
||||
Defaults to env[OS_REGION_NAME].
|
||||
--service_type SERVICE_TYPE
|
||||
Defaults to compute for most actions
|
||||
--service_name SERVICE_NAME
|
||||
Defaults to env[NOVA_SERVICE_NAME]
|
||||
--endpoint_type ENDPOINT_TYPE
|
||||
Defaults to env[NOVA_ENDPOINT_TYPE] or publicURL.
|
||||
--version VERSION Accepts 1.1, defaults to env[NOVA_VERSION].
|
||||
--region_name NAME The region name in the Keystone Service Catalog
|
||||
to use after authentication. Defaults to first
|
||||
in the list returned.
|
||||
|
||||
|
||||
See "nova help COMMAND" for help on a specific command.
|
||||
|
||||
|
@ -11,23 +11,23 @@ First, you'll need an OpenStack Nova account and an API key. You get this
|
||||
by using the `nova-manage` command in OpenStack Nova.
|
||||
|
||||
You'll need to provide :program:`nova` with your OpenStack username and
|
||||
API key. You can do this with the :option:`--username`, :option:`--password`
|
||||
and :option:`--projectid` options, but it's easier to just set them as
|
||||
API key. You can do this with the :option:`--os_username`, :option:`--os_password`
|
||||
and :option:`--os_tenant_id` options, but it's easier to just set them as
|
||||
environment variables by setting two environment variables:
|
||||
|
||||
.. envvar:: NOVA_USERNAME
|
||||
.. envvar:: OS_USERNAME
|
||||
|
||||
Your OpenStack Nova username.
|
||||
|
||||
.. envvar:: NOVA_PASSWORD
|
||||
.. envvar:: OS_PASSWORD
|
||||
|
||||
Your password.
|
||||
|
||||
.. envvar:: NOVA_PROJECT_ID
|
||||
.. envvar:: OS_TENANT_NAME
|
||||
|
||||
Project for work.
|
||||
|
||||
.. envvar:: NOVA_URL
|
||||
.. envvar:: OS_AUTH_URL
|
||||
|
||||
The OpenStack API server URL.
|
||||
|
||||
@ -37,10 +37,10 @@ environment variables by setting two environment variables:
|
||||
|
||||
For example, in Bash you'd use::
|
||||
|
||||
export NOVA_USERNAME=yourname
|
||||
export NOVA_PASSWORD=yadayadayada
|
||||
export NOVA_PROJECT_ID=myproject
|
||||
export NOVA_URL=http://...
|
||||
export OS_USERNAME=yourname
|
||||
export OS_PASSWORD=yadayadayada
|
||||
export OS_TENANT_NAME=myproject
|
||||
export OS_AUTH_URL=http://...
|
||||
export NOVA_VERSION=1.1
|
||||
|
||||
From there, all shell commands take the form::
|
||||
|
@ -83,23 +83,23 @@ class OpenStackComputeShell(object):
|
||||
action='store_true',
|
||||
help="Print debugging output")
|
||||
|
||||
parser.add_argument('--username',
|
||||
parser.add_argument('--os_username',
|
||||
default=utils.env('OS_USERNAME', 'NOVA_USERNAME'),
|
||||
help='Defaults to env[OS_USERNAME].')
|
||||
|
||||
parser.add_argument('--password',
|
||||
parser.add_argument('--os_password',
|
||||
default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
|
||||
help='Defaults to env[OS_PASSWORD].')
|
||||
|
||||
parser.add_argument('--tenant_name',
|
||||
parser.add_argument('--os_tenant_name',
|
||||
default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
|
||||
help='Defaults to env[OS_TENANT_NAME].')
|
||||
|
||||
parser.add_argument('--auth_url',
|
||||
parser.add_argument('--os_auth_url',
|
||||
default=utils.env('OS_AUTH_URL', 'NOVA_URL'),
|
||||
help='Defaults to env[OS_AUTH_URL].')
|
||||
|
||||
parser.add_argument('--region_name',
|
||||
parser.add_argument('--os_region_name',
|
||||
default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
|
||||
help='Defaults to env[OS_REGION_NAME].')
|
||||
|
||||
@ -125,20 +125,31 @@ class OpenStackComputeShell(object):
|
||||
action='store_true',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
# alias for --password, left in for backwards compatibility
|
||||
parser.add_argument('--apikey',
|
||||
# FIXME(dtroyer): The args below are here for diablo compatibility,
|
||||
# remove them in folsum cycle
|
||||
|
||||
# alias for --os_username, left in for backwards compatibility
|
||||
parser.add_argument('--username',
|
||||
help='Deprecated')
|
||||
|
||||
# alias for --os_region_name, left in for backwards compatibility
|
||||
parser.add_argument('--region_name',
|
||||
help='Deprecated')
|
||||
|
||||
# alias for --os_password, left in for backwards compatibility
|
||||
parser.add_argument('--apikey', '--password', dest='apikey',
|
||||
default=utils.env('NOVA_API_KEY'),
|
||||
help=argparse.SUPPRESS)
|
||||
help='Deprecated')
|
||||
|
||||
# alias for --tenant_name, left in for backward compatibility
|
||||
parser.add_argument('--projectid',
|
||||
# alias for --os_tenant_name, left in for backward compatibility
|
||||
parser.add_argument('--projectid', '--tenant_name', dest='projectid',
|
||||
default=utils.env('NOVA_PROJECT_ID'),
|
||||
help=argparse.SUPPRESS)
|
||||
help='Deprecated')
|
||||
|
||||
# alias for --auth_url, left in for backward compatibility
|
||||
parser.add_argument('--url',
|
||||
# alias for --os_auth_url, left in for backward compatibility
|
||||
parser.add_argument('--url', '--auth_url', dest='url',
|
||||
default=utils.env('NOVA_URL'),
|
||||
help=argparse.SUPPRESS)
|
||||
help='Deprecated')
|
||||
|
||||
return parser
|
||||
|
||||
@ -270,13 +281,16 @@ class OpenStackComputeShell(object):
|
||||
self.do_bash_completion(args)
|
||||
return 0
|
||||
|
||||
(user, apikey, password, projectid, tenant_name, url, auth_url,
|
||||
region_name, endpoint_type, insecure, service_type,
|
||||
service_name) = (
|
||||
args.username, args.apikey, args.password,
|
||||
args.projectid, args.tenant_name, args.url,
|
||||
args.auth_url, args.region_name, args.endpoint_type,
|
||||
args.insecure, args.service_type, args.service_name)
|
||||
(os_username, os_password, os_tenant_name, os_auth_url,
|
||||
os_region_name, endpoint_type,
|
||||
insecure, service_type, service_name,
|
||||
username, apikey, projectid, url, region_name) = (
|
||||
args.os_username, args.os_password,
|
||||
args.os_tenant_name, args.os_auth_url,
|
||||
args.os_region_name, args.endpoint_type,
|
||||
args.insecure, args.service_type, args.service_name,
|
||||
args.username, args.apikey, args.projectid,
|
||||
args.url, args.region_name)
|
||||
|
||||
if not endpoint_type:
|
||||
endpoint_type = DEFAULT_NOVA_ENDPOINT_TYPE
|
||||
@ -286,46 +300,54 @@ class OpenStackComputeShell(object):
|
||||
service_type = utils.get_service_type(args.func) or service_type
|
||||
|
||||
#FIXME(usrleon): Here should be restrict for project id same as
|
||||
# for username or password but for compatibility it is not.
|
||||
# for os_username or os_password but for compatibility it is not.
|
||||
|
||||
if not utils.isunauthenticated(args.func):
|
||||
if not user:
|
||||
raise exc.CommandError("You must provide a username "
|
||||
"via either --username or env[OS_USERNAME]")
|
||||
if not os_username:
|
||||
if not username:
|
||||
raise exc.CommandError("You must provide a username "
|
||||
"via either --os_username or env[OS_USERNAME]")
|
||||
else:
|
||||
os_username = username
|
||||
|
||||
if not password:
|
||||
if not os_password:
|
||||
if not apikey:
|
||||
raise exc.CommandError("You must provide a password "
|
||||
"via either --password or via env[OS_PASSWORD]")
|
||||
"via either --os_password or via "
|
||||
"env[OS_PASSWORD]")
|
||||
else:
|
||||
password = apikey
|
||||
os_password = apikey
|
||||
|
||||
if not tenant_name:
|
||||
if not os_tenant_name:
|
||||
if not projectid:
|
||||
raise exc.CommandError("You must provide a tenant name "
|
||||
"via either --tenant_name or env[OS_TENANT_NAME]")
|
||||
"via either --os_tenant_name or "
|
||||
"env[OS_TENANT_NAME]")
|
||||
else:
|
||||
tenant_name = projectid
|
||||
os_tenant_name = projectid
|
||||
|
||||
if not auth_url:
|
||||
if not os_auth_url:
|
||||
if not url:
|
||||
raise exc.CommandError("You must provide an auth url "
|
||||
"via either --auth_url or env[OS_AUTH_URL]")
|
||||
"via either --os_auth_url or env[OS_AUTH_URL]")
|
||||
else:
|
||||
auth_url = url
|
||||
os_auth_url = url
|
||||
|
||||
if not os_region_name and region_name:
|
||||
os_region_name = region_name
|
||||
|
||||
if options.version and options.version != '1.0':
|
||||
if not tenant_name:
|
||||
if not os_tenant_name:
|
||||
raise exc.CommandError("You must provide a tenant name "
|
||||
"via either --tenant_name or env[OS_TENANT_NAME]")
|
||||
"via either --os_tenant_name or env[OS_TENANT_NAME]")
|
||||
|
||||
if not auth_url:
|
||||
if not os_auth_url:
|
||||
raise exc.CommandError("You must provide an auth url "
|
||||
"via either --auth_url or env[OS_AUTH_URL]")
|
||||
"via either --os_auth_url or env[OS_AUTH_URL]")
|
||||
|
||||
self.cs = client.Client(options.version, user, password,
|
||||
tenant_name, auth_url, insecure,
|
||||
region_name=region_name,
|
||||
self.cs = client.Client(options.version, os_username, os_password,
|
||||
os_tenant_name, os_auth_url, insecure,
|
||||
region_name=os_region_name,
|
||||
endpoint_type=endpoint_type,
|
||||
extensions=self.extensions,
|
||||
service_type=service_type,
|
||||
|
Loading…
x
Reference in New Issue
Block a user