]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix a problem in creating consistency group in ProphetStor driver.
authorrick.chen <rick.chen@prophetstor.com>
Wed, 12 Nov 2014 03:50:37 +0000 (11:50 +0800)
committerrick.chen <rick.chen@prophetstor.com>
Tue, 18 Nov 2014 13:37:46 +0000 (21:37 +0800)
a.Failed to create CG in the storage:
  Storage site cannot accept CG uuid including "-" word. Before
  sending API to back-end storage, the "-" word in the CG uuid
  needs to be removed.
b.Failed to delete volume of CG:
  Corrected api leaving group operation key.

Change-Id: I017b2f65c4da6961219f0b972edae2b1cb447878
Closes-Bug: 1391724

cinder/tests/test_prophetstor_dpl.py
cinder/volume/drivers/prophetstor/dplcommon.py

index 1539eef0783c9bbbc25cb965633d23ece6b78715..c390af722e543355de8db105fac8eb57768d2b1a 100644 (file)
@@ -90,7 +90,7 @@ DATA_OUTPUT = 0, None
 
 MOD_OUTPUT = {'status': 'available'}
 
-DATA_IN_GROUP = {'id': 'group123',
+DATA_IN_GROUP = {'id': 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee',
                  'name': 'group123',
                  'description': 'des123',
                  'status': ''}
@@ -104,7 +104,8 @@ DATA_IN_VOLUME_VG = {'id': 'abc123',
                      'display_name': 'abc123',
                      'display_description': '',
                      'size': 1,
-                     'consistencygroup_id': 'group123',
+                     'consistencygroup_id':
+                         'fe2dbc51-5810-451d-ab2f-8c8a48d15bee',
                      'status': 'available'}
 
 DATA_IN_VOLUME1 = {'id': 'abc456',
@@ -112,22 +113,24 @@ DATA_IN_VOLUME1 = {'id': 'abc456',
                    'display_description': '',
                    'size': 1}
 
-DATA_IN_CG_SNAPSHOT = {'consistencygroup_id': 'group123',
-                       'id': 'cgsnapshot1',
-                       'name': 'cgsnapshot1',
-                       'description': 'cgsnapshot1',
-                       'status': ''}
+DATA_IN_CG_SNAPSHOT = {
+    'consistencygroup_id': 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee',
+    'id': 'cgsnapshot1',
+    'name': 'cgsnapshot1',
+    'description': 'cgsnapshot1',
+    'status': ''}
 
 DATA_IN_SNAPSHOT = {'id': 'snapshot1',
                     'volume_id': 'abc123',
                     'display_name': 'snapshot1',
                     'display_description': ''}
 
-DATA_OUT_SNAPSHOT_CG = {'id': 'snapshot1',
-                        'volume_id': 'abc123',
-                        'display_name': 'snapshot1',
-                        'display_description': '',
-                        'cgsnapshot_id': 'cgsnapshot1'}
+DATA_OUT_SNAPSHOT_CG = {
+    'id': 'snapshot1',
+    'volume_id': 'abc123',
+    'display_name': 'snapshot1',
+    'display_description': '',
+    'cgsnapshot_id': 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee'}
 
 
 class TestProphetStorDPLVolume(test.TestCase):
@@ -484,6 +487,17 @@ class TestProphetStorDPLDriver(test.TestCase):
         self.DPL_MOCK.delete_vdev.assert_called_once_with(
             self._conver_uuid2hex(DATA_IN_VOLUME['id']))
 
+    def test_delete_volume_of_group(self):
+        self.DPL_MOCK.delete_vdev.return_value = DATA_OUTPUT
+        self.DPL_MOCK.leave_vg.return_volume = DATA_OUTPUT
+        self.dpldriver.delete_volume(DATA_IN_VOLUME_VG)
+        self.DPL_MOCK.leave_vg.assert_called_once_with(
+            self._conver_uuid2hex(DATA_IN_VOLUME_VG['id']),
+            self._conver_uuid2hex(DATA_IN_GROUP['id'])
+        )
+        self.DPL_MOCK.delete_vdev.assert_called_once_with(
+            self._conver_uuid2hex(DATA_IN_VOLUME['id']))
+
     def test_create_volume_from_snapshot(self):
         self.DPL_MOCK.create_vdev_from_snapshot.return_value = DATA_OUTPUT
         self.dpldriver.create_volume_from_snapshot(DATA_IN_VOLUME,
@@ -589,7 +603,7 @@ class TestProphetStorDPLDriver(test.TestCase):
         model_update = self.dpldriver.create_consistencygroup(self.context,
                                                               DATA_IN_GROUP)
         self.DPL_MOCK.create_vg.assert_called_once_with(
-            DATA_IN_GROUP['id'], DATA_IN_GROUP['name'],
+            self._conver_uuid2hex(DATA_IN_GROUP['id']), DATA_IN_GROUP['name'],
             DATA_IN_GROUP['description'])
         self.assertDictMatch({'status': 'available'}, model_update)
 
index 26d55bba0bd7817e9a9c84b83552a3872e2be73b..92557a557fc9a12db11ec4b4fa524f608a2f7efc 100644 (file)
@@ -667,7 +667,7 @@ class DPLVolume(object):
         metadata = {}
         params = {}
         url = '/%s/%s/' % (DPL_OBJ_VOLUMEGROUP, groupID)
-        metadata['volume_group_operation'] = 'level'
+        metadata['volume_group_operation'] = 'leave'
         metadata['volume'] = []
         metadata['volume'].append(volumeID)
         params['metadata'] = metadata
@@ -831,8 +831,10 @@ class DPLCOMMONDriver(driver.VolumeDriver):
                  {'group_name': group['name'], 'id': group['id']})
         model_update = {'status': 'available'}
         try:
-            ret, output = self.dpl.create_vg(group['id'], group['name'],
-                                             group['description'])
+            ret, output = self.dpl.create_vg(
+                self._conver_uuid2hex(group['id']),
+                group['name'],
+                group['description'])
             if ret:
                 msg = _('Failed to create consistency group '
                         '%(id)s:%(ret)s.') % {'id': group['id'],
@@ -1156,6 +1158,7 @@ class DPLCOMMONDriver(driver.VolumeDriver):
 
     def delete_volume(self, volume):
         """Deletes a volume."""
+        ret = 0
         if volume.get('consistencygroup_id', None):
             msg = ''
             try: