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',
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):
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