def launch_node()

in lib/muchos/ec2.py [0:0]


    def launch_node(self, hostname, services, sg_id):

        request = self.init_request(hostname, services, sg_id)

        request["MinCount"] = 1
        request["MaxCount"] = 1

        tags = [
            {
                "Key": "Name",
                "Value": self.config.cluster_name + "-" + hostname,
            },
            {"Key": "Muchos", "Value": self.config.cluster_name},
        ]

        for key, val in self.config.instance_tags().items():
            tags.append({"Key": key, "Value": val})

        request["TagSpecifications"] = [
            {"ResourceType": "instance", "Tags": tags}
        ]

        if self.config.has_option("ec2", "user_data_path"):
            user_data_path = self.config.get("ec2", "user_data_path")
            with open(user_data_path, "r") as user_data_file:
                user_data = user_data_file.read()
            request["UserData"] = user_data

        ec2 = boto3.client("ec2")
        response = None
        try:
            response = ec2.run_instances(**request)
        except ClientError as e:
            exit(
                "ERROR - Failed to launch EC2 instance due to exception:"
                "\n\n{0}\n\n{1}".format(e, AMI_HELP_MSG)
            )

        if response is None or len(response["Instances"]) != 1:
            exit("ERROR - Failed to start {0} node".format(hostname))

        print(
            "Launching {0} node using {1}".format(hostname, request["ImageId"])
        )
        return response["Instances"][0]