summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Alekseyev <ialekseev@griddynamics.com>2011-04-14 21:23:40 +0400
committerIlya Alekseyev <ialekseev@griddynamics.com>2011-04-14 21:23:40 +0400
commit76e643dc0b6b8b6e2ad499034f4d4491380e91ba (patch)
tree2768ea57650176d06500f9b0d0331ed531c476ce
parent1b460de2f881d3cda0fd58bacedc3886020e4ca7 (diff)
bugfix
-rw-r--r--nova/compute/manager.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 63d374326..94fee36a5 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -252,9 +252,34 @@ class ComputeManager(manager.SchedulerDependentManager):
FLAGS.network_topic,
{"method": "allocate_floating_ip",
"args": {"project_id": context.project_id}})
- self.network_manager.associate_floating_ip(context,
- floating_address=public_ip,
- fixed_address=address)
+
+ fixed_ip = self.db.fixed_ip_get_by_address(context, address)
+ floating_ip = self.db.floating_ip_get_by_address(context,
+ public_ip)
+ # Check if the floating ip address is allocated
+ if floating_ip['project_id'] is None:
+ raise exception.Error(_("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"
+ " project (%(project)s)"),
+ {'address': floating_ip['address'],
+ 'project': context.project_id})
+ raise exception.Error(_("Address (%(address)s) is not "
+ "allocated to your project"
+ "(%(project)s)") %
+ {'address': floating_ip['address'],
+ 'project': context.project_id})
+
+ host = fixed_ip['network']['host']
+ rpc.cast(context,
+ self.db.queue_get_for(context,
+ FLAGS.network_topic, host),
+ {"method": "associate_floating_ip",
+ "args": {"floating_address": floating_ip['address'],
+ "fixed_address": fixed_ip['address']}})
self._update_state(context, instance_id)