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:
Dean Troyer 2012-03-13 22:30:52 -05:00
parent f90aa8c91a
commit cc72d6dfe2
3 changed files with 109 additions and 77 deletions

View File

@ -39,37 +39,39 @@ Command-line API
Installing this package gets you a shell command, ``nova``, that you Installing this package gets you a shell command, ``nova``, that you
can use to interact with any Rackspace compatible API (including OpenStack). 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 You'll need to provide your OpenStack username and password. You can do this
with the ``--username``, ``--password`` and ``--projectid`` params, but it's with the ``--os_username``, ``--os_password`` and ``--os_tenant_name``
easier to just set them as environment variables:: params, but it's easier to just set them as environment variables::
export NOVA_USERNAME=openstack export OS_USERNAME=openstack
export NOVA_PASSWORD=yadayada export OS_PASSWORD=yadayada
export NOVA_PROJECT_ID=myproject export OS_TENANT_NAME=myproject
You will also need to define the authentication url with ``--url`` and the You will also need to define the authentication url with ``--os_auth_url``
version of the API with ``--version``. Or set them as an environment and the version of the API with ``--version``. Or set them as an environment
variables as well:: 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 export NOVA_VERSION=1.1
If you are using Keystone, you need to set the NOVA_URL to the keystone If you are using Keystone, you need to set the NOVA_URL to the keystone
endpoint:: 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 Since Keystone can return multiple regions in the Service Catalog, you
can specify the one you want with ``--region_name`` (or can specify the one you want with ``--os_region_name`` (or
``export NOVA_REGION_NAME``). It defaults to the first in the list returned. ``export OS_REGION_NAME``). It defaults to the first in the list returned.
You'll find complete documentation on the shell by running You'll find complete documentation on the shell by running
``nova help``:: ``nova help``::
usage: nova [--username USERNAME] [--password PASSWORD] [--projectid PROJECTID] usage: nova [--debug] [--os_username OS_USERNAME] [--os_password OS_PASSWORD]
[--url URL] [--version VERSION] [--region_name NAME] [--os_tenant_name OS_TENANT_NAME] [--os_auth_url OS_AUTH_URL]
[--endpoint_name NAME] [--os_region_name OS_REGION_NAME] [--service_type SERVICE_TYPE]
<subcommand> ... [--service_name SERVICE_NAME] [--endpoint_type ENDPOINT_TYPE]
[--version VERSION]
<subcommand> ...
Command-line interface to the OpenStack Nova API. 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-create-cert Create x509 cert for a user in tenant
x509-get-root-cert Fetches the x509 root cert. x509-get-root-cert Fetches the x509 root cert.
Optional arguments: Optional arguments:
--username USERNAME Defaults to env[NOVA_USERNAME]. --debug Print debugging output
--password PASSWORD Defaults to env[NOVA_PASSWORD]. --os_username OS_USERNAME
--projectid PROJECTID Defaults to env[NOVA_PROJECT_ID]. Defaults to env[OS_USERNAME].
--url AUTH_URL Defaults to env[NOVA_URL] or --os_password OS_PASSWORD
https://auth.api.rackspacecloud.com/v1.0 Defaults to env[OS_PASSWORD].
if undefined. --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]. --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. See "nova help COMMAND" for help on a specific command.

View File

@ -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. by using the `nova-manage` command in OpenStack Nova.
You'll need to provide :program:`nova` with your OpenStack username and You'll need to provide :program:`nova` with your OpenStack username and
API key. You can do this with the :option:`--username`, :option:`--password` API key. You can do this with the :option:`--os_username`, :option:`--os_password`
and :option:`--projectid` options, but it's easier to just set them as and :option:`--os_tenant_id` options, but it's easier to just set them as
environment variables by setting two environment variables: environment variables by setting two environment variables:
.. envvar:: NOVA_USERNAME .. envvar:: OS_USERNAME
Your OpenStack Nova username. Your OpenStack Nova username.
.. envvar:: NOVA_PASSWORD .. envvar:: OS_PASSWORD
Your password. Your password.
.. envvar:: NOVA_PROJECT_ID .. envvar:: OS_TENANT_NAME
Project for work. Project for work.
.. envvar:: NOVA_URL .. envvar:: OS_AUTH_URL
The OpenStack API server URL. The OpenStack API server URL.
@ -37,10 +37,10 @@ environment variables by setting two environment variables:
For example, in Bash you'd use:: For example, in Bash you'd use::
export NOVA_USERNAME=yourname export OS_USERNAME=yourname
export NOVA_PASSWORD=yadayadayada export OS_PASSWORD=yadayadayada
export NOVA_PROJECT_ID=myproject export OS_TENANT_NAME=myproject
export NOVA_URL=http://... export OS_AUTH_URL=http://...
export NOVA_VERSION=1.1 export NOVA_VERSION=1.1
From there, all shell commands take the form:: From there, all shell commands take the form::

View File

@ -83,23 +83,23 @@ class OpenStackComputeShell(object):
action='store_true', action='store_true',
help="Print debugging output") help="Print debugging output")
parser.add_argument('--username', parser.add_argument('--os_username',
default=utils.env('OS_USERNAME', 'NOVA_USERNAME'), default=utils.env('OS_USERNAME', 'NOVA_USERNAME'),
help='Defaults to env[OS_USERNAME].') help='Defaults to env[OS_USERNAME].')
parser.add_argument('--password', parser.add_argument('--os_password',
default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'), default=utils.env('OS_PASSWORD', 'NOVA_PASSWORD'),
help='Defaults to env[OS_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'), default=utils.env('OS_TENANT_NAME', 'NOVA_PROJECT_ID'),
help='Defaults to env[OS_TENANT_NAME].') 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'), default=utils.env('OS_AUTH_URL', 'NOVA_URL'),
help='Defaults to env[OS_AUTH_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'), default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
help='Defaults to env[OS_REGION_NAME].') help='Defaults to env[OS_REGION_NAME].')
@ -125,20 +125,31 @@ class OpenStackComputeShell(object):
action='store_true', action='store_true',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
# alias for --password, left in for backwards compatibility # FIXME(dtroyer): The args below are here for diablo compatibility,
parser.add_argument('--apikey', # 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'), default=utils.env('NOVA_API_KEY'),
help=argparse.SUPPRESS) help='Deprecated')
# alias for --tenant_name, left in for backward compatibility # alias for --os_tenant_name, left in for backward compatibility
parser.add_argument('--projectid', parser.add_argument('--projectid', '--tenant_name', dest='projectid',
default=utils.env('NOVA_PROJECT_ID'), default=utils.env('NOVA_PROJECT_ID'),
help=argparse.SUPPRESS) help='Deprecated')
# alias for --auth_url, left in for backward compatibility # alias for --os_auth_url, left in for backward compatibility
parser.add_argument('--url', parser.add_argument('--url', '--auth_url', dest='url',
default=utils.env('NOVA_URL'), default=utils.env('NOVA_URL'),
help=argparse.SUPPRESS) help='Deprecated')
return parser return parser
@ -270,13 +281,16 @@ class OpenStackComputeShell(object):
self.do_bash_completion(args) self.do_bash_completion(args)
return 0 return 0
(user, apikey, password, projectid, tenant_name, url, auth_url, (os_username, os_password, os_tenant_name, os_auth_url,
region_name, endpoint_type, insecure, service_type, os_region_name, endpoint_type,
service_name) = ( insecure, service_type, service_name,
args.username, args.apikey, args.password, username, apikey, projectid, url, region_name) = (
args.projectid, args.tenant_name, args.url, args.os_username, args.os_password,
args.auth_url, args.region_name, args.endpoint_type, args.os_tenant_name, args.os_auth_url,
args.insecure, args.service_type, args.service_name) 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: if not endpoint_type:
endpoint_type = DEFAULT_NOVA_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 service_type = utils.get_service_type(args.func) or service_type
#FIXME(usrleon): Here should be restrict for project id same as #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 utils.isunauthenticated(args.func):
if not user: if not os_username:
raise exc.CommandError("You must provide a username " if not username:
"via either --username or env[OS_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: if not apikey:
raise exc.CommandError("You must provide a password " 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: else:
password = apikey os_password = apikey
if not tenant_name: if not os_tenant_name:
if not projectid: if not projectid:
raise exc.CommandError("You must provide a 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]")
else: else:
tenant_name = projectid os_tenant_name = projectid
if not auth_url: if not os_auth_url:
if not url: if not url:
raise exc.CommandError("You must provide an 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]")
else: 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 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 " 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 " 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, self.cs = client.Client(options.version, os_username, os_password,
tenant_name, auth_url, insecure, os_tenant_name, os_auth_url, insecure,
region_name=region_name, region_name=os_region_name,
endpoint_type=endpoint_type, endpoint_type=endpoint_type,
extensions=self.extensions, extensions=self.extensions,
service_type=service_type, service_type=service_type,