From 30351a17a8a7cdec0b1023786bcee6829d40eb7b Mon Sep 17 00:00:00 2001 From: Brano Zarnovican Date: Mon, 7 Jan 2013 15:37:05 +0100 Subject: [PATCH] FEATURE: allow to create volume from snapshot of smaller size --- nova/volume/netapp.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/nova/volume/netapp.py b/nova/volume/netapp.py index 43e65c9..597ded6 100644 --- a/nova/volume/netapp.py +++ b/nova/volume/netapp.py @@ -921,6 +921,19 @@ class NetAppISCSIDriver(driver.ISCSIDriver): Request=request) self._check_fail(request, response) + def _resize_lun(self, lun_id, new_size): + """Resize LUN to the 'new_size' (GB)""" + server = self.client.service + gigabytes = 1073741824L # 2^30 + try: + res = server.LunResize(LunNameOrId=lun_id, + NewSize=(new_size * gigabytes), + ResizeUnderlyingVolume=False) + self._wait_for_job(res) + except (suds.WebFault, Exception): + msg = _('Failed to resize lun "%s"') + raise exception.VolumeBackendAPIException(data=msg % lun_id) + def _create_qtree(self, host_id, vol_name, qtree_name): """Create a qtree the filer.""" request = self.client.factory.create('Request') @@ -978,7 +991,7 @@ class NetAppISCSIDriver(driver.ISCSIDriver): """ vol_size = volume['size'] snap_size = snapshot['volume_size'] - if vol_size != snap_size: + if vol_size < snap_size: msg = _('Cannot create volume of size %(vol_size)s from ' 'snapshot of size %(snap_size)s') raise exception.VolumeBackendAPIException(data=msg % locals()) @@ -1006,6 +1019,9 @@ class NetAppISCSIDriver(driver.ISCSIDriver): self._clone_lun(lun.HostId, src_path, dest_path, False) self._refresh_dfm_luns(lun.HostId) self._discover_dataset_luns(dataset, clone_name) + if vol_size > snap_size: + new_lun = self._lookup_lun_for_volume(clone_name, project) + self._resize_lun(new_lun.id, vol_size) def check_for_export(self, context, volume_id): raise NotImplementedError() -- 1.7.11.7