'Test that attaching volume reserved for another mode fails.'

def test_attach_attaching_volume_with_different_mode(self):

    volume = self._create_volume(self.ctx, {'provider_location': '', 'size': 1, 'status': 'attaching', 'instance_uuid': fake.INSTANCE_ID, 'admin_metadata': {'attached_mode': 'rw'}})
    values = {'status': 'attaching'}
    db.volume_update(self.ctx, volume['id'], values)
    db.volume_admin_metadata_update(self.ctx, volume['id'], {'attached_mode': 'rw'}, False)
    mountpoint = '/dev/vbd'
    self.assertRaises(exception.InvalidVolume, self.volume_api.attach, self.ctx, volume, fake.INSTANCE_ID, None, mountpoint, 'ro')
