swift_context.py 文件源码

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

项目:charm-swift-proxy 作者: openstack 项目源码 文件源码
def get_swift_hash():
    if os.path.isfile(SWIFT_HASH_FILE):
        with open(SWIFT_HASH_FILE, 'r') as hashfile:
            swift_hash = hashfile.read().strip()
    elif config('swift-hash'):
        swift_hash = config('swift-hash')
        with open(SWIFT_HASH_FILE, 'w') as hashfile:
            hashfile.write(swift_hash)
    else:
        model_uuid = os.environ.get("JUJU_ENV_UUID",
                                    os.environ.get("JUJU_MODEL_UUID"))
        swift_hash = str(uuid.uuid3(uuid.UUID(model_uuid),
                                    service_name()))
        with open(SWIFT_HASH_FILE, 'w') as hashfile:
            hashfile.write(swift_hash)

    return swift_hash
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号