summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorIlya Alekseyev <ialekseev@griddynamics.com>2011-04-11 22:35:09 +0400
committerIlya Alekseyev <ialekseev@griddynamics.com>2011-04-11 22:35:09 +0400
commit9ce66a4a09094d2b0403deea77416149aa789f3c (patch)
tree998c093707a4aa5a2c88b19b607e0e310fb5094c /nova/compute
parent8ae129ace401a1493cd953d3f4b9ecc22d74a70f (diff)
Floating ips auto assignment
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/manager.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 68b163355..86273b6b4 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -73,6 +73,8 @@ flags.DEFINE_integer('live_migration_retry_count', 30,
flags.DEFINE_integer("rescue_timeout", 0,
"Automatically unrescue an instance after N seconds."
" Set to 0 to disable.")
+flags.DEFINE_bool('auto_assign_floating_ip',False, 'Autoassigning floating'
+ ' ip to VM')
LOG = logging.getLogger('nova.compute.manager')
@@ -224,6 +226,16 @@ class ComputeManager(manager.SchedulerDependentManager):
self.network_manager.setup_compute_network(context,
instance_id)
+ if FLAGS.auto_assign_floating_ip:
+ public_ip = rpc.call(context,
+ FLAGS.network_topic,
+ {"method": "allocate_floating_ip",
+ "args": {"project_id": context.project_id}})
+ self.network_manager.associate_floating_ip(context,
+ instance_id=instance_id,
+ address=public_ip)
+
+
# TODO(vish) check to make sure the availability zone matches
self.db.instance_set_state(context,
instance_id,
@@ -271,6 +283,15 @@ class ComputeManager(manager.SchedulerDependentManager):
network_topic,
{"method": "disassociate_floating_ip",
"args": {"floating_address": address}})
+
+ if FLAGS.auto_assign_floating_ip:
+ LOG.debug(_("Deallocating floating ip %s"),
+ floating_ip['address'], context=context)
+ rpc.cast(context,
+ FLAGS.network_topic,
+ {"method": "deallocate_floating_ip",
+ "args": {"floating_address":
+ floating_ip['address']}})
address = fixed_ip['address']
if address: