core.py 文件源码

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

项目:builder 作者: elifesciences 项目源码 文件源码
def current_ec2_node_id():
    """Assumes it is called inside the 'workfn' of a 'stack_all_ec2_nodes'.

    Sticking to the 'node' terminology because 'instance' is too overloaded.

    Sample value: 'i-0553487b4b6916bc9'"""

    ensure(env.host is not None, "This is supposed to be called with settings for connecting to an EC2 instance")
    current_public_ip = env.host

    ensure('public_ips' in env, "This is supposed to be called by stack_all_ec2_nodes, which provides the correct configuration")
    matching_instance_ids = [instance_id for (instance_id, public_ip) in env.public_ips.items() if current_public_ip == public_ip]

    ensure(len(matching_instance_ids) == 1, "Too many instance ids (%s) pointing to this ip (%s)" % (matching_instance_ids, current_public_ip))
    return matching_instance_ids[0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号