diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index 53965c0a591d..241d50718089 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -394,13 +394,8 @@ class ComputeVolumeTestCase(BaseTestCase): def test_attach_volume_serial(self): fake_bdm = objects.BlockDeviceMapping(context=self.context, **self.fake_volume) - - with test.nested( - mock.patch.object(cinder.API, 'get_volume_encryption_metadata'), - mock.patch.object(self.compute.driver, 'get_volume_connector') - ) as (mock_encryptor, mock_connector): - mock_encryptor.return_value = {} - mock_connector.return_value = {'host': 'fake_host'} + with (mock.patch.object(cinder.API, 'get_volume_encryption_metadata', + return_value={})): instance = self._create_fake_instance_obj() self.compute.attach_volume(self.context, instance, bdm=fake_bdm) self.assertEqual(self.cinfo.get('serial'), uuids.volume_id) @@ -525,12 +520,9 @@ class ComputeVolumeTestCase(BaseTestCase): self.assertEqual(1, attempts) def test_boot_volume_serial(self): - - with test.nested( - mock.patch.object(objects.BlockDeviceMapping, 'save'), - mock.patch.object(self.compute.driver, 'get_volume_connector') - ) as (mock_save, mock_connector): - mock_connector.return_value = {'host': 'fake_host'} + with ( + mock.patch.object(objects.BlockDeviceMapping, 'save') + ) as mock_save: block_device_mapping = [ block_device.BlockDeviceDict({ 'id': 1, @@ -785,10 +777,7 @@ class ComputeVolumeTestCase(BaseTestCase): self.stubs.Set(cinder.API, 'get_volume_encryption_metadata', fake_get_volume_encryption_metadata) - with (mock.patch.object(self.compute.driver, 'get_volume_connector') - ) as mock_connector: - mock_connector.return_value = {'host': 'fake_host'} - self.compute.attach_volume(self.context, instance, bdm) + self.compute.attach_volume(self.context, instance, bdm) # Poll volume usage & then detach the volume. This will update the # total fields in the volume usage cache. @@ -4675,14 +4664,14 @@ class ComputeTestCase(BaseTestCase): self.stubs.Set(cinder.API, "initialize_connection", fake_init_conn) def fake_attach(self, context, volume_id, instance_uuid, device_name, - mode='rw', host='fake_host'): + mode='rw'): volume['instance_uuid'] = instance_uuid volume['device_name'] = device_name self.stubs.Set(cinder.API, "attach", fake_attach) # stub out virt driver attach def fake_get_volume_connector(*args, **kwargs): - return {'host': 'fake_host'} + return {} self.stubs.Set(self.compute.driver, 'get_volume_connector', fake_get_volume_connector) diff --git a/nova/tests/unit/fake_volume.py b/nova/tests/unit/fake_volume.py index 8da77f97015c..d2e2d090b155 100644 --- a/nova/tests/unit/fake_volume.py +++ b/nova/tests/unit/fake_volume.py @@ -206,8 +206,7 @@ class API(object): if instance and not volume.get('attachments', {}).get(instance.uuid): raise exception.VolumeUnattached(volume_id=volume['id']) - def attach(self, context, volume_id, instance_uuid, mountpoint, mode='rw', - host=None): + def attach(self, context, volume_id, instance_uuid, mountpoint, mode='rw'): LOG.info('attaching volume %s', volume_id) volume = self.get(context, volume_id) volume['status'] = 'in-use' diff --git a/nova/tests/unit/virt/test_block_device.py b/nova/tests/unit/virt/test_block_device.py index 4f81d0a0ad04..6b28fd9217b0 100644 --- a/nova/tests/unit/virt/test_block_device.py +++ b/nova/tests/unit/virt/test_block_device.py @@ -450,14 +450,11 @@ class TestDriverBlockDevice(test.NoDBTestCase): if not fail_volume_attach: self.volume_api.attach(elevated_context, fake_volume['id'], 'fake_uuid', bdm_dict['device_name'], - mode=access_mode, - host=connector['host']).AndReturn( - None) + mode=access_mode).AndReturn(None) else: self.volume_api.attach(elevated_context, fake_volume['id'], 'fake_uuid', bdm_dict['device_name'], - mode=access_mode, - host=connector['host']).AndRaise( + mode=access_mode).AndRaise( test.TestingException) if driver_attach: self.virt_driver.detach_volume( diff --git a/nova/tests/unit/volume/test_cinder.py b/nova/tests/unit/volume/test_cinder.py index c37218d9cb4a..6c86cdcbceb7 100644 --- a/nova/tests/unit/volume/test_cinder.py +++ b/nova/tests/unit/volume/test_cinder.py @@ -252,12 +252,11 @@ class CinderApiTestCase(test.NoDBTestCase): mock_volumes = mock.MagicMock() mock_cinderclient.return_value = mock.MagicMock(volumes=mock_volumes) - self.api.attach(self.ctx, 'id1', 'uuid', 'point', host='fake_host') + self.api.attach(self.ctx, 'id1', 'uuid', 'point') mock_cinderclient.assert_called_once_with(self.ctx) mock_volumes.attach.assert_called_once_with('id1', 'uuid', 'point', - mode='rw', - host_name='fake_host') + mode='rw') @mock.patch('nova.volume.cinder.cinderclient') def test_attach_with_mode(self, mock_cinderclient): @@ -268,7 +267,7 @@ class CinderApiTestCase(test.NoDBTestCase): mock_cinderclient.assert_called_once_with(self.ctx) mock_volumes.attach.assert_called_once_with('id1', 'uuid', 'point', - mode='ro', host_name=None) + mode='ro') def test_detach(self): self.mox.StubOutWithMock(self.api, diff --git a/nova/virt/block_device.py b/nova/virt/block_device.py index 27768bf6c9e8..0527cf5ae2c7 100644 --- a/nova/virt/block_device.py +++ b/nova/virt/block_device.py @@ -300,10 +300,8 @@ class DriverVolumeBlockDevice(DriverBlockDevice): # detach. self.save() try: - host = connector.get('host') volume_api.attach(context, volume_id, instance.uuid, - self['mount_device'], mode=mode, - host=host) + self['mount_device'], mode=mode) except Exception: with excutils.save_and_reraise_exception(): if do_driver_attach: diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index 634855aaddb3..264935da0ed4 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -358,11 +358,9 @@ class API(object): cinderclient(context).volumes.roll_detaching(volume_id) @translate_volume_exception - def attach(self, context, volume_id, instance_uuid, mountpoint, mode='rw', - host=None): + def attach(self, context, volume_id, instance_uuid, mountpoint, mode='rw'): cinderclient(context).volumes.attach(volume_id, instance_uuid, - mountpoint, mode=mode, - host_name=host) + mountpoint, mode=mode) @translate_volume_exception def detach(self, context, volume_id, instance_uuid=None,