]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Check replication status failed for non-replication
authorTaoBai <baitaosh@cn.ibm.com>
Tue, 16 Sep 2014 08:14:16 +0000 (11:14 +0300)
committerTaoBai <baitaosh@cn.ibm.com>
Wed, 17 Sep 2014 06:38:13 +0000 (09:38 +0300)
Need to check self.replication whether is None before the
function get_replication_status be called.

Closes-bug: #1365392

Change-Id: I6f6939a98091e40537f2355bb716b4b3205845e2

cinder/tests/test_storwize_svc.py
cinder/volume/drivers/ibm/storwize_svc/__init__.py

index a79b59271db7abff60cc91364476cfb2ce042089..6e474476a0bc887a92a7b55e1a43e0f8c26a38cf 100644 (file)
@@ -2796,6 +2796,15 @@ class StorwizeSVCDriverTestCase(test.TestCase):
 
         self.assertEqual(term_data, term_ret)
 
+    def test_storwize_create_volume_with_replication_disable(self):
+        volume = self._generate_vol_info(None, None)
+
+        model_update = self.driver.create_volume(volume)
+        self.assertIsNone(model_update)
+
+        model_update = self.driver.get_replication_status(self.ctxt, volume)
+        self.assertIsNone(model_update)
+
     def test_storwize_create_volume_with_strech_cluster_replication(self):
         # Set replication flag, set pool openstack2 for secondary volume.
         self._set_flag('storwize_svc_stretched_cluster_partner', 'openstack2')
index ce649ac1ce6f29f239675b6440d0c2061779e05f..4bdb194f8ceea8a5842efd8f1246cab536e7fe65 100644 (file)
@@ -753,7 +753,10 @@ class StorwizeSVCDriver(san.SanDriver):
         return replica_status
 
     def get_replication_status(self, ctxt, volume):
-        return self.replication.get_replication_status(volume)
+        replica_status = None
+        if self.replication:
+            replica_status = self.replication.get_replication_status(volume)
+        return replica_status
 
     def _check_volume_copy_ops(self):
         LOG.debug("enter: update volume copy status")