i18n support for help and error messages in cinder

Change-Id: I98fbc959034fe0530966291643b381855801de20
This commit is contained in:
Sheel Rana 2016-05-23 22:26:24 +05:30
parent 17bc850440
commit 53e05e7c2d
13 changed files with 257 additions and 223 deletions

View File

@ -16,6 +16,7 @@
import logging import logging
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -73,7 +74,7 @@ def build_option_parser(parser):
'--os-volume-api-version', '--os-volume-api-version',
metavar='<volume-api-version>', metavar='<volume-api-version>',
default=utils.env('OS_VOLUME_API_VERSION'), default=utils.env('OS_VOLUME_API_VERSION'),
help='Volume API version, default=' + help=_('Volume API version, default=%s '
DEFAULT_API_VERSION + '(Env: OS_VOLUME_API_VERSION)') % DEFAULT_API_VERSION
' (Env: OS_VOLUME_API_VERSION)') )
return parser return parser

View File

@ -20,6 +20,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateBackup(command.ShowOne): class CreateBackup(command.ShowOne):
@ -30,23 +31,23 @@ class CreateBackup(command.ShowOne):
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar='<volume>', metavar='<volume>',
help='Volume to backup (name or ID)', help=_('Volume to backup (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--container', '--container',
metavar='<container>', metavar='<container>',
required=False, required=False,
help='Optional backup container name', help=_('Optional backup container name'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='Name of the backup', help=_('Name of the backup'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='Description of the backup', help=_('Description of the backup'),
) )
return parser return parser
@ -74,7 +75,7 @@ class DeleteBackup(command.Command):
'backups', 'backups',
metavar='<backup>', metavar='<backup>',
nargs="+", nargs="+",
help='Backup(s) to delete (ID only)', help=_('Backup(s) to delete (ID only)'),
) )
return parser return parser
@ -95,7 +96,7 @@ class ListBackup(command.Lister):
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -148,11 +149,13 @@ class RestoreBackup(command.Command):
parser.add_argument( parser.add_argument(
'backup', 'backup',
metavar='<backup>', metavar='<backup>',
help='Backup to restore (ID only)') help=_('Backup to restore (ID only)')
)
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar='<volume>', metavar='<volume>',
help='Volume to restore to (name or ID)') help=_('Volume to restore to (name or ID)')
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@ -173,7 +176,8 @@ class ShowBackup(command.ShowOne):
parser.add_argument( parser.add_argument(
'backup', 'backup',
metavar='<backup>', metavar='<backup>',
help='Backup to display (ID only)') help=_('Backup to display (ID only)')
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):

View File

@ -20,6 +20,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import parseractions from openstackclient.common import parseractions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class AssociateQos(command.Command): class AssociateQos(command.Command):
@ -30,12 +31,12 @@ class AssociateQos(command.Command):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to modify (name or ID)', help=_('QoS specification to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'volume_type', 'volume_type',
metavar='<volume-type>', metavar='<volume-type>',
help='Volume type to associate the QoS (name or ID)', help=_('Volume type to associate the QoS (name or ID)'),
) )
return parser return parser
@ -57,7 +58,7 @@ class CreateQos(command.ShowOne):
parser.add_argument( parser.add_argument(
'name', 'name',
metavar='<name>', metavar='<name>',
help='New QoS specification name', help=_('New QoS specification name'),
) )
consumer_choices = ['front-end', 'back-end', 'both'] consumer_choices = ['front-end', 'back-end', 'both']
parser.add_argument( parser.add_argument(
@ -65,15 +66,16 @@ class CreateQos(command.ShowOne):
metavar='<consumer>', metavar='<consumer>',
choices=consumer_choices, choices=consumer_choices,
default='both', default='both',
help='Consumer of the QoS. Valid consumers: %s ' help=(_('Consumer of the QoS. Valid consumers: %s '
"(defaults to 'both')" % utils.format_list(consumer_choices) "(defaults to 'both')") %
utils.format_list(consumer_choices))
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a QoS specification property ' help=_('Set a QoS specification property '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -99,7 +101,7 @@ class DeleteQos(command.Command):
'qos_specs', 'qos_specs',
metavar='<qos-spec>', metavar='<qos-spec>',
nargs="+", nargs="+",
help='QoS specification(s) to delete (name or ID)', help=_('QoS specification(s) to delete (name or ID)'),
) )
return parser return parser
@ -118,19 +120,19 @@ class DisassociateQos(command.Command):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to modify (name or ID)', help=_('QoS specification to modify (name or ID)'),
) )
volume_type_group = parser.add_mutually_exclusive_group() volume_type_group = parser.add_mutually_exclusive_group()
volume_type_group.add_argument( volume_type_group.add_argument(
'--volume-type', '--volume-type',
metavar='<volume-type>', metavar='<volume-type>',
help='Volume type to disassociate the QoS from (name or ID)', help=_('Volume type to disassociate the QoS from (name or ID)'),
) )
volume_type_group.add_argument( volume_type_group.add_argument(
'--all', '--all',
action='store_true', action='store_true',
default=False, default=False,
help='Disassociate the QoS from every volume type', help=_('Disassociate the QoS from every volume type'),
) )
return parser return parser
@ -181,14 +183,14 @@ class SetQos(command.Command):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to modify (name or ID)', help=_('QoS specification to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Property to add or modify for this QoS specification ' help=_('Property to add or modify for this QoS specification '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -201,7 +203,7 @@ class SetQos(command.Command):
volume_client.qos_specs.set_keys(qos_spec.id, volume_client.qos_specs.set_keys(qos_spec.id,
parsed_args.property) parsed_args.property)
else: else:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))
class ShowQos(command.ShowOne): class ShowQos(command.ShowOne):
@ -212,7 +214,7 @@ class ShowQos(command.ShowOne):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to display (name or ID)', help=_('QoS specification to display (name or ID)'),
) )
return parser return parser
@ -241,15 +243,15 @@ class UnsetQos(command.Command):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to modify (name or ID)', help=_('QoS specification to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key>', metavar='<key>',
action='append', action='append',
default=[], default=[],
help='Property to remove from the QoS specification. ' help=_('Property to remove from the QoS specification. '
'(repeat option to unset multiple properties)', '(repeat option to unset multiple properties)'),
) )
return parser return parser
@ -262,4 +264,4 @@ class UnsetQos(command.Command):
volume_client.qos_specs.unset_keys(qos_spec.id, volume_client.qos_specs.unset_keys(qos_spec.id,
parsed_args.property) parsed_args.property)
else: else:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))

View File

@ -16,6 +16,7 @@
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class ListService(command.Lister): class ListService(command.Lister):
@ -26,16 +27,18 @@ class ListService(command.Lister):
parser.add_argument( parser.add_argument(
"--host", "--host",
metavar="<host>", metavar="<host>",
help="List services on specified host (name only)") help=_("List services on specified host (name only)")
)
parser.add_argument( parser.add_argument(
"--service", "--service",
metavar="<service>", metavar="<service>",
help="List only specified service (name only)") help=_("List only specified service (name only)")
)
parser.add_argument( parser.add_argument(
"--long", "--long",
action="store_true", action="store_true",
default=False, default=False,
help="List additional fields in output" help=_("List additional fields in output")
) )
return parser return parser

View File

@ -21,6 +21,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import parseractions from openstackclient.common import parseractions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateSnapshot(command.ShowOne): class CreateSnapshot(command.ShowOne):
@ -31,24 +32,25 @@ class CreateSnapshot(command.ShowOne):
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar='<volume>', metavar='<volume>',
help='Volume to snapshot (name or ID)', help=_('Volume to snapshot (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='Name of the snapshot', help=_('Name of the snapshot'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='Description of the snapshot', help=_('Description of the snapshot'),
) )
parser.add_argument( parser.add_argument(
'--force', '--force',
dest='force', dest='force',
action='store_true', action='store_true',
default=False, default=False,
help='Create a snapshot attached to an instance. Default is False', help=_('Create a snapshot attached to an instance. '
'Default is False'),
) )
return parser return parser
@ -79,7 +81,7 @@ class DeleteSnapshot(command.Command):
'snapshots', 'snapshots',
metavar='<snapshot>', metavar='<snapshot>',
nargs="+", nargs="+",
help='Snapshot(s) to delete (name or ID)', help=_('Snapshot(s) to delete (name or ID)'),
) )
return parser return parser
@ -100,13 +102,13 @@ class ListSnapshot(command.Lister):
'--all-projects', '--all-projects',
action='store_true', action='store_true',
default=False, default=False,
help='Include all projects (admin only)', help=_('Include all projects (admin only)'),
) )
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -170,21 +172,24 @@ class SetSnapshot(command.Command):
parser.add_argument( parser.add_argument(
'snapshot', 'snapshot',
metavar='<snapshot>', metavar='<snapshot>',
help='Snapshot to modify (name or ID)') help=_('Snapshot to modify (name or ID)')
)
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='New snapshot name') help=_('New snapshot name')
)
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New snapshot description') help=_('New snapshot description')
)
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Property to add/change for this snapshot ' help=_('Property to add/change for this snapshot '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -204,7 +209,7 @@ class SetSnapshot(command.Command):
kwargs['display_description'] = parsed_args.description kwargs['display_description'] = parsed_args.description
if not kwargs and not parsed_args.property: if not kwargs and not parsed_args.property:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))
return return
snapshot.update(**kwargs) snapshot.update(**kwargs)
@ -218,7 +223,8 @@ class ShowSnapshot(command.ShowOne):
parser.add_argument( parser.add_argument(
'snapshot', 'snapshot',
metavar='<snapshot>', metavar='<snapshot>',
help='Snapshot to display (name or ID)') help=_('Snapshot to display (name or ID)')
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@ -241,16 +247,16 @@ class UnsetSnapshot(command.Command):
parser.add_argument( parser.add_argument(
'snapshot', 'snapshot',
metavar='<snapshot>', metavar='<snapshot>',
help='Snapshot to modify (name or ID)', help=_('Snapshot to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key>', metavar='<key>',
action='append', action='append',
default=[], default=[],
help='Property to remove from snapshot '
'(repeat option to remove multiple properties)',
required=True, required=True,
help=_('Property to remove from snapshot '
'(repeat option to remove multiple properties)'),
) )
return parser return parser
@ -265,4 +271,4 @@ class UnsetSnapshot(command.Command):
parsed_args.property, parsed_args.property,
) )
else: else:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))

View File

@ -21,6 +21,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import parseractions from openstackclient.common import parseractions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateVolume(command.ShowOne): class CreateVolume(command.ShowOne):
@ -31,30 +32,30 @@ class CreateVolume(command.ShowOne):
parser.add_argument( parser.add_argument(
'name', 'name',
metavar='<name>', metavar='<name>',
help='Volume name', help=_('Volume name'),
) )
parser.add_argument( parser.add_argument(
'--size', '--size',
metavar='<size>', metavar='<size>',
required=True, required=True,
type=int, type=int,
help='Volume size in GB', help=_('Volume size in GB'),
) )
parser.add_argument( parser.add_argument(
'--type', '--type',
metavar='<volume-type>', metavar='<volume-type>',
help="Set the type of volume", help=_("Set the type of volume"),
) )
parser.add_argument( parser.add_argument(
'--image', '--image',
metavar='<image>', metavar='<image>',
help='Use <image> as source of volume (name or ID)', help=_('Use <image> as source of volume (name or ID)'),
) )
snapshot_group = parser.add_mutually_exclusive_group() snapshot_group = parser.add_mutually_exclusive_group()
snapshot_group.add_argument( snapshot_group.add_argument(
'--snapshot', '--snapshot',
metavar='<snapshot>', metavar='<snapshot>',
help='Use <snapshot> as source of volume (name or ID)', help=_('Use <snapshot> as source of volume (name or ID)'),
) )
snapshot_group.add_argument( snapshot_group.add_argument(
'--snapshot-id', '--snapshot-id',
@ -64,34 +65,34 @@ class CreateVolume(command.ShowOne):
parser.add_argument( parser.add_argument(
'--source', '--source',
metavar='<volume>', metavar='<volume>',
help='Volume to clone (name or ID)', help=_('Volume to clone (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='Volume description', help=_('Volume description'),
) )
parser.add_argument( parser.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
help='Specify an alternate user (name or ID)', help=_('Specify an alternate user (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Specify an alternate project (name or ID)', help=_('Specify an alternate project (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--availability-zone', '--availability-zone',
metavar='<availability-zone>', metavar='<availability-zone>',
help='Create volume in <availability-zone>', help=_('Create volume in <availability-zone>'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a property on this volume ' help=_('Set a property on this volume '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -165,15 +166,15 @@ class DeleteVolume(command.Command):
'volumes', 'volumes',
metavar='<volume>', metavar='<volume>',
nargs="+", nargs="+",
help='Volume(s) to delete (name or ID)', help=_('Volume(s) to delete (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--force', '--force',
dest='force', dest='force',
action='store_true', action='store_true',
default=False, default=False,
help='Attempt forced removal of volume(s), regardless of state ' help=_('Attempt forced removal of volume(s), regardless of state '
'(defaults to False)', '(defaults to False)'),
) )
return parser return parser
@ -196,24 +197,24 @@ class ListVolume(command.Lister):
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='Filter results by volume name', help=_('Filter results by volume name'),
) )
parser.add_argument( parser.add_argument(
'--status', '--status',
metavar='<status>', metavar='<status>',
help='Filter results by status', help=_('Filter results by status'),
) )
parser.add_argument( parser.add_argument(
'--all-projects', '--all-projects',
action='store_true', action='store_true',
default=False, default=False,
help='Include all projects (admin only)', help=_('Include all projects (admin only)'),
) )
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -308,30 +309,30 @@ class SetVolume(command.Command):
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar='<volume>', metavar='<volume>',
help='Volume to modify (name or ID)', help=_('Volume to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='New volume name', help=_('New volume name'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New volume description', help=_('New volume description'),
) )
parser.add_argument( parser.add_argument(
'--size', '--size',
metavar='<size>', metavar='<size>',
type=int, type=int,
help='Extend volume size in GB', help=_('Extend volume size in GB'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a property on this volume ' help=_('Set a property on this volume '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -341,12 +342,12 @@ class SetVolume(command.Command):
if parsed_args.size: if parsed_args.size:
if volume.status != 'available': if volume.status != 'available':
self.app.log.error("Volume is in %s state, it must be " self.app.log.error(_("Volume is in %s state, it must be "
"available before size can be extended" % "available before size can be extended") %
volume.status) volume.status)
return return
if parsed_args.size <= volume.size: if parsed_args.size <= volume.size:
self.app.log.error("New size must be greater than %s GB" % self.app.log.error(_("New size must be greater than %s GB") %
volume.size) volume.size)
return return
volume_client.volumes.extend(volume.id, parsed_args.size) volume_client.volumes.extend(volume.id, parsed_args.size)
@ -363,7 +364,7 @@ class SetVolume(command.Command):
volume_client.volumes.update(volume.id, **kwargs) volume_client.volumes.update(volume.id, **kwargs)
if not kwargs and not parsed_args.property and not parsed_args.size: if not kwargs and not parsed_args.property and not parsed_args.size:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))
class ShowVolume(command.ShowOne): class ShowVolume(command.ShowOne):
@ -374,7 +375,7 @@ class ShowVolume(command.ShowOne):
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar='<volume>', metavar='<volume>',
help='Volume to display (name or ID)', help=_('Volume to display (name or ID)'),
) )
return parser return parser
@ -404,15 +405,15 @@ class UnsetVolume(command.Command):
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar='<volume>', metavar='<volume>',
help='Volume to modify (name or ID)', help=_('Volume to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key>', metavar='<key>',
action='append', action='append',
default=[], default=[],
help='Remove a property from volume ' help=_('Remove a property from volume '
'(repeat option to remove multiple properties)', '(repeat option to remove multiple properties)'),
required=True, required=True,
) )
return parser return parser
@ -428,4 +429,4 @@ class UnsetVolume(command.Command):
parsed_args.property, parsed_args.property,
) )
else: else:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))

View File

@ -20,6 +20,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import parseractions from openstackclient.common import parseractions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateVolumeType(command.ShowOne): class CreateVolumeType(command.ShowOne):
@ -30,14 +31,14 @@ class CreateVolumeType(command.ShowOne):
parser.add_argument( parser.add_argument(
'name', 'name',
metavar='<name>', metavar='<name>',
help='Volume type name', help=_('Volume type name'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a property on this volume type ' help=_('Set a property on this volume type '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -62,7 +63,7 @@ class DeleteVolumeType(command.Command):
parser.add_argument( parser.add_argument(
'volume_type', 'volume_type',
metavar='<volume-type>', metavar='<volume-type>',
help='Volume type to delete (name or ID)', help=_('Volume type to delete (name or ID)'),
) )
return parser return parser
@ -82,7 +83,8 @@ class ListVolumeType(command.Lister):
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output') help=_('List additional fields in output')
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@ -108,14 +110,14 @@ class SetVolumeType(command.Command):
parser.add_argument( parser.add_argument(
'volume_type', 'volume_type',
metavar='<volume-type>', metavar='<volume-type>',
help='Volume type to modify (name or ID)', help=_('Volume type to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a property on this volume type ' help=_('Set a property on this volume type '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -136,7 +138,7 @@ class ShowVolumeType(command.ShowOne):
parser.add_argument( parser.add_argument(
"volume_type", "volume_type",
metavar="<volume-type>", metavar="<volume-type>",
help="Volume type to display (name or ID)" help=_("Volume type to display (name or ID)")
) )
return parser return parser
@ -157,15 +159,15 @@ class UnsetVolumeType(command.Command):
parser.add_argument( parser.add_argument(
'volume_type', 'volume_type',
metavar='<volume-type>', metavar='<volume-type>',
help='Volume type to modify (name or ID)', help=_('Volume type to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key>', metavar='<key>',
action='append', action='append',
default=[], default=[],
help='Remove a property from this volume type ' help=_('Remove a property from this volume type '
'(repeat option to remove multiple properties)', '(repeat option to remove multiple properties)'),
required=True, required=True,
) )
return parser return parser
@ -180,4 +182,4 @@ class UnsetVolumeType(command.Command):
if parsed_args.property: if parsed_args.property:
volume_type.unset_keys(parsed_args.property) volume_type.unset_keys(parsed_args.property)
else: else:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))

View File

@ -20,6 +20,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateBackup(command.ShowOne): class CreateBackup(command.ShowOne):
@ -30,22 +31,22 @@ class CreateBackup(command.ShowOne):
parser.add_argument( parser.add_argument(
"volume", "volume",
metavar="<volume>", metavar="<volume>",
help="Volume to backup (name or ID)" help=_("Volume to backup (name or ID)")
) )
parser.add_argument( parser.add_argument(
"--name", "--name",
metavar="<name>", metavar="<name>",
help="Name of the backup" help=_("Name of the backup")
) )
parser.add_argument( parser.add_argument(
"--description", "--description",
metavar="<description>", metavar="<description>",
help="Description of the backup" help=_("Description of the backup")
) )
parser.add_argument( parser.add_argument(
"--container", "--container",
metavar="<container>", metavar="<container>",
help="Optional backup container name" help=_("Optional backup container name")
) )
return parser return parser
@ -72,7 +73,7 @@ class DeleteBackup(command.Command):
"backups", "backups",
metavar="<backup>", metavar="<backup>",
nargs="+", nargs="+",
help="Backup(s) to delete (name or ID)" help=_("Backup(s) to delete (name or ID)")
) )
return parser return parser
@ -93,7 +94,7 @@ class ListBackup(command.Lister):
"--long", "--long",
action="store_true", action="store_true",
default=False, default=False,
help="List additional fields in output" help=_("List additional fields in output")
) )
return parser return parser
@ -146,12 +147,12 @@ class RestoreBackup(command.ShowOne):
parser.add_argument( parser.add_argument(
"backup", "backup",
metavar="<backup>", metavar="<backup>",
help="Backup to restore (ID only)" help=_("Backup to restore (ID only)")
) )
parser.add_argument( parser.add_argument(
"volume", "volume",
metavar="<volume>", metavar="<volume>",
help="Volume to restore to (name or ID)" help=_("Volume to restore to (name or ID)")
) )
return parser return parser
@ -171,7 +172,8 @@ class ShowBackup(command.ShowOne):
parser.add_argument( parser.add_argument(
"backup", "backup",
metavar="<backup>", metavar="<backup>",
help="Backup to display (name or ID)") help=_("Backup to display (name or ID)")
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):

View File

@ -20,6 +20,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import parseractions from openstackclient.common import parseractions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class AssociateQos(command.Command): class AssociateQos(command.Command):
@ -30,12 +31,12 @@ class AssociateQos(command.Command):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to modify (name or ID)', help=_('QoS specification to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'volume_type', 'volume_type',
metavar='<volume-type>', metavar='<volume-type>',
help='Volume type to associate the QoS (name or ID)', help=_('Volume type to associate the QoS (name or ID)'),
) )
return parser return parser
@ -57,7 +58,7 @@ class CreateQos(command.ShowOne):
parser.add_argument( parser.add_argument(
'name', 'name',
metavar='<name>', metavar='<name>',
help='New QoS specification name', help=_('New QoS specification name'),
) )
consumer_choices = ['front-end', 'back-end', 'both'] consumer_choices = ['front-end', 'back-end', 'both']
parser.add_argument( parser.add_argument(
@ -65,15 +66,16 @@ class CreateQos(command.ShowOne):
metavar='<consumer>', metavar='<consumer>',
choices=consumer_choices, choices=consumer_choices,
default='both', default='both',
help='Consumer of the QoS. Valid consumers: %s ' help=(_('Consumer of the QoS. Valid consumers: %s '
"(defaults to 'both')" % utils.format_list(consumer_choices) "(defaults to 'both')") %
utils.format_list(consumer_choices))
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a QoS specification property ' help=_('Set a QoS specification property '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -99,7 +101,7 @@ class DeleteQos(command.Command):
'qos_specs', 'qos_specs',
metavar='<qos-spec>', metavar='<qos-spec>',
nargs="+", nargs="+",
help='QoS specification(s) to delete (name or ID)', help=_('QoS specification(s) to delete (name or ID)'),
) )
return parser return parser
@ -118,19 +120,19 @@ class DisassociateQos(command.Command):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to modify (name or ID)', help=_('QoS specification to modify (name or ID)'),
) )
volume_type_group = parser.add_mutually_exclusive_group() volume_type_group = parser.add_mutually_exclusive_group()
volume_type_group.add_argument( volume_type_group.add_argument(
'--volume-type', '--volume-type',
metavar='<volume-type>', metavar='<volume-type>',
help='Volume type to disassociate the QoS from (name or ID)', help=_('Volume type to disassociate the QoS from (name or ID)'),
) )
volume_type_group.add_argument( volume_type_group.add_argument(
'--all', '--all',
action='store_true', action='store_true',
default=False, default=False,
help='Disassociate the QoS from every volume type', help=_('Disassociate the QoS from every volume type'),
) )
return parser return parser
@ -181,14 +183,14 @@ class SetQos(command.Command):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to modify (name or ID)', help=_('QoS specification to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Property to add or modify for this QoS specification ' help=_('Property to add or modify for this QoS specification '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -201,7 +203,7 @@ class SetQos(command.Command):
volume_client.qos_specs.set_keys(qos_spec.id, volume_client.qos_specs.set_keys(qos_spec.id,
parsed_args.property) parsed_args.property)
else: else:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))
class ShowQos(command.ShowOne): class ShowQos(command.ShowOne):
@ -212,7 +214,7 @@ class ShowQos(command.ShowOne):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to display (name or ID)', help=_('QoS specification to display (name or ID)'),
) )
return parser return parser
@ -241,15 +243,15 @@ class UnsetQos(command.Command):
parser.add_argument( parser.add_argument(
'qos_spec', 'qos_spec',
metavar='<qos-spec>', metavar='<qos-spec>',
help='QoS specification to modify (name or ID)', help=_('QoS specification to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key>', metavar='<key>',
action='append', action='append',
default=[], default=[],
help='Property to remove from the QoS specification. ' help=('Property to remove from the QoS specification. '
'(repeat option to unset multiple properties)', '(repeat option to unset multiple properties)'),
) )
return parser return parser
@ -262,4 +264,4 @@ class UnsetQos(command.Command):
volume_client.qos_specs.unset_keys(qos_spec.id, volume_client.qos_specs.unset_keys(qos_spec.id,
parsed_args.property) parsed_args.property)
else: else:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))

View File

@ -16,6 +16,7 @@
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class ListService(command.Lister): class ListService(command.Lister):
@ -26,16 +27,18 @@ class ListService(command.Lister):
parser.add_argument( parser.add_argument(
"--host", "--host",
metavar="<host>", metavar="<host>",
help="List services on specified host (name only)") help=_("List services on specified host (name only)")
)
parser.add_argument( parser.add_argument(
"--service", "--service",
metavar="<service>", metavar="<service>",
help="List only specified service (name only)") help=_("List only specified service (name only)")
)
parser.add_argument( parser.add_argument(
"--long", "--long",
action="store_true", action="store_true",
default=False, default=False,
help="List additional fields in output" help=_("List additional fields in output")
) )
return parser return parser

View File

@ -21,6 +21,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import parseractions from openstackclient.common import parseractions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
class CreateSnapshot(command.ShowOne): class CreateSnapshot(command.ShowOne):
@ -31,24 +32,25 @@ class CreateSnapshot(command.ShowOne):
parser.add_argument( parser.add_argument(
"volume", "volume",
metavar="<volume>", metavar="<volume>",
help="Volume to snapshot (name or ID)" help=_("Volume to snapshot (name or ID)")
) )
parser.add_argument( parser.add_argument(
"--name", "--name",
metavar="<name>", metavar="<name>",
help="Name of the snapshot" help=("Name of the snapshot")
) )
parser.add_argument( parser.add_argument(
"--description", "--description",
metavar="<description>", metavar="<description>",
help="Description of the snapshot" help=_("Description of the snapshot")
) )
parser.add_argument( parser.add_argument(
"--force", "--force",
dest="force", dest="force",
action="store_true", action="store_true",
default=False, default=False,
help="Create a snapshot attached to an instance. Default is False" help=_("Create a snapshot attached to an instance. "
"Default is False")
) )
return parser return parser
@ -77,7 +79,7 @@ class DeleteSnapshot(command.Command):
"snapshots", "snapshots",
metavar="<snapshot>", metavar="<snapshot>",
nargs="+", nargs="+",
help="Snapshot(s) to delete (name or ID)" help=_("Snapshot(s) to delete (name or ID)")
) )
return parser return parser
@ -98,13 +100,13 @@ class ListSnapshot(command.Lister):
'--all-projects', '--all-projects',
action='store_true', action='store_true',
default=False, default=False,
help='Include all projects (admin only)', help=_('Include all projects (admin only)'),
) )
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -163,29 +165,32 @@ class SetSnapshot(command.Command):
parser.add_argument( parser.add_argument(
'snapshot', 'snapshot',
metavar='<snapshot>', metavar='<snapshot>',
help='Snapshot to modify (name or ID)') help=_('Snapshot to modify (name or ID)')
)
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='New snapshot name') help=_('New snapshot name')
)
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New snapshot description') help=_('New snapshot description')
)
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Property to add/change for this snapshot ' help=_('Property to add/change for this snapshot '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
parser.add_argument( parser.add_argument(
'--state', '--state',
metavar='<state>', metavar='<state>',
choices=['available', 'error', 'creating', 'deleting', choices=['available', 'error', 'creating', 'deleting',
'error-deleting'], 'error-deleting'],
help='New snapshot state. Valid values are available, ' help=_('New snapshot state. Valid values are available, '
'error, creating, deleting, and error-deleting.', 'error, creating, deleting, and error-deleting.'),
) )
return parser return parser
@ -202,7 +207,7 @@ class SetSnapshot(command.Command):
if (not kwargs and not parsed_args.property and not if (not kwargs and not parsed_args.property and not
parsed_args.state): parsed_args.state):
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))
return return
if parsed_args.property: if parsed_args.property:
@ -222,7 +227,7 @@ class ShowSnapshot(command.ShowOne):
parser.add_argument( parser.add_argument(
"snapshot", "snapshot",
metavar="<snapshot>", metavar="<snapshot>",
help="Snapshot to display (name or ID)" help=_("Snapshot to display (name or ID)")
) )
return parser return parser
@ -244,15 +249,15 @@ class UnsetSnapshot(command.Command):
parser.add_argument( parser.add_argument(
'snapshot', 'snapshot',
metavar='<snapshot>', metavar='<snapshot>',
help='Snapshot to modify (name or ID)', help=_('Snapshot to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key>', metavar='<key>',
action='append', action='append',
default=[], default=[],
help='Property to remove from snapshot ' help=_('Property to remove from snapshot '
'(repeat option to remove multiple properties)', '(repeat option to remove multiple properties)'),
) )
return parser return parser
@ -267,4 +272,4 @@ class UnsetSnapshot(command.Command):
parsed_args.property, parsed_args.property,
) )
else: else:
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))

View File

@ -21,6 +21,7 @@ import six
from openstackclient.common import command from openstackclient.common import command
from openstackclient.common import parseractions from openstackclient.common import parseractions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
from openstackclient.identity import common as identity_common from openstackclient.identity import common as identity_common
@ -32,61 +33,61 @@ class CreateVolume(command.ShowOne):
parser.add_argument( parser.add_argument(
"name", "name",
metavar="<name>", metavar="<name>",
help="Volume name", help=_("Volume name"),
) )
parser.add_argument( parser.add_argument(
"--size", "--size",
metavar="<size>", metavar="<size>",
type=int, type=int,
required=True, required=True,
help="Volume size in GB", help=_("Volume size in GB"),
) )
parser.add_argument( parser.add_argument(
"--type", "--type",
metavar="<volume-type>", metavar="<volume-type>",
help="Set the type of volume", help=_("Set the type of volume"),
) )
parser.add_argument( parser.add_argument(
"--image", "--image",
metavar="<image>", metavar="<image>",
help="Use <image> as source of volume (name or ID)", help=_("Use <image> as source of volume (name or ID)"),
) )
parser.add_argument( parser.add_argument(
"--snapshot", "--snapshot",
metavar="<snapshot>", metavar="<snapshot>",
help="Use <snapshot> as source of volume (name or ID)", help=_("Use <snapshot> as source of volume (name or ID)"),
) )
parser.add_argument( parser.add_argument(
"--source", "--source",
metavar="<volume>", metavar="<volume>",
help="Volume to clone (name or ID)", help=_("Volume to clone (name or ID)"),
) )
parser.add_argument( parser.add_argument(
"--description", "--description",
metavar="<description>", metavar="<description>",
help="Volume description", help=_("Volume description"),
) )
parser.add_argument( parser.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
help='Specify an alternate user (name or ID)', help=_('Specify an alternate user (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Specify an alternate project (name or ID)', help=_('Specify an alternate project (name or ID)'),
) )
parser.add_argument( parser.add_argument(
"--availability-zone", "--availability-zone",
metavar="<availability-zone>", metavar="<availability-zone>",
help="Create volume in <availability-zone>", help=_("Create volume in <availability-zone>"),
) )
parser.add_argument( parser.add_argument(
"--property", "--property",
metavar="<key=value>", metavar="<key=value>",
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help="Set a property to this volume " help=_("Set a property to this volume "
"(repeat option to set multiple properties)", "(repeat option to set multiple properties)"),
) )
return parser return parser
@ -158,15 +159,15 @@ class DeleteVolume(command.Command):
"volumes", "volumes",
metavar="<volume>", metavar="<volume>",
nargs="+", nargs="+",
help="Volume(s) to delete (name or ID)" help=_("Volume(s) to delete (name or ID)")
) )
parser.add_argument( parser.add_argument(
"--force", "--force",
dest="force", dest="force",
action="store_true", action="store_true",
default=False, default=False,
help="Attempt forced removal of volume(s), regardless of state " help=_("Attempt forced removal of volume(s), regardless of state "
"(defaults to False)" "(defaults to False)")
) )
return parser return parser
@ -189,36 +190,36 @@ class ListVolume(command.Lister):
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Filter results by project (name or ID) (admin only)' help=_('Filter results by project (name or ID) (admin only)')
) )
identity_common.add_project_domain_option_to_parser(parser) identity_common.add_project_domain_option_to_parser(parser)
parser.add_argument( parser.add_argument(
'--user', '--user',
metavar='<user>', metavar='<user>',
help='Filter results by user (name or ID) (admin only)' help=_('Filter results by user (name or ID) (admin only)')
) )
identity_common.add_user_domain_option_to_parser(parser) identity_common.add_user_domain_option_to_parser(parser)
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='Filter results by volume name', help=_('Filter results by volume name'),
) )
parser.add_argument( parser.add_argument(
'--status', '--status',
metavar='<status>', metavar='<status>',
help='Filter results by status', help=_('Filter results by status'),
) )
parser.add_argument( parser.add_argument(
'--all-projects', '--all-projects',
action='store_true', action='store_true',
default=False, default=False,
help='Include all projects (admin only)', help=_('Include all projects (admin only)'),
) )
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output', help=_('List additional fields in output'),
) )
return parser return parser
@ -320,37 +321,37 @@ class SetVolume(command.Command):
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar='<volume>', metavar='<volume>',
help='Volume to modify (name or ID)', help=_('Volume to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='New volume name', help=_('New volume name'),
) )
parser.add_argument( parser.add_argument(
'--size', '--size',
metavar='<size>', metavar='<size>',
type=int, type=int,
help='Extend volume size in GB', help=_('Extend volume size in GB'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<description>', metavar='<description>',
help='New volume description', help=_('New volume description'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a property on this volume ' help=_('Set a property on this volume '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
parser.add_argument( parser.add_argument(
'--image-property', '--image-property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set an image property on this volume ' help=_('Set an image property on this volume '
'(repeat option to set multiple image properties)', '(repeat option to set multiple image properties)'),
) )
return parser return parser
@ -360,12 +361,12 @@ class SetVolume(command.Command):
if parsed_args.size: if parsed_args.size:
if volume.status != 'available': if volume.status != 'available':
self.app.log.error("Volume is in %s state, it must be " self.app.log.error(_("Volume is in %s state, it must be "
"available before size can be extended" % "available before size can be extended") %
volume.status) volume.status)
return return
if parsed_args.size <= volume.size: if parsed_args.size <= volume.size:
self.app.log.error("New size must be greater than %s GB" % self.app.log.error(_("New size must be greater than %s GB") %
volume.size) volume.size)
return return
volume_client.volumes.extend(volume.id, parsed_args.size) volume_client.volumes.extend(volume.id, parsed_args.size)
@ -386,7 +387,7 @@ class SetVolume(command.Command):
if (not kwargs and not parsed_args.property if (not kwargs and not parsed_args.property
and not parsed_args.image_property and not parsed_args.size): and not parsed_args.image_property and not parsed_args.size):
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))
class ShowVolume(command.ShowOne): class ShowVolume(command.ShowOne):
@ -397,7 +398,7 @@ class ShowVolume(command.ShowOne):
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar="<volume-id>", metavar="<volume-id>",
help="Volume to display (name or ID)" help=_("Volume to display (name or ID)")
) )
return parser return parser
@ -428,21 +429,21 @@ class UnsetVolume(command.Command):
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar='<volume>', metavar='<volume>',
help='Volume to modify (name or ID)', help=_('Volume to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key>', metavar='<key>',
action='append', action='append',
help='Remove a property from volume ' help=_('Remove a property from volume '
'(repeat option to remove multiple properties)', '(repeat option to remove multiple properties)'),
) )
parser.add_argument( parser.add_argument(
'--image-property', '--image-property',
metavar='<key>', metavar='<key>',
action='append', action='append',
help='Remove an image property from volume ' help=_('Remove an image property from volume '
'(repeat option to remove multiple image properties)', '(repeat option to remove multiple image properties)'),
) )
return parser return parser
@ -459,4 +460,4 @@ class UnsetVolume(command.Command):
volume.id, parsed_args.image_property) volume.id, parsed_args.image_property)
if (not parsed_args.image_property and not parsed_args.property): if (not parsed_args.image_property and not parsed_args.property):
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))

View File

@ -20,6 +20,7 @@ from openstackclient.common import command
from openstackclient.common import exceptions from openstackclient.common import exceptions
from openstackclient.common import parseractions from openstackclient.common import parseractions
from openstackclient.common import utils from openstackclient.common import utils
from openstackclient.i18n import _
from openstackclient.identity import common as identity_common from openstackclient.identity import common as identity_common
@ -31,12 +32,12 @@ class CreateVolumeType(command.ShowOne):
parser.add_argument( parser.add_argument(
"name", "name",
metavar="<name>", metavar="<name>",
help="Volume type name", help=_("Volume type name"),
) )
parser.add_argument( parser.add_argument(
"--description", "--description",
metavar="<description>", metavar="<description>",
help="Volume type description", help=_("Volume type description"),
) )
public_group = parser.add_mutually_exclusive_group() public_group = parser.add_mutually_exclusive_group()
public_group.add_argument( public_group.add_argument(
@ -44,21 +45,21 @@ class CreateVolumeType(command.ShowOne):
dest="public", dest="public",
action="store_true", action="store_true",
default=False, default=False,
help="Volume type is accessible to the public", help=_("Volume type is accessible to the public"),
) )
public_group.add_argument( public_group.add_argument(
"--private", "--private",
dest="private", dest="private",
action="store_true", action="store_true",
default=False, default=False,
help="Volume type is not accessible to the public", help=_("Volume type is not accessible to the public"),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a property on this volume type ' help=_('Set a property on this volume type '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
return parser return parser
@ -93,7 +94,7 @@ class DeleteVolumeType(command.Command):
parser.add_argument( parser.add_argument(
"volume_type", "volume_type",
metavar="<volume-type>", metavar="<volume-type>",
help="Volume type to delete (name or ID)" help=_("Volume type to delete (name or ID)")
) )
return parser return parser
@ -113,7 +114,7 @@ class ListVolumeType(command.Lister):
'--long', '--long',
action='store_true', action='store_true',
default=False, default=False,
help='List additional fields in output') help=_('List additional fields in output'))
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@ -139,29 +140,30 @@ class SetVolumeType(command.Command):
parser.add_argument( parser.add_argument(
'volume_type', 'volume_type',
metavar='<volume-type>', metavar='<volume-type>',
help='Volume type to modify (name or ID)', help=_('Volume type to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--name', '--name',
metavar='<name>', metavar='<name>',
help='Set volume type name', help=_('Set volume type name'),
) )
parser.add_argument( parser.add_argument(
'--description', '--description',
metavar='<name>', metavar='<name>',
help='Set volume type description', help=_('Set volume type description'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key=value>', metavar='<key=value>',
action=parseractions.KeyValueAction, action=parseractions.KeyValueAction,
help='Set a property on this volume type ' help=_('Set a property on this volume type '
'(repeat option to set multiple properties)', '(repeat option to set multiple properties)'),
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Set volume type access to project (name or ID) (admin only)', help=_('Set volume type access to project (name or ID) '
'(admin only)'),
) )
identity_common.add_project_domain_option_to_parser(parser) identity_common.add_project_domain_option_to_parser(parser)
@ -178,7 +180,7 @@ class SetVolumeType(command.Command):
and not parsed_args.description and not parsed_args.description
and not parsed_args.property and not parsed_args.property
and not parsed_args.project): and not parsed_args.project):
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))
return return
result = 0 result = 0
@ -195,15 +197,15 @@ class SetVolumeType(command.Command):
**kwargs **kwargs
) )
except Exception as e: except Exception as e:
self.app.log.error("Failed to update volume type name or" self.app.log.error(_("Failed to update volume type name or"
" description: " + str(e)) " description: %s") % str(e))
result += 1 result += 1
if parsed_args.property: if parsed_args.property:
try: try:
volume_type.set_keys(parsed_args.property) volume_type.set_keys(parsed_args.property)
except Exception as e: except Exception as e:
self.app.log.error("Failed to set volume type property: " + self.app.log.error(_("Failed to set volume type property: ") +
str(e)) str(e))
result += 1 result += 1
@ -218,8 +220,8 @@ class SetVolumeType(command.Command):
volume_client.volume_type_access.add_project_access( volume_client.volume_type_access.add_project_access(
volume_type.id, project_info.id) volume_type.id, project_info.id)
except Exception as e: except Exception as e:
self.app.log.error("Failed to set volume type access to" self.app.log.error(_("Failed to set volume type access to"
" project: " + str(e)) " project: %s") % str(e))
result += 1 result += 1
if result > 0: if result > 0:
@ -235,7 +237,7 @@ class ShowVolumeType(command.ShowOne):
parser.add_argument( parser.add_argument(
"volume_type", "volume_type",
metavar="<volume-type>", metavar="<volume-type>",
help="Volume type to display (name or ID)" help=_("Volume type to display (name or ID)")
) )
return parser return parser
@ -256,19 +258,19 @@ class UnsetVolumeType(command.Command):
parser.add_argument( parser.add_argument(
'volume_type', 'volume_type',
metavar='<volume-type>', metavar='<volume-type>',
help='Volume type to modify (name or ID)', help=_('Volume type to modify (name or ID)'),
) )
parser.add_argument( parser.add_argument(
'--property', '--property',
metavar='<key>', metavar='<key>',
help='Remove a property from this volume type ' help=_('Remove a property from this volume type '
'(repeat option to remove multiple properties)', '(repeat option to remove multiple properties)'),
) )
parser.add_argument( parser.add_argument(
'--project', '--project',
metavar='<project>', metavar='<project>',
help='Removes volume type access to project (name or ID) ' help=_('Removes volume type access to project (name or ID) '
' (admin only)', ' (admin only)'),
) )
identity_common.add_project_domain_option_to_parser(parser) identity_common.add_project_domain_option_to_parser(parser)
@ -285,7 +287,7 @@ class UnsetVolumeType(command.Command):
if (not parsed_args.property if (not parsed_args.property
and not parsed_args.project): and not parsed_args.project):
self.app.log.error("No changes requested\n") self.app.log.error(_("No changes requested\n"))
return return
result = 0 result = 0
@ -293,8 +295,8 @@ class UnsetVolumeType(command.Command):
try: try:
volume_type.unset_keys(parsed_args.property) volume_type.unset_keys(parsed_args.property)
except Exception as e: except Exception as e:
self.app.log.error("Failed to unset volume type property: " + self.app.log.error(_("Failed to unset volume type property: %s"
str(e)) ) % str(e))
result += 1 result += 1
if parsed_args.project: if parsed_args.project:
@ -308,8 +310,8 @@ class UnsetVolumeType(command.Command):
volume_client.volume_type_access.remove_project_access( volume_client.volume_type_access.remove_project_access(
volume_type.id, project_info.id) volume_type.id, project_info.id)
except Exception as e: except Exception as e:
self.app.log.error("Failed to remove volume type access from" self.app.log.error(_("Failed to remove volume type access from"
" project: " + str(e)) " project: ") + str(e))
result += 1 result += 1
if result > 0: if result > 0: