Fix unbound locals in IPAssociationWorkflow

If an error is raised in the AssociateIPAction we assume that a redirect
will be raised. However, certain exception classes will not result in a
redirect when handled by the standard Horizon exception handler. If the
error handler doesn't re-raise some sort of error, control will be
returned to the statement after the except block and some of the
necessary local variables may be unbound.

This fix simply ensures that all of the necessary locals are bound in
the event that an error does occur.

Change-Id: Ib8c92ab218457e51e521d36bb4778c1dc1025342
Closes-Bug: #1290583
This commit is contained in:
Brian DeHamer 2014-03-11 08:40:12 -07:00
parent 698e2189ad
commit e686fb8520
1 changed files with 2 additions and 0 deletions

View File

@ -61,6 +61,7 @@ class AssociateIPAction(workflows.Action):
self.initial['instance_id'] = target_id
def populate_ip_id_choices(self, request, context):
ips = []
try:
ips = api.network.tenant_floating_ip_list(self.request)
except Exception:
@ -77,6 +78,7 @@ class AssociateIPAction(workflows.Action):
return options
def populate_instance_id_choices(self, request, context):
targets = []
try:
targets = api.network.floating_ip_target_list(self.request)
except Exception: