Fix invalid uuid warnings in virt testcases
Currently, unit testcases of virt emit FutureWarnings from oslo.versionedobjects about invalid uuids as documented here[1]. This commit changes these tests to use valid uuids so that when they are run these warnings are no longer emitted. Fake constants are defined for project_id and user_id as they are used without '-' at keystone side. [1] http://docs.openstack.org/developer/oslo.versionedobjects/api/fields.html#oslo_versionedobjects.fields.UUIDField Partial-Bug: #1557378 Change-Id: If69412eddb5e64cb8ccc5dce9176d19382c0b3f1
This commit is contained in:
parent
0f8b89c6bf
commit
7c10322b17
|
@ -17,6 +17,7 @@ from nova.compute import task_states
|
|||
from nova import exception
|
||||
from nova import objects
|
||||
from nova import test
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova import utils
|
||||
from nova.virt.libvirt.storage import rbd_utils
|
||||
from nova.virt.libvirt import utils as libvirt_utils
|
||||
|
@ -326,14 +327,16 @@ class RbdTestCase(test.NoDBTestCase):
|
|||
@mock.patch.object(rbd_utils, 'rados')
|
||||
@mock.patch.object(rbd_utils, 'RADOSClient')
|
||||
def test_cleanup_volumes(self, mock_client, mock_rados, mock_rbd):
|
||||
instance = objects.Instance(id=1, uuid='12345', task_state=None)
|
||||
instance = objects.Instance(id=1, uuid=uuids.instance,
|
||||
task_state=None)
|
||||
|
||||
rbd = mock_rbd.RBD.return_value
|
||||
rbd.list.return_value = ['12345_test', '111_test']
|
||||
rbd.list.return_value = ['%s_test' % uuids.instance, '111_test']
|
||||
|
||||
client = mock_client.return_value
|
||||
self.driver.cleanup_volumes(instance)
|
||||
rbd.remove.assert_called_once_with(client.ioctx, '12345_test')
|
||||
rbd.remove.assert_called_once_with(client.ioctx,
|
||||
'%s_test' % uuids.instance)
|
||||
client.__enter__.assert_called_once_with()
|
||||
client.__exit__.assert_called_once_with(None, None, None)
|
||||
|
||||
|
@ -342,17 +345,18 @@ class RbdTestCase(test.NoDBTestCase):
|
|||
@mock.patch.object(rbd_utils, 'RADOSClient')
|
||||
def _test_cleanup_exception(self, exception_name,
|
||||
mock_client, mock_rados, mock_rbd):
|
||||
instance = objects.Instance(id=1, uuid='12345', task_state=None)
|
||||
instance = objects.Instance(id=1, uuid=uuids.instance,
|
||||
task_state=None)
|
||||
|
||||
setattr(mock_rbd, exception_name, test.TestingException)
|
||||
rbd = mock_rbd.RBD.return_value
|
||||
rbd.remove.side_effect = test.TestingException
|
||||
rbd.list.return_value = ['12345_test', '111_test']
|
||||
rbd.list.return_value = ['%s_test' % uuids.instance, '111_test']
|
||||
|
||||
client = mock_client.return_value
|
||||
with mock.patch('eventlet.greenthread.sleep'):
|
||||
self.driver.cleanup_volumes(instance)
|
||||
rbd.remove.assert_any_call(client.ioctx, '12345_test')
|
||||
rbd.remove.assert_any_call(client.ioctx, '%s_test' % uuids.instance)
|
||||
# NOTE(danms): 10 retries + 1 final attempt to propagate = 11
|
||||
self.assertEqual(11, len(rbd.remove.call_args_list))
|
||||
|
||||
|
@ -372,12 +376,13 @@ class RbdTestCase(test.NoDBTestCase):
|
|||
@mock.patch.object(rbd_utils, 'RBDVolumeProxy')
|
||||
def test_cleanup_volumes_pending_resize(self, mock_proxy, mock_client,
|
||||
mock_rados, mock_rbd):
|
||||
instance = objects.Instance(id=1, uuid='12345', task_state=None)
|
||||
instance = objects.Instance(id=1, uuid=uuids.instance,
|
||||
task_state=None)
|
||||
|
||||
setattr(mock_rbd, 'ImageHasSnapshots', test.TestingException)
|
||||
rbd = mock_rbd.RBD.return_value
|
||||
rbd.remove.side_effect = [test.TestingException, None]
|
||||
rbd.list.return_value = ['12345_test', '111_test']
|
||||
rbd.list.return_value = ['%s_test' % uuids.instance, '111_test']
|
||||
proxy = mock_proxy.return_value
|
||||
proxy.__enter__.return_value = proxy
|
||||
proxy.list_snaps.return_value = [
|
||||
|
@ -385,7 +390,7 @@ class RbdTestCase(test.NoDBTestCase):
|
|||
client = mock_client.return_value
|
||||
self.driver.cleanup_volumes(instance)
|
||||
|
||||
remove_call = mock.call(client.ioctx, '12345_test')
|
||||
remove_call = mock.call(client.ioctx, '%s_test' % uuids.instance)
|
||||
rbd.remove.assert_has_calls([remove_call, remove_call])
|
||||
proxy.remove_snap.assert_called_once_with(
|
||||
libvirt_utils.RESIZE_SNAPSHOT_NAME)
|
||||
|
@ -397,17 +402,18 @@ class RbdTestCase(test.NoDBTestCase):
|
|||
@mock.patch.object(rbd_utils, 'RADOSClient')
|
||||
def test_cleanup_volumes_reverting_resize(self, mock_client, mock_rados,
|
||||
mock_rbd):
|
||||
instance = objects.Instance(id=1, uuid='12345',
|
||||
instance = objects.Instance(id=1, uuid=uuids.instance,
|
||||
task_state=task_states.RESIZE_REVERTING)
|
||||
|
||||
rbd = mock_rbd.RBD.return_value
|
||||
rbd.list.return_value = ['12345_test', '111_test',
|
||||
'12345_test_disk.local']
|
||||
rbd.list.return_value = ['%s_test' % uuids.instance, '111_test',
|
||||
'%s_test_disk.local' % uuids.instance]
|
||||
|
||||
client = mock_client.return_value
|
||||
self.driver.cleanup_volumes(instance)
|
||||
rbd.remove.assert_called_once_with(client.ioctx,
|
||||
'12345_test_disk.local')
|
||||
rbd.remove.assert_called_once_with(
|
||||
client.ioctx,
|
||||
'%s_test_disk.local' % uuids.instance)
|
||||
client.__enter__.assert_called_once_with()
|
||||
client.__exit__.assert_called_once_with(None, None, None)
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ from nova import test
|
|||
from nova.tests.unit import fake_block_device
|
||||
import nova.tests.unit.image.fake
|
||||
from nova.tests.unit.virt import fakelibosinfo
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova.virt import block_device as driver_block_device
|
||||
from nova.virt import driver
|
||||
from nova.virt.libvirt import blockinfo
|
||||
|
@ -878,7 +879,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
|
|||
def test_get_device_name(self):
|
||||
bdm_obj = objects.BlockDeviceMapping(self.context,
|
||||
**fake_block_device.FakeDbBlockDeviceDict(
|
||||
{'id': 3, 'instance_uuid': 'fake-instance',
|
||||
{'id': 3, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/vda',
|
||||
'source_type': 'volume',
|
||||
'destination_type': 'volume',
|
||||
|
@ -1050,7 +1051,7 @@ class DefaultDeviceNamesTestCase(test.NoDBTestCase):
|
|||
|
||||
self.ephemerals = [objects.BlockDeviceMapping(
|
||||
self.context, **fake_block_device.FakeDbBlockDeviceDict(
|
||||
{'id': 1, 'instance_uuid': 'fake-instance',
|
||||
{'id': 1, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/vdb',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
|
@ -1063,7 +1064,7 @@ class DefaultDeviceNamesTestCase(test.NoDBTestCase):
|
|||
|
||||
self.swap = [objects.BlockDeviceMapping(
|
||||
self.context, **fake_block_device.FakeDbBlockDeviceDict(
|
||||
{'id': 2, 'instance_uuid': 'fake-instance',
|
||||
{'id': 2, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/vdc',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
|
@ -1077,7 +1078,7 @@ class DefaultDeviceNamesTestCase(test.NoDBTestCase):
|
|||
self.block_device_mapping = [
|
||||
objects.BlockDeviceMapping(self.context,
|
||||
**fake_block_device.FakeDbBlockDeviceDict(
|
||||
{'id': 3, 'instance_uuid': 'fake-instance',
|
||||
{'id': 3, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/vda',
|
||||
'source_type': 'volume',
|
||||
'destination_type': 'volume',
|
||||
|
@ -1087,7 +1088,7 @@ class DefaultDeviceNamesTestCase(test.NoDBTestCase):
|
|||
'boot_index': 0})),
|
||||
objects.BlockDeviceMapping(self.context,
|
||||
**fake_block_device.FakeDbBlockDeviceDict(
|
||||
{'id': 4, 'instance_uuid': 'fake-instance',
|
||||
{'id': 4, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/vdd',
|
||||
'source_type': 'snapshot',
|
||||
'device_type': 'disk',
|
||||
|
@ -1097,7 +1098,7 @@ class DefaultDeviceNamesTestCase(test.NoDBTestCase):
|
|||
'boot_index': -1})),
|
||||
objects.BlockDeviceMapping(self.context,
|
||||
**fake_block_device.FakeDbBlockDeviceDict(
|
||||
{'id': 5, 'instance_uuid': 'fake-instance',
|
||||
{'id': 5, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/vde',
|
||||
'source_type': 'blank',
|
||||
'device_type': 'disk',
|
||||
|
|
|
@ -79,6 +79,7 @@ from nova.tests.unit.objects import test_pci_device
|
|||
from nova.tests.unit.objects import test_vcpu_model
|
||||
from nova.tests.unit.virt.libvirt import fake_libvirt_utils
|
||||
from nova.tests.unit.virt.libvirt import fakelibvirt
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova import utils
|
||||
from nova import version
|
||||
from nova.virt import block_device as driver_block_device
|
||||
|
@ -3550,7 +3551,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
</domain>
|
||||
"""
|
||||
dom = FakeVirtDomain(fake_xml=xml)
|
||||
instance.ephemeral_key_uuid = 'fake-id' # encrypted
|
||||
instance.ephemeral_key_uuid = uuids.ephemeral_key_uuid # encrypted
|
||||
|
||||
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
|
||||
|
@ -12817,7 +12818,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
|
||||
def test_default_root_device_name(self):
|
||||
instance = {'uuid': 'fake_instance'}
|
||||
image_meta = objects.ImageMeta.from_dict({'id': 'fake'})
|
||||
image_meta = objects.ImageMeta.from_dict({'id': uuids.image_id})
|
||||
root_bdm = {'source_type': 'image',
|
||||
'destination_type': 'volume',
|
||||
'image_id': 'fake_id'}
|
||||
|
@ -13038,7 +13039,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
self.flags(virt_type='lxc', group='libvirt')
|
||||
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
instance = objects.Instance(id=1, uuid='fake-uuid',
|
||||
instance = objects.Instance(id=1, uuid=uuids.instance,
|
||||
image_ref='my_fake_image')
|
||||
|
||||
with test.nested(
|
||||
|
@ -13456,7 +13457,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
|
||||
bdm = objects.BlockDeviceMapping(self.context,
|
||||
**fake_block_device.FakeDbBlockDeviceDict(
|
||||
{'id': 2, 'instance_uuid': 'fake-instance',
|
||||
{'id': 2, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/vdb',
|
||||
'source_type': 'volume',
|
||||
'destination_type': 'volume',
|
||||
|
@ -13939,7 +13940,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
inst['id'] = 1
|
||||
inst['uuid'] = '52d3b512-1152-431f-a8f7-28f0288a622b'
|
||||
inst['os_type'] = 'linux'
|
||||
inst['image_ref'] = '1'
|
||||
inst['image_ref'] = uuids.fake_image_ref
|
||||
inst['reservation_id'] = 'r-fakeres'
|
||||
inst['user_id'] = 'fake'
|
||||
inst['project_id'] = 'fake'
|
||||
|
@ -14927,13 +14928,13 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
@mock.patch('os.path.exists')
|
||||
@mock.patch.object(lvm, 'list_volumes')
|
||||
def test_lvm_disks(self, listlvs, exists):
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
self.flags(images_volume_group='vols', group='libvirt')
|
||||
exists.return_value = True
|
||||
listlvs.return_value = ['fake-uuid_foo',
|
||||
listlvs.return_value = ['%s_foo' % uuids.instance,
|
||||
'other-uuid_foo']
|
||||
disks = self.drvr._lvm_disks(instance)
|
||||
self.assertEqual(['/dev/vols/fake-uuid_foo'], disks)
|
||||
self.assertEqual(['/dev/vols/%s_foo' % uuids.instance], disks)
|
||||
|
||||
def test_is_booted_from_volume(self):
|
||||
func = libvirt_driver.LibvirtDriver._is_booted_from_volume
|
||||
|
@ -15218,7 +15219,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
).AndReturn(mock_backend.root)
|
||||
|
||||
image_meta = objects.ImageMeta.from_dict(
|
||||
{'id': 'fake', 'name': 'fake'})
|
||||
{'id': uuids.image_id, 'name': 'fake'})
|
||||
self.drvr._get_guest_xml(mox.IgnoreArg(), instance,
|
||||
network_info, mox.IgnoreArg(),
|
||||
image_meta,
|
||||
|
@ -15255,7 +15256,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
"</devices></domain>")
|
||||
|
||||
mock_get_instance_path.return_value = '/path'
|
||||
instance = objects.Instance(uuid='fake=uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
fake_dom = FakeVirtDomain(fake_xml=dummyxml)
|
||||
mock_get_domain.return_value = fake_dom
|
||||
mock_load_file.return_value = "fake_unrescue_xml"
|
||||
|
@ -15336,7 +15337,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
extra_md=mox.IgnoreArg(),
|
||||
network_info=mox.IgnoreArg())
|
||||
image_meta = objects.ImageMeta.from_dict(
|
||||
{'id': 'fake', 'name': 'fake'})
|
||||
{'id': uuids.image_id, 'name': 'fake'})
|
||||
self.drvr._get_guest_xml(mox.IgnoreArg(), instance,
|
||||
network_info, mox.IgnoreArg(),
|
||||
image_meta,
|
||||
|
@ -15374,7 +15375,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
def test_delete_instance_files(self, get_instance_path, exists, exe,
|
||||
shutil):
|
||||
get_instance_path.return_value = '/path'
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
exists.side_effect = [False, False, True, False]
|
||||
|
||||
|
@ -15392,7 +15393,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
def test_delete_instance_files_kill_running(
|
||||
self, get_instance_path, kill, exists, exe, shutil):
|
||||
get_instance_path.return_value = '/path'
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
self.drvr.job_tracker.jobs[instance.uuid] = [3, 4]
|
||||
|
||||
exists.side_effect = [False, False, True, False]
|
||||
|
@ -15413,7 +15414,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
def test_delete_instance_files_resize(self, get_instance_path, exists,
|
||||
exe, shutil):
|
||||
get_instance_path.return_value = '/path'
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
nova.utils.execute.side_effect = [Exception(), None]
|
||||
exists.side_effect = [False, False, True, False]
|
||||
|
@ -15433,7 +15434,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
def test_delete_instance_files_failed(self, get_instance_path, exists, exe,
|
||||
shutil):
|
||||
get_instance_path.return_value = '/path'
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
exists.side_effect = [False, False, True, True]
|
||||
|
||||
|
@ -15450,7 +15451,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
def test_delete_instance_files_mv_failed(self, get_instance_path, exists,
|
||||
exe, shutil):
|
||||
get_instance_path.return_value = '/path'
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
nova.utils.execute.side_effect = Exception()
|
||||
exists.side_effect = [True, True]
|
||||
|
@ -15469,7 +15470,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
def test_delete_instance_files_resume(self, get_instance_path, exists,
|
||||
exe, shutil):
|
||||
get_instance_path.return_value = '/path'
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
nova.utils.execute.side_effect = Exception()
|
||||
exists.side_effect = [False, False, True, False]
|
||||
|
@ -15488,7 +15489,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
def test_delete_instance_files_none(self, get_instance_path, exists,
|
||||
exe, shutil):
|
||||
get_instance_path.return_value = '/path'
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
nova.utils.execute.side_effect = Exception()
|
||||
exists.side_effect = [False, False, False, False]
|
||||
|
@ -15508,7 +15509,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
def test_delete_instance_files_concurrent(self, get_instance_path, exists,
|
||||
exe, shutil):
|
||||
get_instance_path.return_value = '/path'
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
nova.utils.execute.side_effect = [Exception(), Exception(), None]
|
||||
exists.side_effect = [False, False, True, False]
|
||||
|
@ -15590,13 +15591,13 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
def test_instance_on_disk(self):
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
self.assertFalse(drvr.instance_on_disk(instance))
|
||||
|
||||
def test_instance_on_disk_rbd(self):
|
||||
self.flags(images_type='rbd', group='libvirt')
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
self.assertTrue(drvr.instance_on_disk(instance))
|
||||
|
||||
def test_get_disk_xml(self):
|
||||
|
@ -15681,8 +15682,9 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
mock_unfilter, mock_delete_volume,
|
||||
mock_get_guest, mock_get_size):
|
||||
drv = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1,
|
||||
ephemeral_key_uuid='000-000-000')
|
||||
instance = objects.Instance(
|
||||
uuid=uuids.instance, id=1,
|
||||
ephemeral_key_uuid=uuids.ephemeral_key_uuid)
|
||||
instance.system_metadata = {}
|
||||
block_device_info = {'root_device_name': '/dev/vda',
|
||||
'ephemerals': [],
|
||||
|
@ -15715,8 +15717,9 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
encrypted=False):
|
||||
|
||||
drv = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1,
|
||||
ephemeral_key_uuid='000-000-000')
|
||||
instance = objects.Instance(
|
||||
uuid=uuids.instance, id=1,
|
||||
ephemeral_key_uuid=uuids.ephemeral_key_uuid)
|
||||
block_device_info = {'root_device_name': '/dev/vda',
|
||||
'ephemerals': [],
|
||||
'block_device_mapping': []}
|
||||
|
@ -15775,7 +15778,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
def test_trigger_crash_dump(self):
|
||||
mock_guest = mock.Mock(libvirt_guest.Guest, id=1)
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
with mock.patch.object(self.drvr._host, 'get_guest',
|
||||
return_value=mock_guest):
|
||||
|
@ -15789,7 +15792,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
mock_guest = mock.Mock(libvirt_guest.Guest, id=1)
|
||||
mock_guest.inject_nmi = mock.Mock(side_effect=ex)
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
with mock.patch.object(self.drvr._host, 'get_guest',
|
||||
return_value=mock_guest):
|
||||
|
@ -15804,7 +15807,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
mock_guest = mock.Mock(libvirt_guest.Guest, id=1)
|
||||
mock_guest.inject_nmi = mock.Mock(side_effect=ex)
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
with mock.patch.object(self.drvr._host, 'get_guest',
|
||||
return_value=mock_guest):
|
||||
|
@ -15819,7 +15822,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
mock_guest = mock.Mock(libvirt_guest.Guest, id=1)
|
||||
mock_guest.inject_nmi = mock.Mock(side_effect=ex)
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
instance = objects.Instance(uuid=uuids.instance, id=1)
|
||||
|
||||
with mock.patch.object(self.drvr._host, 'get_guest',
|
||||
return_value=mock_guest):
|
||||
|
@ -16054,7 +16057,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase):
|
|||
instance = objects.Instance(**self.inst)
|
||||
fake_bdm = fake_block_device.FakeDbBlockDeviceDict({
|
||||
'id': 123,
|
||||
'instance_uuid': 'fake-instance',
|
||||
'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/sdb',
|
||||
'source_type': 'volume',
|
||||
'destination_type': 'volume',
|
||||
|
|
|
@ -30,6 +30,7 @@ from nova import objects
|
|||
from nova import test
|
||||
from nova.tests.unit import fake_network
|
||||
from nova.tests.unit.virt.libvirt import fakelibvirt
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova.virt.libvirt import firewall
|
||||
from nova.virt.libvirt import host
|
||||
from nova.virt import netutils
|
||||
|
@ -378,8 +379,8 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
|
|||
self.fw.do_refresh_security_group_rules("fake")
|
||||
|
||||
def test_do_refresh_security_group_rules_instance_gone(self):
|
||||
instance1 = objects.Instance(None, id=1, uuid='fake-uuid1')
|
||||
instance2 = objects.Instance(None, id=2, uuid='fake-uuid2')
|
||||
instance1 = objects.Instance(None, id=1, uuid=uuids.instance_1)
|
||||
instance2 = objects.Instance(None, id=2, uuid=uuids.instance_2)
|
||||
self.fw.instance_info = {1: (instance1, 'netinfo1'),
|
||||
2: (instance2, 'netinfo2')}
|
||||
mock_filter = mock.MagicMock()
|
||||
|
|
|
@ -32,6 +32,7 @@ from nova import context
|
|||
from nova import objects
|
||||
from nova import test
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova import utils
|
||||
from nova.virt.libvirt import imagecache
|
||||
from nova.virt.libvirt import utils as libvirt_utils
|
||||
|
@ -584,7 +585,7 @@ class ImageCacheManagerTestCase(test.NoDBTestCase):
|
|||
instances = [{'image_ref': '1',
|
||||
'host': CONF.host,
|
||||
'name': 'instance-1',
|
||||
'uuid': '123',
|
||||
'uuid': uuids.instance_1,
|
||||
'vm_state': '',
|
||||
'task_state': ''},
|
||||
{'image_ref': '1',
|
||||
|
@ -592,7 +593,7 @@ class ImageCacheManagerTestCase(test.NoDBTestCase):
|
|||
'ramdisk_id': '22',
|
||||
'host': CONF.host,
|
||||
'name': 'instance-2',
|
||||
'uuid': '456',
|
||||
'uuid': uuids.instance_2,
|
||||
'vm_state': '',
|
||||
'task_state': ''}]
|
||||
all_instances = [fake_instance.fake_instance_obj(None, **instance)
|
||||
|
@ -637,7 +638,7 @@ class ImageCacheManagerTestCase(test.NoDBTestCase):
|
|||
|
||||
ctxt = context.get_admin_context()
|
||||
objects.block_device.BlockDeviceMappingList.bdms_by_instance_uuid(
|
||||
ctxt, ['123', '456']).AndReturn({})
|
||||
ctxt, [uuids.instance_1, uuids.instance_2]).AndReturn({})
|
||||
|
||||
self.mox.ReplayAll()
|
||||
# And finally we can make the call we're actually testing...
|
||||
|
@ -687,12 +688,13 @@ class ImageCacheManagerTestCase(test.NoDBTestCase):
|
|||
was['called'] = True
|
||||
instances = []
|
||||
for x in range(2):
|
||||
instances.append(fake_instance.fake_db_instance(
|
||||
image_ref='1',
|
||||
uuid=x,
|
||||
name=x,
|
||||
vm_state='',
|
||||
task_state=''))
|
||||
instances.append(
|
||||
fake_instance.fake_db_instance(
|
||||
image_ref=uuids.fake_image_ref,
|
||||
uuid=getattr(uuids, 'instance_%s' % x),
|
||||
name='instance-%s' % x,
|
||||
vm_state='',
|
||||
task_state=''))
|
||||
return instances
|
||||
|
||||
with utils.tempdir() as tmpdir:
|
||||
|
|
|
@ -29,6 +29,7 @@ from nova import exception
|
|||
from nova import objects
|
||||
from nova import test
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova import utils
|
||||
from nova.virt.disk import api as disk
|
||||
from nova.virt import images
|
||||
|
@ -674,7 +675,7 @@ disk size: 4.4M
|
|||
|
||||
def test_get_instance_path_at_destination(self):
|
||||
instance = fake_instance.fake_instance_obj(None, name='fake_inst',
|
||||
uuid='fake_uuid')
|
||||
uuid=uuids.instance)
|
||||
|
||||
migrate_data = None
|
||||
inst_path_at_dest = libvirt_utils.get_instance_path_at_destination(
|
||||
|
|
|
@ -25,6 +25,7 @@ from nova import test
|
|||
from nova.tests.unit import fake_block_device
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests.unit import matchers
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova.virt import block_device as driver_block_device
|
||||
from nova.virt import driver
|
||||
from nova.volume import cinder
|
||||
|
@ -42,7 +43,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
}
|
||||
|
||||
swap_bdm_dict = block_device.BlockDeviceDict(
|
||||
{'id': 1, 'instance_uuid': 'fake-instance',
|
||||
{'id': 1, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/sdb1',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
|
@ -62,7 +63,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
'swap_size': 2}
|
||||
|
||||
ephemeral_bdm_dict = block_device.BlockDeviceDict(
|
||||
{'id': 2, 'instance_uuid': 'fake-instance',
|
||||
{'id': 2, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/sdc1',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
|
@ -87,7 +88,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
'num': 0}
|
||||
|
||||
volume_bdm_dict = block_device.BlockDeviceDict(
|
||||
{'id': 3, 'instance_uuid': 'fake-instance',
|
||||
{'id': 3, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/sda1',
|
||||
'source_type': 'volume',
|
||||
'disk_bus': 'scsi',
|
||||
|
@ -115,7 +116,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
'delete_on_termination': False}
|
||||
|
||||
snapshot_bdm_dict = block_device.BlockDeviceDict(
|
||||
{'id': 4, 'instance_uuid': 'fake-instance',
|
||||
{'id': 4, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/sda2',
|
||||
'delete_on_termination': True,
|
||||
'volume_size': 3,
|
||||
|
@ -143,7 +144,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
'delete_on_termination': True}
|
||||
|
||||
image_bdm_dict = block_device.BlockDeviceDict(
|
||||
{'id': 5, 'instance_uuid': 'fake-instance',
|
||||
{'id': 5, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/sda2',
|
||||
'delete_on_termination': True,
|
||||
'volume_size': 1,
|
||||
|
@ -171,7 +172,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
'delete_on_termination': True}
|
||||
|
||||
blank_bdm_dict = block_device.BlockDeviceDict(
|
||||
{'id': 6, 'instance_uuid': 'fake-instance',
|
||||
{'id': 6, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/sda2',
|
||||
'delete_on_termination': True,
|
||||
'volume_size': 3,
|
||||
|
@ -394,7 +395,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
lambda: elevated_context)
|
||||
self.mox.StubOutWithMock(driver_bdm._bdm_obj, 'save')
|
||||
self.mox.StubOutWithMock(encryptors, 'get_encryption_metadata')
|
||||
instance_detail = {'id': '123', 'uuid': 'fake_uuid',
|
||||
instance_detail = {'id': '123', 'uuid': uuids.uuid,
|
||||
'availability_zone': availability_zone}
|
||||
instance = fake_instance.fake_instance_obj(self.context,
|
||||
**instance_detail)
|
||||
|
@ -449,11 +450,11 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
driver_bdm._bdm_obj.save().AndReturn(None)
|
||||
if not fail_volume_attach:
|
||||
self.volume_api.attach(elevated_context, fake_volume['id'],
|
||||
'fake_uuid', bdm_dict['device_name'],
|
||||
uuids.uuid, bdm_dict['device_name'],
|
||||
mode=access_mode).AndReturn(None)
|
||||
else:
|
||||
self.volume_api.attach(elevated_context, fake_volume['id'],
|
||||
'fake_uuid', bdm_dict['device_name'],
|
||||
uuids.uuid, bdm_dict['device_name'],
|
||||
mode=access_mode).AndRaise(
|
||||
test.TestingException)
|
||||
if driver_attach:
|
||||
|
@ -613,7 +614,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
test_bdm = self.driver_classes['snapshot'](
|
||||
self.snapshot_bdm)
|
||||
|
||||
instance = {'id': 'fake_id', 'uuid': 'fake_uuid'}
|
||||
instance = {'id': 'fake_id', 'uuid': uuids.uuid}
|
||||
connector = {'ip': 'fake_ip', 'host': 'fake_host'}
|
||||
connection_info = {'data': {'multipath_id': 'fake_multipath_id'}}
|
||||
expected_conn_info = {'data': {'multipath_id': 'fake_multipath_id'},
|
||||
|
@ -705,7 +706,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
'attach_status': 'detached'}
|
||||
|
||||
instance = fake_instance.fake_instance_obj(mock.sentinel.ctx,
|
||||
**{'uuid': 'fake-uuid'})
|
||||
**{'uuid': uuids.uuid})
|
||||
with test.nested(
|
||||
mock.patch.object(self.volume_api, 'get_snapshot',
|
||||
return_value=snapshot),
|
||||
|
@ -735,7 +736,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
test_bdm = self.driver_classes['snapshot'](
|
||||
self.snapshot_bdm)
|
||||
|
||||
instance = {'id': 'fake_id', 'uuid': 'fake_uuid'}
|
||||
instance = {'id': 'fake_id', 'uuid': uuids.uuid}
|
||||
|
||||
volume_class = self.driver_classes['volume']
|
||||
self.mox.StubOutWithMock(volume_class, 'attach')
|
||||
|
@ -817,7 +818,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
'attach_status': 'detached'}
|
||||
|
||||
instance = fake_instance.fake_instance_obj(mock.sentinel.ctx,
|
||||
**{'uuid': 'fake-uuid'})
|
||||
**{'uuid': uuids.uuid})
|
||||
with test.nested(
|
||||
mock.patch.object(self.volume_api, 'create', return_value=volume),
|
||||
mock.patch.object(self.volume_api, 'delete'),
|
||||
|
@ -844,7 +845,7 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
test_bdm = self.driver_classes['image'](
|
||||
self.image_bdm)
|
||||
|
||||
instance = {'id': 'fake_id', 'uuid': 'fake_uuid'}
|
||||
instance = {'id': 'fake_id', 'uuid': uuids.uuid}
|
||||
|
||||
volume_class = self.driver_classes['volume']
|
||||
self.mox.StubOutWithMock(volume_class, 'attach')
|
||||
|
@ -869,9 +870,9 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
fake_block_device.fake_bdm_object(
|
||||
self.context, no_blank_volume))
|
||||
instance = fake_instance.fake_instance_obj(mock.sentinel.ctx,
|
||||
**{'uuid': 'fake-uuid'})
|
||||
**{'uuid': uuids.uuid})
|
||||
volume = {'id': 'fake-volume-id-2',
|
||||
'display_name': 'fake-uuid-blank-vol'}
|
||||
'display_name': '%s-blank-vol' % uuids.uuid}
|
||||
|
||||
with test.nested(
|
||||
mock.patch.object(self.volume_api, 'create', return_value=volume),
|
||||
|
@ -891,7 +892,8 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
wait_func=wait_func)
|
||||
|
||||
vol_create.assert_called_once_with(
|
||||
self.context, test_bdm.volume_size, 'fake-uuid-blank-vol',
|
||||
self.context, test_bdm.volume_size,
|
||||
'%s-blank-vol' % uuids.uuid,
|
||||
'', availability_zone=None)
|
||||
vol_delete.assert_called_once_with(
|
||||
self.context, volume['id'])
|
||||
|
@ -903,10 +905,10 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
fake_block_device.fake_bdm_object(
|
||||
self.context, no_blank_volume))
|
||||
instance = fake_instance.fake_instance_obj(mock.sentinel.ctx,
|
||||
**{'uuid': 'fake-uuid'})
|
||||
**{'uuid': uuids.uuid})
|
||||
volume_class = self.driver_classes['volume']
|
||||
volume = {'id': 'fake-volume-id-2',
|
||||
'display_name': 'fake-uuid-blank-vol'}
|
||||
'display_name': '%s-blank-vol' % uuids.uuid}
|
||||
|
||||
with test.nested(
|
||||
mock.patch.object(self.volume_api, 'create', return_value=volume),
|
||||
|
@ -916,7 +918,8 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
self.virt_driver)
|
||||
|
||||
vol_create.assert_called_once_with(
|
||||
self.context, test_bdm.volume_size, 'fake-uuid-blank-vol',
|
||||
self.context, test_bdm.volume_size,
|
||||
'%s-blank-vol' % uuids.uuid,
|
||||
'', availability_zone=None)
|
||||
vol_attach.assert_called_once_with(self.context, instance,
|
||||
self.volume_api,
|
||||
|
@ -933,12 +936,12 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
test_bdm = self.driver_classes['blank'](
|
||||
fake_block_device.fake_bdm_object(
|
||||
self.context, no_blank_volume))
|
||||
updates = {'uuid': 'fake-uuid', 'availability_zone': 'test-az'}
|
||||
updates = {'uuid': uuids.uuid, 'availability_zone': 'test-az'}
|
||||
instance = fake_instance.fake_instance_obj(mock.sentinel.ctx,
|
||||
**updates)
|
||||
volume_class = self.driver_classes['volume']
|
||||
volume = {'id': 'fake-volume-id-2',
|
||||
'display_name': 'fake-uuid-blank-vol'}
|
||||
'display_name': '%s-blank-vol' % uuids.uuid}
|
||||
|
||||
with mock.patch.object(self.volume_api, 'create',
|
||||
return_value=volume) as vol_create:
|
||||
|
@ -947,7 +950,8 @@ class TestDriverBlockDevice(test.NoDBTestCase):
|
|||
self.virt_driver)
|
||||
|
||||
vol_create.assert_called_once_with(
|
||||
self.context, test_bdm.volume_size, 'fake-uuid-blank-vol',
|
||||
self.context, test_bdm.volume_size,
|
||||
'%s-blank-vol' % uuids.uuid,
|
||||
'', availability_zone='test-az')
|
||||
vol_attach.assert_called_once_with(self.context, instance,
|
||||
self.volume_api,
|
||||
|
|
|
@ -26,6 +26,7 @@ from nova.objects import base as base_obj
|
|||
from nova.objects import fields
|
||||
from nova.pci import stats
|
||||
from nova import test
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova.virt import hardware as hw
|
||||
|
||||
|
||||
|
@ -1712,7 +1713,7 @@ class HelperMethodsTestCase(test.NoDBTestCase):
|
|||
siblings=[], pinned_cpus=set([])),
|
||||
])
|
||||
self.instancetopo = objects.InstanceNUMATopology(
|
||||
instance_uuid='fake-uuid',
|
||||
instance_uuid=uuids.instance,
|
||||
cells=[
|
||||
objects.InstanceNUMACell(
|
||||
id=0, cpuset=set([0, 1]), memory=256, pagesize=2048,
|
||||
|
|
|
@ -20,12 +20,13 @@ from nova import objects
|
|||
from nova.objects import block_device as block_device_obj
|
||||
from nova import test
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova.virt import imagecache
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
swap_bdm_128 = [block_device.BlockDeviceDict(
|
||||
{'id': 1, 'instance_uuid': 'fake-instance',
|
||||
{'id': 1, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/sdb1',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
|
@ -36,7 +37,7 @@ swap_bdm_128 = [block_device.BlockDeviceDict(
|
|||
'boot_index': -1})]
|
||||
|
||||
swap_bdm_256 = [block_device.BlockDeviceDict(
|
||||
{'id': 1, 'instance_uuid': 'fake-instance',
|
||||
{'id': 1, 'instance_uuid': uuids.instance,
|
||||
'device_name': '/dev/sdb1',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
|
@ -73,13 +74,13 @@ class ImageCacheManagerTests(test.NoDBTestCase):
|
|||
instances = [{'image_ref': '1',
|
||||
'host': CONF.host,
|
||||
'id': '1',
|
||||
'uuid': '123',
|
||||
'uuid': uuids.instance_1,
|
||||
'vm_state': '',
|
||||
'task_state': ''},
|
||||
{'image_ref': '2',
|
||||
'host': CONF.host,
|
||||
'id': '2',
|
||||
'uuid': '456',
|
||||
'uuid': uuids.instance_2,
|
||||
'vm_state': '',
|
||||
'task_state': ''},
|
||||
{'image_ref': '2',
|
||||
|
@ -87,7 +88,7 @@ class ImageCacheManagerTests(test.NoDBTestCase):
|
|||
'ramdisk_id': '22',
|
||||
'host': 'remotehost',
|
||||
'id': '3',
|
||||
'uuid': '789',
|
||||
'uuid': uuids.instance_3,
|
||||
'vm_state': '',
|
||||
'task_state': ''}]
|
||||
|
||||
|
@ -105,9 +106,10 @@ class ImageCacheManagerTests(test.NoDBTestCase):
|
|||
swap_bdm_128_list = block_device_obj.block_device_make_list_from_dicts(
|
||||
ctxt, swap_bdm_128)
|
||||
objects.block_device.BlockDeviceMappingList.bdms_by_instance_uuid(
|
||||
ctxt, ['123', '456', '789']).AndReturn({'123': swap_bdm_256_list,
|
||||
'456': swap_bdm_128_list,
|
||||
'789': swap_bdm_128_list})
|
||||
ctxt, [uuids.instance_1, uuids.instance_2, uuids.instance_3]
|
||||
).AndReturn({uuids.instance_1: swap_bdm_256_list,
|
||||
uuids.instance_2: swap_bdm_128_list,
|
||||
uuids.instance_3: swap_bdm_128_list})
|
||||
self.mox.ReplayAll()
|
||||
|
||||
# The argument here should be a context, but it's mocked out
|
||||
|
@ -126,7 +128,7 @@ class ImageCacheManagerTests(test.NoDBTestCase):
|
|||
running['used_images']['22'])
|
||||
|
||||
self.assertIn('instance-00000001', running['instance_names'])
|
||||
self.assertIn('123', running['instance_names'])
|
||||
self.assertIn(uuids.instance_1, running['instance_names'])
|
||||
|
||||
self.assertEqual(len(running['used_swap_images']), 2)
|
||||
self.assertIn('swap_128', running['used_swap_images'])
|
||||
|
@ -136,7 +138,7 @@ class ImageCacheManagerTests(test.NoDBTestCase):
|
|||
instances = [{'image_ref': '1',
|
||||
'host': CONF.host,
|
||||
'id': '1',
|
||||
'uuid': '123',
|
||||
'uuid': uuids.instance,
|
||||
'vm_state': vm_states.RESIZED,
|
||||
'task_state': None}]
|
||||
|
||||
|
@ -151,7 +153,7 @@ class ImageCacheManagerTests(test.NoDBTestCase):
|
|||
bdms = block_device_obj.block_device_make_list_from_dicts(
|
||||
ctxt, swap_bdm_256)
|
||||
objects.block_device.BlockDeviceMappingList.bdms_by_instance_uuid(
|
||||
ctxt, ['123']).AndReturn({'123': bdms})
|
||||
ctxt, [uuids.instance]).AndReturn({uuids.instance: bdms})
|
||||
|
||||
self.mox.ReplayAll()
|
||||
running = image_cache_manager._list_running_instances(ctxt,
|
||||
|
@ -160,6 +162,7 @@ class ImageCacheManagerTests(test.NoDBTestCase):
|
|||
self.assertEqual(1, len(running['used_images']))
|
||||
self.assertEqual((1, 0, ['instance-00000001']),
|
||||
running['used_images']['1'])
|
||||
self.assertEqual(set(['instance-00000001', '123',
|
||||
'instance-00000001_resize', '123_resize']),
|
||||
self.assertEqual(set(['instance-00000001', uuids.instance,
|
||||
'instance-00000001_resize',
|
||||
'%s_resize' % uuids.instance]),
|
||||
running['instance_names'])
|
||||
|
|
|
@ -42,6 +42,7 @@ from nova.tests.unit import fake_instance
|
|||
from nova.tests.unit.objects import test_flavor
|
||||
from nova.tests.unit.virt.xenapi import stubs
|
||||
from nova.tests.unit.virt.xenapi import test_xenapi
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova import utils
|
||||
from nova.virt import hardware
|
||||
from nova.virt.xenapi.client import session as xenapi_session
|
||||
|
@ -1561,7 +1562,7 @@ class CreateVmTestCase(VMUtilsTestBase):
|
|||
def test_vss_provider(self, mock_extract):
|
||||
self.flags(vcpu_pin_set="2,3")
|
||||
session = _get_fake_session()
|
||||
instance = objects.Instance(uuid="uuid",
|
||||
instance = objects.Instance(uuid=uuids.nova_uuid,
|
||||
os_type="windows",
|
||||
system_metadata={})
|
||||
|
||||
|
@ -1593,7 +1594,7 @@ class CreateVmTestCase(VMUtilsTestBase):
|
|||
'PV_ramdisk': '',
|
||||
'PV_bootloader_args': '',
|
||||
'PCI_bus': '',
|
||||
'other_config': {'nova_uuid': 'uuid'},
|
||||
'other_config': {'nova_uuid': uuids.nova_uuid},
|
||||
'name_label': 'label',
|
||||
'actions_after_reboot': 'restart',
|
||||
'VCPUs_at_startup': '4',
|
||||
|
@ -2220,13 +2221,13 @@ class DeviceIdTestCase(VMUtilsTestBase):
|
|||
class CreateVmRecordTestCase(VMUtilsTestBase):
|
||||
@mock.patch.object(flavors, 'extract_flavor')
|
||||
def test_create_vm_record_linux(self, mock_extract_flavor):
|
||||
instance = objects.Instance(uuid="uuid123",
|
||||
instance = objects.Instance(uuid=uuids.nova_uuid,
|
||||
os_type="linux")
|
||||
self._test_create_vm_record(mock_extract_flavor, instance, False)
|
||||
|
||||
@mock.patch.object(flavors, 'extract_flavor')
|
||||
def test_create_vm_record_windows(self, mock_extract_flavor):
|
||||
instance = objects.Instance(uuid="uuid123",
|
||||
instance = objects.Instance(uuid=uuids.nova_uuid,
|
||||
os_type="windows")
|
||||
with mock.patch.object(instance, 'get_flavor') as get:
|
||||
get.return_value = objects.Flavor._from_db_object(
|
||||
|
@ -2271,7 +2272,7 @@ class CreateVmRecordTestCase(VMUtilsTestBase):
|
|||
'PV_ramdisk': '',
|
||||
'PV_bootloader_args': '',
|
||||
'PCI_bus': '',
|
||||
'other_config': {'nova_uuid': 'uuid123'},
|
||||
'other_config': {'nova_uuid': uuids.nova_uuid},
|
||||
'name_label': 'name',
|
||||
'actions_after_reboot': 'restart',
|
||||
'VCPUs_at_startup': '1',
|
||||
|
|
|
@ -33,6 +33,7 @@ from nova import test
|
|||
from nova.tests.unit import fake_flavor
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests.unit.virt.xenapi import stubs
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova import utils
|
||||
from nova.virt import fake
|
||||
from nova.virt.xenapi import agent as xenapi_agent
|
||||
|
@ -334,7 +335,7 @@ class SpawnTestCase(VMOpsTestBase):
|
|||
name_label = name_label_param
|
||||
if name_label is None:
|
||||
name_label = "dummy"
|
||||
image_meta = objects.ImageMeta.from_dict({"id": "image_id"})
|
||||
image_meta = objects.ImageMeta.from_dict({"id": uuids.image_id})
|
||||
context = "context"
|
||||
session = self.vmops._session
|
||||
injected_files = "fake_files"
|
||||
|
@ -524,7 +525,7 @@ class SpawnTestCase(VMOpsTestBase):
|
|||
"root_device_name": "/dev/xvda"}
|
||||
disk_info = "disk_info"
|
||||
network_info = "net_info"
|
||||
image_meta = objects.ImageMeta.from_dict({"id": "image_id"})
|
||||
image_meta = objects.ImageMeta.from_dict({"id": uuids.image_id})
|
||||
block_device_info = {}
|
||||
import_root = True
|
||||
if booted_from_volume:
|
||||
|
@ -1107,7 +1108,7 @@ class CreateVMRecordTestCase(VMOpsTestBase):
|
|||
mock_get_vm_device_id, mock_determine_vm_mode):
|
||||
|
||||
context = "context"
|
||||
instance = objects.Instance(vm_mode="vm_mode", uuid="uuid123")
|
||||
instance = objects.Instance(vm_mode="vm_mode", uuid=uuids.instance)
|
||||
name_label = "dummy"
|
||||
disk_image_type = "vhd"
|
||||
kernel_file = "kernel"
|
||||
|
|
|
@ -48,6 +48,7 @@ from nova import exception
|
|||
from nova import objects
|
||||
from nova.objects import base
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit.db import fakes as db_fakes
|
||||
from nova.tests.unit import fake_flavor
|
||||
from nova.tests.unit import fake_instance
|
||||
|
@ -58,6 +59,7 @@ from nova.tests.unit import matchers
|
|||
from nova.tests.unit.objects import test_aggregate
|
||||
from nova.tests.unit import utils as test_utils
|
||||
from nova.tests.unit.virt.xenapi import stubs
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova.virt import fake
|
||||
from nova.virt.xenapi import agent
|
||||
from nova.virt.xenapi.client import session as xenapi_session
|
||||
|
@ -75,14 +77,14 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
IMAGE_MACHINE = '1'
|
||||
IMAGE_KERNEL = '2'
|
||||
IMAGE_RAMDISK = '3'
|
||||
IMAGE_RAW = '4'
|
||||
IMAGE_VHD = '5'
|
||||
IMAGE_ISO = '6'
|
||||
IMAGE_IPXE_ISO = '7'
|
||||
IMAGE_FROM_VOLUME = '8'
|
||||
IMAGE_MACHINE = uuids.image_ref
|
||||
IMAGE_KERNEL = uuids.image_kernel_id
|
||||
IMAGE_RAMDISK = uuids.image_ramdisk_id
|
||||
IMAGE_RAW = uuids.image_raw
|
||||
IMAGE_VHD = uuids.image_vhd
|
||||
IMAGE_ISO = uuids.image_iso
|
||||
IMAGE_IPXE_ISO = uuids.image_ipxe_iso
|
||||
IMAGE_FROM_VOLUME = uuids.image_from_volume
|
||||
|
||||
IMAGE_FIXTURES = {
|
||||
IMAGE_MACHINE: {
|
||||
|
@ -297,7 +299,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
stubs.stub_out_vm_methods(self.stubs)
|
||||
fake_processutils.stub_out_processutils_execute(self.stubs)
|
||||
self.user_id = 'fake'
|
||||
self.project_id = 'fake'
|
||||
self.project_id = fakes.FAKE_PROJECT_ID
|
||||
self.context = context.RequestContext(self.user_id, self.project_id)
|
||||
self.conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
self.conn._session.is_local_connection = False
|
||||
|
@ -353,7 +355,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
self.mox.ReplayAll()
|
||||
|
||||
self.stubs.Set(objects.Instance, 'name', 'foo')
|
||||
instance = objects.Instance(uuid='fake-uuid')
|
||||
instance = objects.Instance(uuid=uuids.instance)
|
||||
self.assertTrue(self.conn.instance_exists(instance))
|
||||
|
||||
def test_instance_not_exists(self):
|
||||
|
@ -362,7 +364,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
self.mox.ReplayAll()
|
||||
|
||||
self.stubs.Set(objects.Instance, 'name', 'bar')
|
||||
instance = objects.Instance(uuid='fake-uuid')
|
||||
instance = objects.Instance(uuid=uuids.instance)
|
||||
self.assertFalse(self.conn.instance_exists(instance))
|
||||
|
||||
def test_list_instances_0(self):
|
||||
|
@ -819,9 +821,9 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
self.check_vm_params_for_linux()
|
||||
|
||||
def test_spawn_not_enough_memory(self):
|
||||
self.assertRaises(exception.InsufficientFreeMemory,
|
||||
self._test_spawn,
|
||||
'1', 2, 3, "4") # m1.xlarge
|
||||
self.assertRaises(exception.InsufficientFreeMemory, self._test_spawn,
|
||||
IMAGE_MACHINE, IMAGE_KERNEL,
|
||||
IMAGE_RAMDISK, "4") # m1.xlarge
|
||||
|
||||
def test_spawn_fail_cleanup_1(self):
|
||||
"""Simulates an error while downloading an image.
|
||||
|
@ -831,8 +833,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
vdi_recs_start = self._list_vdis()
|
||||
start_vms = self._list_vms()
|
||||
stubs.stubout_fetch_disk_image(self.stubs, raise_failure=True)
|
||||
self.assertRaises(xenapi_fake.Failure,
|
||||
self._test_spawn, '1', 2, 3)
|
||||
self.assertRaises(xenapi_fake.Failure, self._test_spawn,
|
||||
IMAGE_MACHINE, IMAGE_KERNEL, IMAGE_RAMDISK)
|
||||
# No additional VDI should be found.
|
||||
vdi_recs_end = self._list_vdis()
|
||||
end_vms = self._list_vms()
|
||||
|
@ -848,8 +850,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
vdi_recs_start = self._list_vdis()
|
||||
start_vms = self._list_vms()
|
||||
stubs.stubout_create_vm(self.stubs)
|
||||
self.assertRaises(xenapi_fake.Failure,
|
||||
self._test_spawn, '1', 2, 3)
|
||||
self.assertRaises(xenapi_fake.Failure, self._test_spawn,
|
||||
IMAGE_MACHINE, IMAGE_KERNEL, IMAGE_RAMDISK)
|
||||
# No additional VDI should be found.
|
||||
vdi_recs_end = self._list_vdis()
|
||||
end_vms = self._list_vms()
|
||||
|
@ -865,8 +867,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
stubs.stubout_attach_disks(self.stubs)
|
||||
vdi_recs_start = self._list_vdis()
|
||||
start_vms = self._list_vms()
|
||||
self.assertRaises(xenapi_fake.Failure,
|
||||
self._test_spawn, '1', 2, 3)
|
||||
self.assertRaises(xenapi_fake.Failure, self._test_spawn,
|
||||
IMAGE_MACHINE, IMAGE_KERNEL, IMAGE_RAMDISK)
|
||||
# No additional VDI should be found.
|
||||
vdi_recs_end = self._list_vdis()
|
||||
end_vms = self._list_vms()
|
||||
|
@ -1015,7 +1017,8 @@ iface eth0 inet6 static
|
|||
(r'mount', _mount_handler),
|
||||
(r'umount', _umount_handler),
|
||||
(r'tee.*interfaces', _tee_handler)])
|
||||
self._test_spawn('1', 2, 3, check_injection=True)
|
||||
self._test_spawn(IMAGE_MACHINE, IMAGE_KERNEL,
|
||||
IMAGE_RAMDISK, check_injection=True)
|
||||
|
||||
# tee must not run in this case, where an injection-capable
|
||||
# guest agent is detected
|
||||
|
@ -1027,7 +1030,7 @@ iface eth0 inet6 static
|
|||
self.conn._vmops._inject_auto_disk_config(instance, mox.IgnoreArg())
|
||||
self.mox.ReplayAll()
|
||||
image_meta = objects.ImageMeta.from_dict(
|
||||
IMAGE_FIXTURES['1']["image_meta"])
|
||||
IMAGE_FIXTURES[IMAGE_MACHINE]["image_meta"])
|
||||
self.conn.spawn(self.context, instance, image_meta, [], 'herp', '')
|
||||
|
||||
def test_spawn_vlanmanager(self):
|
||||
|
@ -1544,9 +1547,9 @@ iface eth0 inet6 static
|
|||
'display_name': 'host-',
|
||||
'project_id': self.project_id,
|
||||
'user_id': self.user_id,
|
||||
'image_ref': 1,
|
||||
'kernel_id': 2,
|
||||
'ramdisk_id': 3,
|
||||
'image_ref': IMAGE_MACHINE,
|
||||
'kernel_id': IMAGE_KERNEL,
|
||||
'ramdisk_id': IMAGE_RAMDISK,
|
||||
'root_gb': 80,
|
||||
'ephemeral_gb': 0,
|
||||
'instance_type_id': '3', # m1.large
|
||||
|
@ -1559,7 +1562,7 @@ iface eth0 inet6 static
|
|||
instance_values)
|
||||
network_info = fake_network.fake_get_instance_nw_info(self)
|
||||
image_meta = objects.ImageMeta.from_dict(
|
||||
{'id': IMAGE_VHD,
|
||||
{'id': uuids.image_id,
|
||||
'disk_format': 'vhd'})
|
||||
if spawn:
|
||||
self.conn.spawn(self.context, instance, image_meta, [], 'herp',
|
||||
|
@ -1655,7 +1658,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
|
|||
self.instance_values = {
|
||||
'project_id': self.project_id,
|
||||
'user_id': self.user_id,
|
||||
'image_ref': 1,
|
||||
'image_ref': IMAGE_MACHINE,
|
||||
'kernel_id': None,
|
||||
'ramdisk_id': None,
|
||||
'root_gb': 80,
|
||||
|
@ -1920,7 +1923,8 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
|
|||
self.mox.StubOutWithMock(vmops, '_restore_orig_vm_and_cleanup_orphan')
|
||||
|
||||
instance = objects.Instance(context=self.context,
|
||||
auto_disk_config=True, uuid='uuid')
|
||||
auto_disk_config=True,
|
||||
uuid=uuids.instance)
|
||||
instance.obj_reset_changes()
|
||||
vm_ref = "vm_ref"
|
||||
dest = "dest"
|
||||
|
@ -2293,9 +2297,9 @@ class XenAPIAutoDiskConfigTestCase(stubs.XenAPITestBase):
|
|||
self.instance_values = {
|
||||
'project_id': self.project_id,
|
||||
'user_id': self.user_id,
|
||||
'image_ref': 1,
|
||||
'kernel_id': 2,
|
||||
'ramdisk_id': 3,
|
||||
'image_ref': IMAGE_MACHINE,
|
||||
'kernel_id': IMAGE_KERNEL,
|
||||
'ramdisk_id': IMAGE_RAMDISK,
|
||||
'root_gb': 80,
|
||||
'ephemeral_gb': 0,
|
||||
'instance_type_id': '3', # m1.large
|
||||
|
@ -2332,7 +2336,7 @@ class XenAPIAutoDiskConfigTestCase(stubs.XenAPITestBase):
|
|||
vdi_uuid = session.call_xenapi('VDI.get_record', vdi_ref)['uuid']
|
||||
vdis = {'root': {'uuid': vdi_uuid, 'ref': vdi_ref}}
|
||||
image_meta = objects.ImageMeta.from_dict(
|
||||
{'id': 'null',
|
||||
{'id': uuids.image_id,
|
||||
'disk_format': 'vhd',
|
||||
'properties': {'vm_mode': 'xen'}})
|
||||
self.conn._vmops._attach_disks(instance, image_meta, vm_ref,
|
||||
|
@ -2418,9 +2422,9 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase):
|
|||
self.instance_values = {
|
||||
'project_id': self.project_id,
|
||||
'user_id': self.user_id,
|
||||
'image_ref': 1,
|
||||
'kernel_id': 2,
|
||||
'ramdisk_id': 3,
|
||||
'image_ref': IMAGE_MACHINE,
|
||||
'kernel_id': IMAGE_KERNEL,
|
||||
'ramdisk_id': IMAGE_RAMDISK,
|
||||
'root_gb': 80,
|
||||
'ephemeral_gb': 0,
|
||||
'instance_type_id': '3', # m1.large
|
||||
|
@ -2453,7 +2457,7 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase):
|
|||
vdis = {vdi_key: {'uuid': vdi_uuid, 'ref': vdi_ref}}
|
||||
self.called = False
|
||||
image_meta = objects.ImageMeta.from_dict(
|
||||
{'id': 'null',
|
||||
{'id': uuids.image_id,
|
||||
'disk_format': 'vhd',
|
||||
'properties': {'vm_mode': 'xen'}})
|
||||
self.conn._vmops._attach_disks(instance, image_meta, vm_ref,
|
||||
|
|
Loading…
Reference in New Issue