]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix missing pool name in consistency group
authorWalter A. Boring IV <walter.boring@hp.com>
Tue, 7 Jul 2015 21:34:18 +0000 (14:34 -0700)
committerWalter A. Boring IV <walter.boring@hp.com>
Tue, 7 Jul 2015 21:53:27 +0000 (14:53 -0700)
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
cinder/tests/unit/utils.py
cinder/volume/manager.py

index 26bd8fe4a35a2b1056a14ae1aa4eadf1f5715f17..9196497d860a60bcde61510dcb44c60b4d270082 100644 (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)
index fa77c901057287ddf5e39065290c303b8ad83029..41fce98b715d5facb7cdad48c1a8045281831384 100644 (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',
index d3b34533420d00597aafaed44b63b8162ee67bc0..71d01e126c5daac8b08bee57f3935f8a0c87c45a 100644 (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