From 53e05e7c2d36ab2ff1ba05a8334286d41c5f40e4 Mon Sep 17 00:00:00 2001 From: Sheel Rana Date: Mon, 23 May 2016 22:26:24 +0530 Subject: [PATCH] i18n support for help and error messages in cinder Change-Id: I98fbc959034fe0530966291643b381855801de20 --- openstackclient/volume/client.py | 7 +- openstackclient/volume/v1/backup.py | 22 ++++--- openstackclient/volume/v1/qos_specs.py | 42 ++++++------ openstackclient/volume/v1/service.py | 9 ++- openstackclient/volume/v1/snapshot.py | 42 ++++++------ openstackclient/volume/v1/volume.py | 69 ++++++++++---------- openstackclient/volume/v1/volume_type.py | 28 ++++---- openstackclient/volume/v2/backup.py | 20 +++--- openstackclient/volume/v2/qos_specs.py | 42 ++++++------ openstackclient/volume/v2/service.py | 9 ++- openstackclient/volume/v2/snapshot.py | 45 +++++++------ openstackclient/volume/v2/volume.py | 81 ++++++++++++------------ openstackclient/volume/v2/volume_type.py | 64 ++++++++++--------- 13 files changed, 257 insertions(+), 223 deletions(-) diff --git a/openstackclient/volume/client.py b/openstackclient/volume/client.py index 0973868b8..a60f4b0ed 100644 --- a/openstackclient/volume/client.py +++ b/openstackclient/volume/client.py @@ -16,6 +16,7 @@ import logging from openstackclient.common import utils +from openstackclient.i18n import _ LOG = logging.getLogger(__name__) @@ -73,7 +74,7 @@ def build_option_parser(parser): '--os-volume-api-version', metavar='', default=utils.env('OS_VOLUME_API_VERSION'), - help='Volume API version, default=' + - DEFAULT_API_VERSION + - ' (Env: OS_VOLUME_API_VERSION)') + help=_('Volume API version, default=%s ' + '(Env: OS_VOLUME_API_VERSION)') % DEFAULT_API_VERSION + ) return parser diff --git a/openstackclient/volume/v1/backup.py b/openstackclient/volume/v1/backup.py index 40b603151..607b52114 100644 --- a/openstackclient/volume/v1/backup.py +++ b/openstackclient/volume/v1/backup.py @@ -20,6 +20,7 @@ import six from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class CreateBackup(command.ShowOne): @@ -30,23 +31,23 @@ class CreateBackup(command.ShowOne): parser.add_argument( 'volume', metavar='', - help='Volume to backup (name or ID)', + help=_('Volume to backup (name or ID)'), ) parser.add_argument( '--container', metavar='', required=False, - help='Optional backup container name', + help=_('Optional backup container name'), ) parser.add_argument( '--name', metavar='', - help='Name of the backup', + help=_('Name of the backup'), ) parser.add_argument( '--description', metavar='', - help='Description of the backup', + help=_('Description of the backup'), ) return parser @@ -74,7 +75,7 @@ class DeleteBackup(command.Command): 'backups', metavar='', nargs="+", - help='Backup(s) to delete (ID only)', + help=_('Backup(s) to delete (ID only)'), ) return parser @@ -95,7 +96,7 @@ class ListBackup(command.Lister): '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -148,11 +149,13 @@ class RestoreBackup(command.Command): parser.add_argument( 'backup', metavar='', - help='Backup to restore (ID only)') + help=_('Backup to restore (ID only)') + ) parser.add_argument( 'volume', metavar='', - help='Volume to restore to (name or ID)') + help=_('Volume to restore to (name or ID)') + ) return parser def take_action(self, parsed_args): @@ -173,7 +176,8 @@ class ShowBackup(command.ShowOne): parser.add_argument( 'backup', metavar='', - help='Backup to display (ID only)') + help=_('Backup to display (ID only)') + ) return parser def take_action(self, parsed_args): diff --git a/openstackclient/volume/v1/qos_specs.py b/openstackclient/volume/v1/qos_specs.py index 826e5c493..b9eb87523 100644 --- a/openstackclient/volume/v1/qos_specs.py +++ b/openstackclient/volume/v1/qos_specs.py @@ -20,6 +20,7 @@ import six from openstackclient.common import command from openstackclient.common import parseractions from openstackclient.common import utils +from openstackclient.i18n import _ class AssociateQos(command.Command): @@ -30,12 +31,12 @@ class AssociateQos(command.Command): parser.add_argument( 'qos_spec', metavar='', - help='QoS specification to modify (name or ID)', + help=_('QoS specification to modify (name or ID)'), ) parser.add_argument( 'volume_type', metavar='', - help='Volume type to associate the QoS (name or ID)', + help=_('Volume type to associate the QoS (name or ID)'), ) return parser @@ -57,7 +58,7 @@ class CreateQos(command.ShowOne): parser.add_argument( 'name', metavar='', - help='New QoS specification name', + help=_('New QoS specification name'), ) consumer_choices = ['front-end', 'back-end', 'both'] parser.add_argument( @@ -65,15 +66,16 @@ class CreateQos(command.ShowOne): metavar='', choices=consumer_choices, default='both', - help='Consumer of the QoS. Valid consumers: %s ' - "(defaults to 'both')" % utils.format_list(consumer_choices) + help=(_('Consumer of the QoS. Valid consumers: %s ' + "(defaults to 'both')") % + utils.format_list(consumer_choices)) ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a QoS specification property ' - '(repeat option to set multiple properties)', + help=_('Set a QoS specification property ' + '(repeat option to set multiple properties)'), ) return parser @@ -99,7 +101,7 @@ class DeleteQos(command.Command): 'qos_specs', metavar='', nargs="+", - help='QoS specification(s) to delete (name or ID)', + help=_('QoS specification(s) to delete (name or ID)'), ) return parser @@ -118,19 +120,19 @@ class DisassociateQos(command.Command): parser.add_argument( 'qos_spec', metavar='', - 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.add_argument( '--volume-type', metavar='', - 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( '--all', action='store_true', default=False, - help='Disassociate the QoS from every volume type', + help=_('Disassociate the QoS from every volume type'), ) return parser @@ -181,14 +183,14 @@ class SetQos(command.Command): parser.add_argument( 'qos_spec', metavar='', - help='QoS specification to modify (name or ID)', + help=_('QoS specification to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Property to add or modify for this QoS specification ' - '(repeat option to set multiple properties)', + help=_('Property to add or modify for this QoS specification ' + '(repeat option to set multiple properties)'), ) return parser @@ -201,7 +203,7 @@ class SetQos(command.Command): volume_client.qos_specs.set_keys(qos_spec.id, parsed_args.property) else: - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) class ShowQos(command.ShowOne): @@ -212,7 +214,7 @@ class ShowQos(command.ShowOne): parser.add_argument( 'qos_spec', metavar='', - help='QoS specification to display (name or ID)', + help=_('QoS specification to display (name or ID)'), ) return parser @@ -241,15 +243,15 @@ class UnsetQos(command.Command): parser.add_argument( 'qos_spec', metavar='', - help='QoS specification to modify (name or ID)', + help=_('QoS specification to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action='append', default=[], - help='Property to remove from the QoS specification. ' - '(repeat option to unset multiple properties)', + help=_('Property to remove from the QoS specification. ' + '(repeat option to unset multiple properties)'), ) return parser @@ -262,4 +264,4 @@ class UnsetQos(command.Command): volume_client.qos_specs.unset_keys(qos_spec.id, parsed_args.property) else: - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) diff --git a/openstackclient/volume/v1/service.py b/openstackclient/volume/v1/service.py index f26be13e0..023dda985 100644 --- a/openstackclient/volume/v1/service.py +++ b/openstackclient/volume/v1/service.py @@ -16,6 +16,7 @@ from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class ListService(command.Lister): @@ -26,16 +27,18 @@ class ListService(command.Lister): parser.add_argument( "--host", metavar="", - help="List services on specified host (name only)") + help=_("List services on specified host (name only)") + ) parser.add_argument( "--service", metavar="", - help="List only specified service (name only)") + help=_("List only specified service (name only)") + ) parser.add_argument( "--long", action="store_true", default=False, - help="List additional fields in output" + help=_("List additional fields in output") ) return parser diff --git a/openstackclient/volume/v1/snapshot.py b/openstackclient/volume/v1/snapshot.py index 6c6131ead..bf5bf2646 100644 --- a/openstackclient/volume/v1/snapshot.py +++ b/openstackclient/volume/v1/snapshot.py @@ -21,6 +21,7 @@ import six from openstackclient.common import command from openstackclient.common import parseractions from openstackclient.common import utils +from openstackclient.i18n import _ class CreateSnapshot(command.ShowOne): @@ -31,24 +32,25 @@ class CreateSnapshot(command.ShowOne): parser.add_argument( 'volume', metavar='', - help='Volume to snapshot (name or ID)', + help=_('Volume to snapshot (name or ID)'), ) parser.add_argument( '--name', metavar='', - help='Name of the snapshot', + help=_('Name of the snapshot'), ) parser.add_argument( '--description', metavar='', - help='Description of the snapshot', + help=_('Description of the snapshot'), ) parser.add_argument( '--force', dest='force', action='store_true', 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 @@ -79,7 +81,7 @@ class DeleteSnapshot(command.Command): 'snapshots', metavar='', nargs="+", - help='Snapshot(s) to delete (name or ID)', + help=_('Snapshot(s) to delete (name or ID)'), ) return parser @@ -100,13 +102,13 @@ class ListSnapshot(command.Lister): '--all-projects', action='store_true', default=False, - help='Include all projects (admin only)', + help=_('Include all projects (admin only)'), ) parser.add_argument( '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -170,21 +172,24 @@ class SetSnapshot(command.Command): parser.add_argument( 'snapshot', metavar='', - help='Snapshot to modify (name or ID)') + help=_('Snapshot to modify (name or ID)') + ) parser.add_argument( '--name', metavar='', - help='New snapshot name') + help=_('New snapshot name') + ) parser.add_argument( '--description', metavar='', - help='New snapshot description') + help=_('New snapshot description') + ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Property to add/change for this snapshot ' - '(repeat option to set multiple properties)', + help=_('Property to add/change for this snapshot ' + '(repeat option to set multiple properties)'), ) return parser @@ -204,7 +209,7 @@ class SetSnapshot(command.Command): kwargs['display_description'] = parsed_args.description 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 snapshot.update(**kwargs) @@ -218,7 +223,8 @@ class ShowSnapshot(command.ShowOne): parser.add_argument( 'snapshot', metavar='', - help='Snapshot to display (name or ID)') + help=_('Snapshot to display (name or ID)') + ) return parser def take_action(self, parsed_args): @@ -241,16 +247,16 @@ class UnsetSnapshot(command.Command): parser.add_argument( 'snapshot', metavar='', - help='Snapshot to modify (name or ID)', + help=_('Snapshot to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action='append', default=[], - help='Property to remove from snapshot ' - '(repeat option to remove multiple properties)', required=True, + help=_('Property to remove from snapshot ' + '(repeat option to remove multiple properties)'), ) return parser @@ -265,4 +271,4 @@ class UnsetSnapshot(command.Command): parsed_args.property, ) else: - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) diff --git a/openstackclient/volume/v1/volume.py b/openstackclient/volume/v1/volume.py index 29c197ef8..11e42f837 100644 --- a/openstackclient/volume/v1/volume.py +++ b/openstackclient/volume/v1/volume.py @@ -21,6 +21,7 @@ import six from openstackclient.common import command from openstackclient.common import parseractions from openstackclient.common import utils +from openstackclient.i18n import _ class CreateVolume(command.ShowOne): @@ -31,30 +32,30 @@ class CreateVolume(command.ShowOne): parser.add_argument( 'name', metavar='', - help='Volume name', + help=_('Volume name'), ) parser.add_argument( '--size', metavar='', required=True, type=int, - help='Volume size in GB', + help=_('Volume size in GB'), ) parser.add_argument( '--type', metavar='', - help="Set the type of volume", + help=_("Set the type of volume"), ) parser.add_argument( '--image', metavar='', - help='Use as source of volume (name or ID)', + help=_('Use as source of volume (name or ID)'), ) snapshot_group = parser.add_mutually_exclusive_group() snapshot_group.add_argument( '--snapshot', metavar='', - help='Use as source of volume (name or ID)', + help=_('Use as source of volume (name or ID)'), ) snapshot_group.add_argument( '--snapshot-id', @@ -64,34 +65,34 @@ class CreateVolume(command.ShowOne): parser.add_argument( '--source', metavar='', - help='Volume to clone (name or ID)', + help=_('Volume to clone (name or ID)'), ) parser.add_argument( '--description', metavar='', - help='Volume description', + help=_('Volume description'), ) parser.add_argument( '--user', metavar='', - help='Specify an alternate user (name or ID)', + help=_('Specify an alternate user (name or ID)'), ) parser.add_argument( '--project', metavar='', - help='Specify an alternate project (name or ID)', + help=_('Specify an alternate project (name or ID)'), ) parser.add_argument( '--availability-zone', metavar='', - help='Create volume in ', + help=_('Create volume in '), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a property on this volume ' - '(repeat option to set multiple properties)', + help=_('Set a property on this volume ' + '(repeat option to set multiple properties)'), ) return parser @@ -165,15 +166,15 @@ class DeleteVolume(command.Command): 'volumes', metavar='', nargs="+", - help='Volume(s) to delete (name or ID)', + help=_('Volume(s) to delete (name or ID)'), ) parser.add_argument( '--force', dest='force', action='store_true', default=False, - help='Attempt forced removal of volume(s), regardless of state ' - '(defaults to False)', + help=_('Attempt forced removal of volume(s), regardless of state ' + '(defaults to False)'), ) return parser @@ -196,24 +197,24 @@ class ListVolume(command.Lister): parser.add_argument( '--name', metavar='', - help='Filter results by volume name', + help=_('Filter results by volume name'), ) parser.add_argument( '--status', metavar='', - help='Filter results by status', + help=_('Filter results by status'), ) parser.add_argument( '--all-projects', action='store_true', default=False, - help='Include all projects (admin only)', + help=_('Include all projects (admin only)'), ) parser.add_argument( '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -308,30 +309,30 @@ class SetVolume(command.Command): parser.add_argument( 'volume', metavar='', - help='Volume to modify (name or ID)', + help=_('Volume to modify (name or ID)'), ) parser.add_argument( '--name', metavar='', - help='New volume name', + help=_('New volume name'), ) parser.add_argument( '--description', metavar='', - help='New volume description', + help=_('New volume description'), ) parser.add_argument( '--size', metavar='', type=int, - help='Extend volume size in GB', + help=_('Extend volume size in GB'), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a property on this volume ' - '(repeat option to set multiple properties)', + help=_('Set a property on this volume ' + '(repeat option to set multiple properties)'), ) return parser @@ -341,12 +342,12 @@ class SetVolume(command.Command): if parsed_args.size: if volume.status != 'available': - self.app.log.error("Volume is in %s state, it must be " - "available before size can be extended" % + self.app.log.error(_("Volume is in %s state, it must be " + "available before size can be extended") % volume.status) return 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) return volume_client.volumes.extend(volume.id, parsed_args.size) @@ -363,7 +364,7 @@ class SetVolume(command.Command): volume_client.volumes.update(volume.id, **kwargs) 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): @@ -374,7 +375,7 @@ class ShowVolume(command.ShowOne): parser.add_argument( 'volume', metavar='', - help='Volume to display (name or ID)', + help=_('Volume to display (name or ID)'), ) return parser @@ -404,15 +405,15 @@ class UnsetVolume(command.Command): parser.add_argument( 'volume', metavar='', - help='Volume to modify (name or ID)', + help=_('Volume to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action='append', default=[], - help='Remove a property from volume ' - '(repeat option to remove multiple properties)', + help=_('Remove a property from volume ' + '(repeat option to remove multiple properties)'), required=True, ) return parser @@ -428,4 +429,4 @@ class UnsetVolume(command.Command): parsed_args.property, ) else: - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) diff --git a/openstackclient/volume/v1/volume_type.py b/openstackclient/volume/v1/volume_type.py index 05671c1fe..739270220 100644 --- a/openstackclient/volume/v1/volume_type.py +++ b/openstackclient/volume/v1/volume_type.py @@ -20,6 +20,7 @@ import six from openstackclient.common import command from openstackclient.common import parseractions from openstackclient.common import utils +from openstackclient.i18n import _ class CreateVolumeType(command.ShowOne): @@ -30,14 +31,14 @@ class CreateVolumeType(command.ShowOne): parser.add_argument( 'name', metavar='', - help='Volume type name', + help=_('Volume type name'), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a property on this volume type ' - '(repeat option to set multiple properties)', + help=_('Set a property on this volume type ' + '(repeat option to set multiple properties)'), ) return parser @@ -62,7 +63,7 @@ class DeleteVolumeType(command.Command): parser.add_argument( 'volume_type', metavar='', - help='Volume type to delete (name or ID)', + help=_('Volume type to delete (name or ID)'), ) return parser @@ -82,7 +83,8 @@ class ListVolumeType(command.Lister): '--long', action='store_true', default=False, - help='List additional fields in output') + help=_('List additional fields in output') + ) return parser def take_action(self, parsed_args): @@ -108,14 +110,14 @@ class SetVolumeType(command.Command): parser.add_argument( 'volume_type', metavar='', - help='Volume type to modify (name or ID)', + help=_('Volume type to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a property on this volume type ' - '(repeat option to set multiple properties)', + help=_('Set a property on this volume type ' + '(repeat option to set multiple properties)'), ) return parser @@ -136,7 +138,7 @@ class ShowVolumeType(command.ShowOne): parser.add_argument( "volume_type", metavar="", - help="Volume type to display (name or ID)" + help=_("Volume type to display (name or ID)") ) return parser @@ -157,15 +159,15 @@ class UnsetVolumeType(command.Command): parser.add_argument( 'volume_type', metavar='', - help='Volume type to modify (name or ID)', + help=_('Volume type to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action='append', default=[], - help='Remove a property from this volume type ' - '(repeat option to remove multiple properties)', + help=_('Remove a property from this volume type ' + '(repeat option to remove multiple properties)'), required=True, ) return parser @@ -180,4 +182,4 @@ class UnsetVolumeType(command.Command): if parsed_args.property: volume_type.unset_keys(parsed_args.property) else: - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) diff --git a/openstackclient/volume/v2/backup.py b/openstackclient/volume/v2/backup.py index 016a414c6..e6fbe78dd 100644 --- a/openstackclient/volume/v2/backup.py +++ b/openstackclient/volume/v2/backup.py @@ -20,6 +20,7 @@ import six from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class CreateBackup(command.ShowOne): @@ -30,22 +31,22 @@ class CreateBackup(command.ShowOne): parser.add_argument( "volume", metavar="", - help="Volume to backup (name or ID)" + help=_("Volume to backup (name or ID)") ) parser.add_argument( "--name", metavar="", - help="Name of the backup" + help=_("Name of the backup") ) parser.add_argument( "--description", metavar="", - help="Description of the backup" + help=_("Description of the backup") ) parser.add_argument( "--container", metavar="", - help="Optional backup container name" + help=_("Optional backup container name") ) return parser @@ -72,7 +73,7 @@ class DeleteBackup(command.Command): "backups", metavar="", nargs="+", - help="Backup(s) to delete (name or ID)" + help=_("Backup(s) to delete (name or ID)") ) return parser @@ -93,7 +94,7 @@ class ListBackup(command.Lister): "--long", action="store_true", default=False, - help="List additional fields in output" + help=_("List additional fields in output") ) return parser @@ -146,12 +147,12 @@ class RestoreBackup(command.ShowOne): parser.add_argument( "backup", metavar="", - help="Backup to restore (ID only)" + help=_("Backup to restore (ID only)") ) parser.add_argument( "volume", metavar="", - help="Volume to restore to (name or ID)" + help=_("Volume to restore to (name or ID)") ) return parser @@ -171,7 +172,8 @@ class ShowBackup(command.ShowOne): parser.add_argument( "backup", metavar="", - help="Backup to display (name or ID)") + help=_("Backup to display (name or ID)") + ) return parser def take_action(self, parsed_args): diff --git a/openstackclient/volume/v2/qos_specs.py b/openstackclient/volume/v2/qos_specs.py index 961cc27e5..aa2059d7b 100644 --- a/openstackclient/volume/v2/qos_specs.py +++ b/openstackclient/volume/v2/qos_specs.py @@ -20,6 +20,7 @@ import six from openstackclient.common import command from openstackclient.common import parseractions from openstackclient.common import utils +from openstackclient.i18n import _ class AssociateQos(command.Command): @@ -30,12 +31,12 @@ class AssociateQos(command.Command): parser.add_argument( 'qos_spec', metavar='', - help='QoS specification to modify (name or ID)', + help=_('QoS specification to modify (name or ID)'), ) parser.add_argument( 'volume_type', metavar='', - help='Volume type to associate the QoS (name or ID)', + help=_('Volume type to associate the QoS (name or ID)'), ) return parser @@ -57,7 +58,7 @@ class CreateQos(command.ShowOne): parser.add_argument( 'name', metavar='', - help='New QoS specification name', + help=_('New QoS specification name'), ) consumer_choices = ['front-end', 'back-end', 'both'] parser.add_argument( @@ -65,15 +66,16 @@ class CreateQos(command.ShowOne): metavar='', choices=consumer_choices, default='both', - help='Consumer of the QoS. Valid consumers: %s ' - "(defaults to 'both')" % utils.format_list(consumer_choices) + help=(_('Consumer of the QoS. Valid consumers: %s ' + "(defaults to 'both')") % + utils.format_list(consumer_choices)) ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a QoS specification property ' - '(repeat option to set multiple properties)', + help=_('Set a QoS specification property ' + '(repeat option to set multiple properties)'), ) return parser @@ -99,7 +101,7 @@ class DeleteQos(command.Command): 'qos_specs', metavar='', nargs="+", - help='QoS specification(s) to delete (name or ID)', + help=_('QoS specification(s) to delete (name or ID)'), ) return parser @@ -118,19 +120,19 @@ class DisassociateQos(command.Command): parser.add_argument( 'qos_spec', metavar='', - 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.add_argument( '--volume-type', metavar='', - 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( '--all', action='store_true', default=False, - help='Disassociate the QoS from every volume type', + help=_('Disassociate the QoS from every volume type'), ) return parser @@ -181,14 +183,14 @@ class SetQos(command.Command): parser.add_argument( 'qos_spec', metavar='', - help='QoS specification to modify (name or ID)', + help=_('QoS specification to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Property to add or modify for this QoS specification ' - '(repeat option to set multiple properties)', + help=_('Property to add or modify for this QoS specification ' + '(repeat option to set multiple properties)'), ) return parser @@ -201,7 +203,7 @@ class SetQos(command.Command): volume_client.qos_specs.set_keys(qos_spec.id, parsed_args.property) else: - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) class ShowQos(command.ShowOne): @@ -212,7 +214,7 @@ class ShowQos(command.ShowOne): parser.add_argument( 'qos_spec', metavar='', - help='QoS specification to display (name or ID)', + help=_('QoS specification to display (name or ID)'), ) return parser @@ -241,15 +243,15 @@ class UnsetQos(command.Command): parser.add_argument( 'qos_spec', metavar='', - help='QoS specification to modify (name or ID)', + help=_('QoS specification to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action='append', default=[], - help='Property to remove from the QoS specification. ' - '(repeat option to unset multiple properties)', + help=('Property to remove from the QoS specification. ' + '(repeat option to unset multiple properties)'), ) return parser @@ -262,4 +264,4 @@ class UnsetQos(command.Command): volume_client.qos_specs.unset_keys(qos_spec.id, parsed_args.property) else: - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) diff --git a/openstackclient/volume/v2/service.py b/openstackclient/volume/v2/service.py index f26be13e0..023dda985 100644 --- a/openstackclient/volume/v2/service.py +++ b/openstackclient/volume/v2/service.py @@ -16,6 +16,7 @@ from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class ListService(command.Lister): @@ -26,16 +27,18 @@ class ListService(command.Lister): parser.add_argument( "--host", metavar="", - help="List services on specified host (name only)") + help=_("List services on specified host (name only)") + ) parser.add_argument( "--service", metavar="", - help="List only specified service (name only)") + help=_("List only specified service (name only)") + ) parser.add_argument( "--long", action="store_true", default=False, - help="List additional fields in output" + help=_("List additional fields in output") ) return parser diff --git a/openstackclient/volume/v2/snapshot.py b/openstackclient/volume/v2/snapshot.py index 65cb9a755..db4ce6c33 100644 --- a/openstackclient/volume/v2/snapshot.py +++ b/openstackclient/volume/v2/snapshot.py @@ -21,6 +21,7 @@ import six from openstackclient.common import command from openstackclient.common import parseractions from openstackclient.common import utils +from openstackclient.i18n import _ class CreateSnapshot(command.ShowOne): @@ -31,24 +32,25 @@ class CreateSnapshot(command.ShowOne): parser.add_argument( "volume", metavar="", - help="Volume to snapshot (name or ID)" + help=_("Volume to snapshot (name or ID)") ) parser.add_argument( "--name", metavar="", - help="Name of the snapshot" + help=("Name of the snapshot") ) parser.add_argument( "--description", metavar="", - help="Description of the snapshot" + help=_("Description of the snapshot") ) parser.add_argument( "--force", dest="force", action="store_true", 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 @@ -77,7 +79,7 @@ class DeleteSnapshot(command.Command): "snapshots", metavar="", nargs="+", - help="Snapshot(s) to delete (name or ID)" + help=_("Snapshot(s) to delete (name or ID)") ) return parser @@ -98,13 +100,13 @@ class ListSnapshot(command.Lister): '--all-projects', action='store_true', default=False, - help='Include all projects (admin only)', + help=_('Include all projects (admin only)'), ) parser.add_argument( '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -163,29 +165,32 @@ class SetSnapshot(command.Command): parser.add_argument( 'snapshot', metavar='', - help='Snapshot to modify (name or ID)') + help=_('Snapshot to modify (name or ID)') + ) parser.add_argument( '--name', metavar='', - help='New snapshot name') + help=_('New snapshot name') + ) parser.add_argument( '--description', metavar='', - help='New snapshot description') + help=_('New snapshot description') + ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Property to add/change for this snapshot ' - '(repeat option to set multiple properties)', + help=_('Property to add/change for this snapshot ' + '(repeat option to set multiple properties)'), ) parser.add_argument( '--state', metavar='', choices=['available', 'error', 'creating', 'deleting', 'error-deleting'], - help='New snapshot state. Valid values are available, ' - 'error, creating, deleting, and error-deleting.', + help=_('New snapshot state. Valid values are available, ' + 'error, creating, deleting, and error-deleting.'), ) return parser @@ -202,7 +207,7 @@ class SetSnapshot(command.Command): if (not kwargs and not parsed_args.property and not parsed_args.state): - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) return if parsed_args.property: @@ -222,7 +227,7 @@ class ShowSnapshot(command.ShowOne): parser.add_argument( "snapshot", metavar="", - help="Snapshot to display (name or ID)" + help=_("Snapshot to display (name or ID)") ) return parser @@ -244,15 +249,15 @@ class UnsetSnapshot(command.Command): parser.add_argument( 'snapshot', metavar='', - help='Snapshot to modify (name or ID)', + help=_('Snapshot to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action='append', default=[], - help='Property to remove from snapshot ' - '(repeat option to remove multiple properties)', + help=_('Property to remove from snapshot ' + '(repeat option to remove multiple properties)'), ) return parser @@ -267,4 +272,4 @@ class UnsetSnapshot(command.Command): parsed_args.property, ) else: - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py index 5a739f61c..0e07aa78d 100644 --- a/openstackclient/volume/v2/volume.py +++ b/openstackclient/volume/v2/volume.py @@ -21,6 +21,7 @@ import six from openstackclient.common import command from openstackclient.common import parseractions from openstackclient.common import utils +from openstackclient.i18n import _ from openstackclient.identity import common as identity_common @@ -32,61 +33,61 @@ class CreateVolume(command.ShowOne): parser.add_argument( "name", metavar="", - help="Volume name", + help=_("Volume name"), ) parser.add_argument( "--size", metavar="", type=int, required=True, - help="Volume size in GB", + help=_("Volume size in GB"), ) parser.add_argument( "--type", metavar="", - help="Set the type of volume", + help=_("Set the type of volume"), ) parser.add_argument( "--image", metavar="", - help="Use as source of volume (name or ID)", + help=_("Use as source of volume (name or ID)"), ) parser.add_argument( "--snapshot", metavar="", - help="Use as source of volume (name or ID)", + help=_("Use as source of volume (name or ID)"), ) parser.add_argument( "--source", metavar="", - help="Volume to clone (name or ID)", + help=_("Volume to clone (name or ID)"), ) parser.add_argument( "--description", metavar="", - help="Volume description", + help=_("Volume description"), ) parser.add_argument( '--user', metavar='', - help='Specify an alternate user (name or ID)', + help=_('Specify an alternate user (name or ID)'), ) parser.add_argument( '--project', metavar='', - help='Specify an alternate project (name or ID)', + help=_('Specify an alternate project (name or ID)'), ) parser.add_argument( "--availability-zone", metavar="", - help="Create volume in ", + help=_("Create volume in "), ) parser.add_argument( "--property", metavar="", action=parseractions.KeyValueAction, - help="Set a property to this volume " - "(repeat option to set multiple properties)", + help=_("Set a property to this volume " + "(repeat option to set multiple properties)"), ) return parser @@ -158,15 +159,15 @@ class DeleteVolume(command.Command): "volumes", metavar="", nargs="+", - help="Volume(s) to delete (name or ID)" + help=_("Volume(s) to delete (name or ID)") ) parser.add_argument( "--force", dest="force", action="store_true", default=False, - help="Attempt forced removal of volume(s), regardless of state " - "(defaults to False)" + help=_("Attempt forced removal of volume(s), regardless of state " + "(defaults to False)") ) return parser @@ -189,36 +190,36 @@ class ListVolume(command.Lister): parser.add_argument( '--project', metavar='', - 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) parser.add_argument( '--user', metavar='', - 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) parser.add_argument( '--name', metavar='', - help='Filter results by volume name', + help=_('Filter results by volume name'), ) parser.add_argument( '--status', metavar='', - help='Filter results by status', + help=_('Filter results by status'), ) parser.add_argument( '--all-projects', action='store_true', default=False, - help='Include all projects (admin only)', + help=_('Include all projects (admin only)'), ) parser.add_argument( '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -320,37 +321,37 @@ class SetVolume(command.Command): parser.add_argument( 'volume', metavar='', - help='Volume to modify (name or ID)', + help=_('Volume to modify (name or ID)'), ) parser.add_argument( '--name', metavar='', - help='New volume name', + help=_('New volume name'), ) parser.add_argument( '--size', metavar='', type=int, - help='Extend volume size in GB', + help=_('Extend volume size in GB'), ) parser.add_argument( '--description', metavar='', - help='New volume description', + help=_('New volume description'), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a property on this volume ' - '(repeat option to set multiple properties)', + help=_('Set a property on this volume ' + '(repeat option to set multiple properties)'), ) parser.add_argument( '--image-property', metavar='', action=parseractions.KeyValueAction, - help='Set an image property on this volume ' - '(repeat option to set multiple image properties)', + help=_('Set an image property on this volume ' + '(repeat option to set multiple image properties)'), ) return parser @@ -360,12 +361,12 @@ class SetVolume(command.Command): if parsed_args.size: if volume.status != 'available': - self.app.log.error("Volume is in %s state, it must be " - "available before size can be extended" % + self.app.log.error(_("Volume is in %s state, it must be " + "available before size can be extended") % volume.status) return 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) return 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 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): @@ -397,7 +398,7 @@ class ShowVolume(command.ShowOne): parser.add_argument( 'volume', metavar="", - help="Volume to display (name or ID)" + help=_("Volume to display (name or ID)") ) return parser @@ -428,21 +429,21 @@ class UnsetVolume(command.Command): parser.add_argument( 'volume', metavar='', - help='Volume to modify (name or ID)', + help=_('Volume to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', action='append', - help='Remove a property from volume ' - '(repeat option to remove multiple properties)', + help=_('Remove a property from volume ' + '(repeat option to remove multiple properties)'), ) parser.add_argument( '--image-property', metavar='', action='append', - help='Remove an image property from volume ' - '(repeat option to remove multiple image properties)', + help=_('Remove an image property from volume ' + '(repeat option to remove multiple image properties)'), ) return parser @@ -459,4 +460,4 @@ class UnsetVolume(command.Command): volume.id, parsed_args.image_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")) diff --git a/openstackclient/volume/v2/volume_type.py b/openstackclient/volume/v2/volume_type.py index 305005186..adaccb0a6 100644 --- a/openstackclient/volume/v2/volume_type.py +++ b/openstackclient/volume/v2/volume_type.py @@ -20,6 +20,7 @@ from openstackclient.common import command from openstackclient.common import exceptions from openstackclient.common import parseractions from openstackclient.common import utils +from openstackclient.i18n import _ from openstackclient.identity import common as identity_common @@ -31,12 +32,12 @@ class CreateVolumeType(command.ShowOne): parser.add_argument( "name", metavar="", - help="Volume type name", + help=_("Volume type name"), ) parser.add_argument( "--description", metavar="", - help="Volume type description", + help=_("Volume type description"), ) public_group = parser.add_mutually_exclusive_group() public_group.add_argument( @@ -44,21 +45,21 @@ class CreateVolumeType(command.ShowOne): dest="public", action="store_true", default=False, - help="Volume type is accessible to the public", + help=_("Volume type is accessible to the public"), ) public_group.add_argument( "--private", dest="private", action="store_true", default=False, - help="Volume type is not accessible to the public", + help=_("Volume type is not accessible to the public"), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a property on this volume type ' - '(repeat option to set multiple properties)', + help=_('Set a property on this volume type ' + '(repeat option to set multiple properties)'), ) return parser @@ -93,7 +94,7 @@ class DeleteVolumeType(command.Command): parser.add_argument( "volume_type", metavar="", - help="Volume type to delete (name or ID)" + help=_("Volume type to delete (name or ID)") ) return parser @@ -113,7 +114,7 @@ class ListVolumeType(command.Lister): '--long', action='store_true', default=False, - help='List additional fields in output') + help=_('List additional fields in output')) return parser def take_action(self, parsed_args): @@ -139,29 +140,30 @@ class SetVolumeType(command.Command): parser.add_argument( 'volume_type', metavar='', - help='Volume type to modify (name or ID)', + help=_('Volume type to modify (name or ID)'), ) parser.add_argument( '--name', metavar='', - help='Set volume type name', + help=_('Set volume type name'), ) parser.add_argument( '--description', metavar='', - help='Set volume type description', + help=_('Set volume type description'), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a property on this volume type ' - '(repeat option to set multiple properties)', + help=_('Set a property on this volume type ' + '(repeat option to set multiple properties)'), ) parser.add_argument( '--project', metavar='', - 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) @@ -178,7 +180,7 @@ class SetVolumeType(command.Command): and not parsed_args.description and not parsed_args.property and not parsed_args.project): - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) return result = 0 @@ -195,15 +197,15 @@ class SetVolumeType(command.Command): **kwargs ) except Exception as e: - self.app.log.error("Failed to update volume type name or" - " description: " + str(e)) + self.app.log.error(_("Failed to update volume type name or" + " description: %s") % str(e)) result += 1 if parsed_args.property: try: volume_type.set_keys(parsed_args.property) 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)) result += 1 @@ -218,8 +220,8 @@ class SetVolumeType(command.Command): volume_client.volume_type_access.add_project_access( volume_type.id, project_info.id) except Exception as e: - self.app.log.error("Failed to set volume type access to" - " project: " + str(e)) + self.app.log.error(_("Failed to set volume type access to" + " project: %s") % str(e)) result += 1 if result > 0: @@ -235,7 +237,7 @@ class ShowVolumeType(command.ShowOne): parser.add_argument( "volume_type", metavar="", - help="Volume type to display (name or ID)" + help=_("Volume type to display (name or ID)") ) return parser @@ -256,19 +258,19 @@ class UnsetVolumeType(command.Command): parser.add_argument( 'volume_type', metavar='', - help='Volume type to modify (name or ID)', + help=_('Volume type to modify (name or ID)'), ) parser.add_argument( '--property', metavar='', - help='Remove a property from this volume type ' - '(repeat option to remove multiple properties)', + help=_('Remove a property from this volume type ' + '(repeat option to remove multiple properties)'), ) parser.add_argument( '--project', metavar='', - help='Removes volume type access to project (name or ID) ' - ' (admin only)', + help=_('Removes volume type access to project (name or ID) ' + ' (admin only)'), ) identity_common.add_project_domain_option_to_parser(parser) @@ -285,7 +287,7 @@ class UnsetVolumeType(command.Command): if (not parsed_args.property and not parsed_args.project): - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) return result = 0 @@ -293,8 +295,8 @@ class UnsetVolumeType(command.Command): try: volume_type.unset_keys(parsed_args.property) except Exception as e: - self.app.log.error("Failed to unset volume type property: " + - str(e)) + self.app.log.error(_("Failed to unset volume type property: %s" + ) % str(e)) result += 1 if parsed_args.project: @@ -308,8 +310,8 @@ class UnsetVolumeType(command.Command): volume_client.volume_type_access.remove_project_access( volume_type.id, project_info.id) except Exception as e: - self.app.log.error("Failed to remove volume type access from" - " project: " + str(e)) + self.app.log.error(_("Failed to remove volume type access from" + " project: ") + str(e)) result += 1 if result > 0: