metadata.py 文件源码

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

项目:aws-acl-helper 作者: brandond 项目源码 文件源码
def store_interface(config, interface, key=None, exist='SET_IF_NOT_EXIST'):
    redis = yield from aioredis.create_redis((config.redis_host, config.redis_port))
    pipe = redis.pipeline()
    interface_id = interface['network_interface_id']

    # Only store picked interface data if using default key (not fixed key from instance)
    if not key:
        key = KEY_ENI + interface_id
        pipe.set(key=KEY_ENI + interface_id, value=pickle.dumps(interface), expire=int(config.redis_ttl))

    # Store intermediate key lookups so that we can find metadata given only an IP address
    if 'association' in interface:
        pipe.set(key=KEY_IP + interface['association']['public_ip'], value=key, expire=int(config.redis_ttl), exist=exist)

    for address in interface.get('private_ip_addresses', []):
        pipe.set(key=KEY_IP + address['private_ip_address'], value=key, expire=int(config.redis_ttl), exist=exist)

    yield from pipe.execute()
    redis.close()
    yield from redis.wait_closed()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号