From d2a80a67c739b2eaa76e7ad816318db9fb7b7966 Mon Sep 17 00:00:00 2001 From: David Lyle Date: Fri, 8 Mar 2013 12:57:06 -0700 Subject: [PATCH] Fixes error message formatting in Load Balancers panel Strings were formatted to contain a "%s" to be updated when the message was used. The resulting string in the message box was: Error: Unable to add Pool "%s". The update routine that already existed and was not being called. Calls to the existing routine are now being made. Other places the strings were changed as the name would not be in context any longer and the unused methods removed. Fixes: bug #1152719 Change-Id: I157531a1b65dc73ce4ff1a57079fb4a2fcb9f62e --- .../project/loadbalancers/workflows.py | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/openstack_dashboard/dashboards/project/loadbalancers/workflows.py b/openstack_dashboard/dashboards/project/loadbalancers/workflows.py index f473935cb..526aad93f 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/workflows.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/workflows.py @@ -107,11 +107,10 @@ class AddPool(workflows.Workflow): def handle(self, request, context): try: pool = api.lbaas.pool_create(request, **context) - context['name'] return True except: - exceptions.handle(request, - self.failure_message) + msg = self.format_status_message(self.failure_message) + exceptions.handle(request, msg) return False @@ -240,8 +239,8 @@ class AddVip(workflows.Workflow): api.lbaas.vip_create(request, **context) return True except: - exceptions.handle(request, - self.failure_message) + msg = self.format_status_message(self.failure_message) + exceptions.handle(request, msg) return False @@ -329,10 +328,6 @@ class AddMember(workflows.Workflow): success_url = "horizon:project:loadbalancers:index" default_steps = (AddMemberStep,) - def format_status_message(self, message): - member_id = self.context.get('member_id') - return message % member_id - def handle(self, request, context): if context['members'] == []: self.failure_message = _('No instances available.%s') @@ -354,8 +349,7 @@ class AddMember(workflows.Workflow): context['member_id'] = api.lbaas.member_create( request, **context).id except: - exceptions.handle(request, - self.failure_message) + exceptions.handle(request, _("Unable to add member.")) return False return True @@ -433,16 +427,11 @@ class AddMonitor(workflows.Workflow): success_url = "horizon:project:loadbalancers:index" default_steps = (AddMonitorStep,) - def format_status_message(self, message): - monitor_id = self.context.get('monitor_id') - return message % monitor_id - def handle(self, request, context): try: context['monitor_id'] = api.lbaas.pool_health_monitor_create( request, **context).get('id') return True except: - exceptions.handle(request, - self.failure_message) + exceptions.handle(request, _("Unable to add monitor.")) return False