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
This commit is contained in:
David Lyle 2013-03-08 12:57:06 -07:00
parent 2b5e55c74f
commit d2a80a67c7

View File

@ -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