示例#1
0
def get_proxy_config_for_project(c, project, use):
    existing_data = BuildData.objects.filter(project="myuw",
                                             use="aws_mess_around")

    proxy_instance_id = None
    for data in existing_data:
        if "proxy" == data.role and "instance_id" == data.data_field:
            proxy_instance_id = data.value

    if not proxy_instance_id:
        tags = {
            "Project": "myuw",
            "Use": "messing-around",
            "ResponsibleParty": settings.AWS_RESPONSIBLE_PARTY
        }

        my_security_group = settings.AWS_SECURITY_GROUP_NAME
        new_ids = create_proxy_instances(c, DEMO_DOMAIN, 1,
                                         [my_security_group], tags)

        instance = get_instance(c, new_ids[0])
        ip = instance.public_ip_address
        set_v4_ips_for_domain(c, DEMO_DOMAIN, [ip])

        BuildData.objects.get_or_create(project="myuw",
                                        use="aws_mess_around",
                                        role="proxy",
                                        data_field="instance_id",
                                        defaults={"value": new_ids[0]})

        proxy_instance_id = new_ids[0]

    return {"instance_id": proxy_instance_id}
示例#2
0
def get_proxy_config_for_project(c, project, use):
    existing_data = BuildData.objects.filter(project="myuw",
                                             use="aws_mess_around")

    proxy_instance_id = None
    for data in existing_data:
        if "proxy" == data.role and "instance_id" == data.data_field:
            proxy_instance_id = data.value

    if not proxy_instance_id:
        tags = {"Project": "myuw",
                "Use": "messing-around",
                "ResponsibleParty": settings.AWS_RESPONSIBLE_PARTY}

        my_security_group = settings.AWS_SECURITY_GROUP_NAME
        new_ids = create_proxy_instances(c, DEMO_DOMAIN, 1,
                                         [my_security_group], tags)

        instance = get_instance(c, new_ids[0])
        ip = instance.public_ip_address
        set_v4_ips_for_domain(c, DEMO_DOMAIN, [ip])

        BuildData.objects.get_or_create(project="myuw", use="aws_mess_around",
                                        role="proxy", data_field="instance_id",
                                        defaults={"value": new_ids[0]})

        proxy_instance_id = new_ids[0]

    return {"instance_id": proxy_instance_id}
示例#3
0
def launch_ec2(c):
    session = c["session"]
    region_name = c["region_name"]

    ec2_client = session.client('ec2')
    ec2_region = session.resource('ec2', region_name=region_name)

    my_security_group = settings.AWS_SECURITY_GROUP_NAME
    try:
        manage_web_security_group(c, my_security_group)
    except Exception as ex:
        print "Error managing security group: ", ex

    tags = {
        "Project": "aws-initial-testing",
        "Use": "messing-around",
        "ResponsibleParty": settings.AWS_RESPONSIBLE_PARTY
    }

    instance_ids = create_webapp_instances(c, 2, NEW_DOMAIN_NAME,
                                           [my_security_group], tags)

    proxy_ids = create_proxy_instances(c, NEW_DOMAIN_NAME, 1,
                                       [my_security_group], tags)

    set_app_servers_for_proxies_by_id(c, NEW_DOMAIN_NAME, proxy_ids,
                                      instance_ids)

    public_ips = []
    for new_id in proxy_ids:
        instance = ec2_region.Instance(new_id)
        public_ips.append(instance.public_ip_address)

    set_v4_ips_for_domain(c, NEW_DOMAIN_NAME, public_ips)

    print "All running instances: "
    for instance in ec2_region.instances.all():
        instance_id = instance.id
        print "ID: ", instance_id
        print instance.public_dns_name
        print instance.key_name
def launch_ec2(c):
    session = c["session"]
    region_name = c["region_name"]

    ec2_client = session.client("ec2")
    ec2_region = session.resource("ec2", region_name=region_name)

    my_security_group = settings.AWS_SECURITY_GROUP_NAME
    try:
        manage_web_security_group(c, my_security_group)
    except Exception as ex:
        print "Error managing security group: ", ex

    tags = {
        "Project": "aws-initial-testing",
        "Use": "messing-around",
        "ResponsibleParty": settings.AWS_RESPONSIBLE_PARTY,
    }

    instance_ids = create_webapp_instances(c, 2, NEW_DOMAIN_NAME, [my_security_group], tags)

    proxy_ids = create_proxy_instances(c, NEW_DOMAIN_NAME, 1, [my_security_group], tags)

    set_app_servers_for_proxies_by_id(c, NEW_DOMAIN_NAME, proxy_ids, instance_ids)

    public_ips = []
    for new_id in proxy_ids:
        instance = ec2_region.Instance(new_id)
        public_ips.append(instance.public_ip_address)

    set_v4_ips_for_domain(c, NEW_DOMAIN_NAME, public_ips)

    print "All running instances: "
    for instance in ec2_region.instances.all():
        instance_id = instance.id
        print "ID: ", instance_id
        print instance.public_dns_name
        print instance.key_name