def get_hostnames()

in aws/autoscaling.py [0:0]


    def get_hostnames(self, name, size):
        """
        Waits until the asg has at least <size> instances in "InService"
        state and returns their public dns names.
        """
        for _ in wait_for(f"autoscaling group: {name} to reach size >= {size}"):
            asg_desc = self.describe_asg(name)
            if not asg_desc:
                return []
            else:
                instances = asg_desc["Instances"]
                ready_instance_ids = [
                    e["InstanceId"]
                    for e in instances
                    if e["LifecycleState"] == "InService"
                ]
                if len(ready_instance_ids) >= size:
                    paginator = self._ec2.get_paginator("describe_instances")

                    hostnames = []
                    instance_ids = []
                    for e in paginator.paginate(InstanceIds=ready_instance_ids):
                        for r in e["Reservations"]:
                            for i in r["Instances"]:
                                hostnames.append(i["PublicDnsName"])
                                instance_ids.append(i["InstanceId"])
                    return instance_ids, hostnames