Merge "Help output tweaks, Vol I"
This commit is contained in:
37
README.rst
37
README.rst
@@ -6,9 +6,11 @@ This is a client for the OpenStack Keystone API. There's a Python API (the
|
|||||||
Keystone 2.0 API is still a moving target, so this module will remain in
|
Keystone 2.0 API is still a moving target, so this module will remain in
|
||||||
"Beta" status until the API is finalized and fully implemented.
|
"Beta" status until the API is finalized and fully implemented.
|
||||||
|
|
||||||
Development takes place on GitHub__. Bug reports and patches may be filed there.
|
Development takes place via the usual OpenStack processes as outlined in
|
||||||
|
the `OpenStack wiki`_. The master repository is on GitHub__.
|
||||||
|
|
||||||
__ https://github.com/4P/python-keystoneclient
|
__ http://wiki.openstack.org/HowToContribute
|
||||||
|
__ http://github.com/openstack/python-keystoneclient
|
||||||
|
|
||||||
This code a fork of `Rackspace's python-novaclient`__ which is in turn a fork of
|
This code a fork of `Rackspace's python-novaclient`__ which is in turn a fork of
|
||||||
`Jacobian's python-cloudservers`__. The python-keystoneclient is licensed under
|
`Jacobian's python-cloudservers`__. The python-keystoneclient is licensed under
|
||||||
@@ -36,32 +38,37 @@ By way of a quick-start::
|
|||||||
Command-line API
|
Command-line API
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
.. attention:: COMING SOON
|
|
||||||
|
|
||||||
The CLI is not yet implemented, but will follow the pattern laid
|
|
||||||
out below.
|
|
||||||
|
|
||||||
Installing this package gets you a shell command, ``keystone``, that you
|
Installing this package gets you a shell command, ``keystone``, that you
|
||||||
can use to interact with Keystone's API.
|
can use to interact with Keystone's Identity API.
|
||||||
|
|
||||||
You'll need to provide your OpenStack username and API key. You can do this
|
You'll need to provide your OpenStack tenant, username and password. You can do this
|
||||||
with the ``--username``, ``--apikey`` and ``--projectid`` params, but it's
|
with the ``tenant_name``, ``--username`` and ``--password`` params, but it's
|
||||||
easier to just set them as environment variables::
|
easier to just set them as environment variables::
|
||||||
|
|
||||||
export OS_TENANT_NAME=project
|
export OS_TENANT_NAME=project
|
||||||
export OS_USERNAME=user
|
export OS_USERNAME=user
|
||||||
export OS_PASSWORD=pass
|
export OS_PASSWORD=pass
|
||||||
|
|
||||||
You will also need to define the authentication url with ``--url`` and the
|
You will also need to define the authentication url with ``--auth_url`` and the
|
||||||
version of the API with ``--version``. Or set them as an environment
|
version of the API with ``--identity_api_version``. Or set them as an environment
|
||||||
variables as well::
|
variables as well::
|
||||||
|
|
||||||
export OS_AUTH_URL=http://example.com:5000/v2.0
|
export OS_AUTH_URL=http://example.com:5000/v2.0
|
||||||
export KEYSTONE_ADMIN_URL=http://example.com:35357/v2.0
|
export OS_IDENTITY_API_VERSION=2.0
|
||||||
|
|
||||||
|
Alternatively, to authenticate to Keystone without a username/password,
|
||||||
|
such as when there are no users in the database yet, use the service
|
||||||
|
token and endpoint arguemnts. The service token is set in keystone.conf as
|
||||||
|
``admin_token``; set it with ``service_token``. Note: keep the service token
|
||||||
|
secret as it allows total access to Keystone's database. The admin endpoint is set
|
||||||
|
with ``--endpoint`` or ``SERVICE_ENDPOINT``::
|
||||||
|
|
||||||
|
export SERVICE_TOKEN=thequickbrownfox-jumpsover-thelazydog
|
||||||
|
export SERVICE_ENDPOINT=http://example.com:35357/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 ``--region_name`` (or
|
||||||
``export KEYSTONE_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
|
||||||
``keystone help``::
|
``keystone help``::
|
||||||
@@ -73,7 +80,7 @@ You'll find complete documentation on the shell by running
|
|||||||
[--endpoint ENDPOINT]
|
[--endpoint ENDPOINT]
|
||||||
<subcommand> ...
|
<subcommand> ...
|
||||||
|
|
||||||
Command-line interface to the OpenStack Keystone API.
|
Command-line interface to the OpenStack Identity API.
|
||||||
|
|
||||||
Positional arguments:
|
Positional arguments:
|
||||||
<subcommand>
|
<subcommand>
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Command-line interface to the OpenStack Keystone API.
|
Command-line interface to the OpenStack Identity API.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@@ -57,7 +57,7 @@ class OpenStackIdentityShell(object):
|
|||||||
|
|
||||||
# Global arguments
|
# Global arguments
|
||||||
parser.add_argument('-h', '--help',
|
parser.add_argument('-h', '--help',
|
||||||
action='help',
|
action='store_true',
|
||||||
help=argparse.SUPPRESS,
|
help=argparse.SUPPRESS,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -157,6 +157,12 @@ class OpenStackIdentityShell(object):
|
|||||||
subcommand_parser = self.get_subcommand_parser(api_version)
|
subcommand_parser = self.get_subcommand_parser(api_version)
|
||||||
self.parser = subcommand_parser
|
self.parser = subcommand_parser
|
||||||
|
|
||||||
|
# Handle top-level --help/-h before attempting to parse
|
||||||
|
# a command off the command line
|
||||||
|
if options.help:
|
||||||
|
self.do_help(options)
|
||||||
|
return 0
|
||||||
|
|
||||||
# Parse args again and call whatever callback was selected
|
# Parse args again and call whatever callback was selected
|
||||||
args = subcommand_parser.parse_args(argv)
|
args = subcommand_parser.parse_args(argv)
|
||||||
|
|
||||||
@@ -164,7 +170,7 @@ class OpenStackIdentityShell(object):
|
|||||||
if args.debug:
|
if args.debug:
|
||||||
httplib2.debuglevel = 1
|
httplib2.debuglevel = 1
|
||||||
|
|
||||||
# Short-circuit and deal with help right away.
|
# Short-circuit and deal with help command right away.
|
||||||
if args.func == self.do_help:
|
if args.func == self.do_help:
|
||||||
self.do_help(args)
|
self.do_help(args)
|
||||||
return 0
|
return 0
|
||||||
@@ -208,7 +214,7 @@ class OpenStackIdentityShell(object):
|
|||||||
try:
|
try:
|
||||||
args.func(self.cs, args)
|
args.func(self.cs, args)
|
||||||
except exc.Unauthorized:
|
except exc.Unauthorized:
|
||||||
raise exc.CommandError("Invalid OpenStack Keystone credentials.")
|
raise exc.CommandError("Invalid OpenStack Identity credentials.")
|
||||||
except exc.AuthorizationFailure:
|
except exc.AuthorizationFailure:
|
||||||
raise exc.CommandError("Unable to authorize user")
|
raise exc.CommandError("Unable to authorize user")
|
||||||
|
|
||||||
@@ -226,7 +232,7 @@ class OpenStackIdentityShell(object):
|
|||||||
"""
|
"""
|
||||||
Display help about this program or one of its subcommands.
|
Display help about this program or one of its subcommands.
|
||||||
"""
|
"""
|
||||||
if args.command:
|
if getattr(args, 'command', None):
|
||||||
if args.command in self.subcommands:
|
if args.command in self.subcommands:
|
||||||
self.subcommands[args.command].print_help()
|
self.subcommands[args.command].print_help()
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user