]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
CoraidDriver: retrive volume info (improvement)
authorJean-Baptiste RANSY <jean-baptiste.ransy@alyseo.com>
Tue, 19 Mar 2013 15:56:21 +0000 (16:56 +0100)
committerJean-Baptiste RANSY <jean-baptiste.ransy@alyseo.com>
Tue, 19 Mar 2013 15:58:13 +0000 (16:58 +0100)
Some portions of code into this method are useless since
the REST API on Coraid side has been improved.

Fixes bug #1157242

Change-Id: Ie37b5b76710e77acb2acf627c9688e4f931e686c

cinder/tests/test_coraid.py
cinder/volume/drivers/coraid.py

index e1db993d481c5c66c5520504370ef4b4707d830b..847d651d172332006a92cc2400d10504a1e7b0d0 100644 (file)
@@ -160,7 +160,7 @@ class TestCoraidRESTClient(test.TestCase):
 
     def test__get_volume_info(self):
         setattr(self.rest_mock, '_get_volume_info',
-                lambda *_: True)
+                lambda *_: fake_volume_info)
         self.stubs.Set(CoraidRESTClient, '_esm',
                        lambda *_: fake_esm_fetch)
         self.drv._get_volume_info(fake_volume_name)
index 8471a0b66ddb257ba08d3392800f61ab814e958b..260a48aeae70813d1de01207b689ddf5622245f5 100644 (file)
@@ -144,31 +144,19 @@ class CoraidRESTClient(object):
                 raise CoraidESMException(msg % dict(message=errmsg))
         return False
 
-    def _get_volume_info(self, lvname):
-        """Fetch information for a given Volume or Snapshot."""
-        self._login()
-        url = 'fetch?shelf=cms&orchStrRepo&lv=%s' % (lvname)
-        response = self._esm(url)
-
-        items = []
-        for cmd, reply in response:
-            if len(reply['reply']) != 0:
-                items.append(reply['reply'])
-
-        volume_info = False
-        for item in items[0]:
-            if item['lv']['name'] == lvname:
-                volume_info = {
-                    "pool": item['lv']['containingPool'],
-                    "repo": item['repoName'],
-                    "vsxidx": item['lv']['lunIndex'],
-                    "index": item['lv']['lvStatus']['exportedLun']['lun'],
-                    "shelf": item['lv']['lvStatus']['exportedLun']['shelf']}
-
-        if volume_info:
-            return volume_info
-        else:
-            msg = _('Informtion about Volume %(volname)s not found')
+    def _get_volume_info(self, volume_name):
+        """Retrive volume informations for a given volume name."""
+        url = 'fetch?shelf=cms&orchStrRepo&lv=%s' % (volume_name)
+        try:
+            response = self._esm(url)
+            info = response[0][1]['reply'][0]
+            return {"pool": info['lv']['containingPool'],
+                    "repo": info['repoName'],
+                    "vsxidx": info['lv']['lunIndex'],
+                    "index": info['lv']['lvStatus']['exportedLun']['lun'],
+                    "shelf": info['lv']['lvStatus']['exportedLun']['shelf']}
+        except Exception:
+            msg = _('Unable to retrive volume infos for volume %(volname)s')
             raise CoraidESMException(msg % dict(volname=volume_name))
 
     def _get_lun_address(self, volume_name):