예제 #1
0
def get_health_check_activities(request, group_name):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', DEFAULT_PAGE_SIZE))
    health_checks = autoscaling_groups_helper.get_health_check_activities(request, group_name, index, size)
    asg_status = autoscaling_groups_helper.get_autoscaling_status(request, group_name)
    disabled_actions = autoscaling_groups_helper.get_disabled_asg_actions(request, group_name)
    if "Terminate" in disabled_actions:
        scaling_down_event_enabled = False
    else:
        scaling_down_event_enabled = True

    for check in health_checks:
        env_id = check.get('env_id')
        env = environs_helper.get(request, env_id)
        check['env_name'] = env.get('envName')
        check['stage_name'] = env.get('stageName')

    return render(request, 'groups/health_check_activities.html', {
        "group_name": group_name,
        "health_checks": health_checks,
        "asg_status": asg_status,
        "scaling_down_event_enabled": scaling_down_event_enabled,
        "pageIndex": index,
        "pageSize": DEFAULT_PAGE_SIZE,
        "disablePrevious": index <= 1,
        "disableNext": len(health_checks) < DEFAULT_PAGE_SIZE
    })
예제 #2
0
def get_health_check_activities(request, group_name):
    index = int(request.GET.get("page_index", "1"))
    size = int(request.GET.get("page_size", DEFAULT_PAGE_SIZE))
    health_checks = groups_helper.get_health_check_activities(request, group_name, index, size)
    asg_status = groups_helper.get_autoscaling_status(request, group_name)
    scaling_down_event_enabled = groups_helper.get_scaling_down_event_status(request, group_name)

    for check in health_checks:
        env_id = check.get("env_id")
        env = environs_helper.get(request, env_id)
        check["env_name"] = env.get("envName")
        check["stage_name"] = env.get("stageName")

    return render(
        request,
        "groups/health_check_activities.html",
        {
            "group_name": group_name,
            "health_checks": health_checks,
            "asg_status": asg_status,
            "scaling_down_event_enabled": scaling_down_event_enabled,
            "pageIndex": index,
            "pageSize": DEFAULT_PAGE_SIZE,
            "disablePrevious": index <= 1,
            "disableNext": len(health_checks) < DEFAULT_PAGE_SIZE,
        },
    )
예제 #3
0
def get_health_check_details(request, id):
    health_check = groups_helper.get_health_check(request, id)
    env = environs_helper.get(request, health_check.get('env_id'))
    health_check['env_name'] = env.get('envName')
    health_check['stage_name'] = env.get('stageName')

    health_check_error = groups_helper.get_health_check_error(request, id)
    if health_check_error:
        env = environs_helper.get(request, health_check.get('env_id'))
        health_check_error['env_name'] = env.get('envName')
        health_check_error['stage_name'] = env.get('stageName')

    return render(request, 'groups/health_check_details.html', {
        "health_check": health_check,
        "health_check_error": health_check_error
    })
예제 #4
0
def get_health_check_activities(request, group_name):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', DEFAULT_PAGE_SIZE))
    health_checks = groups_helper.get_health_check_activities(
        request, group_name, index, size)
    asg_status = groups_helper.get_autoscaling_status(request, group_name)
    scaling_down_event_enabled = groups_helper.get_scaling_down_event_status(
        request, group_name)

    for check in health_checks:
        env_id = check.get('env_id')
        env = environs_helper.get(request, env_id)
        check['env_name'] = env.get('envName')
        check['stage_name'] = env.get('stageName')

    return render(
        request, 'groups/health_check_activities.html', {
            "group_name": group_name,
            "health_checks": health_checks,
            "asg_status": asg_status,
            "scaling_down_event_enabled": scaling_down_event_enabled,
            "pageIndex": index,
            "pageSize": DEFAULT_PAGE_SIZE,
            "disablePrevious": index <= 1,
            "disableNext": len(health_checks) < DEFAULT_PAGE_SIZE
        })
예제 #5
0
def get_health_check_details(request, id):
    health_check = groups_helper.get_health_check(request, id)
    env = environs_helper.get(request, health_check.get('env_id'))
    health_check['env_name'] = env.get('envName')
    health_check['stage_name'] = env.get('stageName')

    health_check_error = groups_helper.get_health_check_error(request, id)
    if health_check_error:
        env = environs_helper.get(request, health_check.get('env_id'))
        health_check_error['env_name'] = env.get('envName')
        health_check_error['stage_name'] = env.get('stageName')

    return render(request, 'groups/health_check_details.html', {
        "health_check": health_check,
        "health_check_error": health_check_error
    })
예제 #6
0
def get_health_check_details(request, id):
    health_check = groups_helper.get_health_check(request, id)
    env = environs_helper.get(request, health_check.get("env_id"))
    health_check["env_name"] = env.get("envName")
    health_check["stage_name"] = env.get("stageName")

    health_check_error = groups_helper.get_health_check_error(request, id)
    if health_check_error:
        env = environs_helper.get(request, health_check.get("env_id"))
        health_check_error["env_name"] = env.get("envName")
        health_check_error["stage_name"] = env.get("stageName")

    return render(
        request,
        "groups/health_check_details.html",
        {"health_check": health_check, "health_check_error": health_check_error},
    )
예제 #7
0
 def get(self, request, deploy_id):
     deploy = deploys_helper.get(request, deploy_id)
     build = builds_helper.get_build(request, deploy['buildId'])
     env = None
     if deploy.get('envId'):
         env = environs_helper.get(request, deploy['envId'])
     return render(request, 'deploys/deploy_details.html', {
         "deploy": deploy,
         "build": build,
         "env": env,
     })
예제 #8
0
    def get(self, request, name, stage, hostname):
        agents = agents_helper.get_agents_by_host(request, hostname)
        env = environs_helper.get_env_by_stage(request, name, stage)
        host = environ_hosts_helper.get_host_by_env_and_hostname(
            request, name, stage, hostname)
        show_terminate = False
        asg = ''
        if host and host.get('hostId'):
            if host.get('state') != 'PENDING_TERMINATE' and host.get(
                    'state') != 'TERMINATING' and host.get(
                        'state') != 'TERMINATED':
                show_terminate = True

        cluster_provider = clusters_helper.get_cluster_provider(
            request, name, stage)
        if cluster_provider == 'null':
            cluster_provider = None

        # TODO deprecated it
        if host and host.get('groupName'):
            group_info = groups_helper.get_group_info(request,
                                                      host.get('groupName'))
            if group_info and group_info["asgStatus"] == "ENABLED":
                asg = host.get('groupName')

        # gather the env name and stage info
        agent_wrappers = []
        for agent in agents:
            agent_wrapper = {}
            agent_wrapper["agent"] = agent
            envId = agent['envId']
            agent_env = environs_helper.get(request, envId)
            agent_wrapper["env"] = env
            agent_wrapper["error"] = ""
            if agent.get('lastErrno', 0) != 0:
                agent_wrapper["error"] = agents_helper.get_agent_error(
                    request, agent_env['envName'], agent_env['stageName'],
                    hostname)
            agent_wrappers.append(agent_wrapper)

        return render(
            request, 'hosts/host_details.html', {
                'env_name': name,
                'stage_name': stage,
                'hostname': hostname,
                'host': host,
                'agent_wrappers': agent_wrappers,
                'show_terminate': show_terminate,
                'cluster_provider': cluster_provider,
                'asg_group': asg,
                'pinterest': IS_PINTEREST,
            })
예제 #9
0
def get_health_check_details(request, id):
    health_check = autoscaling_groups_helper.get_health_check(request, id)
    env = environs_helper.get(request, health_check.get('env_id'))
    health_check['env_name'] = env.get('envName')
    health_check['stage_name'] = env.get('stageName')

    health_check_error = autoscaling_groups_helper.get_health_check_error(request, id)
    if health_check_error:
        env = environs_helper.get(request, health_check.get('env_id'))
        health_check_error['env_name'] = env.get('envName')
        health_check_error['stage_name'] = env.get('stageName')
        if IS_PINTEREST and PHOBOS_URL:
            from brood.client import Brood
            cmdb = Brood()
            host_ip = cmdb.get_query(query="id:" + health_check['host_id'],
                                     fields="config.internal_address")[0]['config.internal_address']
            if host_ip is not None:
                health_check_error['phobos_link'] = PHOBOS_URL + host_ip

    return render(request, 'groups/health_check_details.html', {
        "health_check": health_check,
        "health_check_error": health_check_error
    })
예제 #10
0
def _gen_deploy_summary(request, deploys, for_env=None):
    deploy_summaries = []
    for deploy in deploys:
        if for_env:
            env = for_env
        else:
            env = environs_helper.get(request, deploy['envId'])
        build = builds_helper.get_build(request, deploy['buildId'])
        summary = {}
        summary['deploy'] = deploy
        summary['env'] = env
        summary['build'] = build
        deploy_summaries.append(summary)
    return deploy_summaries
예제 #11
0
def get_health_check_details(request, id):
    health_check = autoscaling_groups_helper.get_health_check(request, id)
    env = environs_helper.get(request, health_check.get('env_id'))
    health_check['env_name'] = env.get('envName')
    health_check['stage_name'] = env.get('stageName')

    health_check_error = autoscaling_groups_helper.get_health_check_error(request, id)
    if health_check_error:
        env = environs_helper.get(request, health_check.get('env_id'))
        health_check_error['env_name'] = env.get('envName')
        health_check_error['stage_name'] = env.get('stageName')
        if IS_PINTEREST and PHOBOS_URL:
            from brood.client import Brood
            cmdb = Brood()
            host_ip = cmdb.get_query(query="id:" + health_check['host_id'],
                                     fields="config.internal_address")[0]['config.internal_address']
            if host_ip is not None:
                health_check_error['phobos_link'] = PHOBOS_URL + host_ip

    return render(request, 'groups/health_check_details.html', {
        "health_check": health_check,
        "health_check_error": health_check_error
    })
예제 #12
0
def _gen_deploy_summary(request, deploys, for_env=None):
    deploy_summaries = []
    for deploy in deploys:
        if for_env:
            env = for_env
        else:
            env = environs_helper.get(request, deploy['envId'])
        build = builds_helper.get_build(request, deploy['buildId'])
        summary = {}
        summary['deploy'] = deploy
        summary['env'] = env
        summary['build'] = build
        deploy_summaries.append(summary)
    return deploy_summaries
예제 #13
0
def _get_ongoing_deploys(request, index, size):
    # ongoing deploys are defined as deploys with states as:
    deploy_states = ["RUNNING", "FAILING"]
    deployResult = deploys_helper.get_all(request, deployState=deploy_states,
                                          pageIndex=index, pageSize=size)
    deploy_summaries = []
    for deploy in deployResult['deploys']:
        env = environs_helper.get(request, deploy['envId'])
        build = builds_helper.get_build(request, deploy['buildId'])
        summary = {}
        summary['deploy'] = deploy
        summary['env'] = env
        summary['build'] = build
        deploy_summaries.append(summary)

    return deploy_summaries
예제 #14
0
def _get_ongoing_deploys(request, index, size):
    # ongoing deploys are defined as deploys with states as:
    deploy_states = ["RUNNING", "FAILING"]
    deployResult = deploys_helper.get_all(request, deployState=deploy_states,
                                          pageIndex=index, pageSize=size)
    deploy_summaries = []
    for deploy in deployResult['deploys']:
        env = environs_helper.get(request, deploy['envId'])
        build = builds_helper.get_build(request, deploy['buildId'])
        summary = {}
        summary['deploy'] = deploy
        summary['env'] = env
        summary['build'] = build
        deploy_summaries.append(summary)

    return deploy_summaries
예제 #15
0
def get_agent_wrapper(request, hostname):
    # gather the env name and stage info
    agents = agents_helper.get_agents_by_host(request, hostname)
    agent_wrappers = []
    for agent in agents:
        agent_wrapper = {}
        agent_wrapper["agent"] = agent
        envId = agent['envId']
        agent_env = environs_helper.get(request, envId)
        agent_wrapper["env"] = agent_env
        agent_wrapper["error"] = ""
        if agent.get('lastErrno', 0) != 0:
            agent_wrapper["error"] = agents_helper.get_agent_error(request, agent_env['envName'],
                                                                   agent_env['stageName'], hostname)
        agent_wrappers.append(agent_wrapper)
    return agent_wrappers
예제 #16
0
    def get(self, request, name, stage, hostname):
        agents = agents_helper.get_agents_by_host(request, hostname)
        env = environs_helper.get_env_by_stage(request, name, stage)
        host = environ_hosts_helper.get_host_by_env_and_hostname(request, name, stage, hostname)
        show_terminate = False
        asg = ''
        if host and host.get('hostId'):
            if host.get('state') != 'PENDING_TERMINATE' and host.get('state') != 'TERMINATING' and host.get('state') != 'TERMINATED':
                show_terminate = True

        cluster_provider = clusters_helper.get_cluster_provider(request, name, stage)
        if cluster_provider == 'null':
            cluster_provider = None

        # TODO deprecated it
        if host and host.get('groupName'):
            group_info = groups_helper.get_group_info(request, host.get('groupName'))
            if group_info and group_info["asgStatus"] == "ENABLED":
                asg = host.get('groupName')

        # gather the env name and stage info
        agent_wrappers = []
        for agent in agents:
            agent_wrapper = {}
            agent_wrapper["agent"] = agent
            envId = agent['envId']
            agent_env = environs_helper.get(request, envId)
            agent_wrapper["env"] = env
            agent_wrapper["error"] = ""
            if agent.get('lastErrno', 0) != 0:
                agent_wrapper["error"] = agents_helper.get_agent_error(request, agent_env['envName'],
                                                                       agent_env['stageName'], hostname)
            agent_wrappers.append(agent_wrapper)

        return render(request, 'hosts/host_details.html', {
            'env_name': name,
            'stage_name': stage,
            'hostname': hostname,
            'host': host,
            'agent_wrappers': agent_wrappers,
            'show_terminate': show_terminate,
            'cluster_provider': cluster_provider,
            'asg_group': asg,
            'pinterest': IS_PINTEREST,
        })
예제 #17
0
    def get(self, request, name, stage, hostname):
        host = environ_hosts_helper.get_host_by_env_and_hostname(request, name, stage, hostname)
        show_terminate = False
        if host and host.get('state') and host.get('state') != 'PENDING_TERMINATE' and host.get('state') != 'TERMINATING' and host.get('state') != 'TERMINATED':
            show_terminate = True

        # TODO deprecated it
        asg = ''
        if host and host.get('groupName'):
            group_info = groups_helper.get_group_info(request, host.get('groupName'))
            if group_info and group_info["asgStatus"] == "ENABLED":
                asg = host.get('groupName')

        # gather the env name and stage info
        agents = agents_helper.get_agents_by_host(request, hostname)
        agent_wrappers = []
        show_force_terminate = False
        for agent in agents:
            if agent.get('deployStage') == 'STOPPING' or agent.get('deployStage') == 'STOPPED':
                if is_agent_failed(agent):
                    show_force_terminate = True
            agent_wrapper = {}
            agent_wrapper["agent"] = agent
            envId = agent['envId']
            agent_env = environs_helper.get(request, envId)
            agent_wrapper["env"] = agent_env
            agent_wrapper["error"] = ""
            if agent.get('lastErrno', 0) != 0:
                agent_wrapper["error"] = agents_helper.get_agent_error(request, agent_env['envName'],
                                                                       agent_env['stageName'], hostname)
            agent_wrappers.append(agent_wrapper)

        return render(request, 'hosts/host_details.html', {
            'env_name': name,
            'stage_name': stage,
            'hostname': hostname,
            'host': host,
            'agent_wrappers': agent_wrappers,
            'show_terminate': show_terminate,
            'show_force_terminate': show_force_terminate,
            'asg_group': asg,
            'pinterest': IS_PINTEREST,
        })
예제 #18
0
def get_agent_wrapper(request, hostname):
    # gather the env name and stage info
    agents = agents_helper.get_agents_by_host(request, hostname)
    agent_wrappers = []
    is_unreachable = False
    for agent in agents:
        agent_wrapper = {}
        agent_wrapper["agent"] = agent
        envId = agent['envId']
        agent_env = environs_helper.get(request, envId)
        agent_wrapper["env"] = agent_env
        agent_wrapper["error"] = ""
        if agent.get('lastErrno', 0) != 0:
            agent_wrapper["error"] = agents_helper.get_agent_error(request, agent_env['envName'],
                                                                   agent_env['stageName'], hostname)
        if agent['state'] == 'UNREACHABLE':
            is_unreachable = True

        agent_wrappers.append(agent_wrapper)
    return agent_wrappers, is_unreachable
예제 #19
0
def get_agent_wrapper(request, hostname):
    # gather the env name and stage info
    agents = agents_helper.get_agents_by_host(request, hostname)
    agent_wrappers = []
    is_unreachable = False
    for agent in agents:
        agent_wrapper = {}
        agent_wrapper["agent"] = agent
        envId = agent['envId']
        agent_env = environs_helper.get(request, envId)
        agent_wrapper["env"] = agent_env
        agent_wrapper["error"] = ""
        if agent.get('lastErrno', 0) != 0:
            agent_wrapper["error"] = agents_helper.get_agent_error(request, agent_env['envName'],
                                                                   agent_env['stageName'], hostname)
        if agent['state'] == 'UNREACHABLE':
            is_unreachable = True

        agent_wrappers.append(agent_wrapper)
    return agent_wrappers, is_unreachable
예제 #20
0
def get_agent_wrapper(request, hostname):
    # gather the env name and stage info
    agents = agents_helper.get_agents_by_host(request, hostname)
    agent_wrappers = []
    show_force_terminate = False
    for agent in agents:
        if agent.get('deployStage') == 'STOPPING' or agent.get('deployStage') == 'STOPPED':
            if is_agent_failed(agent):
                show_force_terminate = True
        agent_wrapper = {}
        agent_wrapper["agent"] = agent
        envId = agent['envId']
        agent_env = environs_helper.get(request, envId)
        agent_wrapper["env"] = agent_env
        agent_wrapper["error"] = ""
        if agent.get('lastErrno', 0) != 0:
            agent_wrapper["error"] = agents_helper.get_agent_error(request, agent_env['envName'],
                                                                   agent_env['stageName'], hostname)
        agent_wrappers.append(agent_wrapper)

    return agent_wrappers, show_force_terminate
예제 #21
0
def get_host_details(request, name):
    agents = agents_helper.get_agents_by_host(request, name)
    hosts = hosts_helper.get_hosts_by_name(request, name)
    # gather the env name and stage info
    agent_wrappers = []
    for agent in agents:
        agent_wrapper = {}
        agent_wrapper["agent"] = agent
        envId = agent['envId']
        env = environs_helper.get(request, envId)
        agent_wrapper["env"] = env
        agent_wrapper["error"] = ""
        if agent.get('lastErrno', 0) != 0:
            agent_wrapper["error"] = agents_helper.get_agent_error(
                request, env['envName'], env['stageName'], name)
        agent_wrappers.append(agent_wrapper)

    host_id = ""
    asgGroup = ""
    for host in hosts:
        host_id = host['hostId']
        group_name = host["groupName"]
        # TODO Remove this hack
        if not group_name or group_name == 'NULL':
            continue
        group_info = groups_helper.get_group_info(request, group_name)
        if group_info and group_info["asgStatus"] == "ENABLED":
            asgGroup = group_name
            break

    return render(
        request, 'hosts/host_details.html', {
            'agent_wrappers': agent_wrappers,
            'hosts': hosts,
            'name': name,
            'hostId': host_id,
            'show_terminate': True,
            "asg_group": asgGroup,
            "pinterest": IS_PINTEREST,
        })
예제 #22
0
def get_host_details(request, name):
    agents = agents_helper.get_agents_by_host(request, name)
    hosts = hosts_helper.get_hosts_by_name(request, name)
    # gather the env name and stage info
    agent_wrappers = []
    for agent in agents:
        agent_wrapper = {}
        agent_wrapper["agent"] = agent
        envId = agent['envId']
        env = environs_helper.get(request, envId)
        agent_wrapper["env"] = env
        agent_wrapper["error"] = ""
        if agent.get('lastErrno', 0) != 0:
            agent_wrapper["error"] = agents_helper.get_agent_error(request, env['envName'],
                                                                   env['stageName'], name)
        agent_wrappers.append(agent_wrapper)

    host_id = ""
    asgGroup = ""
    for host in hosts:
        host_id = host['hostId']
        group_name = host["groupName"]
        # TODO Remove this hack
        if not group_name or group_name == 'NULL':
            continue
        group_info = groups_helper.get_group_info(request, group_name)
        if group_info and group_info["asgStatus"] == "ENABLED":
            asgGroup = group_name
            break

    return render(request, 'hosts/host_details.html', {
        'agent_wrappers': agent_wrappers,
        'hosts': hosts,
        'name': name,
        'hostId': host_id,
        'show_terminate': True,
        "asg_group": asgGroup,
        "pinterest": IS_PINTEREST,
    })