Revert "Pass host when call attach to Cinder"

Older Cinder blows up because of the extra parameter in the detach call
to Cinder. We need to find another way to pass the info.

This reverts commit d31bb4be8e.

Closes-Bug: #1538620
Change-Id: I99335827ee6492d3f5629850be8e7cbe19371830
This commit is contained in:
Ildiko Vancsa 2016-01-27 15:17:46 +00:00 committed by Matt Riedemann
parent d31bb4be8e
commit ed5958d552
6 changed files with 17 additions and 37 deletions

View File

@ -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)

View File

@ -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'

View File

@ -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(

View File

@ -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,

View File

@ -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:

View File

@ -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,