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
This commit is contained in:
@@ -26,7 +26,6 @@ SHOULD include dedicated exception logging.
|
||||
|
||||
import functools
|
||||
import itertools
|
||||
import sys
|
||||
|
||||
import webob.exc
|
||||
|
||||
@@ -420,6 +419,10 @@ class InvalidEc2Id(Invalid):
|
||||
message = _("Ec2 id %(ec2_id)s is unacceptable.")
|
||||
|
||||
|
||||
class InvalidUUID(Invalid):
|
||||
message = _("Expected a uuid but received %(uuid).")
|
||||
|
||||
|
||||
class NotFound(NovaException):
|
||||
message = _("Resource could not be found.")
|
||||
code = 404
|
||||
|
||||
@@ -477,7 +477,6 @@ class SchedulerTestCase(test.TestCase):
|
||||
instance = self._live_migration_instance()
|
||||
db.instance_get(self.context, instance['id']).AndReturn(instance)
|
||||
|
||||
# Source checks (volume and source compute are up)
|
||||
db.service_get_all_compute_by_host(self.context,
|
||||
instance['host']).AndReturn(['fake_service2'])
|
||||
utils.service_is_up('fake_service2').AndReturn(True)
|
||||
|
||||
@@ -1215,7 +1215,9 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
instance_dict)
|
||||
vol_dict = {'status': 'migrating', 'size': 1}
|
||||
volume_ref = db.volume_create(self.context, vol_dict)
|
||||
db.volume_attached(self.context, volume_ref['id'], instance_ref['id'],
|
||||
db.volume_attached(self.context,
|
||||
volume_ref['id'],
|
||||
instance_ref['uuid'],
|
||||
'/dev/fake')
|
||||
|
||||
# Preparing mocks
|
||||
|
||||
@@ -48,7 +48,9 @@ class VolumeTestCase(test.TestCase):
|
||||
self.flags(connection_type='fake')
|
||||
self.volume = importutils.import_object(FLAGS.volume_manager)
|
||||
self.context = context.get_admin_context()
|
||||
self.instance_id = db.instance_create(self.context, {})['id']
|
||||
instance = db.instance_create(self.context, {})
|
||||
self.instance_id = instance['id']
|
||||
self.instance_uuid = instance['uuid']
|
||||
|
||||
def tearDown(self):
|
||||
db.instance_destroy(self.context, self.instance_id)
|
||||
@@ -175,25 +177,26 @@ class VolumeTestCase(test.TestCase):
|
||||
inst['project_id'] = 'fake'
|
||||
inst['instance_type_id'] = '2' # m1.tiny
|
||||
inst['ami_launch_index'] = 0
|
||||
instance_id = db.instance_create(self.context, inst)['id']
|
||||
instance = db.instance_create(self.context, {})
|
||||
instance_id = instance['id']
|
||||
instance_uuid = instance['uuid']
|
||||
mountpoint = "/dev/sdf"
|
||||
volume = self._create_volume()
|
||||
volume_id = volume['id']
|
||||
self.volume.create_volume(self.context, volume_id)
|
||||
if FLAGS.fake_tests:
|
||||
db.volume_attached(self.context, volume_id, instance_id,
|
||||
db.volume_attached(self.context, volume_id, instance_uuid,
|
||||
mountpoint)
|
||||
else:
|
||||
self.compute.attach_volume(self.context,
|
||||
instance_id,
|
||||
instance_uuid,
|
||||
volume_id,
|
||||
mountpoint)
|
||||
vol = db.volume_get(context.get_admin_context(), volume_id)
|
||||
self.assertEqual(vol['status'], "in-use")
|
||||
self.assertEqual(vol['attach_status'], "attached")
|
||||
self.assertEqual(vol['mountpoint'], mountpoint)
|
||||
instance_ref = db.volume_get_instance(self.context, volume_id)
|
||||
self.assertEqual(instance_ref['id'], instance_id)
|
||||
self.assertEqual(vol['instance_uuid'], instance_uuid)
|
||||
|
||||
self.assertRaises(exception.NovaException,
|
||||
self.volume.delete_volume,
|
||||
@@ -203,7 +206,7 @@ class VolumeTestCase(test.TestCase):
|
||||
db.volume_detached(self.context, volume_id)
|
||||
else:
|
||||
self.compute.detach_volume(self.context,
|
||||
instance_id,
|
||||
instance_uuid,
|
||||
volume_id)
|
||||
vol = db.volume_get(self.context, volume_id)
|
||||
self.assertEqual(vol['status'], "available")
|
||||
@@ -323,7 +326,7 @@ class VolumeTestCase(test.TestCase):
|
||||
|
||||
volume = self._create_volume()
|
||||
self.volume.create_volume(self.context, volume['id'])
|
||||
db.volume_attached(self.context, volume['id'], self.instance_id,
|
||||
db.volume_attached(self.context, volume['id'], self.instance_uuid,
|
||||
'/dev/sda1')
|
||||
|
||||
volume_api = nova.volume.api.API()
|
||||
@@ -383,7 +386,9 @@ class DriverTestCase(test.TestCase):
|
||||
log.logger.addHandler(logging.logging.StreamHandler(self.stream))
|
||||
|
||||
inst = {}
|
||||
self.instance_id = db.instance_create(self.context, inst)['id']
|
||||
instance = db.instance_create(self.context, {})
|
||||
self.instance_id = instance['id']
|
||||
self.instance_uuid = instance['uuid']
|
||||
|
||||
def _attach_volume(self):
|
||||
"""Attach volumes to an instance. This function also sets
|
||||
@@ -436,7 +441,7 @@ class ISCSITestCase(DriverTestCase):
|
||||
|
||||
# each volume has a different mountpoint
|
||||
mountpoint = "/dev/sd" + chr((ord('b') + index))
|
||||
db.volume_attached(self.context, vol_ref['id'], self.instance_id,
|
||||
db.volume_attached(self.context, vol_ref['id'], self.instance_uuid,
|
||||
mountpoint)
|
||||
volume_id_list.append(vol_ref['id'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user