]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Implements extend volume feature in HP 3PAR driver
authorViraj Hardikar <viraj.hardikar@hp.com>
Mon, 22 Jul 2013 18:53:47 +0000 (11:53 -0700)
committerViraj Hardikar <viraj.hardikar@hp.com>
Wed, 24 Jul 2013 18:41:10 +0000 (11:41 -0700)
This patch enables the extend volume feature to be used in cinder
when the backend storage is a 3PAR array.

Change-Id: I8c8422f0ffc6d55ebe80fa8b2962b54eca266974

cinder/tests/test_hp3par.py
cinder/volume/drivers/san/hp/hp_3par_common.py
cinder/volume/drivers/san/hp/hp_3par_fc.py
cinder/volume/drivers/san/hp/hp_3par_iscsi.py

index f81654f1edba39782a4d90fee486746853c17647..26eb9c9701fae3c9829482d77df12ac16c8c7825 100644 (file)
@@ -396,6 +396,15 @@ class HP3PARBaseDriver():
     def fake_get_domain(self, cpg):
         return HP3PAR_DOMAIN
 
+    def fake_extend_volume(self, volume, new_size):
+        vol = self.driver.common.client.getVolume(volume['name'])
+        old_size = vol['sizeMiB']
+        option = {'comment': vol['comment'], 'snapCPG': vol['snapCPG']}
+        self.driver.common.client.deleteVolume(volume['name'])
+        self.driver.common.client.createVolume(vol['name'],
+                                               vol['userCPG'],
+                                               new_size, option)
+
     def fake_get_3par_host(self, hostname):
         if hostname not in self._hosts:
             msg = {'code': 'NON_EXISTENT_HOST',
@@ -537,6 +546,22 @@ class HP3PARBaseDriver():
                           self.driver.common.client.getVLUN,
                           self.VOLUME_3PAR_NAME)
 
+    def test_extend_volume(self):
+        self.flags(lock_path=self.tempdir)
+        self.stubs.UnsetAll()
+        self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "extend_volume",
+                       self.fake_extend_volume)
+        option = {'comment': '', 'snapCPG': HP3PAR_CPG_SNAP}
+        self.driver.common.client.createVolume(self.volume['name'],
+                                               HP3PAR_CPG,
+                                               self.volume['size'],
+                                               option)
+        old_size = self.volume['size']
+        volume = self.driver.common.client.getVolume(self.volume['name'])
+        self.driver.extend_volume(volume, str(old_size + 1))
+        vol = self.driver.common.client.getVolume(self.volume['name'])
+        self.assertEqual(vol['sizeMiB'], str(old_size + 1))
+
 
 class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
 
index 5fa12ea02247964e3167a41b75991608b4feecb0..14e7e327b05112f9e4b8e4ed4df5333355f26071 100644 (file)
@@ -195,6 +195,19 @@ class HP3PARCommon(object):
             raise exception.InvalidInput(reason=err)
         return domain
 
+    def extend_volume(self, volume, new_size):
+        volume_name = self._get_3par_vol_name(volume['id'])
+        old_size = volume.size
+        growth_size = int(new_size) - old_size
+        LOG.debug("Extending Volume %s from %s to %s, by %s GB." %
+                  (volume_name, old_size, new_size, growth_size))
+        try:
+            self._cli_run("growvv -f %s %sg" % (volume_name, growth_size),
+                          None)
+        except Exception:
+            with excutils.save_and_reraise_exception():
+                LOG.error(_("Error extending volume %s") % volume)
+
     def _get_3par_vol_name(self, volume_id):
         """
         Converts the openstack volume id from
index 66046a9f3f78c7d86a46cd1511c4411805b5af7d..29f7be9034d23845275018806c02e88fb4c4138e 100644 (file)
@@ -248,3 +248,6 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
     @utils.synchronized('3par', external=True)
     def remove_export(self, context, volume):
         pass
+
+    def extend_volume(self, volume, new_size):
+        self.common.extend_volume(volume, new_size)
index 92799df42ffb5416c837bc5942d253ec6f249a2d..fc4602855aaef1a468b4083fbcd89dcb214fb63a 100644 (file)
@@ -384,3 +384,6 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver):
                     current_smallest_count = count
 
         return current_least_used_nsp
+
+    def extend_volume(self, volume, new_size):
+        self.common.extend_volume(volume, new_size)