예제 #1
0
    def post(self, request, name, stage):
        log.info("Post to capacity with data {0}".format(request.body))
        try:
            cluster_name = '{}-{}'.format(name, stage)
            cluster_info = json.loads(request.body)

            log.info("Create Capacity in the provider")
            clusters_helper.create_cluster(request, cluster_name, cluster_info)

            log.info("Associate cluster_name to environment")
            # Update cluster info
            environs_helper.update_env_basic_config(
                request, name, stage, data={"clusterName": cluster_name})

            log.info("Update capacity to the environment")
            # set up env and group relationship
            environs_helper.add_env_capacity(request,
                                             name,
                                             stage,
                                             capacity_type="GROUP",
                                             data=cluster_name)
            return HttpResponse("{}", content_type="application/json")
        except Exception as e:
            log.info("Have an error {}".format(e))
            return HttpResponse(e, status=500, content_type="application/json")
예제 #2
0
    def post(self, request, name, stage):
        log.info("Post to capacity with data {0}".format(request.body))
        try:
            cluster_name = '{}-{}'.format(name, stage)
            cluster_info = json.loads(request.body)

            log.info("Create Capacity in the provider")
            clusters_helper.create_cluster_with_env(request, cluster_name, name, stage, cluster_info)

            log.info("Associate cluster_name to environment")
            # Update cluster info
            environs_helper.update_env_basic_config(
                request, name, stage, data={"clusterName": cluster_name})

            log.info("Update capacity to the environment")
            # set up env and group relationship
            environs_helper.add_env_capacity(
                request, name, stage, capacity_type="GROUP", data=cluster_name)
            return HttpResponse("{}", content_type="application/json")
        except NotAuthorizedException as e:
            log.error("Have an NotAuthorizedException error {}".format(e))
            return HttpResponse(e, status=403, content_type="application/json")
        except Exception as e:
            log.error("Have an error {}".format(e))
            return HttpResponse(e, status=500, content_type="application/json")
예제 #3
0
    def post(self, request, name, stage):
        log.info("Post to capacity with data {0}".format(request.body))
        try:
            cluster_name = '{}-{}'.format(name, stage)
            cluster_info = json.loads(request.body)

            log.info("Create Capacity in the provider")
            if 'configs' in cluster_info:
                if 'spiffe_id' in cluster_info['configs']:
                    log.error("Teletraan does not support user to change spiffe_id %s"  % cluster_info['spiffe_id'])
                    raise TeletraanException("Teletraan does not support user to create spiffe_id")

            clusters_helper.create_cluster_with_env(request, cluster_name, name, stage, cluster_info)

            log.info("Associate cluster_name to environment")
            # Update cluster info
            environs_helper.update_env_basic_config(
                request, name, stage, data={"clusterName": cluster_name})

            log.info("Update capacity to the environment")
            # set up env and group relationship
            environs_helper.add_env_capacity(
                request, name, stage, capacity_type="GROUP", data=cluster_name)
            return HttpResponse("{}", content_type="application/json")
        except NotAuthorizedException as e:
            log.error("Have an NotAuthorizedException error {}".format(e))
            return HttpResponse(e, status=403, content_type="application/json")
        except Exception as e:
            log.error("Have an error {}".format(e))
            return HttpResponse(e, status=500, content_type="application/json")
예제 #4
0
def create_cluster(request, name, stage):
    params = request.POST
    cluster_name = '{}-{}'.format(name, stage)
    cluster_info = parse_cluster_info(request, name, stage, cluster_name)
    user_data_configs = parse_configs(params)
    cluster_info['configs'] = user_data_configs
    clusters_helper.create_cluster(request, cluster_name, cluster_info)

    # set up env and group relationship
    environs_helper.add_env_capacity(request, name, stage, capacity_type="GROUP", data=cluster_name)
    return get_basic_cluster(request, name, stage)
예제 #5
0
def create_cmp_cluster(request, name, stage):
    params = request.POST
    cluster_name = "{}-{}".format(name, stage)
    cluster_info = parse_cluster_info(request, name, stage, cluster_name)
    config_map = get_default_cmp_configs(name, stage)
    user_data_configs = parse_configs(params)
    config_map.update(user_data_configs)
    cluster_info["configs"] = config_map
    clusters_helper.create_cluster(request, cluster_name, cluster_info)

    # set up env and group relationship
    environs_helper.add_env_capacity(request, name, stage, capacity_type="GROUP", data=cluster_name)
    return get_cmp_cluster(request, name, stage)