コード例 #1
0
ファイル: capella_utils.py プロジェクト: couchbaselabs/TAF
    def create_cluster(pod, tenant, cluster_details, timeout=1800):
        end_time = time.time() + timeout
        while time.time() < end_time:
            subnet = CapellaUtils.get_next_cidr() + "/20"
            CapellaUtils.log.info("Trying with cidr: {}".format(subnet))
            cluster_details["place"]["hosted"].update({"CIDR": subnet})
            cluster_details.update({"projectId": tenant.project_id})
            capella_api = CapellaAPI(pod.url_public, tenant.api_secret_key,
                                     tenant.api_access_key, tenant.user,
                                     tenant.pwd)
            capella_api_resp = capella_api.create_cluster(cluster_details)

            # Check resp code , 202 is success
            if capella_api_resp.status_code == 202:
                break
            else:
                CapellaUtils.log.critical("Create capella cluster failed.")
                CapellaUtils.log.critical("Capella API returned " +
                                          str(capella_api_resp.status_code))
                CapellaUtils.log.critical(capella_api_resp.json()["message"])

        cluster_id = capella_api_resp.headers['Location'].split("/")[-1]
        CapellaUtils.log.info("Cluster created with cluster ID: {}"\
                              .format(cluster_id))
        CapellaUtils.wait_until_done(pod,
                                     tenant,
                                     cluster_id,
                                     "Creating Cluster {}".format(
                                         cluster_details.get("clusterName")),
                                     timeout=timeout)
        cluster_srv = CapellaUtils.get_cluster_srv(pod, tenant, cluster_id)
        CapellaUtils.allow_my_ip(pod, tenant, cluster_id)
        servers = CapellaUtils.get_nodes(pod, tenant, cluster_id)
        return cluster_id, cluster_srv, servers
コード例 #2
0
def main(cmd_line_args):

    cappella_api = CapellaAPI()

    if cmd_line_args.debug:
        capella_logging('debug')
        cappella_api.set_logging_level('DEBUG')
    else:
        capella_logging('info')

    cluster_configuration = {
        "environment": "hosted",
        "clusterName": cmd_line_args.clusterName,
        "description": "Example hosted cluster create from Public API",
        "projectId": cmd_line_args.projectID,
        "place": {
            "singleAZ": False,
            "hosted": {
                "provider": "aws",
                "CIDR": "10.199.0.0/20",
                "region": "us-east-2"
            }
        },
        "servers": [
            {
                "compute": "m5.xlarge",
                "size": 3,
                "services": ["data", "index", "search", "query"],
                "storage": {
                    "size": 50,
                    "IOPS": 3000,
                    "type": "GP3"
                    },
            }
        ],
        "supportPackage": {
            "timezone": "GMT",
            "type": "DeveloperPro"
        },
        "version": "latest",
    }

    # Create the cluster, indicate that this is a hosted cluster by calling with True
    # and pass the configuration
    capella_api_response = cappella_api.create_cluster(True, cluster_configuration)

    # Check response code , 202 is success
    if capella_api_response.status_code == 202:
        print("Creating cluster ")
        print("Check deployment status here: " + cappella_api.API_BASE_URL +
              capella_api_response.headers['Location'] + '/status')
    else:
        print("Failed to create cluster ")
        print("Capella API returned " + str(capella_api_response.status_code))
        print("Full error message")
        print(capella_api_response.json()["message"])
コード例 #3
0
def main(cmd_line_args):

    cappella_api = CapellaAPI()

    if cmd_line_args.debug:
        capella_logging('debug')
        cappella_api.set_logging_level('DEBUG')
    else:
        capella_logging('info')

    cluster_configuration = {
        "cloudId": cmd_line_args.cloudID,
        "name": cmd_line_args.clusterName,
        "projectId": cmd_line_args.projectID,
        "servers": [
            {
                "services": [
                    "data", "index", "query", "search"
                ],
                "size": 3,
                "aws": {
                    "ebsSizeGib": 50,
                    "instanceSize": "m5.xlarge"
                }
            }
        ],
        "version": "latest"
    }

    # Create the cluster, pass the configuration
    # and indicate that this cluster will run in the customers own cloud by calling with False
    capella_api_response = cappella_api.create_cluster(False, cluster_configuration)

    # Check response code , 201 is success
    if capella_api_response.status_code == 202:
        print("Creating cluster ")
        print("Check deployment status here: " + cappella_api.API_BASE_URL +
              capella_api_response.headers['Location'] + '/status')
    else:
        print("Failed to create cluster ")
        print("Capella API returned " + str(capella_api_response.status_code))
        print("Full error message")
        print(capella_api_response.json()["message"])