Fixes local imports unit tests
Replaces local imports with oslo_windows imports. Fixes unit tests. Removed unused constants in constants.py. Unit tests are functional.
This commit is contained in:
parent
9a349635c5
commit
e95c55d2bb
|
@ -19,18 +19,18 @@ Unit tests for the Hyper-V utils factory.
|
|||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslotest import base
|
||||
|
||||
from nova import test
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import hostutils
|
||||
from nova.virt.hyperv import utilsfactory
|
||||
from nova.virt.hyperv import vmutils
|
||||
from nova.virt.hyperv import vmutilsv2
|
||||
from oslo_windows import utilsfactory
|
||||
from oslo_windows.utils import hostutils
|
||||
from oslo_windows.utils import vmutils
|
||||
from oslo_windows.utils import vmutilsv2
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestHyperVUtilsFactory(test.NoDBTestCase):
|
||||
class TestHyperVUtilsFactory(base.BaseTestCase):
|
||||
def test_get_vmutils_force_v1_and_min_version(self):
|
||||
self._test_returned_class(None, True, True)
|
||||
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from nova import test
|
||||
from nova.virt.hyperv import basevolumeutils
|
||||
from oslo_windows.utils import basevolumeutils
|
||||
|
||||
|
||||
def _exception_thrower():
|
||||
raise Exception("Testing exception handling.")
|
||||
|
||||
|
||||
class BaseVolumeUtilsTestCase(test.NoDBTestCase):
|
||||
class BaseVolumeUtilsTestCase(base.BaseTestCase):
|
||||
"""Unit tests for the Hyper-V BaseVolumeUtils class."""
|
||||
|
||||
_FAKE_COMPUTER_NAME = "fake_computer_name"
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from nova import test
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import hostutils
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import hostutils
|
||||
|
||||
|
||||
class FakeCPUSpec(object):
|
||||
|
@ -29,7 +29,7 @@ class FakeCPUSpec(object):
|
|||
NumberOfLogicalProcessors = mock.sentinel.cpu_procs
|
||||
|
||||
|
||||
class HostUtilsTestCase(test.NoDBTestCase):
|
||||
class HostUtilsTestCase(base.BaseTestCase):
|
||||
"""Unit tests for the Hyper-V hostutils class."""
|
||||
|
||||
_FAKE_MEMORY_TOTAL = 1024
|
||||
|
@ -45,7 +45,7 @@ class HostUtilsTestCase(test.NoDBTestCase):
|
|||
|
||||
super(HostUtilsTestCase, self).setUp()
|
||||
|
||||
@mock.patch('nova.virt.hyperv.hostutils.ctypes')
|
||||
@mock.patch('oslo_windows.utils.hostutils.ctypes')
|
||||
def test_get_host_tick_count64(self, mock_ctypes):
|
||||
tick_count64 = "100"
|
||||
mock_ctypes.windll.kernel32.GetTickCount64.return_value = tick_count64
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from nova import test
|
||||
from nova.virt.hyperv import hostutilsv2
|
||||
from oslo_windows.utils import hostutilsv2
|
||||
|
||||
|
||||
class HostUtilsV2TestCase(test.NoDBTestCase):
|
||||
class HostUtilsV2TestCase(base.BaseTestCase):
|
||||
"""Unit tests for the Hyper-V hostutilsv2 class."""
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
# under the License.import mock
|
||||
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
import os
|
||||
|
||||
from nova import test
|
||||
from nova.virt.hyperv import ioutils
|
||||
from oslo_windows.utils import ioutils
|
||||
|
||||
|
||||
class IOThreadTestCase(test.NoDBTestCase):
|
||||
class IOThreadTestCase(base.BaseTestCase):
|
||||
_FAKE_SRC = r'fake_source_file'
|
||||
_FAKE_DEST = r'fake_dest_file'
|
||||
_FAKE_MAX_BYTES = 1
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from nova import test
|
||||
from nova.virt.hyperv import livemigrationutils
|
||||
from oslo_windows.utils import livemigrationutils
|
||||
|
||||
|
||||
class LiveMigrationUtilsTestCase(test.NoDBTestCase):
|
||||
class LiveMigrationUtilsTestCase(base.BaseTestCase):
|
||||
"""Unit tests for the Hyper-V LiveMigrationUtils class."""
|
||||
|
||||
_FAKE_RET_VAL = 0
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from nova import test
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import networkutils
|
||||
from oslo_windows.utils import networkutils
|
||||
|
||||
|
||||
class NetworkUtilsTestCase(test.NoDBTestCase):
|
||||
class NetworkUtilsTestCase(base.BaseTestCase):
|
||||
"""Unit tests for the Hyper-V NetworkUtils class."""
|
||||
|
||||
_FAKE_PORT = {'Name': mock.sentinel.FAKE_PORT_NAME}
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
import mock
|
||||
|
||||
from nova.tests.unit.virt.hyperv import test_networkutils
|
||||
from nova.virt.hyperv import networkutilsv2
|
||||
from oslo_windows.tests.utils import test_networkutils
|
||||
from oslo_windows.utils import networkutilsv2
|
||||
|
||||
|
||||
class NetworkUtilsV2TestCase(test_networkutils.NetworkUtilsTestCase):
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
import os
|
||||
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from nova.tests.unit.virt.hyperv import test_base
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import pathutils
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import pathutils
|
||||
|
||||
|
||||
class PathUtilsTestCase(test_base.HyperVBaseTestCase):
|
||||
class PathUtilsTestCase(base.BaseTestCase):
|
||||
"""Unit tests for the Hyper-V PathUtils class."""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -31,6 +31,7 @@ class PathUtilsTestCase(test_base.HyperVBaseTestCase):
|
|||
self.fake_instance_name = 'fake_instance_name'
|
||||
|
||||
self._pathutils = pathutils.PathUtils()
|
||||
self._pathutils._smb_conn = mock.MagicMock()
|
||||
|
||||
@mock.patch.object(pathutils.PathUtils, 'rename')
|
||||
@mock.patch.object(os.path, 'isfile')
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova import test
|
||||
from nova.virt.hyperv import rdpconsoleutils
|
||||
from oslotest import base
|
||||
|
||||
from oslo_windows.utils import rdpconsoleutils
|
||||
|
||||
|
||||
class RDPConsoleUtilsTestCase(test.NoDBTestCase):
|
||||
class RDPConsoleUtilsTestCase(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
self._rdpconsoleutils = rdpconsoleutils.RDPConsoleUtils()
|
||||
super(RDPConsoleUtilsTestCase, self).setUp()
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from nova import test
|
||||
from nova.virt.hyperv import rdpconsoleutilsv2
|
||||
from oslo_windows.utils import rdpconsoleutilsv2
|
||||
|
||||
|
||||
class RDPConsoleUtilsV2TestCase(test.NoDBTestCase):
|
||||
class RDPConsoleUtilsV2TestCase(base.BaseTestCase):
|
||||
_FAKE_RDP_PORT = 1000
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
|
||||
import mock
|
||||
from oslo_utils import units
|
||||
from oslotest import base
|
||||
|
||||
from nova import test
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import vhdutils
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import vhdutils
|
||||
|
||||
|
||||
class VHDUtilsBaseTestCase(test.NoDBTestCase):
|
||||
class VHDUtilsBaseTestCase(base.BaseTestCase):
|
||||
"Base Class unit test classes of Hyper-V VHD Utils classes."
|
||||
|
||||
_FAKE_VHD_PATH = "C:\\fake_path.vhdx"
|
||||
|
@ -233,7 +233,7 @@ class VHDUtilsTestCase(VHDUtilsBaseTestCase):
|
|||
self.assertEqual(expected_vhd_size, real_size)
|
||||
|
||||
def test_get_vhd_format_vhdx(self):
|
||||
with mock.patch('nova.virt.hyperv.vhdutils.open',
|
||||
with mock.patch('oslo_windows.utils.vhdutils.open',
|
||||
mock.mock_open(read_data=vhdutils.VHDX_SIGNATURE),
|
||||
create=True):
|
||||
|
||||
|
@ -242,7 +242,7 @@ class VHDUtilsTestCase(VHDUtilsBaseTestCase):
|
|||
self.assertEqual(constants.DISK_FORMAT_VHDX, format)
|
||||
|
||||
def test_get_vhd_format_vhd(self):
|
||||
with mock.patch('nova.virt.hyperv.vhdutils.open',
|
||||
with mock.patch('oslo_windows.utils.vhdutils.open',
|
||||
mock.mock_open(),
|
||||
create=True) as mock_open:
|
||||
f = mock_open.return_value
|
||||
|
@ -260,7 +260,7 @@ class VHDUtilsTestCase(VHDUtilsBaseTestCase):
|
|||
self.assertEqual(constants.DISK_FORMAT_VHD, format)
|
||||
|
||||
def test_get_vhd_format_invalid_format(self):
|
||||
with mock.patch('nova.virt.hyperv.vhdutils.open',
|
||||
with mock.patch('oslo_windows.utils.vhdutils.open',
|
||||
mock.mock_open(read_data='invalid'),
|
||||
create=True) as mock_open:
|
||||
f = mock_open.return_value
|
||||
|
@ -271,7 +271,7 @@ class VHDUtilsTestCase(VHDUtilsBaseTestCase):
|
|||
self._FAKE_VHD_PATH)
|
||||
|
||||
def test_get_vhd_format_zero_length_file(self):
|
||||
with mock.patch('nova.virt.hyperv.vhdutils.open',
|
||||
with mock.patch('oslo_windows.utils.vhdutils.open',
|
||||
mock.mock_open(read_data=''),
|
||||
create=True) as mock_open:
|
||||
f = mock_open.return_value
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
import mock
|
||||
|
||||
from oslo_windows import exceptions
|
||||
from nova.tests.unit.virt.hyperv import test_vhdutils
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import vhdutilsv2
|
||||
from oslo_windows.tests.utils import test_vhdutils
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import vhdutilsv2
|
||||
|
||||
|
||||
class VHDUtilsV2TestCase(test_vhdutils.VHDUtilsBaseTestCase):
|
||||
|
@ -168,7 +168,7 @@ class VHDUtilsV2TestCase(test_vhdutils.VHDUtilsBaseTestCase):
|
|||
else:
|
||||
self._vhdutils.get_vhd_info.return_value = self._fake_vhd_info
|
||||
|
||||
@mock.patch('nova.virt.hyperv.vhdutils.VHDUtils.get_vhd_format')
|
||||
@mock.patch('oslo_windows.utils.vhdutils.VHDUtils.get_vhd_format')
|
||||
def test_get_vhdx_internal_size(self, mock_get_vhd_format):
|
||||
mock_get_vhd_format.return_value = constants.DISK_FORMAT_VHDX
|
||||
self._mock_get_vhd_info()
|
||||
|
|
|
@ -14,16 +14,16 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base
|
||||
|
||||
from six.moves import range
|
||||
|
||||
from nova import test
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import vmutils
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import vmutils
|
||||
|
||||
|
||||
class VMUtilsTestCase(test.NoDBTestCase):
|
||||
class VMUtilsTestCase(base.BaseTestCase):
|
||||
"""Unit tests for the Hyper-V VMUtils class."""
|
||||
|
||||
_FAKE_VM_NAME = 'fake_vm'
|
||||
|
@ -175,7 +175,7 @@ class VMUtilsTestCase(test.NoDBTestCase):
|
|||
self._vmutils.soft_shutdown_vm(self._FAKE_VM_NAME)
|
||||
self.assertFalse(mock_check.called)
|
||||
|
||||
@mock.patch('nova.virt.hyperv.vmutils.VMUtils._get_vm_disks')
|
||||
@mock.patch('oslo_windows.utils.vmutils.VMUtils._get_vm_disks')
|
||||
def test_get_vm_storage_paths(self, mock_get_vm_disks):
|
||||
self._lookup_vm()
|
||||
mock_rasds = self._create_mock_disks()
|
||||
|
@ -255,7 +255,7 @@ class VMUtilsTestCase(test.NoDBTestCase):
|
|||
path = self._vmutils.get_vm_scsi_controller(self._FAKE_VM_NAME)
|
||||
self.assertEqual(self._FAKE_RES_PATH, path)
|
||||
|
||||
@mock.patch("nova.virt.hyperv.vmutils.VMUtils.get_attached_disks")
|
||||
@mock.patch("oslo_windows.utils.vmutils.VMUtils.get_attached_disks")
|
||||
def test_get_free_controller_slot(self, mock_get_attached_disks):
|
||||
mock_disk = mock.MagicMock()
|
||||
mock_disk.AddressOnParent = 3
|
||||
|
@ -310,8 +310,8 @@ class VMUtilsTestCase(test.NoDBTestCase):
|
|||
mock_rasds.ResourceSubType = mock_subtype
|
||||
return mock_rasds
|
||||
|
||||
@mock.patch("nova.virt.hyperv.vmutils.VMUtils.get_free_controller_slot")
|
||||
@mock.patch("nova.virt.hyperv.vmutils.VMUtils._get_vm_scsi_controller")
|
||||
@mock.patch("oslo_windows.utils.vmutils.VMUtils.get_free_controller_slot")
|
||||
@mock.patch("oslo_windows.utils.vmutils.VMUtils._get_vm_scsi_controller")
|
||||
def test_attach_scsi_drive(self, mock_get_vm_scsi_controller,
|
||||
mock_get_free_controller_slot):
|
||||
mock_vm = self._lookup_vm()
|
||||
|
@ -657,7 +657,7 @@ class VMUtilsTestCase(test.NoDBTestCase):
|
|||
['ElementName', 'Notes'],
|
||||
SettingType=self._vmutils._VIRTUAL_SYSTEM_CURRENT_SETTINGS)
|
||||
|
||||
@mock.patch('nova.virt.hyperv.vmutils.VMUtils.check_ret_val')
|
||||
@mock.patch('oslo_windows.utils.vmutils.VMUtils.check_ret_val')
|
||||
def test_modify_virtual_system(self, mock_check_ret_val):
|
||||
mock_vs_man_svc = mock.MagicMock()
|
||||
mock_vmsetting = mock.MagicMock()
|
||||
|
@ -677,10 +677,10 @@ class VMUtilsTestCase(test.NoDBTestCase):
|
|||
SystemSettingData=mock_vmsetting.GetText_(1))
|
||||
mock_check_ret_val.assert_called_once_with(fake_ret_val, fake_job_path)
|
||||
|
||||
@mock.patch('nova.virt.hyperv.vmutils.VMUtils.check_ret_val')
|
||||
@mock.patch('nova.virt.hyperv.vmutils.VMUtils._get_wmi_obj')
|
||||
@mock.patch('nova.virt.hyperv.vmutils.VMUtils._modify_virtual_system')
|
||||
@mock.patch('nova.virt.hyperv.vmutils.VMUtils._get_vm_setting_data')
|
||||
@mock.patch('oslo_windows.utils.vmutils.VMUtils.check_ret_val')
|
||||
@mock.patch('oslo_windows.utils.vmutils.VMUtils._get_wmi_obj')
|
||||
@mock.patch('oslo_windows.utils.vmutils.VMUtils._modify_virtual_system')
|
||||
@mock.patch('oslo_windows.utils.vmutils.VMUtils._get_vm_setting_data')
|
||||
def test_create_vm_obj(self, mock_get_vm_setting_data,
|
||||
mock_modify_virtual_system,
|
||||
mock_get_wmi_obj, mock_check_ret_val):
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
import mock
|
||||
|
||||
from nova.tests.unit.virt.hyperv import test_vmutils
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import vmutilsv2
|
||||
from oslo_windows.tests.utils import test_vmutils
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import vmutilsv2
|
||||
|
||||
|
||||
class VMUtilsV2TestCase(test_vmutils.VMUtilsTestCase):
|
||||
|
@ -89,7 +89,7 @@ class VMUtilsV2TestCase(test_vmutils.VMUtilsTestCase):
|
|||
self._vmutils.set_nic_connection(self._FAKE_VM_NAME, None, None)
|
||||
mock_add_virt_res.assert_called_with(fake_eth_port, self._FAKE_VM_PATH)
|
||||
|
||||
@mock.patch('nova.virt.hyperv.vmutils.VMUtils._get_vm_disks')
|
||||
@mock.patch('oslo_windows.utils.vmutils.VMUtils._get_vm_disks')
|
||||
def test_enable_vm_metrics_collection(self, mock_get_vm_disks):
|
||||
self._lookup_vm()
|
||||
mock_svc = self._vmutils._conn.Msvm_MetricService()[0]
|
||||
|
@ -153,8 +153,8 @@ class VMUtilsV2TestCase(test_vmutils.VMUtilsTestCase):
|
|||
def _get_fake_instance_notes(self):
|
||||
return [self._FAKE_VM_UUID]
|
||||
|
||||
@mock.patch('nova.virt.hyperv.vmutilsv2.VMUtilsV2.check_ret_val')
|
||||
@mock.patch('nova.virt.hyperv.vmutilsv2.VMUtilsV2._get_wmi_obj')
|
||||
@mock.patch('oslo_windows.utils.vmutilsv2.VMUtilsV2.check_ret_val')
|
||||
@mock.patch('oslo_windows.utils.vmutilsv2.VMUtilsV2._get_wmi_obj')
|
||||
def _test_create_vm_obj(self, mock_get_wmi_obj, mock_check_ret_val,
|
||||
vm_path, dynamic_memory_ratio=1.0):
|
||||
mock_vs_man_svc = mock.MagicMock()
|
||||
|
|
|
@ -15,15 +15,10 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
|
||||
from oslo_windows import exceptions
|
||||
from nova.tests.unit.virt.hyperv import test_basevolumeutils
|
||||
from nova.virt.hyperv import volumeutils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('volume_attach_retry_count', 'nova.virt.hyperv.volumeops',
|
||||
'hyperv')
|
||||
from oslo_windows.tests.utils import test_basevolumeutils
|
||||
from oslo_windows.utils import volumeutils
|
||||
|
||||
|
||||
class VolumeUtilsTestCase(test_basevolumeutils.BaseVolumeUtilsTestCase):
|
||||
|
@ -41,8 +36,6 @@ class VolumeUtilsTestCase(test_basevolumeutils.BaseVolumeUtilsTestCase):
|
|||
self._volutils = volumeutils.VolumeUtils()
|
||||
self._volutils._conn_wmi = mock.MagicMock()
|
||||
self._volutils._conn_cimv2 = mock.MagicMock()
|
||||
self.flags(volume_attach_retry_count=4, group='hyperv')
|
||||
self.flags(volume_attach_retry_interval=0, group='hyperv')
|
||||
|
||||
def _test_login_target_portal(self, portal_connected):
|
||||
fake_portal = '%s:%s' % (self._FAKE_PORTAL_ADDR,
|
||||
|
@ -73,8 +66,11 @@ class VolumeUtilsTestCase(test_basevolumeutils.BaseVolumeUtilsTestCase):
|
|||
def test_login_new_portal(self):
|
||||
self._test_login_target_portal(False)
|
||||
|
||||
def _test_login_target(self, target_connected=False, raise_exception=False,
|
||||
use_chap=False):
|
||||
@mock.patch.object(volumeutils, 'CONF')
|
||||
def _test_login_target(self, mock_CONF, target_connected=False,
|
||||
raise_exception=False, use_chap=False):
|
||||
mock_CONF.hyperv.volume_attach_retry_count = 4
|
||||
mock_CONF.hyperv.volume_attach_retry_interval = 0
|
||||
fake_portal = '%s:%s' % (self._FAKE_PORTAL_ADDR,
|
||||
self._FAKE_PORTAL_PORT)
|
||||
self._volutils.execute = mock.MagicMock()
|
||||
|
|
|
@ -13,18 +13,13 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslotest import base
|
||||
|
||||
from nova import test
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import volumeutilsv2
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('volume_attach_retry_count', 'nova.virt.hyperv.volumeops',
|
||||
'hyperv')
|
||||
from oslo_windows.utils import volumeutilsv2
|
||||
|
||||
|
||||
class VolumeUtilsV2TestCase(test.NoDBTestCase):
|
||||
class VolumeUtilsV2TestCase(base.BaseTestCase):
|
||||
"""Unit tests for the Hyper-V VolumeUtilsV2 class."""
|
||||
|
||||
_FAKE_PORTAL_ADDR = '10.1.1.1'
|
||||
|
@ -37,8 +32,6 @@ class VolumeUtilsV2TestCase(test.NoDBTestCase):
|
|||
self._volutilsv2 = volumeutilsv2.VolumeUtilsV2()
|
||||
self._volutilsv2._conn_storage = mock.MagicMock()
|
||||
self._volutilsv2._conn_wmi = mock.MagicMock()
|
||||
self.flags(volume_attach_retry_count=4, group='hyperv')
|
||||
self.flags(volume_attach_retry_interval=0, group='hyperv')
|
||||
|
||||
def _test_login_target_portal(self, portal_connected):
|
||||
fake_portal = '%s:%s' % (self._FAKE_PORTAL_ADDR,
|
||||
|
@ -68,8 +61,11 @@ class VolumeUtilsV2TestCase(test.NoDBTestCase):
|
|||
def test_login_new_portal(self):
|
||||
self._test_login_target_portal(False)
|
||||
|
||||
def _test_login_target(self, target_connected=False, raise_exception=False,
|
||||
use_chap=False):
|
||||
@mock.patch.object(volumeutilsv2, 'CONF')
|
||||
def _test_login_target(self, mock_CONF, target_connected=False,
|
||||
raise_exception=False, use_chap=False):
|
||||
mock_CONF.hyperv.volume_attach_retry_count = 4
|
||||
mock_CONF.hyperv.volume_attach_retry_interval = 0
|
||||
fake_portal = '%s:%s' % (self._FAKE_PORTAL_ADDR,
|
||||
self._FAKE_PORTAL_PORT)
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
Constants used in ops classes
|
||||
"""
|
||||
|
||||
from nova.compute import arch
|
||||
from nova.compute import power_state
|
||||
|
||||
HYPERV_VM_STATE_OTHER = 1
|
||||
HYPERV_VM_STATE_ENABLED = 2
|
||||
HYPERV_VM_STATE_DISABLED = 3
|
||||
|
@ -28,37 +25,6 @@ HYPERV_VM_STATE_REBOOT = 10
|
|||
HYPERV_VM_STATE_PAUSED = 32768
|
||||
HYPERV_VM_STATE_SUSPENDED = 32769
|
||||
|
||||
HYPERV_POWER_STATE = {
|
||||
HYPERV_VM_STATE_DISABLED: power_state.SHUTDOWN,
|
||||
HYPERV_VM_STATE_SHUTTING_DOWN: power_state.SHUTDOWN,
|
||||
HYPERV_VM_STATE_ENABLED: power_state.RUNNING,
|
||||
HYPERV_VM_STATE_PAUSED: power_state.PAUSED,
|
||||
HYPERV_VM_STATE_SUSPENDED: power_state.SUSPENDED
|
||||
}
|
||||
|
||||
WMI_WIN32_PROCESSOR_ARCHITECTURE = {
|
||||
0: arch.I686,
|
||||
1: arch.MIPS,
|
||||
2: arch.ALPHA,
|
||||
3: arch.PPC,
|
||||
5: arch.ARMV7,
|
||||
6: arch.IA64,
|
||||
9: arch.X86_64,
|
||||
}
|
||||
|
||||
PROCESSOR_FEATURE = {
|
||||
7: '3dnow',
|
||||
3: 'mmx',
|
||||
12: 'nx',
|
||||
9: 'pae',
|
||||
8: 'rdtsc',
|
||||
20: 'slat',
|
||||
13: 'sse3',
|
||||
21: 'vmx',
|
||||
6: 'sse',
|
||||
10: 'sse2',
|
||||
17: 'xsave',
|
||||
}
|
||||
|
||||
WMI_JOB_STATUS_STARTED = 4096
|
||||
WMI_JOB_STATE_RUNNING = 4
|
||||
|
|
|
@ -21,7 +21,7 @@ if sys.platform == 'win32':
|
|||
import wmi
|
||||
|
||||
from oslo_windows._i18n import _
|
||||
from nova.virt.hyperv import constants
|
||||
from oslo_windows.utils import constants
|
||||
|
||||
|
||||
class HostUtils(object):
|
||||
|
|
|
@ -18,7 +18,7 @@ import sys
|
|||
if sys.platform == 'win32':
|
||||
import wmi
|
||||
|
||||
from nova.virt.hyperv import hostutils
|
||||
from oslo_windows.utils import hostutils
|
||||
|
||||
|
||||
class HostUtilsV2(hostutils.HostUtils):
|
||||
|
|
|
@ -22,8 +22,8 @@ from oslo_log import log as logging
|
|||
|
||||
from oslo_windows._i18n import _, _LE
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import vmutilsv2
|
||||
from nova.virt.hyperv import volumeutilsv2
|
||||
from oslo_windows.utils import vmutilsv2
|
||||
from oslo_windows.utils import volumeutilsv2
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ if sys.platform == 'win32':
|
|||
|
||||
from oslo_windows._i18n import _
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import networkutils
|
||||
from oslo_windows.utils import networkutils
|
||||
|
||||
|
||||
class NetworkUtilsV2(networkutils.NetworkUtils):
|
||||
|
|
|
@ -27,7 +27,7 @@ from oslo_log import log as logging
|
|||
from oslo_windows._i18n import _
|
||||
from oslo_windows import _utils
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import constants
|
||||
from oslo_windows.utils import constants
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
import sys
|
||||
|
||||
from nova.virt.hyperv import rdpconsoleutils
|
||||
from oslo_windows.utils import rdpconsoleutils
|
||||
|
||||
if sys.platform == 'win32':
|
||||
import wmi
|
||||
|
|
|
@ -33,8 +33,8 @@ from xml.etree import ElementTree
|
|||
|
||||
from oslo_windows._i18n import _
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import vmutils
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import vmutils
|
||||
|
||||
|
||||
VHD_HEADER_SIZE_FIX = 512
|
||||
|
|
|
@ -30,9 +30,9 @@ from oslo_utils import units
|
|||
|
||||
from oslo_windows._i18n import _
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import vhdutils
|
||||
from nova.virt.hyperv import vmutilsv2
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import vhdutils
|
||||
from oslo_windows.utils import vmutilsv2
|
||||
|
||||
|
||||
VHDX_BAT_ENTRY_SIZE = 8
|
||||
|
|
|
@ -33,8 +33,8 @@ from six.moves import range
|
|||
|
||||
from oslo_windows._i18n import _, _LW
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import hostutils
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import hostutils
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -27,8 +27,8 @@ if sys.platform == 'win32':
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from nova.virt.hyperv import constants
|
||||
from nova.virt.hyperv import vmutils
|
||||
from oslo_windows.utils import constants
|
||||
from oslo_windows.utils import vmutils
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -33,7 +33,7 @@ from six.moves import range
|
|||
from oslo_windows._i18n import _
|
||||
from oslo_windows import _utils
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import basevolumeutils
|
||||
from oslo_windows.utils import basevolumeutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ from six.moves import range
|
|||
from oslo_windows._i18n import _
|
||||
from oslo_windows import _utils
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import basevolumeutils
|
||||
from oslo_windows.utils import basevolumeutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
|
|
@ -18,20 +18,20 @@ from oslo_log import log as logging
|
|||
|
||||
from oslo_windows._i18n import _
|
||||
from oslo_windows import exceptions
|
||||
from nova.virt.hyperv import hostutils
|
||||
from nova.virt.hyperv import hostutilsv2
|
||||
from nova.virt.hyperv import livemigrationutils
|
||||
from nova.virt.hyperv import networkutils
|
||||
from nova.virt.hyperv import networkutilsv2
|
||||
from nova.virt.hyperv import pathutils
|
||||
from nova.virt.hyperv import rdpconsoleutils
|
||||
from nova.virt.hyperv import rdpconsoleutilsv2
|
||||
from nova.virt.hyperv import vhdutils
|
||||
from nova.virt.hyperv import vhdutilsv2
|
||||
from nova.virt.hyperv import vmutils
|
||||
from nova.virt.hyperv import vmutilsv2
|
||||
from nova.virt.hyperv import volumeutils
|
||||
from nova.virt.hyperv import volumeutilsv2
|
||||
from oslo_windows.utils import hostutils
|
||||
from oslo_windows.utils import hostutilsv2
|
||||
from oslo_windows.utils import livemigrationutils
|
||||
from oslo_windows.utils import networkutils
|
||||
from oslo_windows.utils import networkutilsv2
|
||||
from oslo_windows.utils import pathutils
|
||||
from oslo_windows.utils import rdpconsoleutils
|
||||
from oslo_windows.utils import rdpconsoleutilsv2
|
||||
from oslo_windows.utils import vhdutils
|
||||
from oslo_windows.utils import vhdutilsv2
|
||||
from oslo_windows.utils import vmutils
|
||||
from oslo_windows.utils import vmutilsv2
|
||||
from oslo_windows.utils import volumeutils
|
||||
from oslo_windows.utils import volumeutilsv2
|
||||
|
||||
hyper_opts = [
|
||||
cfg.BoolOpt('force_hyperv_utils_v1',
|
||||
|
|
Loading…
Reference in New Issue