Remove deprecated methods and exceptions
This change cleans up some deprecated methods and an exception. Change-Id: I02ce0624d9b0963db7b00a5098e76a33552c1b12
This commit is contained in:
parent
4e24801719
commit
204156f69d
@ -236,15 +236,6 @@ class ClusterWin32Exception(ClusterException, Win32Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# TODO(lpetrut): Remove this exception in Q. It was never used outside
|
|
||||||
# os-win.
|
|
||||||
class InvalidClusterGroupState(ClusterException):
|
|
||||||
msg_fmt = _("The cluster group %(group_name)s is in an invalid state. "
|
|
||||||
"Expected state %(expected_state)s. Expected owner node: "
|
|
||||||
"%(expected_node)s. Current group state: %(group_state)s. "
|
|
||||||
"Current owner node: %(owner_node)s.")
|
|
||||||
|
|
||||||
|
|
||||||
class ClusterGroupMigrationFailed(ClusterException):
|
class ClusterGroupMigrationFailed(ClusterException):
|
||||||
msg_fmt = _("Failed to migrate cluster group %(group_name)s. "
|
msg_fmt = _("Failed to migrate cluster group %(group_name)s. "
|
||||||
"Expected state %(expected_state)s. "
|
"Expected state %(expected_state)s. "
|
||||||
|
@ -359,21 +359,6 @@ class VMUtilsTestCase(test_base.OsWinBaseTestCase):
|
|||||||
mock_modify_virtual_system.assert_called_once_with(
|
mock_modify_virtual_system.assert_called_once_with(
|
||||||
mock_vmsettings)
|
mock_vmsettings)
|
||||||
|
|
||||||
@mock.patch.object(vmutils.VMUtils, '_set_vm_memory')
|
|
||||||
@mock.patch.object(vmutils.VMUtils, '_create_vm_obj')
|
|
||||||
def test_create_vm(self, mock_create_vm_obj, mock_set_mem):
|
|
||||||
self._vmutils._vs_man_svc.DefineSystem.return_value = (
|
|
||||||
None, self._FAKE_JOB_PATH, self._FAKE_RET_VAL)
|
|
||||||
self._vmutils.create_vm(self._FAKE_VM_NAME,
|
|
||||||
mock.sentinel.vnuma_enabled,
|
|
||||||
self._VM_GEN,
|
|
||||||
mock.sentinel.instance_path)
|
|
||||||
|
|
||||||
mock_create_vm_obj.assert_called_once_with(
|
|
||||||
self._FAKE_VM_NAME, mock.sentinel.vnuma_enabled,
|
|
||||||
self._VM_GEN, None, mock.sentinel.instance_path)
|
|
||||||
self.assertFalse(mock_set_mem.called)
|
|
||||||
|
|
||||||
@mock.patch.object(_wqlutils, 'get_element_associated_class')
|
@mock.patch.object(_wqlutils, 'get_element_associated_class')
|
||||||
def test_get_vm_scsi_controller(self, mock_get_element_associated_class):
|
def test_get_vm_scsi_controller(self, mock_get_element_associated_class):
|
||||||
self._prepare_get_vm_controller(self._vmutils._SCSI_CTRL_RES_SUB_TYPE,
|
self._prepare_get_vm_controller(self._vmutils._SCSI_CTRL_RES_SUB_TYPE,
|
||||||
@ -782,28 +767,6 @@ class VMUtilsTestCase(test_base.OsWinBaseTestCase):
|
|||||||
self.assertEqual(mock_diskdrive.HostResource,
|
self.assertEqual(mock_diskdrive.HostResource,
|
||||||
[self._FAKE_MOUNTED_DISK_PATH])
|
[self._FAKE_MOUNTED_DISK_PATH])
|
||||||
|
|
||||||
def test_set_disk_host_resource(self):
|
|
||||||
self._lookup_vm()
|
|
||||||
mock_rasds = self._create_mock_disks()
|
|
||||||
|
|
||||||
self._vmutils._get_vm_disks = mock.MagicMock(
|
|
||||||
return_value=([mock_rasds[0]], [mock_rasds[1]]))
|
|
||||||
self._vmutils._get_disk_resource_address = mock.MagicMock(
|
|
||||||
return_value=self._FAKE_ADDRESS)
|
|
||||||
|
|
||||||
self._vmutils.set_disk_host_resource(
|
|
||||||
self._FAKE_VM_NAME,
|
|
||||||
self._FAKE_CTRL_PATH,
|
|
||||||
self._FAKE_ADDRESS,
|
|
||||||
mock.sentinel.fake_new_mounted_disk_path)
|
|
||||||
self._vmutils._get_disk_resource_address.assert_called_with(
|
|
||||||
mock_rasds[0])
|
|
||||||
self._vmutils._jobutils.modify_virt_resource.assert_called_once_with(
|
|
||||||
mock_rasds[0])
|
|
||||||
self.assertEqual(
|
|
||||||
mock.sentinel.fake_new_mounted_disk_path,
|
|
||||||
mock_rasds[0].HostResource[0])
|
|
||||||
|
|
||||||
@mock.patch.object(vmutils.VMUtils, '_modify_virtual_system')
|
@mock.patch.object(vmutils.VMUtils, '_modify_virtual_system')
|
||||||
@ddt.data(None, mock.sentinel.snap_name)
|
@ddt.data(None, mock.sentinel.snap_name)
|
||||||
def test_take_vm_snapshot(self, snap_name, mock_modify_virtual_system):
|
def test_take_vm_snapshot(self, snap_name, mock_modify_virtual_system):
|
||||||
@ -954,36 +917,6 @@ class VMUtilsTestCase(test_base.OsWinBaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(['active_vm'], active_instances)
|
self.assertEqual(['active_vm'], active_instances)
|
||||||
|
|
||||||
@mock.patch.object(_wqlutils, 'get_element_associated_class')
|
|
||||||
def _test_get_vm_serial_port_connection(self,
|
|
||||||
mock_get_element_associated_class,
|
|
||||||
new_connection=None):
|
|
||||||
old_serial_connection = 'old_serial_connection'
|
|
||||||
|
|
||||||
mock_vmsettings = [self._lookup_vm()]
|
|
||||||
|
|
||||||
fake_serial_port = mock.MagicMock()
|
|
||||||
|
|
||||||
fake_serial_port.ResourceSubType = (
|
|
||||||
self._vmutils._SERIAL_PORT_RES_SUB_TYPE)
|
|
||||||
fake_serial_port.Connection = [old_serial_connection]
|
|
||||||
mock_rasds = [fake_serial_port]
|
|
||||||
mock_get_element_associated_class.return_value = mock_rasds
|
|
||||||
fake_modify = self._vmutils._jobutils.modify_virt_resource
|
|
||||||
|
|
||||||
ret_val = self._vmutils.get_vm_serial_port_connection(
|
|
||||||
self._FAKE_VM_NAME, update_connection=new_connection)
|
|
||||||
|
|
||||||
mock_get_element_associated_class.assert_called_once_with(
|
|
||||||
self._vmutils._conn, self._vmutils._SERIAL_PORT_SETTING_DATA_CLASS,
|
|
||||||
element_instance_id=mock_vmsettings[0].InstanceID)
|
|
||||||
|
|
||||||
if new_connection:
|
|
||||||
self.assertEqual(new_connection, ret_val)
|
|
||||||
fake_modify.assert_called_once_with(fake_serial_port)
|
|
||||||
else:
|
|
||||||
self.assertEqual(old_serial_connection, ret_val)
|
|
||||||
|
|
||||||
@mock.patch.object(_wqlutils, 'get_element_associated_class')
|
@mock.patch.object(_wqlutils, 'get_element_associated_class')
|
||||||
def test_get_vm_serial_ports(self, mock_get_element_associated_class):
|
def test_get_vm_serial_ports(self, mock_get_element_associated_class):
|
||||||
mock_vmsettings = self._lookup_vm()
|
mock_vmsettings = self._lookup_vm()
|
||||||
@ -1037,13 +970,6 @@ class VMUtilsTestCase(test_base.OsWinBaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(expected_ret_val, ret_val)
|
self.assertEqual(expected_ret_val, ret_val)
|
||||||
|
|
||||||
def test_set_vm_serial_port_connection(self):
|
|
||||||
self._test_get_vm_serial_port_connection(
|
|
||||||
new_connection='new_serial_connection')
|
|
||||||
|
|
||||||
def test_get_vm_serial_port_connection(self):
|
|
||||||
self._test_get_vm_serial_port_connection()
|
|
||||||
|
|
||||||
def test_list_instance_notes(self):
|
def test_list_instance_notes(self):
|
||||||
vs = mock.MagicMock()
|
vs = mock.MagicMock()
|
||||||
attrs = {'ElementName': 'fake_name',
|
attrs = {'ElementName': 'fake_name',
|
||||||
@ -1075,8 +1001,9 @@ class VMUtilsTestCase(test_base.OsWinBaseTestCase):
|
|||||||
self._vmutils._jobutils.check_ret_val.assert_called_once_with(
|
self._vmutils._jobutils.check_ret_val.assert_called_once_with(
|
||||||
fake_ret_val, fake_job_path)
|
fake_ret_val, fake_job_path)
|
||||||
|
|
||||||
|
@ddt.data(True, False)
|
||||||
@mock.patch.object(vmutils.VMUtils, '_get_wmi_obj')
|
@mock.patch.object(vmutils.VMUtils, '_get_wmi_obj')
|
||||||
def _test_create_vm_obj(self, mock_get_wmi_obj, vnuma_enabled=True):
|
def test_create_vm(self, mock_get_wmi_obj, vnuma_enabled=True):
|
||||||
mock_vs_man_svc = self._vmutils._vs_man_svc
|
mock_vs_man_svc = self._vmutils._vs_man_svc
|
||||||
mock_vs_data = mock.MagicMock()
|
mock_vs_data = mock.MagicMock()
|
||||||
fake_job_path = 'fake job path'
|
fake_job_path = 'fake job path'
|
||||||
@ -1090,7 +1017,7 @@ class VMUtilsTestCase(test_base.OsWinBaseTestCase):
|
|||||||
mock.sentinel.vm_path,
|
mock.sentinel.vm_path,
|
||||||
fake_ret_val)
|
fake_ret_val)
|
||||||
|
|
||||||
self._vmutils._create_vm_obj(vm_name=fake_vm_name,
|
self._vmutils.create_vm(vm_name=fake_vm_name,
|
||||||
vm_gen=constants.VM_GEN_2,
|
vm_gen=constants.VM_GEN_2,
|
||||||
notes='fake notes',
|
notes='fake notes',
|
||||||
vnuma_enabled=vnuma_enabled,
|
vnuma_enabled=vnuma_enabled,
|
||||||
@ -1122,12 +1049,6 @@ class VMUtilsTestCase(test_base.OsWinBaseTestCase):
|
|||||||
self.assertEqual(mock.sentinel.instance_path,
|
self.assertEqual(mock.sentinel.instance_path,
|
||||||
mock_vs_data.SwapFileDataRoot)
|
mock_vs_data.SwapFileDataRoot)
|
||||||
|
|
||||||
def test_create_vm_obj(self):
|
|
||||||
self._test_create_vm_obj()
|
|
||||||
|
|
||||||
def test_create_vm_obj_vnuma_disabled(self):
|
|
||||||
self._test_create_vm_obj(vnuma_enabled=False)
|
|
||||||
|
|
||||||
def test_list_instances(self):
|
def test_list_instances(self):
|
||||||
vs = mock.MagicMock()
|
vs = mock.MagicMock()
|
||||||
attrs = {'ElementName': 'fake_name'}
|
attrs = {'ElementName': 'fake_name'}
|
||||||
|
@ -330,11 +330,6 @@ class VMUtils(baseutils.BaseUtilsVirt):
|
|||||||
def create_vm(self, vm_name, vnuma_enabled, vm_gen, instance_path,
|
def create_vm(self, vm_name, vnuma_enabled, vm_gen, instance_path,
|
||||||
notes=None):
|
notes=None):
|
||||||
LOG.debug('Creating VM %s', vm_name)
|
LOG.debug('Creating VM %s', vm_name)
|
||||||
self._create_vm_obj(vm_name, vnuma_enabled, vm_gen, notes,
|
|
||||||
instance_path)
|
|
||||||
|
|
||||||
def _create_vm_obj(self, vm_name, vnuma_enabled, vm_gen, notes,
|
|
||||||
instance_path):
|
|
||||||
vs_data = self._compat_conn.Msvm_VirtualSystemSettingData.new()
|
vs_data = self._compat_conn.Msvm_VirtualSystemSettingData.new()
|
||||||
vs_data.ElementName = vm_name
|
vs_data.ElementName = vm_name
|
||||||
vs_data.Notes = notes
|
vs_data.Notes = notes
|
||||||
@ -586,34 +581,6 @@ class VMUtils(baseutils.BaseUtilsVirt):
|
|||||||
diskdrive.HostResource = [mounted_disk_path]
|
diskdrive.HostResource = [mounted_disk_path]
|
||||||
self._jobutils.modify_virt_resource(diskdrive)
|
self._jobutils.modify_virt_resource(diskdrive)
|
||||||
|
|
||||||
def set_disk_host_resource(self, vm_name, controller_path, address,
|
|
||||||
mounted_disk_path):
|
|
||||||
# TODO(lpetrut): remove this method after the patch fixing
|
|
||||||
# swapped disks after host reboot merges in Nova.
|
|
||||||
disk_found = False
|
|
||||||
vmsettings = self._lookup_vm_check(vm_name)
|
|
||||||
(disk_resources, volume_resources) = self._get_vm_disks(vmsettings)
|
|
||||||
for disk_resource in disk_resources + volume_resources:
|
|
||||||
if (disk_resource.Parent == controller_path and
|
|
||||||
self._get_disk_resource_address(disk_resource) ==
|
|
||||||
str(address)):
|
|
||||||
if (disk_resource.HostResource and
|
|
||||||
disk_resource.HostResource[0] != mounted_disk_path):
|
|
||||||
LOG.debug('Updating disk host resource "%(old)s" to '
|
|
||||||
'"%(new)s"' %
|
|
||||||
{'old': disk_resource.HostResource[0],
|
|
||||||
'new': mounted_disk_path})
|
|
||||||
disk_resource.HostResource = [mounted_disk_path]
|
|
||||||
self._jobutils.modify_virt_resource(disk_resource)
|
|
||||||
disk_found = True
|
|
||||||
break
|
|
||||||
if not disk_found:
|
|
||||||
LOG.warning('Disk not found on controller '
|
|
||||||
'"%(controller_path)s" with '
|
|
||||||
'address "%(address)s"',
|
|
||||||
{'controller_path': controller_path,
|
|
||||||
'address': address})
|
|
||||||
|
|
||||||
def _get_nic_data_by_name(self, name):
|
def _get_nic_data_by_name(self, name):
|
||||||
nics = self._conn.Msvm_SyntheticEthernetPortSettingData(
|
nics = self._conn.Msvm_SyntheticEthernetPortSettingData(
|
||||||
ElementName=name)
|
ElementName=name)
|
||||||
@ -873,25 +840,6 @@ class VMUtils(baseutils.BaseUtilsVirt):
|
|||||||
raise exceptions.HyperVException(
|
raise exceptions.HyperVException(
|
||||||
_("Exceeded the maximum number of slots"))
|
_("Exceeded the maximum number of slots"))
|
||||||
|
|
||||||
def get_vm_serial_port_connection(self, vm_name, update_connection=None):
|
|
||||||
# TODO(lpetrut): Remove this method after the patch implementing
|
|
||||||
# serial console access support merges in Nova.
|
|
||||||
vmsettings = self._lookup_vm_check(vm_name)
|
|
||||||
|
|
||||||
rasds = _wqlutils.get_element_associated_class(
|
|
||||||
self._compat_conn, self._SERIAL_PORT_SETTING_DATA_CLASS,
|
|
||||||
element_instance_id=vmsettings.InstanceID)
|
|
||||||
serial_port = (
|
|
||||||
[r for r in rasds if
|
|
||||||
r.ResourceSubType == self._SERIAL_PORT_RES_SUB_TYPE][0])
|
|
||||||
|
|
||||||
if update_connection:
|
|
||||||
serial_port.Connection = [update_connection]
|
|
||||||
self._jobutils.modify_virt_resource(serial_port)
|
|
||||||
|
|
||||||
if len(serial_port.Connection) > 0:
|
|
||||||
return serial_port.Connection[0]
|
|
||||||
|
|
||||||
def _get_vm_serial_ports(self, vmsettings):
|
def _get_vm_serial_ports(self, vmsettings):
|
||||||
rasds = _wqlutils.get_element_associated_class(
|
rasds = _wqlutils.get_element_associated_class(
|
||||||
self._compat_conn, self._SERIAL_PORT_SETTING_DATA_CLASS,
|
self._compat_conn, self._SERIAL_PORT_SETTING_DATA_CLASS,
|
||||||
|
Loading…
Reference in New Issue
Block a user