Skip to content

Commit

Permalink
fix generation of exception for mismatched floating ip tenant-ids
Browse files Browse the repository at this point in the history
bug 1048104

There was a KeyError in the case where we tried to throw an exception
to inform the user that a newly created floating ip could not be
associated with the requested port because they belonged to different
tenants.

Change-Id: I387e5f166761da78b941b62a9a396809491b8f09
  • Loading branch information
Dan Wendlandt committed Sep 9, 2012
1 parent 4ce397d commit 1820686
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions quantum/db/l3_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,17 @@ def get_assoc_data(self, context, fip, floating_network_id):
"""
internal_port = self._get_port(context, fip['port_id'])
if not internal_port['tenant_id'] == fip['tenant_id']:
msg = ('Port %s is associated with a different tenant'
'and therefore cannot be found to floating IP %s'
% (fip['port_id'], fip['id']))
raise q_exc.BadRequest(resource='floating', msg=msg)
port_id = fip['port_id']
if 'id' in fip:
floatingip_id = fip['id']
msg = _('Port %(port_id)s is associated with a different '
'tenant than Floating IP %(floatingip_id)s and '
'therefore cannot be bound.')
else:
msg = _('Cannnot create floating IP and bind it to '
'Port %(port_id)s, since that port is owned by a '
'different tenant.')
raise q_exc.BadRequest(resource='floatingip', msg=msg % locals())

internal_subnet_id = None
if 'fixed_ip_address' in fip and fip['fixed_ip_address']:
Expand Down

0 comments on commit 1820686

Please sign in to comment.