diff --git a/trove/taskmanager/api.py b/trove/taskmanager/api.py index 437e720b21..93b6fe51e2 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 @@ -94,7 +95,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 32deb57f73..da03111960 100755 --- a/trove/taskmanager/models.py +++ b/trove/taskmanager/models.py @@ -726,7 +726,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, @@ -748,23 +748,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) @@ -1002,8 +1003,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) @@ -1527,8 +1528,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)