Merge lp:~tpatil/nova/bug745152 into lp:~hudson-openstack/nova/trunk

Proposed by Tushar Patil
Status: Merged
Approved by: Soren Hansen
Approved revision: 925
Merged at revision: 926
Proposed branch: lp:~tpatil/nova/bug745152
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 25 lines (+15/-0)
1 file modified
nova/network/api.py (+15/-0)
To merge this branch: bzr merge lp:~tpatil/nova/bug745152
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
termie (community) Approve
Vish Ishaya (community) Needs Fixing
Review via email: mp+55633@code.launchpad.net

Commit message

If the floating ip address is not allocated or is allocated to another project, then the user trying to associate the floating ip address to an instance should get a proper error message.

Description of the change

If the floating ip address is not allocated or is allocated to another project, then the user trying to associate the floating ip address to an instance should get a proper error message.

To post a comment you must log in.
Revision history for this message
Vish Ishaya (vishvananda) wrote :

you need to fix the i18n of the strings or it will fail the test. For multiple replacement strings you need to use the dictionary format "%(address)s %(project)s" % {'address': xxxx, 'project': xxxx}

Otherwise it looks good

review: Needs Fixing
Revision history for this message
termie (termie) wrote :

lgtm

review: Approve
lp:~tpatil/nova/bug745152 updated
924. By Tushar Patil

fixed review comment for i18n string multiple replacement strings need to use dictionary format

925. By Tushar Patil

fixed review comment for i18n string multiple replacement strings need to use dictionary format

Revision history for this message
Tushar Patil (tpatil) wrote :

Fixed the review comments. Please review the code.

Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/network/api.py'
2--- nova/network/api.py 2011-02-22 23:50:42 +0000
3+++ nova/network/api.py 2011-03-30 22:13:14 +0000
4@@ -66,6 +66,21 @@
5 if isinstance(fixed_ip, str) or isinstance(fixed_ip, unicode):
6 fixed_ip = self.db.fixed_ip_get_by_address(context, fixed_ip)
7 floating_ip = self.db.floating_ip_get_by_address(context, floating_ip)
8+ # Check if the floating ip address is allocated
9+ if floating_ip['project_id'] is None:
10+ raise exception.ApiError(_("Address (%s) is not allocated") %
11+ floating_ip['address'])
12+ # Check if the floating ip address is allocated to the same project
13+ if floating_ip['project_id'] != context.project_id:
14+ LOG.warn(_("Address (%(address)s) is not allocated to your "
15+ "project (%(project)s)"),
16+ {'address': floating_ip['address'],
17+ 'project': context.project_id})
18+ raise exception.ApiError(_("Address (%(address)s) is not "
19+ "allocated to your project"
20+ "(%(project)s)") %
21+ {'address': floating_ip['address'],
22+ 'project': context.project_id})
23 # NOTE(vish): Perhaps we should just pass this on to compute and
24 # let compute communicate with network.
25 host = fixed_ip['network']['host']