summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2011-11-28 22:56:59 +0000
committerGerrit Code Review <review@openstack.org>2011-11-28 22:56:59 +0000
commit9c2e69b4966895fe04edb16158f0199956fda657 (patch)
tree3b598ac8553cf50b4fda7b88d241852fae654e91 /nova/compute
parent53b84fb28b1a7c9b3f6f24cbe0865495cfd1cb93 (diff)
parentdd44abb728e592fbd020af7fa362886b1436b968 (diff)
Merge "Updating {add,remove}_fixed_ip_from_instance in compute.api and compute.manager to use instance uuid instead of instance id. blueprint internal-uuids"
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py12
-rw-r--r--nova/compute/manager.py14
2 files changed, 12 insertions, 14 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 8e2c806b2..32f329a04 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -1307,23 +1307,19 @@ class API(base.Base):
@scheduler_api.reroute_compute("add_fixed_ip")
def add_fixed_ip(self, context, instance, network_id):
"""Add fixed_ip from specified network to given instance."""
- #NOTE(bcwaldon): We need to use the integer id since the
- # network manager doesn't support uuids
- instance_id = instance['id']
+ instance_uuid = instance['uuid']
self._cast_compute_message('add_fixed_ip_to_instance',
context,
- instance_id,
+ instance_uuid,
params=dict(network_id=network_id))
@scheduler_api.reroute_compute("remove_fixed_ip")
def remove_fixed_ip(self, context, instance, address):
"""Remove fixed_ip from specified network to given instance."""
- #NOTE(bcwaldon): We need to use the integer id since the
- # network manager doesn't support uuids
- instance_id = instance['id']
+ instance_uuid = instance['uuid']
self._cast_compute_message('remove_fixed_ip_from_instance',
context,
- instance_id,
+ instance_uuid,
params=dict(address=address))
#TODO(tr3buchet): how to run this in the correct zone?
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 006345b04..2eed738c1 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1196,15 +1196,16 @@ class ComputeManager(manager.SchedulerDependentManager):
{'status': 'finished', })
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
- @checks_instance_lock
- def add_fixed_ip_to_instance(self, context, instance_id, network_id):
+ @checks_instance_lock_uuid
+ def add_fixed_ip_to_instance(self, context, instance_uuid, network_id):
"""Calls network_api to add new fixed_ip to instance
then injects the new network info and resets instance networking.
"""
+ instance_ref = self.db.instance_get_by_uuid(context, instance_uuid)
+ instance_id = instance_ref['id']
self.network_api.add_fixed_ip_to_instance(context, instance_id,
self.host, network_id)
- instance_ref = self.db.instance_get(context, instance_id)
usage = utils.usage_from_instance(instance_ref)
notifier.notify('compute.%s' % self.host,
'compute.instance.create_ip',
@@ -1214,15 +1215,16 @@ class ComputeManager(manager.SchedulerDependentManager):
self.reset_network(context, instance_ref['uuid'])
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
- @checks_instance_lock
- def remove_fixed_ip_from_instance(self, context, instance_id, address):
+ @checks_instance_lock_uuid
+ def remove_fixed_ip_from_instance(self, context, instance_uuid, address):
"""Calls network_api to remove existing fixed_ip from instance
by injecting the altered network info and resetting
instance networking.
"""
+ instance_ref = self.db.instance_get_by_uuid(context, instance_uuid)
+ instance_id = instance_ref['id']
self.network_api.remove_fixed_ip_from_instance(context, instance_id,
address)
- instance_ref = self.db.instance_get(context, instance_id)
usage = utils.usage_from_instance(instance_ref)
notifier.notify('compute.%s' % self.host,
'compute.instance.delete_ip',