def is_image_extendable(image): """Check whether we can extend the image.""" LOG.debug('Checking if we can extend filesystem inside %(image)s.', {'image': image}) # For anything except a local raw file we must # go via the VFS layer if (not isinstance(image, imgmodel.LocalImage) or image.format != imgmodel.FORMAT_RAW): fs = None try: fs = vfs.VFS.instance_for_image(image, None) fs.setup(mount=False) if fs.get_image_fs() in SUPPORTED_FS_TO_EXTEND: return True except exception.NovaException as e: # FIXME(sahid): At this step we probably want to break the # process if something wrong happens however our CI # provides a bad configuration for libguestfs reported in # the bug lp#1413142. When resolved we should remove this # except to let the error to be propagated. LOG.warning( 'Unable to mount image %(image)s with ' 'error %(error)s. Cannot resize.', { 'image': image, 'error': e }) finally: if fs is not None: fs.teardown() return False else: # For raw, we can directly inspect the file system try: utils.execute('e2label', image.path) except processutils.ProcessExecutionError as e: LOG.debug( 'Unable to determine label for image %(image)s with ' 'error %(error)s. Cannot resize.', { 'image': image, 'error': e }) return False return True
def is_image_extendable(image): """Check whether we can extend the image.""" LOG.debug('Checking if we can extend filesystem inside %(image)s.', {'image': image}) # For anything except a local raw file we must # go via the VFS layer if (not isinstance(image, imgmodel.LocalImage) or image.format != imgmodel.FORMAT_RAW): fs = None try: fs = vfs.VFS.instance_for_image(image, None) fs.setup(mount=False) if fs.get_image_fs() in SUPPORTED_FS_TO_EXTEND: return True except exception.NovaException as e: # FIXME(sahid): At this step we probably want to break the # process if something wrong happens however our CI # provides a bad configuration for libguestfs reported in # the bug lp#1413142. When resolved we should remove this # except to let the error to be propagated. LOG.warning('Unable to mount image %(image)s with ' 'error %(error)s. Cannot resize.', {'image': image, 'error': e}) finally: if fs is not None: fs.teardown() return False else: # For raw, we can directly inspect the file system try: processutils.execute('e2label', image.path) except processutils.ProcessExecutionError as e: LOG.debug('Unable to determine label for image %(image)s with ' 'error %(error)s. Cannot resize.', {'image': image, 'error': e}) return False return True