summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor McCasland <TM2086@att.com>2016-12-05 11:26:27 -0600
committeramrith <amrith.kumar@gmail.com>2017-01-29 03:03:23 +0000
commitc50c06542681843e44b6f5e77a14ac38d7f0677f (patch)
treecc6632cde9e2284bb35ec6a2dd4c4b6cd78ae841
parent4f9c538f682c0f7234110ec5d1abe933e4ab5bde (diff)
downloadtrove-c50c06542681843e44b6f5e77a14ac38d7f0677f.tar.gz
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
-rw-r--r--trove/taskmanager/api.py3
-rw-r--r--trove/taskmanager/manager.py18
-rwxr-xr-xtrove/taskmanager/models.py21
3 files changed, 23 insertions, 19 deletions
diff --git a/trove/taskmanager/api.py b/trove/taskmanager/api.py
index 1c1b01aa..9d82e51d 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 4e2555d2..69963024 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 160cf1c9..b7ac6646 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)