From c50c06542681843e44b6f5e77a14ac38d7f0677f Mon Sep 17 00:00:00 2001 From: Trevor McCasland Date: Mon, 5 Dec 2016 11:26:27 -0600 Subject: [PATCH] Add i18n translation to others 3/3 This is 3 of 3 commits to add i18n translation to misc files. Custom hacking rules will be added later to enforce this style. Change-Id: I88284f61b5f37d78ad050a97c679f6bde23d832d Depends-On: I6fb2bdcc4b83457e08b24599fb4a297ef6ec6c14 --- trove/taskmanager/api.py | 3 ++- trove/taskmanager/manager.py | 18 ++++++++++-------- trove/taskmanager/models.py | 21 +++++++++++---------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/trove/taskmanager/api.py b/trove/taskmanager/api.py index 1c1b01aa7f..9d82e51ddf 100644 --- a/trove/taskmanager/api.py +++ b/trove/taskmanager/api.py @@ -23,6 +23,7 @@ import oslo_messaging as messaging from trove.common import cfg from trove.common import exception +from trove.common.i18n import _ from trove.common.notification import NotificationCastWrapper from trove.common.strategies.cluster import strategy from trove.guestagent import models as agent_models @@ -89,7 +90,7 @@ class API(object): if obj_dict.get('manager'): del obj_dict['manager'] return obj_dict - raise ValueError("Could not transform %s" % obj_ref) + raise ValueError(_("Could not transform %s") % obj_ref) def _delete_heartbeat(self, instance_id): agent_heart_beat = agent_models.AgentHeartBeat() diff --git a/trove/taskmanager/manager.py b/trove/taskmanager/manager.py index 4e2555d215..699630249a 100644 --- a/trove/taskmanager/manager.py +++ b/trove/taskmanager/manager.py @@ -148,11 +148,12 @@ class Manager(periodic_task.PeriodicTasks): self._set_task_status(exception_replicas, InstanceTasks.PROMOTION_ERROR) msg = (_("promote-to-replica-source %(id)s: The following " - "replicas may not have been switched: %(replicas)s") % + "replicas may not have been switched: %(replicas)s:" + "\n%(err)s") % {"id": master_candidate.id, - "replicas": [repl.id for repl in exception_replicas]}) - raise ReplicationSlaveAttachError("%s:\n%s" % - (msg, error_messages)) + "replicas": [repl.id for repl in exception_replicas], + "err": error_messages}) + raise ReplicationSlaveAttachError(msg) with EndNotification(context): master_candidate = BuiltInstanceTasks.load(context, instance_id) @@ -228,11 +229,12 @@ class Manager(periodic_task.PeriodicTasks): self._set_task_status(exception_replicas, InstanceTasks.EJECTION_ERROR) msg = (_("eject-replica-source %(id)s: The following " - "replicas may not have been switched: %(replicas)s") % + "replicas may not have been switched: %(replicas)s:" + "\n%(err)s") % {"id": master_candidate.id, - "replicas": [repl.id for repl in exception_replicas]}) - raise ReplicationSlaveAttachError("%s:\n%s" % - (msg, error_messages)) + "replicas": [repl.id for repl in exception_replicas], + "err": error_messages}) + raise ReplicationSlaveAttachError(msg) with EndNotification(context): master = BuiltInstanceTasks.load(context, instance_id) diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py index 160cf1c9e3..b7ac66467b 100755 --- a/trove/taskmanager/models.py +++ b/trove/taskmanager/models.py @@ -724,7 +724,7 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin): try: heat_template = heat_template_unicode.encode('utf-8') except UnicodeEncodeError: - raise TroveError("Failed to utf-8 encode Heat template.") + raise TroveError(_("Failed to utf-8 encode Heat template.")) parameters = {"Flavor": flavor["name"], "VolumeSize": volume_size, @@ -746,23 +746,24 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin): sleep_time=USAGE_SLEEP_TIME, time_out=HEAT_TIME_OUT) except PollTimeOut: - raise TroveError("Failed to obtain Heat stack status. " - "Timeout occurred.") + raise TroveError(_("Failed to obtain Heat stack status. " + "Timeout occurred.")) stack = client.stacks.get(stack_name) if ((stack.action, stack.stack_status) not in HEAT_STACK_SUCCESSFUL_STATUSES): - raise TroveError("Failed to create Heat stack.") + raise TroveError(_("Failed to create Heat stack.")) resource = client.resources.get(stack.id, 'BaseInstance') if resource.resource_status != HEAT_RESOURCE_SUCCESSFUL_STATE: - raise TroveError("Failed to provision Heat base instance.") + raise TroveError(_("Failed to provision Heat base instance.")) instance_id = resource.physical_resource_id if self.volume_support: resource = client.resources.get(stack.id, 'DataVolume') if resource.resource_status != HEAT_RESOURCE_SUCCESSFUL_STATE: - raise TroveError("Failed to provision Heat data volume.") + raise TroveError(_("Failed to provision Heat data " + "volume.")) volume_id = resource.physical_resource_id self.update_db(compute_instance_id=instance_id, volume_id=volume_id) @@ -1000,8 +1001,8 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin): LOG.debug("Creating dns entry...") ip = self.dns_ip_address if not ip: - raise TroveError("Failed to create DNS entry for instance %s. " - "No IP available." % self.id) + raise TroveError(_("Failed to create DNS entry for instance " + "%s. No IP available.") % self.id) dns_client.create_instance_entry(self.id, ip) LOG.debug("Successfully created DNS entry for instance: %s" % self.id) @@ -1507,8 +1508,8 @@ class BackupTasks(object): "Details: %s") % e) backup.state = bkup_models.BackupState.DELETE_FAILED backup.save() - raise TroveError("Failed to delete swift object for backup %s." - % backup_id) + raise TroveError(_("Failed to delete swift object for backup " + "%s.") % backup_id) else: backup.delete() LOG.info(_("Deleted backup %s successfully.") % backup_id)