ec2_vpc_route_table_helper.py 文件源码

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

项目:ansible-oss 作者: sailthru 项目源码 文件源码
def lookup_instance(self, name):
        try:
            ec2_conn = boto.ec2.connect_to_region(region_name=self.region, profile_name=self.profile)
        except Exception as e:
            raise AnsibleError(e)
        filters = {self.filter: name}

        reservations = ec2_conn.get_all_instances(filters={'tag:name': 'nat-main'})

        instances = [i for r in reservations for i in r.instances]

        for instance in instances:

            if instance.state == 'terminated' or instance.state == 'stopped':
                continue
            return instance.id.encode('utf-8')

        return name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号