Fix missing pool name in consistency group

This patch makes sure that the entire host is used
in the consistency group host entry.  Previously,
whatever host entry was in the database was being
overwritten by the volume manager's self.host entry,
which doesn't contain a pool.

Change-Id: Ib377429f9cb442b5aaeb2338dd36b6e33f49a41c
Closes-Bug: 1472344
This commit is contained in:
Walter A. Boring IV 2015-07-07 14:34:18 -07:00
parent 5464cdd836
commit fc3ca7a9fd
3 changed files with 16 additions and 7 deletions

View File

@ -4573,20 +4573,30 @@ class VolumeTestCase(BaseVolumeTestCase):
return_value=["RESERVATION"])
@mock.patch.object(CGQUOTAS, "commit")
@mock.patch.object(CGQUOTAS, "rollback")
@mock.patch.object(driver.VolumeDriver,
"create_consistencygroup",
return_value={'status': 'available'})
@mock.patch.object(driver.VolumeDriver,
"delete_consistencygroup",
return_value=({'status': 'deleted'}, []))
def test_create_delete_consistencygroup(self, fake_delete_cg,
fake_create_cg, fake_rollback,
fake_rollback,
fake_commit, fake_reserve):
"""Test consistencygroup can be created and deleted."""
def fake_driver_create_cg(context, group):
"""Make sure that the pool is part of the host."""
self.assertIn('host', group)
host = group['host']
pool = volutils.extract_host(host, level='pool')
self.assertEqual(pool, 'fakepool')
return {'status': 'available'}
self.stubs.Set(self.volume.driver, 'create_consistencygroup',
fake_driver_create_cg)
group = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2')
volume_type='type1,type2',
host='fakehost@fakedrv#fakepool')
group_id = group['id']
self.assertEqual(0, len(self.notifier.notifications),
self.notifier.notifications)

View File

@ -98,7 +98,7 @@ def create_snapshot(ctxt,
def create_consistencygroup(ctxt,
host='test_host',
host='test_host@fakedrv#fakepool',
name='test_cg',
description='this is a test cg',
status='available',

View File

@ -1902,7 +1902,6 @@ class VolumeManager(manager.SchedulerDependentManager):
"""Creates the consistency group."""
context = context.elevated()
group_ref = self.db.consistencygroup_get(context, group_id)
group_ref['host'] = self.host
status = 'available'
model_update = False