From ba5715b46d82498ed30aa146294850a134022617 Mon Sep 17 00:00:00 2001 From: Tushar Patil Date: Wed, 30 Mar 2011 13:32:13 -0700 Subject: Fix for LP Bug #745152 --- nova/network/api.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nova/network/api.py b/nova/network/api.py index 4ee1148cb..424c3f592 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -66,6 +66,18 @@ class API(base.Base): if isinstance(fixed_ip, str) or isinstance(fixed_ip, unicode): fixed_ip = self.db.fixed_ip_get_by_address(context, fixed_ip) floating_ip = self.db.floating_ip_get_by_address(context, floating_ip) + # Check if the floating ip address is allocated + if floating_ip['project_id'] is None: + raise exception.ApiError(_("Address (%s) is not allocated") + % floating_ip['address']) + # Check if the floating ip address is allocated to the same project + if floating_ip['project_id'] != context.project_id: + LOG.warn(_("Address (%s) is not allocated to your project " + "(%s)"), floating_ip['address'], context.project_id) + raise exception.ApiError(_("Address (%s) is not " + "allocated to your project (%s)") % + (floating_ip['address'], + context.project_id)) # NOTE(vish): Perhaps we should just pass this on to compute and # let compute communicate with network. host = fixed_ip['network']['host'] -- cgit From bb1c49bc324956241383add85297510842d4464c Mon Sep 17 00:00:00 2001 From: Tushar Patil Date: Wed, 30 Mar 2011 15:00:47 -0700 Subject: fixed review comment for i18n string multiple replacement strings need to use dictionary format --- nova/network/api.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/nova/network/api.py b/nova/network/api.py index 424c3f592..47e56ebc6 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -68,16 +68,20 @@ class API(base.Base): floating_ip = self.db.floating_ip_get_by_address(context, floating_ip) # Check if the floating ip address is allocated if floating_ip['project_id'] is None: - raise exception.ApiError(_("Address (%s) is not allocated") - % floating_ip['address']) + raise exception.ApiError(_("Address (%(address)s) is not " + "allocated") % {'address': + floating_ip['address']}) # Check if the floating ip address is allocated to the same project if floating_ip['project_id'] != context.project_id: - LOG.warn(_("Address (%s) is not allocated to your project " - "(%s)"), floating_ip['address'], context.project_id) - raise exception.ApiError(_("Address (%s) is not " - "allocated to your project (%s)") % - (floating_ip['address'], - context.project_id)) + LOG.warn(_("Address (%(address)s) is not allocated to your " + "project (%(project)s)"), + {'address': floating_ip['address'], + 'project': context.project_id}) + raise exception.ApiError(_("Address (%(address)s) is not " + "allocated to your project" + "(%(project)s)") % + {'address': floating_ip['address'], + 'project': context.project_id}) # NOTE(vish): Perhaps we should just pass this on to compute and # let compute communicate with network. host = fixed_ip['network']['host'] -- cgit From 7d86a9e478c92ac9f79039c4592c6355c91b8b61 Mon Sep 17 00:00:00 2001 From: Tushar Patil Date: Wed, 30 Mar 2011 15:10:55 -0700 Subject: fixed review comment for i18n string multiple replacement strings need to use dictionary format --- nova/network/api.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nova/network/api.py b/nova/network/api.py index 47e56ebc6..c56e3062b 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -68,9 +68,8 @@ class API(base.Base): floating_ip = self.db.floating_ip_get_by_address(context, floating_ip) # Check if the floating ip address is allocated if floating_ip['project_id'] is None: - raise exception.ApiError(_("Address (%(address)s) is not " - "allocated") % {'address': - floating_ip['address']}) + raise exception.ApiError(_("Address (%s) is not allocated") % + floating_ip['address']) # Check if the floating ip address is allocated to the same project if floating_ip['project_id'] != context.project_id: LOG.warn(_("Address (%(address)s) is not allocated to your " -- cgit