Don't import libvirt_utils in disk api.
Updates the virt/disk/api so that we no longer import libvirt_utils. This fixes issues when using Nova compute with compute drivers other than libvirt. (xenapi, etc.) Fixes LP Bug #1029501. Change-Id: I46ece309480ce0a0941a96371a51d77712c41eb6
This commit is contained in:
@@ -35,10 +35,6 @@ def create_cow_image(backing_file, path):
|
||||
pass
|
||||
|
||||
|
||||
def get_disk_size(path):
|
||||
return disk_sizes.get(path, 1024 * 1024 * 20)
|
||||
|
||||
|
||||
def get_disk_backing_file(path):
|
||||
return disk_backing_files.get(path, None)
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ class LvmTestCase(_ImageTestCase):
|
||||
fn = self.mox.CreateMockAnything()
|
||||
self.mox.StubOutWithMock(self.disk, 'resize2fs')
|
||||
self.mox.StubOutWithMock(self.libvirt_utils, 'create_lvm_image')
|
||||
self.mox.StubOutWithMock(self.libvirt_utils, 'get_disk_size')
|
||||
self.mox.StubOutWithMock(self.disk, 'get_disk_size')
|
||||
self.mox.StubOutWithMock(self.utils, 'execute')
|
||||
return fn
|
||||
|
||||
@@ -249,7 +249,7 @@ class LvmTestCase(_ImageTestCase):
|
||||
self.LV,
|
||||
self.TEMPLATE_SIZE,
|
||||
sparse=sparse)
|
||||
self.libvirt_utils.get_disk_size(self.TEMPLATE_PATH
|
||||
self.disk.get_disk_size(self.TEMPLATE_PATH
|
||||
).AndReturn(self.TEMPLATE_SIZE)
|
||||
cmd = ('dd', 'if=%s' % self.TEMPLATE_PATH,
|
||||
'of=%s' % self.PATH, 'bs=4M')
|
||||
@@ -279,7 +279,7 @@ class LvmTestCase(_ImageTestCase):
|
||||
fn(target=self.TEMPLATE_PATH)
|
||||
self.libvirt_utils.create_lvm_image(self.VG, self.LV,
|
||||
self.SIZE, sparse=sparse)
|
||||
self.libvirt_utils.get_disk_size(self.TEMPLATE_PATH
|
||||
self.disk.get_disk_size(self.TEMPLATE_PATH
|
||||
).AndReturn(self.TEMPLATE_SIZE)
|
||||
cmd = ('dd', 'if=%s' % self.TEMPLATE_PATH,
|
||||
'of=%s' % self.PATH, 'bs=4M')
|
||||
@@ -321,7 +321,7 @@ class LvmTestCase(_ImageTestCase):
|
||||
self.SIZE,
|
||||
sparse=False
|
||||
).AndRaise(RuntimeError())
|
||||
self.libvirt_utils.get_disk_size(self.TEMPLATE_PATH
|
||||
self.disk.get_disk_size(self.TEMPLATE_PATH
|
||||
).AndReturn(self.TEMPLATE_SIZE)
|
||||
self.mox.StubOutWithMock(self.libvirt_utils, 'remove_logical_volumes')
|
||||
self.libvirt_utils.remove_logical_volumes(self.PATH)
|
||||
|
||||
@@ -46,6 +46,7 @@ from nova.tests import fake_libvirt_utils
|
||||
from nova.tests import fake_network
|
||||
import nova.tests.image.fake
|
||||
from nova import utils
|
||||
from nova.virt.disk import api as disk
|
||||
from nova.virt import driver
|
||||
from nova.virt import firewall as base_firewall
|
||||
from nova.virt import images
|
||||
@@ -1803,13 +1804,6 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
"<target dev='vdb' bus='virtio'/></disk>"
|
||||
"</devices></domain>")
|
||||
|
||||
ret = ("image: /test/disk\n"
|
||||
"file format: raw\n"
|
||||
"virtual size: 20G (21474836480 bytes)\n"
|
||||
"disk size: 3.1G\n"
|
||||
"cluster_size: 2097152\n"
|
||||
"backing file: /test/dummy (actual path: /backing/file)\n")
|
||||
|
||||
# Preparing mocks
|
||||
vdmock = self.mox.CreateMock(libvirt.virDomain)
|
||||
self.mox.StubOutWithMock(vdmock, "XMLDesc")
|
||||
@@ -1829,6 +1823,17 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
os.path.getsize('/test/disk').AndReturn((10737418240))
|
||||
os.path.getsize('/test/disk.local').AndReturn((21474836480))
|
||||
|
||||
ret = ("image: /test/disk\n"
|
||||
"file format: raw\n"
|
||||
"virtual size: 20G (21474836480 bytes)\n"
|
||||
"disk size: 3.1G\n"
|
||||
"cluster_size: 2097152\n"
|
||||
"backing file: /test/dummy (actual path: /backing/file)\n")
|
||||
|
||||
self.mox.StubOutWithMock(utils, "execute")
|
||||
utils.execute('env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info',
|
||||
'/test/disk.local').AndReturn((ret, ''))
|
||||
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_driver.LibvirtDriver(False)
|
||||
info = conn.get_instance_disk_info(instance_ref.name)
|
||||
@@ -3207,7 +3212,7 @@ disk size: 4.4M''', ''))
|
||||
|
||||
# Start test
|
||||
self.mox.ReplayAll()
|
||||
self.assertEquals(libvirt_utils.get_disk_size('/some/path'), 4592640)
|
||||
self.assertEquals(disk.get_disk_size('/some/path'), 4592640)
|
||||
|
||||
def test_copy_image(self):
|
||||
dst_fd, dst_path = tempfile.mkstemp()
|
||||
|
||||
Reference in New Issue
Block a user