示例#1
0
def update_deploy_progress(request, name, stage):
    env = environs_helper.get_env_by_stage(request, name, stage)
    progress = deploys_helper.update_progress(request, name, stage)
    showMode = _fetch_param_with_cookie(request, 'showMode', MODE_COOKIE_NAME,
                                        'complete')
    sortByStatus = _fetch_param_with_cookie(request, 'sortByStatus',
                                            STATUS_COOKIE_NAME, 'true')

    report = agent_report.gen_report(request,
                                     env,
                                     progress,
                                     sortByStatus=sortByStatus)

    report.showMode = showMode
    report.sortByStatus = sortByStatus
    html = render_to_string('deploys/deploy_progress.tmpl', {
        "report": report,
        "env": env,
    })

    response = HttpResponse(html)

    # save preferences
    response.set_cookie(MODE_COOKIE_NAME, showMode)
    response.set_cookie(STATUS_COOKIE_NAME, sortByStatus)

    return response
示例#2
0
    def get(self, request, name, stage=None):
        envs = environs_helper.get_all_env_stages(request, name)

        if len(envs) == 0:
            return redirect('/')

        stages, env = common.get_all_stages(envs, stage)
        env_promote = environs_helper.get_env_promotes_config(request, name, env['stageName'])
        stage = env['stageName']
        username = request.teletraan_user_id.name
        request_feedback = check_feedback_eligible(request, username)
        groups = environs_helper.get_env_capacity(request, name, stage, capacity_type="GROUP")
        metrics = environs_helper.get_env_metrics_config(request, name, stage)
        alarms = environs_helper.get_env_alarms_config(request, name, stage)

        if not env['deployId']:
            capacity_hosts = deploys_helper.get_missing_hosts(request, name, stage)
            response = render(request, 'environs/env_landing.html', {
                "env": env,
                "env_promote": env_promote,
                "stages": stages,
                "metrics": metrics,
                "alarms": alarms,
                "request_feedback": request_feedback,
                "groups": groups,
                "capacity_hosts": capacity_hosts,
                "pinterest": IS_PINTEREST,
            })
            showMode = 'complete'
            sortByStatus = 'true'
        else:
            # Get deploy progress
            progress = deploys_helper.update_progress(request, name, stage)
            showMode = _fetch_param_with_cookie(
                request, 'showMode', MODE_COOKIE_NAME, 'complete')
            sortByStatus = _fetch_param_with_cookie(
                request, 'sortByStatus', STATUS_COOKIE_NAME, 'true')
            report = agent_report.gen_report(request, env, progress, sortByStatus=sortByStatus)
            report.showMode = showMode
            report.sortByStatus = sortByStatus
            response = render(request, 'environs/env_landing.html', {
                "env": env,
                "env_promote": env_promote,
                "stages": stages,
                "report": report,
                "has_deploy": True,
                "metrics": metrics,
                "alarms": alarms,
                "request_feedback": request_feedback,
                "groups": groups,
                "pinterest": IS_PINTEREST,
            })

        # save preferences
        response.set_cookie(ENV_COOKIE_NAME, genEnvCookie(request, name))
        response.set_cookie(MODE_COOKIE_NAME, showMode)
        response.set_cookie(STATUS_COOKIE_NAME, sortByStatus)

        return response
示例#3
0
def get_all_hosts(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    progress = deploys_helper.update_progress(request, name, stage)
    agents_wrapper = agent_report.gen_agent_by_deploy(progress, env['deployId'],
                                                      TOTAL_HOST_REPORT)
    title = "All hosts"

    return render(request, 'environs/env_hosts.html', {
        "env": env,
        "stages": stages,
        "agents_wrapper": agents_wrapper,
        "title": title,
    })
示例#4
0
def get_provisioning_hosts(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    progress = deploys_helper.update_progress(request, name, stage)
    agents_wrapper = agent_report.gen_agent_by_deploy(progress,
                                                      env['deployId'],
                                                      PROVISION_HOST_REPORT)
    title = "Provisioning hosts"

    return render(
        request, 'environs/env_hosts.html', {
            "env": env,
            "stages": stages,
            "agents_wrapper": agents_wrapper,
            "title": title,
        })
示例#5
0
def get_failed_hosts(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    progress = deploys_helper.update_progress(request, name, stage)
    agents_wrapper = agent_report.gen_agent_by_deploy(progress,
                                                      env['deployId'],
                                                      FAILED_HOST_REPORT)
    title = "Failed Hosts"

    return render(
        request, 'environs/env_hosts.html', {
            "env": env,
            "stages": stages,
            "agents_wrapper": agents_wrapper,
            "title": title,
            "is_retryable": True
        })
示例#6
0
def get_failed_hosts(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    progress = deploys_helper.update_progress(request, name, stage)
    agents_wrapper = agent_report.gen_agent_by_deploy(progress, env['deployId'],
                                                      FAILED_HOST_REPORT)
    failed_hosts = [agent['hostId'] for agent in agents_wrapper[env['deployId']]]
    host_ids = ",".join(failed_hosts)
    title = "Failed Hosts"

    return render(request, 'environs/env_hosts.html', {
        "env": env,
        "stages": stages,
        "agents_wrapper": agents_wrapper,
        "title": title,
        "is_retryable": True,
        "host_ids": host_ids,
        "pinterest": IS_PINTEREST,
    })
示例#7
0
def get_hosts_by_deploy(request, name, stage, deploy_id):
    hostStageString = request.GET.get('hostStage')
    if hostStageString is None:
        hostStage = TOTAL_ALIVE_HOST_REPORT
    else:
        hostStage = hostStageString
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    progress = deploys_helper.update_progress(request, name, stage)
    agents_wrapper = agent_report.gen_agent_by_deploy(progress, deploy_id,
                                                      ALIVE_STAGE_HOST_REPORT, hostStage)
    title = "All hosts with deploy " + deploy_id

    return render(request, 'environs/env_hosts.html', {
        "env": env,
        "stages": stages,
        "agents_wrapper": agents_wrapper,
        "title": title,
    })
示例#8
0
def get_hosts_by_deploy(request, name, stage, deploy_id):
    hostStageString = request.GET.get('hostStage')
    if hostStageString is None:
        hostStage = TOTAL_ALIVE_HOST_REPORT
    else:
        hostStage = hostStageString
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    progress = deploys_helper.update_progress(request, name, stage)
    agents_wrapper = agent_report.gen_agent_by_deploy(progress, deploy_id,
                                                      ALIVE_STAGE_HOST_REPORT,
                                                      hostStage)
    title = "All hosts with deploy " + deploy_id

    return render(
        request, 'environs/env_hosts.html', {
            "env": env,
            "stages": stages,
            "agents_wrapper": agents_wrapper,
            "title": title,
        })
示例#9
0
def get_failed_hosts(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    progress = deploys_helper.update_progress(request, name, stage)
    agents_wrapper = agent_report.gen_agent_by_deploy(progress,
                                                      env['deployId'],
                                                      FAILED_HOST_REPORT)
    failed_hosts = [
        agent['hostId'] for agent in agents_wrapper[env['deployId']]
    ]
    host_ids = ",".join(failed_hosts)
    title = "Failed Hosts"

    return render(
        request, 'environs/env_hosts.html', {
            "env": env,
            "stages": stages,
            "agents_wrapper": agents_wrapper,
            "title": title,
            "is_retryable": True,
            "host_ids": host_ids,
            "pinterest": IS_PINTEREST,
        })
示例#10
0
def update_deploy_progress(request, name, stage):
    env = environs_helper.get_env_by_stage(request, name, stage)
    progress = deploys_helper.update_progress(request, name, stage)
    showMode = _fetch_param_with_cookie(
        request, 'showMode', MODE_COOKIE_NAME, 'complete')
    sortByStatus = _fetch_param_with_cookie(
        request, 'sortByStatus', STATUS_COOKIE_NAME, 'true')

    report = agent_report.gen_report(request, env, progress, sortByStatus=sortByStatus)

    report.showMode = showMode
    report.sortByStatus = sortByStatus
    html = render_to_string('deploys/deploy_progress.tmpl', {
        "report": report,
    })

    response = HttpResponse(html)

    # save preferences
    response.set_cookie(MODE_COOKIE_NAME, showMode)
    response.set_cookie(STATUS_COOKIE_NAME, sortByStatus)

    return response
示例#11
0
    def get(self, request, name, stage=None):
        envs = environs_helper.get_all_env_stages(request, name)

        if len(envs) == 0:
            return redirect('/')

        stages, env = common.get_all_stages(envs, stage)
        env_promote = environs_helper.get_env_promotes_config(request, name, env['stageName'])
        stage = env['stageName']
        username = request.teletraan_user_id.name
        request_feedback = check_feedback_eligible(request, username)
        groups = environs_helper.get_env_capacity(request, name, stage, capacity_type="GROUP")
        metrics = environs_helper.get_env_metrics_config(request, name, stage)
        alarms = environs_helper.get_env_alarms_config(request, name, stage)
        basic_cluster_info = None
        if IS_PINTEREST:
            basic_cluster_info = clusters_helper.get_cluster(request, name, stage)

        if not env['deployId']:
            capacity_hosts = deploys_helper.get_missing_hosts(request, name, stage)
            provisioning_hosts = environ_hosts_helper.get_hosts(request, name, stage)
            if IS_PINTEREST:
                basic_cluster_info = clusters_helper.get_cluster(request, env['envName'], env['stageName'])
                if basic_cluster_info and basic_cluster_info.get('capacity'):
                    hosts_in_cluster = clusters_helper.get_host_names(request, env['envName'], env['stageName'])
                    num_to_fake = basic_cluster_info.get('capacity') - len(hosts_in_cluster)
                    for i in range(num_to_fake):
                        faked_host = {}
                        faked_host['hostName'] = 'UNKNOWN'
                        faked_host['hostId'] = 'UNKNOWN'
                        faked_host['state'] = 'PROVISIONED'
                        provisioning_hosts.append(faked_host)

            response = render(request, 'environs/env_landing.html', {
                "env": env,
                "env_promote": env_promote,
                "stages": stages,
                "metrics": metrics,
                "alarms": alarms,
                "request_feedback": request_feedback,
                "groups": groups,
                "capacity_hosts": capacity_hosts,
                "provisioning_hosts": provisioning_hosts,
                "basic_cluster_info": basic_cluster_info,
                "pinterest": IS_PINTEREST,
            })
            showMode = 'complete'
            sortByStatus = 'true'
        else:
            # Get deploy progress
            progress = deploys_helper.update_progress(request, name, stage)
            showMode = _fetch_param_with_cookie(
                request, 'showMode', MODE_COOKIE_NAME, 'complete')
            sortByStatus = _fetch_param_with_cookie(
                request, 'sortByStatus', STATUS_COOKIE_NAME, 'true')
            report = agent_report.gen_report(request, env, progress, sortByStatus=sortByStatus)
            report.showMode = showMode
            report.sortByStatus = sortByStatus
            response = render(request, 'environs/env_landing.html', {
                "env": env,
                "env_promote": env_promote,
                "stages": stages,
                "report": report,
                "has_deploy": True,
                "metrics": metrics,
                "alarms": alarms,
                "request_feedback": request_feedback,
                "groups": groups,
                "basic_cluster_info": basic_cluster_info,
                "pinterest": IS_PINTEREST,
            })

        # save preferences
        response.set_cookie(ENV_COOKIE_NAME, genEnvCookie(request, name))
        response.set_cookie(MODE_COOKIE_NAME, showMode)
        response.set_cookie(STATUS_COOKIE_NAME, sortByStatus)

        return response
示例#12
0
    def get(self, request, name, stage=None):
        envs = environs_helper.get_all_env_stages(request, name)

        if len(envs) == 0:
            return redirect('/')

        stages, env = common.get_all_stages(envs, stage)
        env_promote = environs_helper.get_env_promotes_config(
            request, name, env['stageName'])
        stage = env['stageName']
        username = request.teletraan_user_id.name
        request_feedback = check_feedback_eligible(request, username)
        groups = environs_helper.get_env_capacity(request,
                                                  name,
                                                  stage,
                                                  capacity_type="GROUP")
        metrics = environs_helper.get_env_metrics_config(request, name, stage)
        alarms = environs_helper.get_env_alarms_config(request, name, stage)
        basic_cluster_info = clusters_helper.get_cluster(request, name, stage)

        if not env['deployId']:
            capacity_hosts = deploys_helper.get_missing_hosts(
                request, name, stage)
            provisioning_hosts = environ_hosts_helper.get_hosts(
                request, name, stage)
            response = render(
                request, 'environs/env_landing.html', {
                    "env": env,
                    "env_promote": env_promote,
                    "stages": stages,
                    "metrics": metrics,
                    "alarms": alarms,
                    "request_feedback": request_feedback,
                    "groups": groups,
                    "capacity_hosts": capacity_hosts,
                    "provisioning_hosts": provisioning_hosts,
                    "basic_cluster_info": basic_cluster_info,
                    "pinterest": IS_PINTEREST,
                })
            showMode = 'complete'
            sortByStatus = 'true'
        else:
            # Get deploy progress
            progress = deploys_helper.update_progress(request, name, stage)
            showMode = _fetch_param_with_cookie(request, 'showMode',
                                                MODE_COOKIE_NAME, 'complete')
            sortByStatus = _fetch_param_with_cookie(request, 'sortByStatus',
                                                    STATUS_COOKIE_NAME, 'true')
            report = agent_report.gen_report(request,
                                             env,
                                             progress,
                                             sortByStatus=sortByStatus)
            report.showMode = showMode
            report.sortByStatus = sortByStatus
            response = render(
                request, 'environs/env_landing.html', {
                    "env": env,
                    "env_promote": env_promote,
                    "stages": stages,
                    "report": report,
                    "has_deploy": True,
                    "metrics": metrics,
                    "alarms": alarms,
                    "request_feedback": request_feedback,
                    "groups": groups,
                    "basic_cluster_info": basic_cluster_info,
                    "pinterest": IS_PINTEREST,
                })

        # save preferences
        response.set_cookie(ENV_COOKIE_NAME, genEnvCookie(request, name))
        response.set_cookie(MODE_COOKIE_NAME, showMode)
        response.set_cookie(STATUS_COOKIE_NAME, sortByStatus)

        return response