def can_resize_fs(image, size, use_cow=False):
 LOG.debug(_('Checking if we can resize image %(image)s. size=%(size)s, CoW=%(use_cow)s'), locals())
 virt_size = get_disk_size(image)
 if (virt_size >= size):
  LOG.debug(_('Cannot resize filesystem %s to a smaller size.'), image)
  return False
 if use_cow:
  try:
   fs = vfs.VFS.instance_for_image(image, 'qcow2', None)
   fs.setup()
   fs.teardown()
  except exception.NovaException as e:
   LOG.debug(_('Unable to mount image %(image)s with error %(error)s. Cannot resize.'), {'image': image, 'error': e})
   return False
 else:
  try:
   utils.execute('e2label', image)
  except exception.ProcessExecutionError as e:
   LOG.debug(_('Unable to determine label for image %(image)s with error %(errror)s. Cannot resize.'), {'image': image, 'error': e})
   return False
 return True

def can_resize_fs ( image , size , use_cow = False ) : LOG . debug ( _ ( 'Checking if we can resize image %(image)s. size=%(size)s, CoW=%(use_cow)s' ) , locals ( ) ) virt_size = get_disk_size ( image ) if ( virt_size >= size ) : LOG . debug ( _ ( 'Cannot resize filesystem %s to a smaller size.' ) , image ) return False if use_cow : try : fs = vfs . VFS . instance_for_image ( image , 'qcow2' , None ) fs . setup ( ) fs . teardown ( ) except exception . NovaException as e : LOG . debug ( _ ( 'Unable to mount image %(image)s with error %(error)s. Cannot resize.' ) , { 'image' : image , 'error' : e } ) return False else : try : utils . execute ( 'e2label' , image ) except exception . ProcessExecutionError as e : LOG . debug ( _ ( 'Unable to determine label for image %(image)s with error %(errror)s. Cannot resize.' ) , { 'image' : image , 'error' : e } ) return False return True
check whether we can resize contained file system .