Merge "Prevent libvirt driver starting on non Linux platform"
This commit is contained in:
commit
8e2170d708
|
@ -28,6 +28,7 @@ import random
|
|||
import re
|
||||
import shutil
|
||||
import signal
|
||||
import sys
|
||||
import testtools
|
||||
import threading
|
||||
import time
|
||||
|
@ -1053,6 +1054,12 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
self.assertTrue(drvr.capabilities['supports_image_type_ploop'])
|
||||
|
||||
def test_driver_raises_on_non_linux_platform(self):
|
||||
with utils.temporary_mutation(sys, platform='darwin'):
|
||||
self.assertRaises(
|
||||
exception.InternalError, libvirt_driver.LibvirtDriver,
|
||||
fake.FakeVirtAPI(), False)
|
||||
|
||||
def create_fake_libvirt_mock(self, **kwargs):
|
||||
"""Defining mocks for LibvirtDriver(libvirt is not used)."""
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import os
|
|||
import pwd
|
||||
import random
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import typing as ty
|
||||
|
@ -330,6 +331,10 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
}
|
||||
super(LibvirtDriver, self).__init__(virtapi)
|
||||
|
||||
if not sys.platform.startswith('linux'):
|
||||
raise exception.InternalError(
|
||||
_('The libvirt driver only works on Linux'))
|
||||
|
||||
global libvirt
|
||||
if libvirt is None:
|
||||
libvirt = importutils.import_module('libvirt')
|
||||
|
|
|
@ -359,8 +359,6 @@ class ImageCacheManager(imagecache.ImageCacheManager):
|
|||
try:
|
||||
# If the cache is on a different device than the instance dir then
|
||||
# it does not consume the same disk resource as instances.
|
||||
# NOTE(gibi): this does not work on Windows properly as st_dev is
|
||||
# always 0
|
||||
if (os.stat(CONF.instances_path).st_dev !=
|
||||
os.stat(self.cache_dir).st_dev):
|
||||
return 0
|
||||
|
|
Loading…
Reference in New Issue