From fc3ca7a9fdb6ead6a6d196cfc81abae9024151e8 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Tue, 7 Jul 2015 14:34:18 -0700 Subject: [PATCH] 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 --- cinder/tests/unit/test_volume.py | 20 +++++++++++++++----- cinder/tests/unit/utils.py | 2 +- cinder/volume/manager.py | 1 - 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cinder/tests/unit/test_volume.py b/cinder/tests/unit/test_volume.py index 26bd8fe4a..9196497d8 100644 --- a/cinder/tests/unit/test_volume.py +++ b/cinder/tests/unit/test_volume.py @@ -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) diff --git a/cinder/tests/unit/utils.py b/cinder/tests/unit/utils.py index fa77c9010..41fce98b7 100644 --- a/cinder/tests/unit/utils.py +++ b/cinder/tests/unit/utils.py @@ -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', diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index d3b345334..71d01e126 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -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 -- 2.45.2