diff options
author | John Griffith <john.griffith@solidfire.com> | 2012-05-04 11:31:56 -0600 |
---|---|---|
committer | John Griffith <john.griffith@solidfire.com> | 2012-05-10 13:36:32 -0600 |
commit | dcad314fb9713104f0029311c43907e362ec6d49 (patch) | |
tree | 4e6fffab1e7f064e94cee264192d05269ad1c0d4 /nova/compute | |
parent | d9ed81222048f589b6863aaf2a99983ba5a3094f (diff) | |
download | nova-dcad314fb9713104f0029311c43907e362ec6d49.tar.gz nova-dcad314fb9713104f0029311c43907e362ec6d49.tar.xz nova-dcad314fb9713104f0029311c43907e362ec6d49.zip |
Remove instance Foreign Key in volumes table, replace with instance_uuid
* Remove the instance relationship and instance_id FK
* Add instance_uuuid column to volumes table
* Passed unit tests and devstack tests
Change-Id: Id598f1f1d7915d1af6bf3dd75e5819dce08aaa0f
Diffstat (limited to 'nova/compute')
-rw-r--r-- | nova/compute/api.py | 5 | ||||
-rw-r--r-- | nova/compute/manager.py | 9 |
2 files changed, 9 insertions, 5 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 32b7d79ce..5e1426fce 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1654,7 +1654,10 @@ class API(BaseAPI): # the volume ID via volume API and pass it and the volume object here def detach_volume(self, context, volume_id): """Detach a volume from an instance.""" - instance = self.db.volume_get_instance(context.elevated(), volume_id) + volume = self.volume_api.get(context, volume_id) + instance_uuid = volume['instance_uuid'] + instance = self.db.instance_get_by_uuid(context.elevated(), + instance_uuid) if not instance: raise exception.VolumeUnattached(volume_id=volume_id) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 382464e7d..d558144ed 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -67,7 +67,6 @@ from nova.openstack.common import importutils from nova import rpc from nova import utils from nova.virt import driver -from nova import vnc from nova import volume @@ -261,7 +260,6 @@ class ComputeManager(manager.SchedulerDependentManager): context = nova.context.get_admin_context() instances = self.db.instance_get_all_by_host(context, self.host) for instance in instances: - instance_uuid = instance['uuid'] db_state = instance['power_state'] drv_state = self._get_power_state(context, instance) @@ -1725,7 +1723,7 @@ class ComputeManager(manager.SchedulerDependentManager): connection_info = self.volume_api.initialize_connection(context, volume, connector) - self.volume_api.attach(context, volume, instance_id, mountpoint) + self.volume_api.attach(context, volume, instance_uuid, mountpoint) return connection_info @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @@ -1764,7 +1762,10 @@ class ComputeManager(manager.SchedulerDependentManager): volume, connector) - self.volume_api.attach(context, volume, instance_ref['id'], mountpoint) + self.volume_api.attach(context, + volume, + instance_ref['uuid'], + mountpoint) values = { 'instance_uuid': instance_ref['uuid'], 'connection_info': utils.dumps(connection_info), |