From: Viraj Hardikar Date: Mon, 22 Jul 2013 18:53:47 +0000 (-0700) Subject: Implements extend volume feature in HP 3PAR driver X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ef75b0c97352f16c5e02fc28bcd34aefe079ccfc;p=openstack-build%2Fcinder-build.git Implements extend volume feature in HP 3PAR driver This patch enables the extend volume feature to be used in cinder when the backend storage is a 3PAR array. Change-Id: I8c8422f0ffc6d55ebe80fa8b2962b54eca266974 --- diff --git a/cinder/tests/test_hp3par.py b/cinder/tests/test_hp3par.py index f81654f1e..26eb9c970 100644 --- a/cinder/tests/test_hp3par.py +++ b/cinder/tests/test_hp3par.py @@ -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): diff --git a/cinder/volume/drivers/san/hp/hp_3par_common.py b/cinder/volume/drivers/san/hp/hp_3par_common.py index 5fa12ea02..14e7e327b 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_common.py +++ b/cinder/volume/drivers/san/hp/hp_3par_common.py @@ -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 diff --git a/cinder/volume/drivers/san/hp/hp_3par_fc.py b/cinder/volume/drivers/san/hp/hp_3par_fc.py index 66046a9f3..29f7be903 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_fc.py +++ b/cinder/volume/drivers/san/hp/hp_3par_fc.py @@ -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) diff --git a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py index 92799df42..fc4602855 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py +++ b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py @@ -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)