Update help strings for cinder client

Make text consistent and clear.
Add periods to end of sentences.
Adjust test suite for change

Closes-Bug: #1275881

Change-Id: I1dfde51636e8dc4b42e4c4810c27c1c4ac513d82
This commit is contained in:
Diane Fleming
2014-02-03 13:39:15 -06:00
parent 4163fa23a4
commit 0d2bf657ae
19 changed files with 570 additions and 520 deletions

View File

@@ -1,5 +1,5 @@
# Copyright 2011 OpenStack LLC. # Copyright 2011-2014 OpenStack Foundation
# All Rights Reserved. # All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -74,8 +74,7 @@ class OpenStackCinderShell(object):
parser = CinderClientArgumentParser( parser = CinderClientArgumentParser(
prog='cinder', prog='cinder',
description=__doc__.strip(), description=__doc__.strip(),
epilog='See "cinder help COMMAND" ' epilog='Run "cinder help SUBCOMMAND" for help on a subcommand.',
'for help on a specific command.',
add_help=False, add_help=False,
formatter_class=OpenStackHelpFormatter, formatter_class=OpenStackHelpFormatter,
) )
@@ -93,13 +92,14 @@ class OpenStackCinderShell(object):
action='store_true', action='store_true',
default=utils.env('CINDERCLIENT_DEBUG', default=utils.env('CINDERCLIENT_DEBUG',
default=False), default=False),
help="Print debugging output") help="Shows debugging output.")
parser.add_argument('--os-username', parser.add_argument('--os-username',
metavar='<auth-user-name>', metavar='<auth-user-name>',
default=utils.env('OS_USERNAME', default=utils.env('OS_USERNAME',
'CINDER_USERNAME'), 'CINDER_USERNAME'),
help='Defaults to env[OS_USERNAME].') help='OpenStack user name. '
'Default=env[OS_USERNAME].')
parser.add_argument('--os_username', parser.add_argument('--os_username',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@@ -107,7 +107,8 @@ class OpenStackCinderShell(object):
metavar='<auth-password>', metavar='<auth-password>',
default=utils.env('OS_PASSWORD', default=utils.env('OS_PASSWORD',
'CINDER_PASSWORD'), 'CINDER_PASSWORD'),
help='Defaults to env[OS_PASSWORD].') help='Password for OpenStack user. '
'Default=env[OS_PASSWORD].')
parser.add_argument('--os_password', parser.add_argument('--os_password',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@@ -115,7 +116,8 @@ class OpenStackCinderShell(object):
metavar='<auth-tenant-name>', metavar='<auth-tenant-name>',
default=utils.env('OS_TENANT_NAME', default=utils.env('OS_TENANT_NAME',
'CINDER_PROJECT_ID'), 'CINDER_PROJECT_ID'),
help='Defaults to env[OS_TENANT_NAME].') help='Tenant name. '
'Default=env[OS_TENANT_NAME].')
parser.add_argument('--os_tenant_name', parser.add_argument('--os_tenant_name',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@@ -123,7 +125,8 @@ class OpenStackCinderShell(object):
metavar='<auth-tenant-id>', metavar='<auth-tenant-id>',
default=utils.env('OS_TENANT_ID', default=utils.env('OS_TENANT_ID',
'CINDER_TENANT_ID'), 'CINDER_TENANT_ID'),
help='Defaults to env[OS_TENANT_ID].') help='ID for the tenant. '
'Default=env[OS_TENANT_ID].')
parser.add_argument('--os_tenant_id', parser.add_argument('--os_tenant_id',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@@ -131,7 +134,8 @@ class OpenStackCinderShell(object):
metavar='<auth-url>', metavar='<auth-url>',
default=utils.env('OS_AUTH_URL', default=utils.env('OS_AUTH_URL',
'CINDER_URL'), 'CINDER_URL'),
help='Defaults to env[OS_AUTH_URL].') help='URL for the authentication service. '
'Default=env[OS_AUTH_URL].')
parser.add_argument('--os_auth_url', parser.add_argument('--os_auth_url',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@@ -139,7 +143,8 @@ class OpenStackCinderShell(object):
metavar='<region-name>', metavar='<region-name>',
default=utils.env('OS_REGION_NAME', default=utils.env('OS_REGION_NAME',
'CINDER_REGION_NAME'), 'CINDER_REGION_NAME'),
help='Defaults to env[OS_REGION_NAME].') help='Region name. '
'Default=env[OS_REGION_NAME].')
parser.add_argument('--os_region_name', parser.add_argument('--os_region_name',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@@ -152,21 +157,24 @@ class OpenStackCinderShell(object):
parser.add_argument('--service-type', parser.add_argument('--service-type',
metavar='<service-type>', metavar='<service-type>',
help='Defaults to volume for most actions') help='Service type. '
'For most actions, default is volume.')
parser.add_argument('--service_type', parser.add_argument('--service_type',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--service-name', parser.add_argument('--service-name',
metavar='<service-name>', metavar='<service-name>',
default=utils.env('CINDER_SERVICE_NAME'), default=utils.env('CINDER_SERVICE_NAME'),
help='Defaults to env[CINDER_SERVICE_NAME]') help='Service name. '
'Default=env[CINDER_SERVICE_NAME].')
parser.add_argument('--service_name', parser.add_argument('--service_name',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--volume-service-name', parser.add_argument('--volume-service-name',
metavar='<volume-service-name>', metavar='<volume-service-name>',
default=utils.env('CINDER_VOLUME_SERVICE_NAME'), default=utils.env('CINDER_VOLUME_SERVICE_NAME'),
help='Defaults to env[CINDER_VOLUME_SERVICE_NAME]') help='Volume service name. '
'Default=env[CINDER_VOLUME_SERVICE_NAME].')
parser.add_argument('--volume_service_name', parser.add_argument('--volume_service_name',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@@ -174,7 +182,9 @@ class OpenStackCinderShell(object):
metavar='<endpoint-type>', metavar='<endpoint-type>',
default=utils.env('CINDER_ENDPOINT_TYPE', default=utils.env('CINDER_ENDPOINT_TYPE',
default=DEFAULT_CINDER_ENDPOINT_TYPE), default=DEFAULT_CINDER_ENDPOINT_TYPE),
help='Defaults to env[CINDER_ENDPOINT_TYPE] or ' help='Endpoint type, which is publicURL or '
'internalURL. '
'Default=nova env[CINDER_ENDPOINT_TYPE] or '
+ DEFAULT_CINDER_ENDPOINT_TYPE + '.') + DEFAULT_CINDER_ENDPOINT_TYPE + '.')
parser.add_argument('--endpoint_type', parser.add_argument('--endpoint_type',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@@ -183,17 +193,18 @@ class OpenStackCinderShell(object):
metavar='<volume-api-ver>', metavar='<volume-api-ver>',
default=utils.env('OS_VOLUME_API_VERSION', default=utils.env('OS_VOLUME_API_VERSION',
default=None), default=None),
help='Accepts 1 or 2,defaults ' help='Block Storage API version. '
'to env[OS_VOLUME_API_VERSION].') 'Valid values are 1 or 2. '
'Default=env[OS_VOLUME_API_VERSION].')
parser.add_argument('--os_volume_api_version', parser.add_argument('--os_volume_api_version',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--os-cacert', parser.add_argument('--os-cacert',
metavar='<ca-certificate>', metavar='<ca-certificate>',
default=utils.env('OS_CACERT', default=None), default=utils.env('OS_CACERT', default=None),
help='Specify a CA bundle file to use in ' help='A CA bundle file that is used to '
'verifying a TLS (https) server certificate. ' 'verify a TLS (https) server certificate. '
'Defaults to env[OS_CACERT]') 'Default=env[OS_CACERT].')
parser.add_argument('--insecure', parser.add_argument('--insecure',
default=utils.env('CINDERCLIENT_INSECURE', default=utils.env('CINDERCLIENT_INSECURE',
@@ -419,24 +430,24 @@ class OpenStackCinderShell(object):
if not os_username: if not os_username:
if not username: if not username:
raise exc.CommandError( raise exc.CommandError(
"You must provide a username " "You must provide a user name "
"via either --os-username or env[OS_USERNAME]") "through --os-username or env[OS_USERNAME].")
else: else:
os_username = username os_username = username
if not os_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 --os-password or via " "through --os-password or "
"env[OS_PASSWORD]") "env[OS_PASSWORD].")
else: else:
os_password = apikey os_password = apikey
if not (os_tenant_name or os_tenant_id): if not (os_tenant_name or os_tenant_id):
if not projectid: if not projectid:
raise exc.CommandError("You must provide a tenant_id " raise exc.CommandError("You must provide a tenant ID "
"via either --os-tenant-id or " "through --os-tenant-id or "
"env[OS_TENANT_ID]") "env[OS_TENANT_ID].")
else: else:
os_tenant_name = projectid os_tenant_name = projectid
@@ -447,8 +458,8 @@ class OpenStackCinderShell(object):
if not os_auth_url: if not os_auth_url:
if not url: if not url:
raise exc.CommandError( raise exc.CommandError(
"You must provide an auth url " "You must provide an authentication URL "
"via either --os-auth-url or env[OS_AUTH_URL]") "through --os-auth-url or env[OS_AUTH_URL].")
else: else:
os_auth_url = url os_auth_url = url
@@ -457,13 +468,13 @@ class OpenStackCinderShell(object):
if not (os_tenant_name or os_tenant_id): if not (os_tenant_name or os_tenant_id):
raise exc.CommandError( raise exc.CommandError(
"You must provide a tenant_id " "You must provide a tenant ID "
"via either --os-tenant-id or env[OS_TENANT_ID]") "through --os-tenant-id or env[OS_TENANT_ID].")
if not os_auth_url: if not os_auth_url:
raise exc.CommandError( raise exc.CommandError(
"You must provide an auth url " "You must provide an authentication URL "
"via either --os-auth-url or env[OS_AUTH_URL]") "through --os-auth-url or env[OS_AUTH_URL].")
self.cs = client.Client(options.os_volume_api_version, os_username, self.cs = client.Client(options.os_volume_api_version, os_username,
os_password, os_tenant_name, os_auth_url, os_password, os_tenant_name, os_auth_url,
@@ -483,9 +494,9 @@ class OpenStackCinderShell(object):
if not utils.isunauthenticated(args.func): if not utils.isunauthenticated(args.func):
self.cs.authenticate() self.cs.authenticate()
except exc.Unauthorized: except exc.Unauthorized:
raise exc.CommandError("Invalid OpenStack Cinder credentials.") raise exc.CommandError("OpenStack credentials are not valid.")
except exc.AuthorizationFailure: except exc.AuthorizationFailure:
raise exc.CommandError("Unable to authorize user") raise exc.CommandError("Unable to authorize user.")
endpoint_api_version = None endpoint_api_version = None
# Try to get the API version from the endpoint URL. If that fails fall # Try to get the API version from the endpoint URL. If that fails fall
@@ -496,37 +507,37 @@ class OpenStackCinderShell(object):
endpoint_api_version = \ endpoint_api_version = \
self.cs.get_volume_api_version_from_endpoint() self.cs.get_volume_api_version_from_endpoint()
if endpoint_api_version != options.os_volume_api_version: if endpoint_api_version != options.os_volume_api_version:
msg = (("Volume API version is set to %s " msg = (("OpenStack Block Storage API version is set to %s "
"but you are accessing a %s endpoint. " "but you are accessing a %s endpoint. "
"Change its value via either --os-volume-api-version " "Change its value through --os-volume-api-version "
"or env[OS_VOLUME_API_VERSION]") "or env[OS_VOLUME_API_VERSION].")
% (options.os_volume_api_version, endpoint_api_version)) % (options.os_volume_api_version, endpoint_api_version))
raise exc.InvalidAPIVersion(msg) raise exc.InvalidAPIVersion(msg)
except exc.UnsupportedVersion: except exc.UnsupportedVersion:
endpoint_api_version = options.os_volume_api_version endpoint_api_version = options.os_volume_api_version
if api_version_input: if api_version_input:
logger.warning("Unable to determine the API version via " logger.warning("Cannot determine the API version from "
"endpoint URL. Falling back to user " "the endpoint URL. Falling back to the "
"specified version: %s" % "user-specified version: %s" %
endpoint_api_version) endpoint_api_version)
else: else:
logger.warning("Unable to determine the API version from " logger.warning("Cannot determine the API version from the "
"endpoint URL or user input. Falling back to " "endpoint URL or user input. Falling back "
"default API version: %s" % "to the default API version: %s" %
endpoint_api_version) endpoint_api_version)
args.func(self.cs, args) args.func(self.cs, args)
def _run_extension_hooks(self, hook_type, *args, **kwargs): def _run_extension_hooks(self, hook_type, *args, **kwargs):
"""Run hooks for all registered extensions.""" """Runs hooks for all registered extensions."""
for extension in self.extensions: for extension in self.extensions:
extension.run_hooks(hook_type, *args, **kwargs) extension.run_hooks(hook_type, *args, **kwargs)
def do_bash_completion(self, args): def do_bash_completion(self, args):
"""Print arguments for bash_completion. """Prints arguments for bash_completion.
Prints all of the commands and options to stdout so that the Prints all commands and options to stdout so that the
cinder.bash_completion script doesn't have to hard code them. cinder.bash_completion script does not have to hard code them.
""" """
commands = set() commands = set()
options = set() options = set()
@@ -540,10 +551,10 @@ class OpenStackCinderShell(object):
print(' '.join(commands | options)) print(' '.join(commands | options))
@utils.arg('command', metavar='<subcommand>', nargs='?', @utils.arg('command', metavar='<subcommand>', nargs='?',
help='Display help for <subcommand>') help='Shows help for <subcommand>.')
def do_help(self, args): def do_help(self, args):
""" """
Display help about this program or one of its subcommands. Shows help about this program or one of its subcommands.
""" """
if args.command: if args.command:
if args.command in self.subcommands: if args.command in self.subcommands:

View File

@@ -61,8 +61,8 @@ class ShellTest(utils.TestCase):
def test_help(self): def test_help(self):
required = [ required = [
'.*?^usage: ', '.*?^usage: ',
'.*?(?m)^\s+create\s+Add a new volume.', '.*?(?m)^\s+create\s+Creates a volume.',
'.*?(?m)^See "cinder help COMMAND" for help on a specific command', '.*?(?m)^Run "cinder help SUBCOMMAND" for help on a subcommand.',
] ]
help_text = self.shell('help') help_text = self.shell('help')
for r in required: for r in required:
@@ -72,7 +72,7 @@ class ShellTest(utils.TestCase):
def test_help_on_subcommand(self): def test_help_on_subcommand(self):
required = [ required = [
'.*?^usage: cinder list', '.*?^usage: cinder list',
'.*?(?m)^List all the volumes.', '.*?(?m)^Lists all volumes.',
] ]
help_text = self.shell('help list') help_text = self.shell('help list')
for r in required: for r in required:

View File

@@ -31,7 +31,7 @@ class AvailabilityZoneManager(base.ManagerWithFind):
resource_class = AvailabilityZone resource_class = AvailabilityZone
def list(self, detailed=False): def list(self, detailed=False):
"""Get a list of all availability zones """Lists all availability zones.
:rtype: list of :class:`AvailabilityZone` :rtype: list of :class:`AvailabilityZone`
""" """

View File

@@ -40,7 +40,7 @@ class ListExtManager(base.Manager):
@utils.service_type('volume') @utils.service_type('volume')
def do_list_extensions(client, _args): def do_list_extensions(client, _args):
""" """
List all the os-api extensions that are available. Lists all available os-api extensions.
""" """
extensions = client.list_extensions.show_all() extensions = client.list_extensions.show_all()
fields = ["Name", "Summary", "Alias", "Updated"] fields = ["Name", "Summary", "Alias", "Updated"]

File diff suppressed because it is too large Load Diff

View File

@@ -36,7 +36,7 @@ class VolumeBackupManager(base.ManagerWithFind):
def create(self, volume_id, container=None, def create(self, volume_id, container=None,
name=None, description=None): name=None, description=None):
"""Create a volume backup. """Creates a volume backup.
:param volume_id: The ID of the volume to backup. :param volume_id: The ID of the volume to backup.
:param container: The name of the backup service container. :param container: The name of the backup service container.

View File

@@ -65,7 +65,7 @@ class VolumeEncryptionTypeManager(base.ManagerWithFind):
def create(self, volume_type, specs): def create(self, volume_type, specs):
""" """
Create a new encryption type for the specified volume type. Creates encryption type for a volume type. Default: admin only.
:param volume_type: the volume type on which to add an encryption type :param volume_type: the volume type on which to add an encryption type
:param specs: the encryption type specifications to add :param specs: the encryption type specifications to add

View File

@@ -35,7 +35,7 @@ class VolumeTransferManager(base.ManagerWithFind):
resource_class = VolumeTransfer resource_class = VolumeTransfer
def create(self, volume_id, name=None): def create(self, volume_id, name=None):
"""Create a volume transfer. """Creates a volume transfer.
:param volume_id: The ID of the volume to transfer. :param volume_id: The ID of the volume to transfer.
:param name: The name of the transfer. :param name: The name of the transfer.

View File

@@ -107,7 +107,7 @@ class VolumeTypeManager(base.ManagerWithFind):
def create(self, name): def create(self, name):
""" """
Create a volume type. Creates a volume type.
:param name: Descriptive name of the volume type :param name: Descriptive name of the volume type
:rtype: :class:`VolumeType` :rtype: :class:`VolumeType`

View File

@@ -149,7 +149,7 @@ class VolumeManager(base.ManagerWithFind):
project_id=None, availability_zone=None, project_id=None, availability_zone=None,
metadata=None, imageRef=None): metadata=None, imageRef=None):
""" """
Create a volume. Creates a volume.
:param size: Size of volume in GB :param size: Size of volume in GB
:param snapshot_id: ID of the snapshot :param snapshot_id: ID of the snapshot

View File

@@ -31,7 +31,7 @@ class AvailabilityZoneManager(base.ManagerWithFind):
resource_class = AvailabilityZone resource_class = AvailabilityZone
def list(self, detailed=False): def list(self, detailed=False):
"""Get a list of all availability zones """Lists all availability zones.
:rtype: list of :class:`AvailabilityZone` :rtype: list of :class:`AvailabilityZone`
""" """

View File

@@ -39,7 +39,9 @@ class ListExtManager(base.Manager):
@utils.service_type('volumev2') @utils.service_type('volumev2')
def do_list_extensions(client, _args): def do_list_extensions(client, _args):
"""List all the os-api extensions that are available.""" """
Lists all available os-api extensions.
"""
extensions = client.list_extensions.show_all() extensions = client.list_extensions.show_all()
fields = ["Name", "Summary", "Alias", "Updated"] fields = ["Name", "Summary", "Alias", "Updated"]
utils.print_list(extensions, fields) utils.print_list(extensions, fields)

File diff suppressed because it is too large Load Diff

View File

@@ -36,7 +36,7 @@ class VolumeBackupManager(base.ManagerWithFind):
def create(self, volume_id, container=None, def create(self, volume_id, container=None,
name=None, description=None): name=None, description=None):
"""Create a volume backup. """Creates a volume backup.
:param volume_id: The ID of the volume to backup. :param volume_id: The ID of the volume to backup.
:param container: The name of the backup service container. :param container: The name of the backup service container.
@@ -51,7 +51,7 @@ class VolumeBackupManager(base.ManagerWithFind):
return self._create('/backups', body, 'backup') return self._create('/backups', body, 'backup')
def get(self, backup_id): def get(self, backup_id):
"""Show details of a volume backup. """Show volume backup details.
:param backup_id: The ID of the backup to display. :param backup_id: The ID of the backup to display.
:rtype: :class:`VolumeBackup` :rtype: :class:`VolumeBackup`

View File

@@ -65,7 +65,7 @@ class VolumeEncryptionTypeManager(base.ManagerWithFind):
def create(self, volume_type, specs): def create(self, volume_type, specs):
""" """
Create a new encryption type for the specified volume type. Creates encryption type for a volume type. Default: admin only.
:param volume_type: the volume type on which to add an encryption type :param volume_type: the volume type on which to add an encryption type
:param specs: the encryption type specifications to add :param specs: the encryption type specifications to add

View File

@@ -69,7 +69,7 @@ class SnapshotManager(base.ManagerWithFind):
def create(self, volume_id, force=False, def create(self, volume_id, force=False,
name=None, description=None): name=None, description=None):
"""Create a snapshot of the given volume. """Creates a snapshot of the given volume.
:param volume_id: The ID of the volume to snapshot. :param volume_id: The ID of the volume to snapshot.
:param force: If force is True, create a snapshot even if the volume is :param force: If force is True, create a snapshot even if the volume is
@@ -85,7 +85,7 @@ class SnapshotManager(base.ManagerWithFind):
return self._create('/snapshots', body, 'snapshot') return self._create('/snapshots', body, 'snapshot')
def get(self, snapshot_id): def get(self, snapshot_id):
"""Get a snapshot. """Shows snapshot details.
:param snapshot_id: The ID of the snapshot to get. :param snapshot_id: The ID of the snapshot to get.
:rtype: :class:`Snapshot` :rtype: :class:`Snapshot`

View File

@@ -35,7 +35,7 @@ class VolumeTransferManager(base.ManagerWithFind):
resource_class = VolumeTransfer resource_class = VolumeTransfer
def create(self, volume_id, name=None): def create(self, volume_id, name=None):
"""Create a volume transfer. """Creates a volume transfer.
:param volume_id: The ID of the volume to transfer. :param volume_id: The ID of the volume to transfer.
:param name: The name of the transfer. :param name: The name of the transfer.

View File

@@ -71,7 +71,7 @@ class VolumeTypeManager(base.ManagerWithFind):
resource_class = VolumeType resource_class = VolumeType
def list(self, search_opts=None): def list(self, search_opts=None):
"""Get a list of all volume types. """Lists all volume types.
:rtype: list of :class:`VolumeType`. :rtype: list of :class:`VolumeType`.
""" """
@@ -86,14 +86,14 @@ class VolumeTypeManager(base.ManagerWithFind):
return self._get("/types/%s" % base.getid(volume_type), "volume_type") return self._get("/types/%s" % base.getid(volume_type), "volume_type")
def delete(self, volume_type): def delete(self, volume_type):
"""Delete a specific volume_type. """Deletes a specific volume_type.
:param volume_type: The name or ID of the :class:`VolumeType` to get. :param volume_type: The name or ID of the :class:`VolumeType` to get.
""" """
self._delete("/types/%s" % base.getid(volume_type)) self._delete("/types/%s" % base.getid(volume_type))
def create(self, name): def create(self, name):
"""Create a volume type. """Creates a volume type.
:param name: Descriptive name of the volume type :param name: Descriptive name of the volume type
:rtype: :class:`VolumeType` :rtype: :class:`VolumeType`

View File

@@ -144,7 +144,7 @@ class VolumeManager(base.ManagerWithFind):
volume_type=None, user_id=None, volume_type=None, user_id=None,
project_id=None, availability_zone=None, project_id=None, availability_zone=None,
metadata=None, imageRef=None, scheduler_hints=None): metadata=None, imageRef=None, scheduler_hints=None):
"""Create a volume. """Creates a volume.
:param size: Size of volume in GB :param size: Size of volume in GB
:param snapshot_id: ID of the snapshot :param snapshot_id: ID of the snapshot
@@ -196,7 +196,7 @@ class VolumeManager(base.ManagerWithFind):
return self._get("/volumes/%s" % volume_id, "volume") return self._get("/volumes/%s" % volume_id, "volume")
def list(self, detailed=True, search_opts=None): def list(self, detailed=True, search_opts=None):
"""Get a list of all volumes. """Lists all volumes.
:rtype: list of :class:`Volume` :rtype: list of :class:`Volume`
""" """