Skip to content

Commit

Permalink
virt: Remove 'set_bootable' API
Browse files Browse the repository at this point in the history
Change-Id: I02b4e5b48c4974c426b8b576292f27f50565fb4f
Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Sep 11, 2020
1 parent 39fe221 commit caa5f9e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 49 deletions.
7 changes: 0 additions & 7 deletions nova/compute/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9990,13 +9990,6 @@ def _cleanup_running_deleted_instances(self, context):
"DELETED but still present on host.",
instance.name, instance=instance)
try:
try:
# disable starting the instance
self.driver.set_bootable(instance, False)
except NotImplementedError:
LOG.debug("set_bootable is not implemented "
"for the current driver")
# and power it off
self.driver.power_off(instance)
except Exception:
LOG.warning("Failed to power off instance",
Expand Down
35 changes: 6 additions & 29 deletions nova/tests/unit/compute/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -7047,10 +7047,10 @@ def test_cleanup_running_deleted_instances_reap(self, mock_get_uuid,

@mock.patch.object(compute_manager.ComputeManager,
'_get_instances_on_driver')
@mock.patch.object(fake.FakeDriver, "set_bootable")
@mock.patch.object(fake.FakeDriver, "power_off")
def test_cleanup_running_deleted_instances_shutdown(self, mock_power,
mock_set, mock_get):
def test_cleanup_running_deleted_instances_shutdown(
self, mock_power, mock_get,
):
ctxt, inst1, inst2 = self._test_cleanup_running('shutdown')
mock_get.return_value = [inst1, inst2]

Expand All @@ -7060,34 +7060,13 @@ def test_cleanup_running_deleted_instances_shutdown(self, mock_power,
{'deleted': True,
'soft_deleted': False})
mock_power.assert_has_calls([mock.call(inst1), mock.call(inst2)])
mock_set.assert_has_calls([mock.call(inst1, False),
mock.call(inst2, False)])

@mock.patch.object(compute_manager.ComputeManager,
'_get_instances_on_driver')
@mock.patch.object(fake.FakeDriver, "set_bootable")
@mock.patch.object(fake.FakeDriver, "power_off")
def test_cleanup_running_deleted_instances_shutdown_notimpl(self,
mock_power, mock_set, mock_get):
ctxt, inst1, inst2 = self._test_cleanup_running('shutdown')
mock_get.return_value = [inst1, inst2]
mock_set.side_effect = [NotImplementedError, NotImplementedError]

self.compute._cleanup_running_deleted_instances(ctxt)

mock_get.assert_called_once_with(ctxt,
{'deleted': True,
'soft_deleted': False})
mock_set.assert_has_calls([mock.call(inst1, False),
mock.call(inst2, False)])
mock_power.assert_has_calls([mock.call(inst1), mock.call(inst2)])

@mock.patch.object(compute_manager.ComputeManager,
'_get_instances_on_driver')
@mock.patch.object(fake.FakeDriver, "set_bootable")
@mock.patch.object(fake.FakeDriver, "power_off")
def test_cleanup_running_deleted_instances_shutdown_error(self, mock_power,
mock_set, mock_get):
def test_cleanup_running_deleted_instances_shutdown_error(
self, mock_power, mock_get,
):
ctxt, inst1, inst2 = self._test_cleanup_running('shutdown')
e = test.TestingException('bad')
mock_get.return_value = [inst1, inst2]
Expand All @@ -7099,8 +7078,6 @@ def test_cleanup_running_deleted_instances_shutdown_error(self, mock_power,
{'deleted': True,
'soft_deleted': False})
mock_power.assert_has_calls([mock.call(inst1), mock.call(inst2)])
mock_set.assert_has_calls([mock.call(inst1, False),
mock.call(inst2, False)])

@mock.patch.object(compute_manager.ComputeManager,
'_get_instances_on_driver')
Expand Down
4 changes: 0 additions & 4 deletions nova/tests/unit/virt/test_virt_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,6 @@ def test_emit_unicode_event(self):
self.connection.emit_event(started_event)
callback.assert_called_once_with(started_event)

def test_set_bootable(self):
self.assertRaises(NotImplementedError, self.connection.set_bootable,
'instance', True)

@catch_notimplementederror
def test_get_instance_disk_info(self):
# This should be implemented by any driver that supports live migrate.
Expand Down
9 changes: 0 additions & 9 deletions nova/virt/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,15 +866,6 @@ def rescue(self, context, instance, network_info, image_meta,
"""
raise NotImplementedError()

# TODO(stephenfin): This was only implemented (properly) for XenAPI and
# should be removed.
def set_bootable(self, instance, is_bootable):
"""Set the ability to power on/off an instance.
:param instance: nova.objects.instance.Instance
"""
raise NotImplementedError()

def unrescue(
self,
context: nova_context.RequestContext,
Expand Down

0 comments on commit caa5f9e

Please sign in to comment.