diff options
| author | Sheel Rana <ranasheel2000@gmail.com> | 2016-05-23 22:26:24 +0530 |
|---|---|---|
| committer | Sheel Rana <ranasheel2000@gmail.com> | 2016-05-23 18:04:36 +0000 |
| commit | 53e05e7c2d36ab2ff1ba05a8334286d41c5f40e4 (patch) | |
| tree | 658edbf0d29fc44f2939041ac7256802be92e184 /openstackclient/volume/v1 | |
| parent | 17bc850440045128871c381244540eeedaa569a7 (diff) | |
| download | python-openstackclient-53e05e7c2d36ab2ff1ba05a8334286d41c5f40e4.tar.gz | |
i18n support for help and error messages in cinder
Change-Id: I98fbc959034fe0530966291643b381855801de20
Diffstat (limited to 'openstackclient/volume/v1')
| -rw-r--r-- | openstackclient/volume/v1/backup.py | 22 | ||||
| -rw-r--r-- | openstackclient/volume/v1/qos_specs.py | 42 | ||||
| -rw-r--r-- | openstackclient/volume/v1/service.py | 9 | ||||
| -rw-r--r-- | openstackclient/volume/v1/snapshot.py | 42 | ||||
| -rw-r--r-- | openstackclient/volume/v1/volume.py | 69 | ||||
| -rw-r--r-- | openstackclient/volume/v1/volume_type.py | 28 |
6 files changed, 115 insertions, 97 deletions
diff --git a/openstackclient/volume/v1/backup.py b/openstackclient/volume/v1/backup.py index 40b60315..607b5211 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='<volume>', - help='Volume to backup (name or ID)', + help=_('Volume to backup (name or ID)'), ) parser.add_argument( '--container', metavar='<container>', required=False, - help='Optional backup container name', + help=_('Optional backup container name'), ) parser.add_argument( '--name', metavar='<name>', - help='Name of the backup', + help=_('Name of the backup'), ) parser.add_argument( '--description', metavar='<description>', - help='Description of the backup', + help=_('Description of the backup'), ) return parser @@ -74,7 +75,7 @@ class DeleteBackup(command.Command): 'backups', metavar='<backup>', 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='<backup>', - help='Backup to restore (ID only)') + help=_('Backup to restore (ID only)') + ) parser.add_argument( 'volume', metavar='<volume>', - 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='<backup>', - 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 826e5c49..b9eb8752 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='<qos-spec>', - help='QoS specification to modify (name or ID)', + help=_('QoS specification to modify (name or ID)'), ) parser.add_argument( '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 @@ -57,7 +58,7 @@ class CreateQos(command.ShowOne): parser.add_argument( 'name', metavar='<name>', - 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='<consumer>', 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='<key=value>', 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='<qos-spec>', 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='<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.add_argument( '--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( '--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='<qos-spec>', - help='QoS specification to modify (name or ID)', + help=_('QoS specification to modify (name or ID)'), ) parser.add_argument( '--property', metavar='<key=value>', 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='<qos-spec>', - 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='<qos-spec>', - help='QoS specification to modify (name or ID)', + help=_('QoS specification to modify (name or ID)'), ) parser.add_argument( '--property', metavar='<key>', 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 f26be13e..023dda98 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="<host>", - help="List services on specified host (name only)") + help=_("List services on specified host (name only)") + ) parser.add_argument( "--service", metavar="<service>", - 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 6c6131ea..bf5bf264 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='<volume>', - help='Volume to snapshot (name or ID)', + help=_('Volume to snapshot (name or ID)'), ) parser.add_argument( '--name', metavar='<name>', - help='Name of the snapshot', + help=_('Name of the snapshot'), ) parser.add_argument( '--description', metavar='<description>', - 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='<snapshot>', 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='<snapshot>', - help='Snapshot to modify (name or ID)') + help=_('Snapshot to modify (name or ID)') + ) parser.add_argument( '--name', metavar='<name>', - help='New snapshot name') + help=_('New snapshot name') + ) parser.add_argument( '--description', metavar='<description>', - help='New snapshot description') + help=_('New snapshot description') + ) parser.add_argument( '--property', metavar='<key=value>', 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='<snapshot>', - 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='<snapshot>', - help='Snapshot to modify (name or ID)', + help=_('Snapshot to modify (name or ID)'), ) parser.add_argument( '--property', metavar='<key>', 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 29c197ef..11e42f83 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='<name>', - help='Volume name', + help=_('Volume name'), ) parser.add_argument( '--size', metavar='<size>', required=True, type=int, - help='Volume size in GB', + help=_('Volume size in GB'), ) parser.add_argument( '--type', metavar='<volume-type>', - help="Set the type of volume", + help=_("Set the type of volume"), ) parser.add_argument( '--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.add_argument( '--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-id', @@ -64,34 +65,34 @@ class CreateVolume(command.ShowOne): parser.add_argument( '--source', metavar='<volume>', - help='Volume to clone (name or ID)', + help=_('Volume to clone (name or ID)'), ) parser.add_argument( '--description', metavar='<description>', - help='Volume description', + help=_('Volume description'), ) parser.add_argument( '--user', metavar='<user>', - help='Specify an alternate user (name or ID)', + help=_('Specify an alternate user (name or ID)'), ) parser.add_argument( '--project', metavar='<project>', - help='Specify an alternate project (name or ID)', + help=_('Specify an alternate project (name or ID)'), ) parser.add_argument( '--availability-zone', metavar='<availability-zone>', - help='Create volume in <availability-zone>', + help=_('Create volume in <availability-zone>'), ) parser.add_argument( '--property', metavar='<key=value>', 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='<volume>', 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='<name>', - help='Filter results by volume name', + help=_('Filter results by volume name'), ) parser.add_argument( '--status', metavar='<status>', - 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='<volume>', - help='Volume to modify (name or ID)', + help=_('Volume to modify (name or ID)'), ) parser.add_argument( '--name', metavar='<name>', - help='New volume name', + help=_('New volume name'), ) parser.add_argument( '--description', metavar='<description>', - help='New volume description', + help=_('New volume description'), ) parser.add_argument( '--size', metavar='<size>', type=int, - help='Extend volume size in GB', + help=_('Extend volume size in GB'), ) parser.add_argument( '--property', metavar='<key=value>', 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='<volume>', - 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='<volume>', - help='Volume to modify (name or ID)', + help=_('Volume to modify (name or ID)'), ) parser.add_argument( '--property', metavar='<key>', 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 05671c1f..73927022 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='<name>', - help='Volume type name', + help=_('Volume type name'), ) parser.add_argument( '--property', metavar='<key=value>', 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='<volume-type>', - 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='<volume-type>', - help='Volume type to modify (name or ID)', + help=_('Volume type to modify (name or ID)'), ) parser.add_argument( '--property', metavar='<key=value>', 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="<volume-type>", - 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='<volume-type>', - help='Volume type to modify (name or ID)', + help=_('Volume type to modify (name or ID)'), ) parser.add_argument( '--property', metavar='<key>', 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")) |
