def qemu_img_info(path, format=None):
 if ((not os.path.exists(path)) and (CONF.libvirt.images_type != 'rbd')):
  raise exception.DiskNotFound(location=path)
 try:
  if (os.path.isdir(path) and os.path.exists(os.path.join(path, 'DiskDescriptor.xml'))):
   path = os.path.join(path, 'root.hds')
  cmd = ('env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info', path)
  if (format is not None):
   cmd = (cmd + ('-f', format))
  (out, err) = utils.execute(prlimit=QEMU_IMG_LIMITS, *cmd)
 except processutils.ProcessExecutionError as exp:
  if (exp.exit_code == (-9)):
   msg = (_('qemu-img aborted by prlimits when inspecting %(path)s : %(exp)s') % {'path': path, 'exp': exp})
  else:
   msg = (_('qemu-img failed to execute on %(path)s : %(exp)s') % {'path': path, 'exp': exp})
  raise exception.InvalidDiskInfo(reason=msg)
 if (not out):
  msg = (_('Failed to run qemu-img info on %(path)s : %(error)s') % {'path': path, 'error': err})
  raise exception.InvalidDiskInfo(reason=msg)
 return imageutils.QemuImgInfo(out)

def qemu_img_info ( path , format = None ) : if ( ( not os . path . exists ( path ) ) and ( CONF . libvirt . images_type != 'rbd' ) ) : raise exception . DiskNotFound ( location = path ) try : if ( os . path . isdir ( path ) and os . path . exists ( os . path . join ( path , 'DiskDescriptor.xml' ) ) ) : path = os . path . join ( path , 'root.hds' ) cmd = ( 'env' , 'LC_ALL=C' , 'LANG=C' , 'qemu-img' , 'info' , path ) if ( format is not None ) : cmd = ( cmd + ( '-f' , format ) ) ( out , err ) = utils . execute ( prlimit = QEMU_IMG_LIMITS , * cmd ) except processutils . ProcessExecutionError as exp : if ( exp . exit_code == ( - 9 ) ) : msg = ( _ ( 'qemu-img aborted by prlimits when inspecting %(path)s : %(exp)s' ) % { 'path' : path , 'exp' : exp } ) else : msg = ( _ ( 'qemu-img failed to execute on %(path)s : %(exp)s' ) % { 'path' : path , 'exp' : exp } ) raise exception . InvalidDiskInfo ( reason = msg ) if ( not out ) : msg = ( _ ( 'Failed to run qemu-img info on %(path)s : %(error)s' ) % { 'path' : path , 'error' : err } ) raise exception . InvalidDiskInfo ( reason = msg ) return imageutils . QemuImgInfo ( out )
return an object containing the parsed output from qemu-img info .