Fix a typo in compute/manager::remove_volume_connection()
A typo made in the placement of a paren in a recent refactoring resulted in definitely broken code. Unfortunately, this was not in a tested path and so went unnoticed. This adds a test and fixes the problem. Change-Id: Id24169894ffda6da0301d1dc38b2f2bb29ebbd58
This commit is contained in:
parent
0c0a848c7d
commit
1f349440f9
|
@ -4363,9 +4363,10 @@ class ComputeManager(manager.Manager):
|
|||
try:
|
||||
bdm = block_device_obj.BlockDeviceMapping.get_by_volume_id(
|
||||
context, volume_id)
|
||||
self._detach_volume(context,
|
||||
instance_obj.Instance._from_db_object(
|
||||
context, instance, bdm))
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
context, instance_obj.Instance(),
|
||||
instance)
|
||||
self._detach_volume(context, inst_obj, bdm)
|
||||
connector = self.driver.get_volume_connector(instance)
|
||||
self.volume_api.terminate_connection(context, volume_id, connector)
|
||||
except exception.NotFound:
|
||||
|
|
|
@ -1194,6 +1194,20 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
self.assertFalse(allow_reboot)
|
||||
self.assertEqual(reboot_type, 'HARD')
|
||||
|
||||
@mock.patch('nova.objects.block_device.BlockDeviceMapping.'
|
||||
'get_by_volume_id')
|
||||
@mock.patch('nova.compute.manager.ComputeManager._detach_volume')
|
||||
@mock.patch('nova.objects.instance.Instance._from_db_object')
|
||||
def test_remove_volume_connection(self, inst_from_db, detach, bdm_get):
|
||||
bdm = mock.sentinel.bdm
|
||||
inst_obj = mock.sentinel.inst_obj
|
||||
bdm_get.return_value = bdm
|
||||
inst_from_db.return_value = inst_obj
|
||||
with mock.patch.object(self.compute, 'volume_api'):
|
||||
self.compute.remove_volume_connection(self.context, 'vol',
|
||||
{'uuid': 'fake-inst'})
|
||||
detach.assert_called_once_with(self.context, inst_obj, bdm)
|
||||
|
||||
|
||||
class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue