コード例 #1
0
    def get(self, request, name, stage):
        host_types = hosttypes_helper.get_by_provider(request, DEFAULT_PROVIDER)
        for host_type in host_types:
            host_type['mem'] = float(host_type['mem']) / 1024

        security_zones = securityzones_helper.get_by_provider(request, DEFAULT_PROVIDER)
        placements = placements_helper.get_by_provider(request, DEFAULT_PROVIDER)
        base_images = baseimages_helper.get_by_name(request, DEFAULT_CMP_IMAGE)
        base_images_names = baseimages_helper.get_image_names(request, DEFAULT_PROVIDER)

        env = environs_helper.get_env_by_stage(request, name, stage)
        provider_list = baseimages_helper.get_all_providers(request)

        capacity_creation_info = {
            'environment': env,
            'hostTypes': host_types,
            'securityZones': security_zones,
            'placements': placements,
            'defaultMappings': PINTEREST_SECURITY_GROUP_PLACEMENTMAPPING,
            'baseImages': base_images,
            'baseImageNames': base_images_names,
            'defaultBaseImage': DEFAULT_CMP_IMAGE,
            'defaultCMPConfigs': get_default_cmp_configs(name, stage),
            'defaultProvider': DEFAULT_PROVIDER,
            'providerList': provider_list,
            'configList': get_aws_config_name_list_by_image(DEFAULT_CMP_IMAGE)
        }
        # cluster manager
        return render(request, 'configs/new_capacity_adv.html', {
            'env': env,
            'capacity_creation_info': json.dumps(capacity_creation_info)})
コード例 #2
0
ファイル: cluster_view.py プロジェクト: sonia-y/teletraan
def get_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    basic_cluster_info = clusters_helper.get_cluster(request, env.get('clusterName'))
    adv = False
    is_cmp = False
    if basic_cluster_info:
        base_image_id = basic_cluster_info.get('baseImageId')
        base_image = baseimages_helper.get_by_id(request, base_image_id)
        if base_image.get('abstract_name') != 'CMP-DOCKER':
            adv = True
        else:
            is_cmp = True

    params = request.GET
    if params.get('adv'):
        adv = params.get('adv')

    return render(request, 'clusters/clusters.html', {
        'env': env,
        'envs': envs,
        'stages': stages,
        'provider_list': provider_list,
        'basic_cluster_info': basic_cluster_info,
        'adv': adv,
        'is_cmp': is_cmp,
    })
コード例 #3
0
ファイル: cluster_view.py プロジェクト: pinterest/teletraan
def get_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    basic_cluster_info = clusters_helper.get_cluster(request, env.get("clusterName"))
    adv = False
    is_cmp = False
    if basic_cluster_info:
        base_image_id = basic_cluster_info.get("baseImageId")
        base_image = baseimages_helper.get_by_id(request, base_image_id)
        if base_image.get("abstract_name") != CMP_DOCKER_IMAGE:
            adv = True
        else:
            is_cmp = True

    params = request.GET
    if params.get("adv"):
        adv = params.get("adv")

    return render(
        request,
        "clusters/clusters.html",
        {
            "env": env,
            "envs": envs,
            "stages": stages,
            "provider_list": provider_list,
            "basic_cluster_info": basic_cluster_info,
            "adv": adv,
            "is_cmp": is_cmp,
        },
    )
コード例 #4
0
ファイル: cluster_view.py プロジェクト: vichetuc/teletraan
    def get(self, request, name, stage):
        host_types = hosttypes_helper.get_by_provider(
            request, DEFAULT_PROVIDER)
        for host_type in host_types:
            host_type['mem'] = float(host_type['mem']) / 1024

        security_zones = securityzones_helper.get_by_provider(
            request, DEFAULT_PROVIDER)
        placements = placements_helper.get_by_provider(
            request, DEFAULT_PROVIDER)
        base_images = get_base_image_info_by_name(request, DEFAULT_CMP_IMAGE)
        base_images_names = baseimages_helper.get_image_names(
            request, DEFAULT_PROVIDER)

        env = environs_helper.get_env_by_stage(request, name, stage)
        provider_list = baseimages_helper.get_all_providers(request)

        capacity_creation_info = {
            'environment': env,
            'hostTypes': host_types,
            'securityZones': security_zones,
            'placements': placements,
            'baseImages': base_images,
            'baseImageNames': base_images_names,
            'defaultBaseImage': DEFAULT_CMP_IMAGE,
            'defaultCMPConfigs': get_default_cmp_configs(name, stage),
            'defaultProvider': DEFAULT_PROVIDER,
            'defaultHostType': DEFAULT_CMP_HOST_TYPE,
            'providerList': provider_list,
            'configList': get_aws_config_name_list_by_image(DEFAULT_CMP_IMAGE)
        }
        # cluster manager
        return render(request, 'configs/new_capacity_adv.html', {
            'env': env,
            'capacity_creation_info': json.dumps(capacity_creation_info)})
コード例 #5
0
    def get(self, request, name, stage):
        # cluster manager
        provider_list = None
        basic_cluster_info = None
        create_new = False
        adv = False
        env = environs_helper.get_env_by_stage(request, name, stage)
        if IS_PINTEREST:
            provider_list = baseimages_helper.get_all_providers(request)
            basic_cluster_info = clusters_helper.get_cluster(request, env.get('clusterName'))
            if basic_cluster_info:
                base_image_id = basic_cluster_info.get('baseImageId')
                base_image = baseimages_helper.get_by_id(request, base_image_id)
                if base_image.get('abstract_name') != 'CMP-DOCKER':
                    adv = True

            params = request.GET
            if params.get('adv'):
                adv = params.get('adv')
            if params.get('create_new'):
                create_new = params.get('create_new')

        if request.is_ajax():
            # return data for ajax calls
            hosts = environs_helper.get_env_capacity(request, name, stage, capacity_type="HOST")
            groups = common.get_non_cmp_group(request, name, stage)
            html = render_to_string("configs/capacity.tmpl", {
                "env": env,
                "hosts": ','.join(hosts),
                "groups": ','.join(groups),
                "csrf_token": get_token(request),
                'is_pinterest': IS_PINTEREST,
                'provider_list': provider_list,
                'basic_cluster_info': basic_cluster_info,
                'adv': adv,
                'create_new': create_new,
            })
            return HttpResponse(json.dumps({'html': html}), content_type="application/json")

        # otherwise, return a page
        envs = environs_helper.get_all_env_stages(request, name)
        stages, env = common.get_all_stages(envs, stage)
        hosts = environs_helper.get_env_capacity(request, name, stage, capacity_type="HOST")
        groups = common.get_non_cmp_group(request, name, stage)
        return render(request, 'configs/capacity.html', {
            "envs": envs,
            "env": env,
            "stages": stages,
            "hosts": ','.join(hosts),
            "groups": ','.join(groups),
            'is_pinterest': IS_PINTEREST,
            'provider_list': provider_list,
            'basic_cluster_info': basic_cluster_info,
            'adv': adv,
            'create_new': create_new,
        })
コード例 #6
0
def get_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    basic_cluster_info = clusters_helper.get_cluster(request, name, stage)

    return render(request, 'clusters/clusters.html', {
        'env': env,
        'stages': stages,
        'provider_list': provider_list,
        'basic_cluster_info': basic_cluster_info,
    })
コード例 #7
0
ファイル: cluster_view.py プロジェクト: khanchan/teletraan
def get_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    basic_cluster_info = clusters_helper.get_cluster(request, name, stage)

    return render(request, 'clusters/clusters.html', {
        'env': env,
        'stages': stages,
        'provider_list': provider_list,
        'basic_cluster_info': basic_cluster_info,
    })
コード例 #8
0
ファイル: cluster_view.py プロジェクト: eweizman/teletraan
def get_new_cmp_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    base_images = baseimages_helper.get_by_name(request, "CMP-DOCKER")
    html = render_to_string('clusters/cmp_cluster_creation.tmpl', {
        'env': env,
        'stages': stages,
        'provider_list': provider_list,
        'base_images': base_images,
        'csrf_token': get_token(request),
    })
    return HttpResponse(json.dumps(html), content_type="application/json")
コード例 #9
0
    def get(self, request, name, stage):

        cluster_name = '{}-{}'.format(name, stage)
        current_cluster = clusters_helper.get_cluster(request, cluster_name)
        host_types = hosttypes_helper.get_by_provider(request,
                                                      DEFAULT_PROVIDER)
        current_image = baseimages_helper.get_by_id(
            request, current_cluster['baseImageId'])
        current_cluster['baseImageName'] = current_image['abstract_name']
        for host_type in host_types:
            host_type['mem'] = float(host_type['mem']) / 1024

        cells = cells_helper.get_by_provider(request,
                                             current_cluster['provider'])
        security_zones = securityzones_helper.get_by_provider_and_cell_name(
            request, current_cluster['provider'], current_cluster['cellName'])
        placements = placements_helper.get_by_provider_and_cell_name(
            request, current_cluster['provider'], current_cluster['cellName'])
        base_images = get_base_image_info_by_name(
            request, current_image['abstract_name'],
            current_cluster['cellName'])
        base_images_names = baseimages_helper.get_image_names(
            request, current_cluster['provider'], current_cluster['cellName'])

        env = environs_helper.get_env_by_stage(request, name, stage)
        provider_list = baseimages_helper.get_all_providers(request)

        capacity_creation_info = {
            'environment': env,
            'cells': cells,
            'hostTypes': host_types,
            'securityZones': security_zones,
            'placements': placements,
            'baseImages': base_images,
            'baseImageNames': base_images_names,
            'defaultBaseImage': DEFAULT_CMP_IMAGE,
            'defaultCMPConfigs': get_default_cmp_configs(name, stage),
            'defaultProvider': DEFAULT_PROVIDER,
            'providerList': provider_list,
            'configList': get_aws_config_name_list_by_image(DEFAULT_CMP_IMAGE),
            'currentCluster': current_cluster
        }

        return render(
            request, 'clusters/cluster_configuration.html', {
                'env': env,
                'capacity_creation_info': json.dumps(capacity_creation_info),
                'user_data_config_settings_wiki':
                USER_DATA_CONFIG_SETTINGS_WIKI,
                'is_pinterest': IS_PINTEREST
            })
コード例 #10
0
ファイル: cluster_view.py プロジェクト: sonia-y/teletraan
def get_new_cmp_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    base_images = baseimages_helper.get_by_name(request, "CMP-DOCKER")
    html = render_to_string('clusters/cmp_cluster_creation.tmpl', {
        'env': env,
        'envs': envs,
        'stages': stages,
        'provider_list': provider_list,
        'base_images': base_images,
        'csrf_token': get_token(request),
    })
    return HttpResponse(json.dumps(html), content_type="application/json")
コード例 #11
0
ファイル: cluster_view.py プロジェクト: sonia-y/teletraan
def get_basic_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    basic_cluster_info = clusters_helper.get_cluster(request, env.get('clusterName'))
    html = render_to_string('clusters/clusters.tmpl', {
        'env': env,
        'envs': envs,
        'stages': stages,
        'provider_list': provider_list,
        'basic_cluster_info': basic_cluster_info,
        'csrf_token': get_token(request),
    })
    return HttpResponse(json.dumps(html), content_type="application/json")
コード例 #12
0
ファイル: cluster_view.py プロジェクト: sonia-y/teletraan
def get_base_images(request):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', DEFAULT_PAGE_SIZE))
    base_images = baseimages_helper.get_all(request, index, size)
    provider_list = baseimages_helper.get_all_providers(request)

    return render(request, 'clusters/base_images.html', {
        'base_images': base_images,
        'provider_list': provider_list,
        'pageIndex': index,
        'pageSize': DEFAULT_PAGE_SIZE,
        'disablePrevious': index <= 1,
        'disableNext': len(base_images) < DEFAULT_PAGE_SIZE,
    })
コード例 #13
0
ファイル: cluster_view.py プロジェクト: hellovivi/teletraan
def get_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    basic_cluster_info = clusters_helper.get_cluster(request, name, stage)
    hosts_in_clusters = clusters_helper.get_hosts(request, env['envName'], env['stageName'], [])
    host_ids = ','.join(hosts_in_clusters)

    return render(request, 'clusters/clusters.html', {
        'env': env,
        'stages': stages,
        'provider_list': provider_list,
        'basic_cluster_info': basic_cluster_info,
        'host_ids': host_ids,
    })
コード例 #14
0
def get_placements(request):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', DEFAULT_PAGE_SIZE))
    placements = placements_helper.get_all(request, index, size)
    provider_list = baseimages_helper.get_all_providers(request)
    cells_list = cells_helper.get_by_provider(request, DEFAULT_PROVIDER)

    return render(request, 'clusters/placements.html', {
        'placements': placements,
        'provider_list': provider_list,
        'cells_list': cells_list,
        'pageIndex': index,
        'pageSize': DEFAULT_PAGE_SIZE,
        'disablePrevious': index <= 1,
        'disableNext': len(placements) < DEFAULT_PAGE_SIZE,
    })
コード例 #15
0
ファイル: cluster_view.py プロジェクト: sonia-y/teletraan
def get_host_types(request):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', DEFAULT_PAGE_SIZE))
    host_types = hosttypes_helper.get_all(request, index, size)
    for host_type in host_types:
        host_type['mem'] = float(host_type['mem']) / 1024
    provider_list = baseimages_helper.get_all_providers(request)

    return render(request, 'clusters/host_types.html', {
        'host_types': host_types,
        'provider_list': provider_list,
        'pageIndex': index,
        'pageSize': DEFAULT_PAGE_SIZE,
        'disablePrevious': index <= 1,
        'disableNext': len(host_types) < DEFAULT_PAGE_SIZE,
    })
コード例 #16
0
ファイル: cluster_view.py プロジェクト: lilida/teletraan
def get_placements(request):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', DEFAULT_PAGE_SIZE))
    placements = placements_helper.get_all(request, index, size)
    provider_list = baseimages_helper.get_all_providers(request)
    cells_list = cells_helper.get_by_provider(request, DEFAULT_PROVIDER)

    return render(request, 'clusters/placements.html', {
        'placements': placements,
        'provider_list': provider_list,
        'cells_list': cells_list,
        'pageIndex': index,
        'pageSize': DEFAULT_PAGE_SIZE,
        'disablePrevious': index <= 1,
        'disableNext': len(placements) < DEFAULT_PAGE_SIZE,
    })
コード例 #17
0
ファイル: cluster_view.py プロジェクト: lilida/teletraan
def get_security_zones(request):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', DEFAULT_PAGE_SIZE))
    security_zones = securityzones_helper.get_all(request, index, size)
    provider_list = baseimages_helper.get_all_providers(request)
    cells_list = cells_helper.get_by_provider(request, DEFAULT_PROVIDER)

    return render(request, 'clusters/security_zones.html', {
        'security_zones': security_zones,
        'provider_list': provider_list,
        'cells_list': cells_list,
        'pageIndex': index,
        'pageSize': DEFAULT_PAGE_SIZE,
        'disablePrevious': index <= 1,
        'disableNext': len(security_zones) < DEFAULT_PAGE_SIZE,
    })
コード例 #18
0
def get_security_zones(request):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', DEFAULT_PAGE_SIZE))
    security_zones = securityzones_helper.get_all(request, index, size)
    provider_list = baseimages_helper.get_all_providers(request)
    cells_list = cells_helper.get_by_provider(request, DEFAULT_PROVIDER)

    return render(request, 'clusters/security_zones.html', {
        'security_zones': security_zones,
        'provider_list': provider_list,
        'cells_list': cells_list,
        'pageIndex': index,
        'pageSize': DEFAULT_PAGE_SIZE,
        'disablePrevious': index <= 1,
        'disableNext': len(security_zones) < DEFAULT_PAGE_SIZE,
    })
コード例 #19
0
ファイル: cluster_view.py プロジェクト: pinterest/teletraan
def get_basic_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    basic_cluster_info = clusters_helper.get_cluster(request, env.get("clusterName"))
    html = render_to_string(
        "clusters/clusters.tmpl",
        {
            "env": env,
            "envs": envs,
            "stages": stages,
            "provider_list": provider_list,
            "basic_cluster_info": basic_cluster_info,
            "csrf_token": get_token(request),
        },
    )
    return HttpResponse(json.dumps(html), content_type="application/json")
コード例 #20
0
ファイル: cluster_view.py プロジェクト: theradcoder/teletraan
def get_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    basic_cluster_info = clusters_helper.get_cluster(request, name, stage)
    hosts_in_clusters = clusters_helper.get_hosts(request, env['envName'],
                                                  env['stageName'], [])
    host_ids = ','.join(hosts_in_clusters)

    return render(
        request, 'clusters/clusters.html', {
            'env': env,
            'stages': stages,
            'provider_list': provider_list,
            'basic_cluster_info': basic_cluster_info,
            'host_ids': host_ids,
        })
コード例 #21
0
ファイル: cluster_view.py プロジェクト: pinterest/teletraan
def get_new_cmp_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    base_images = baseimages_helper.get_by_name(request, CMP_DOCKER_IMAGE)
    html = render_to_string(
        "clusters/cmp_cluster_creation.tmpl",
        {
            "env": env,
            "envs": envs,
            "stages": stages,
            "provider_list": provider_list,
            "base_images": base_images,
            "csrf_token": get_token(request),
        },
    )
    return HttpResponse(json.dumps(html), content_type="application/json")
コード例 #22
0
    def get(self, request, name, stage):
        host_types = hosttypes_helper.get_by_provider(request,
                                                      DEFAULT_PROVIDER)
        for host_type in host_types:
            host_type['mem'] = float(host_type['mem']) / 1024

        security_zones = securityzones_helper.get_by_provider_and_cell_name(
            request, DEFAULT_PROVIDER, DEFAULT_CELL)
        placements = placements_helper.get_by_provider_and_cell_name(
            request, DEFAULT_PROVIDER, DEFAULT_CELL)
        cells = cells_helper.get_by_provider(request, DEFAULT_PROVIDER)
        base_images = get_base_image_info_by_name(request, DEFAULT_CMP_IMAGE,
                                                  DEFAULT_CELL)
        base_images_names = baseimages_helper.get_image_names(
            request, DEFAULT_PROVIDER, DEFAULT_CELL)

        env = environs_helper.get_env_by_stage(request, name, stage)
        provider_list = baseimages_helper.get_all_providers(request)

        capacity_creation_info = {
            'environment': env,
            'hostTypes': host_types,
            'securityZones': security_zones,
            'placements': placements,
            'cells': cells,
            'baseImages': base_images,
            'baseImageNames': base_images_names,
            'defaultBaseImage': DEFAULT_CMP_IMAGE,
            'defaultCMPConfigs': get_default_cmp_configs(name, stage),
            'defaultProvider': DEFAULT_PROVIDER,
            'defaultCell': DEFAULT_CELL,
            'defaultHostType': DEFAULT_CMP_HOST_TYPE,
            'defaultSeurityZone': DEFAULT_PLACEMENT,
            'providerList': provider_list,
            'configList': get_aws_config_name_list_by_image(DEFAULT_CMP_IMAGE)
        }
        # cluster manager
        return render(
            request, 'configs/new_capacity_adv.html', {
                'env': env,
                'capacity_creation_info': json.dumps(capacity_creation_info),
                'user_data_config_settings_wiki':
                USER_DATA_CONFIG_SETTINGS_WIKI,
                'is_pinterest': IS_PINTEREST
            })
コード例 #23
0
ファイル: cluster_view.py プロジェクト: lilida/teletraan
    def get(self, request, name, stage):

        cluster_name = '{}-{}'.format(name, stage)
        current_cluster = clusters_helper.get_cluster(request, cluster_name)
        host_types = hosttypes_helper.get_by_provider(
            request, DEFAULT_PROVIDER)
        current_image = baseimages_helper.get_by_id(
            request, current_cluster['baseImageId'])
        current_cluster['baseImageName'] = current_image['abstract_name']
        for host_type in host_types:
            host_type['mem'] = float(host_type['mem']) / 1024

        cells = cells_helper.get_by_provider(request, current_cluster['provider'])
        security_zones = securityzones_helper.get_by_provider_and_cell_name(
            request, current_cluster['provider'], current_cluster['cellName'])
        placements = placements_helper.get_by_provider_and_cell_name(
            request, current_cluster['provider'], current_cluster['cellName'])
        base_images = get_base_image_info_by_name(
            request, current_image['abstract_name'], current_cluster['cellName'])
        base_images_names = baseimages_helper.get_image_names(
            request, current_cluster['provider'], current_cluster['cellName'])

        env = environs_helper.get_env_by_stage(request, name, stage)
        provider_list = baseimages_helper.get_all_providers(request)

        capacity_creation_info = {
            'environment': env,
            'cells': cells,
            'hostTypes': host_types,
            'securityZones': security_zones,
            'placements': placements,
            'baseImages': base_images,
            'baseImageNames': base_images_names,
            'defaultBaseImage': DEFAULT_CMP_IMAGE,
            'defaultCMPConfigs': get_default_cmp_configs(name, stage),
            'defaultProvider': DEFAULT_PROVIDER,
            'providerList': provider_list,
            'configList': get_aws_config_name_list_by_image(DEFAULT_CMP_IMAGE),
            'currentCluster': current_cluster
        }
        return render(request, 'clusters/cluster_configuration.html', {
            'env': env,
            'capacity_creation_info': json.dumps(capacity_creation_info),
            'user_data_config_settings_wiki': USER_DATA_CONFIG_SETTINGS_WIKI,
            'is_pinterest': IS_PINTEREST})
コード例 #24
0
ファイル: cluster_view.py プロジェクト: pinterest/teletraan
def get_base_images(request):
    index = int(request.GET.get("page_index", "1"))
    size = int(request.GET.get("page_size", DEFAULT_PAGE_SIZE))
    base_images = baseimages_helper.get_all(request, index, size)
    provider_list = baseimages_helper.get_all_providers(request)

    return render(
        request,
        "clusters/base_images.html",
        {
            "base_images": base_images,
            "provider_list": provider_list,
            "pageIndex": index,
            "pageSize": DEFAULT_PAGE_SIZE,
            "disablePrevious": index <= 1,
            "disableNext": len(base_images) < DEFAULT_PAGE_SIZE,
        },
    )
コード例 #25
0
ファイル: cluster_view.py プロジェクト: jans1086/teletraan
def get_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    cluster_provider = clusters_helper.get_cluster_provider(request, name, stage)
    if cluster_provider == 'null':
        cluster_provider = None
    basic_cluster_info = clusters_helper.get_cluster(request, name, stage)
    advanced_cluster_info = clusters_helper.get_advanced_cluster(request, name, stage, cluster_provider)

    return render(request, 'clusters/clusters.html', {
        'env': env,
        'stages': stages,
        'provider_list': provider_list,
        'cluster_provider': cluster_provider,
        'basic_cluster_info': basic_cluster_info,
        'advanced_cluster_info': advanced_cluster_info,
    })
コード例 #26
0
    def get(self, request, name, stage):

        cluster_name = '{}-{}'.format(name, stage)
        current_cluster = clusters_helper.get_cluster(request, cluster_name)
        host_types = hosttypes_helper.get_by_provider(request,
                                                      DEFAULT_PROVIDER)
        current_image = baseimages_helper.get_by_id(
            request, current_cluster['baseImageId'])
        current_cluster['baseImageName'] = current_image['abstract_name']
        for host_type in host_types:
            host_type['mem'] = float(host_type['mem']) / 1024

        security_zones = securityzones_helper.get_by_provider(
            request, current_cluster['provider'])
        placements = placements_helper.get_by_provider(
            request, current_cluster['provider'])
        base_images = baseimages_helper.get_by_name(
            request, current_image['abstract_name'])
        base_images_names = baseimages_helper.get_image_names(
            request, current_cluster['provider'])

        env = environs_helper.get_env_by_stage(request, name, stage)
        provider_list = baseimages_helper.get_all_providers(request)

        capacity_creation_info = {
            'environment': env,
            'hostTypes': host_types,
            'securityZones': security_zones,
            'placements': placements,
            'defaultMappings': PINTEREST_SECURITY_GROUP_PLACEMENTMAPPING,
            'baseImages': base_images,
            'baseImageNames': base_images_names,
            'defaultBaseImage': DEFAULT_CMP_IMAGE,
            'defaultCMPConfigs': get_default_cmp_configs(name, stage),
            'defaultProvider': DEFAULT_PROVIDER,
            'providerList': provider_list,
            'configList': get_aws_config_name_list_by_image(DEFAULT_CMP_IMAGE),
            'currentCluster': current_cluster
        }
        return render(
            request, 'clusters/cluster_configuration.html', {
                'env': env,
                'capacity_creation_info': json.dumps(capacity_creation_info)
            })
コード例 #27
0
ファイル: cluster_view.py プロジェクト: pinterest/teletraan
def get_host_types(request):
    index = int(request.GET.get("page_index", "1"))
    size = int(request.GET.get("page_size", DEFAULT_PAGE_SIZE))
    host_types = hosttypes_helper.get_all(request, index, size)
    for host_type in host_types:
        host_type["mem"] = float(host_type["mem"]) / 1024
    provider_list = baseimages_helper.get_all_providers(request)

    return render(
        request,
        "clusters/host_types.html",
        {
            "host_types": host_types,
            "provider_list": provider_list,
            "pageIndex": index,
            "pageSize": DEFAULT_PAGE_SIZE,
            "disablePrevious": index <= 1,
            "disableNext": len(host_types) < DEFAULT_PAGE_SIZE,
        },
    )
コード例 #28
0
ファイル: cluster_view.py プロジェクト: lilida/teletraan
    def get(self, request, name, stage):
        host_types = hosttypes_helper.get_by_provider(
            request, DEFAULT_PROVIDER)
        for host_type in host_types:
            host_type['mem'] = float(host_type['mem']) / 1024

        security_zones = securityzones_helper.get_by_provider_and_cell_name(
            request, DEFAULT_PROVIDER, DEFAULT_CELL)
        placements = placements_helper.get_by_provider_and_cell_name(
            request, DEFAULT_PROVIDER, DEFAULT_CELL)
        cells = cells_helper.get_by_provider(request, DEFAULT_PROVIDER)
        base_images = get_base_image_info_by_name(request, DEFAULT_CMP_IMAGE, DEFAULT_CELL)
        base_images_names = baseimages_helper.get_image_names(
            request, DEFAULT_PROVIDER, DEFAULT_CELL)

        env = environs_helper.get_env_by_stage(request, name, stage)
        provider_list = baseimages_helper.get_all_providers(request)

        capacity_creation_info = {
            'environment': env,
            'hostTypes': host_types,
            'securityZones': security_zones,
            'placements': placements,
            'cells': cells,
            'baseImages': base_images,
            'baseImageNames': base_images_names,
            'defaultBaseImage': DEFAULT_CMP_IMAGE,
            'defaultCMPConfigs': get_default_cmp_configs(name, stage),
            'defaultProvider': DEFAULT_PROVIDER,
            'defaultCell': DEFAULT_CELL,
            'defaultHostType': DEFAULT_CMP_HOST_TYPE,
            'defaultSeurityZone': DEFAULT_PLACEMENT,
            'providerList': provider_list,
            'configList': get_aws_config_name_list_by_image(DEFAULT_CMP_IMAGE)
        }
        # cluster manager
        return render(request, 'configs/new_capacity_adv.html', {
            'env': env,
            'capacity_creation_info': json.dumps(capacity_creation_info),
            'user_data_config_settings_wiki': USER_DATA_CONFIG_SETTINGS_WIKI,
            'is_pinterest': IS_PINTEREST})
コード例 #29
0
def get_cluster(request, name, stage):
    envs = environs_helper.get_all_env_stages(request, name)
    stages, env = common.get_all_stages(envs, stage)
    provider_list = baseimages_helper.get_all_providers(request)
    cluster_provider = clusters_helper.get_cluster_provider(
        request, name, stage)
    if cluster_provider == 'null':
        cluster_provider = None
    basic_cluster_info = clusters_helper.get_cluster(request, name, stage)
    advanced_cluster_info = clusters_helper.get_advanced_cluster(
        request, name, stage, cluster_provider)

    return render(
        request, 'clusters/clusters.html', {
            'env': env,
            'stages': stages,
            'provider_list': provider_list,
            'cluster_provider': cluster_provider,
            'basic_cluster_info': basic_cluster_info,
            'advanced_cluster_info': advanced_cluster_info,
        })
コード例 #30
0
    def get(self, request, name, stage):

        cluster_name = '{}-{}'.format(name, stage)
        current_cluster = clusters_helper.get_cluster(request, cluster_name)
        host_types = hosttypes_helper.get_by_provider(request, DEFAULT_PROVIDER)
        current_image = baseimages_helper.get_by_id(request, current_cluster['baseImageId'])
        current_cluster['baseImageName'] = current_image['abstract_name']
        for host_type in host_types:
            host_type['mem'] = float(host_type['mem']) / 1024

        security_zones = securityzones_helper.get_by_provider(request, current_cluster['provider'])
        placements = placements_helper.get_by_provider(request, current_cluster['provider'])
        base_images = baseimages_helper.get_by_name(request, current_image['abstract_name'])
        base_images_names = baseimages_helper.get_image_names(request, current_cluster['provider'])


        env = environs_helper.get_env_by_stage(request, name, stage)
        provider_list = baseimages_helper.get_all_providers(request)

        capacity_creation_info = {
            'environment': env,
            'hostTypes': host_types,
            'securityZones': security_zones,
            'placements': placements,
            'defaultMappings': PINTEREST_SECURITY_GROUP_PLACEMENTMAPPING,
            'baseImages': base_images,
            'baseImageNames': base_images_names,
            'defaultBaseImage': DEFAULT_CMP_IMAGE,
            'defaultCMPConfigs': get_default_cmp_configs(name, stage),
            'defaultProvider': DEFAULT_PROVIDER,
            'providerList': provider_list,
            'configList': get_aws_config_name_list_by_image(DEFAULT_CMP_IMAGE),
            'currentCluster': current_cluster
        }
        return render(request, 'clusters/cluster_configuration.html', {
            'env': env,
            'capacity_creation_info': json.dumps(capacity_creation_info)})
コード例 #31
0
    def get(self, request, name, stage):
        # cluster manager
        provider_list = None
        basic_cluster_info = None
        create_new = False
        adv = False
        env = environs_helper.get_env_by_stage(request, name, stage)
        cluster_name = env.get('clusterName')
        if IS_PINTEREST:
            provider_list = baseimages_helper.get_all_providers(request)
            basic_cluster_info = clusters_helper.get_cluster(request, cluster_name)
            if basic_cluster_info:
                base_image_id = basic_cluster_info.get('baseImageId')
                base_image = baseimages_helper.get_by_id(request, base_image_id)
                asg_cluster = autoscaling_groups_helper.get_group_info(request, cluster_name)
                basic_cluster_info['asg_info'] = asg_cluster

            params = request.GET
            if params.get('adv'):
                adv = params.get('adv')
            if params.get('create_new'):
                create_new = params.get('create_new')

        if request.is_ajax():
            # return data for ajax calls
            hosts = environs_helper.get_env_capacity(request, name, stage, capacity_type="HOST")
            groups = common.get_env_groups(request, name, stage)
            if cluster_name in groups:
                groups.remove(cluster_name)
            info = {
                "env": env,
                "hosts": hosts,
                "groups": groups,
                "csrf_token": get_token(request),
                'is_pinterest': IS_PINTEREST,
                'provider_list': provider_list,
                'basic_cluster_info': basic_cluster_info,
                'adv': adv,
                'create_new': create_new,
            }
            return HttpResponse(json.dumps(info), content_type="application/json")

        # otherwise, return a page
        envs = environs_helper.get_all_env_stages(request, name)
        stages, env = common.get_all_stages(envs, stage)
        hosts = environs_helper.get_env_capacity(request, name, stage, capacity_type="HOST")
        groups = common.get_env_groups(request, name, stage)
        if cluster_name in groups:
            groups.remove(cluster_name)
        data = {
            "envs": envs,
            "env": env,
            "stages": stages,
            "hosts": hosts,
            "groups": groups,
            'is_pinterest': IS_PINTEREST,
            'provider_list': provider_list,
            'basic_cluster_info': basic_cluster_info,
            'adv': adv,
            'create_new': create_new
        }
        data['info'] = json.dumps(data)
        return render(request, 'configs/capacity.html', data)
コード例 #32
0
    def get(self, request, name, stage):
        # cluster manager
        provider_list = None
        basic_cluster_info = None
        create_new = False
        adv = False
        env = environs_helper.get_env_by_stage(request, name, stage)
        cluster_name = env.get('clusterName')
        if IS_PINTEREST:
            provider_list = baseimages_helper.get_all_providers(request)
            basic_cluster_info = clusters_helper.get_cluster(request, cluster_name)
            if basic_cluster_info:
                base_image_id = basic_cluster_info.get('baseImageId')
                base_image = baseimages_helper.get_by_id(request, base_image_id)
                asg_cluster = autoscaling_groups_helper.get_group_info(request, cluster_name)
                basic_cluster_info['asg_info'] = asg_cluster
                basic_cluster_info['base_image_info'] = base_image

            params = request.GET
            if params.get('adv'):
                adv = params.get('adv')
            if params.get('create_new'):
                create_new = params.get('create_new')

        if request.is_ajax():
            # return data for ajax calls
            hosts = environs_helper.get_env_capacity(request, name, stage, capacity_type="HOST")
            groups = common.get_env_groups(request, name, stage)
            if cluster_name in groups:
                groups.remove(cluster_name)
            info = {
                "env": env,
                "hosts": hosts,
                "groups": groups,
                "csrf_token": get_token(request),
                'is_pinterest': IS_PINTEREST,
                'provider_list': provider_list,
                'basic_cluster_info': basic_cluster_info,
                'adv': adv,
                'create_new': create_new,
            }
            return HttpResponse(json.dumps(info), content_type="application/json")

        # otherwise, return a page
        envs = environs_helper.get_all_env_stages(request, name)
        stages, env = common.get_all_stages(envs, stage)
        hosts = environs_helper.get_env_capacity(request, name, stage, capacity_type="HOST")
        groups = common.get_env_groups(request, name, stage)
        if cluster_name in groups:
            groups.remove(cluster_name)
        data = {
            "envs": envs,
            "env": env,
            "stages": stages,
            "hosts": hosts,
            "groups": groups,
            'is_pinterest': IS_PINTEREST,
            'provider_list': provider_list,
            'basic_cluster_info': basic_cluster_info,
            'adv': adv,
            'create_new': create_new
        }
        data['info'] = json.dumps(data)
        return render(request, 'configs/capacity.html', data)
コード例 #33
0
ファイル: capacity_views.py プロジェクト: sonia-y/teletraan
    def get(self, request, name, stage):
        # cluster manager
        provider_list = None
        basic_cluster_info = None
        create_new = False
        adv = False
        env = environs_helper.get_env_by_stage(request, name, stage)
        if IS_PINTEREST:
            provider_list = baseimages_helper.get_all_providers(request)
            basic_cluster_info = clusters_helper.get_cluster(
                request, env.get('clusterName'))
            if basic_cluster_info:
                base_image_id = basic_cluster_info.get('baseImageId')
                base_image = baseimages_helper.get_by_id(
                    request, base_image_id)
                if base_image.get('abstract_name') != 'CMP-DOCKER':
                    adv = True

            params = request.GET
            if params.get('adv'):
                adv = params.get('adv')
            if params.get('create_new'):
                create_new = params.get('create_new')

        if request.is_ajax():
            # return data for ajax calls
            hosts = environs_helper.get_env_capacity(request,
                                                     name,
                                                     stage,
                                                     capacity_type="HOST")
            groups = common.get_non_cmp_group(request, name, stage)
            html = render_to_string(
                "configs/capacity.tmpl", {
                    "env": env,
                    "hosts": ','.join(hosts),
                    "groups": ','.join(groups),
                    "csrf_token": get_token(request),
                    'is_pinterest': IS_PINTEREST,
                    'provider_list': provider_list,
                    'basic_cluster_info': basic_cluster_info,
                    'adv': adv,
                    'create_new': create_new,
                })
            return HttpResponse(json.dumps({'html': html}),
                                content_type="application/json")

        # otherwise, return a page
        envs = environs_helper.get_all_env_stages(request, name)
        stages, env = common.get_all_stages(envs, stage)
        hosts = environs_helper.get_env_capacity(request,
                                                 name,
                                                 stage,
                                                 capacity_type="HOST")
        groups = common.get_non_cmp_group(request, name, stage)
        return render(
            request, 'configs/capacity.html', {
                "envs": envs,
                "env": env,
                "stages": stages,
                "hosts": ','.join(hosts),
                "groups": ','.join(groups),
                'is_pinterest': IS_PINTEREST,
                'provider_list': provider_list,
                'basic_cluster_info': basic_cluster_info,
                'adv': adv,
                'create_new': create_new,
            })