コード例 #1
0
def abort():
    utils.status("Aborting %s QA deploy" % env.environment)
    qa_autoscaling_group = autoscale.get(asg_type='QA')
    if not qa_autoscaling_group:
        utils.failure('No QA %s environment exists' % env.environment)
        sys.exit(1)
    ec2.remove_nagios_config(autoscaling_group=qa_autoscaling_group)
    qa_autoscaling_group.shutdown_instances()
    qa_autoscaling_group.delete(force_delete=True)
    autoscale.delete_launch_config(autoscaling_group=qa_autoscaling_group)
    utils.success(
        "Successfully aborted the %s QA deploy" % env.environment)
コード例 #2
0
def confirm():
    utils.status("Confirm QA => %s deployment" % env.environment)
    active_autoscaling_group = autoscale.get(asg_type='Active')
    qa_autoscaling_group = autoscale.get(asg_type='QA')
    if not qa_autoscaling_group:
        utils.failure("There is no QA autoscaling group to confirm, exiting.")
        sys.exit(0)
    autoscale.tag_qa_as_active()
    autoscale.tag_active_as_inactive()
    load_balancer = elb.get(load_balancer_name=env.load_balancer_name)
    elb.register_instances(load_balancer=load_balancer,
                           autoscaling_group=qa_autoscaling_group)
    qa_autoscaling_group.resume_processes(
        scaling_processes=['AddToLoadBalancer'])
    route53.link_base_urls(load_balancer=load_balancer)
    route53.unlink_qa_urls(autoscaling_group=qa_autoscaling_group)

    utils.status('Waiting 15 seconds before removing old instances')
    """
    We sleep here for 15 seconds before removing the currently live
    infrastructure from the load balancer to be on the safe side. Removing the
    live infrastructure before we've properly added the new infrastrucutre to
    the load balancer would result in bad times.
    """
    time.sleep(15)
    ec2.remove_nagios_config(autoscaling_group=active_autoscaling_group)
    elb.deregister_instances(load_balancer=load_balancer,
                             autoscaling_group=active_autoscaling_group)

    utils.status('Scaling down old live autoscaling group')
    autoscale.scale_down(autoscaling_group=active_autoscaling_group)

    utils.status('Shutting down old autoscaling group')
    autoscale.tag_inactive_as_old()
    old_autoscaling_group = autoscale.get(asg_type='Old')
    if old_autoscaling_group:
        old_autoscaling_group.shutdown_instances()
        old_autoscaling_group.delete(force_delete=True)
        autoscale.delete_launch_config(
            autoscaling_group=old_autoscaling_group)
    utils.success("Successfully confirmed the %s deploy" % env.environment)