kvESX.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:vsphere-storage-for-docker 作者: vmware 项目源码 文件源码
def load(volpath):
    """
    Load and return dictionary from the sidecar
    """
    meta_file = lib.DiskLib_SidecarMakeFileName(volpath.encode(),
                                                DVOL_KEY.encode())
    retry_count = 0
    vol_name = vmdk_utils.get_volname_from_vmdk_path(volpath)
    while True:
        try:
            with open(meta_file, "r") as fh:
                kv_str = fh.read()
            break
        except IOError as open_error:
            # This is a workaround to the timing/locking with metadata files issue #626
            if open_error.errno == errno.EBUSY and retry_count <= vmdk_utils.VMDK_RETRY_COUNT:
                logging.warning("Meta file %s busy for load(), retrying...", meta_file)
                vmdk_utils.log_volume_lsof(vol_name)
                retry_count += 1
                time.sleep(vmdk_utils.VMDK_RETRY_SLEEP)
            else:
                logging.exception("Failed to access %s", meta_file)
                return None

    try:
        return json.loads(kv_str)
    except ValueError:
        logging.exception("load:Failed to decode meta-data for %s", volpath)
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号