def _check_resize_vhd(self, vhd_path, vhd_info, new_size): curr_size = vhd_info['MaxInternalSize'] if new_size < curr_size: raise vmutils.VHDResizeException( _("Cannot resize a VHD " "to a smaller size")) elif new_size > curr_size: self._resize_vhd(vhd_path, new_size)
def _check_target_flavor(self, instance, flavor): new_root_gb = flavor.root_gb curr_root_gb = instance.root_gb if new_root_gb < curr_root_gb: raise exception.InstanceFaultRollback( vmutils.VHDResizeException( _("Cannot resize the root disk to a smaller size. " "Current size: %(curr_root_gb)s GB. Requested size: " "%(new_root_gb)s GB") % { 'curr_root_gb': curr_root_gb, 'new_root_gb': new_root_gb }))
def _is_resize_needed(self, vhd_path, old_size, new_size, instance): if new_size < old_size: error_msg = _("Cannot resize a VHD to a smaller size, the" " original size is %(old_size)s, the" " newer size is %(new_size)s" ) % {'old_size': old_size, 'new_size': new_size} raise vmutils.VHDResizeException(error_msg) elif new_size > old_size: LOG.debug("Resizing VHD %(vhd_path)s to new " "size %(new_size)s" % {'new_size': new_size, 'vhd_path': vhd_path}, instance=instance) return True return False