Create a tenant

2024-11-06 03:13:28  Updated

Description

You can call this operation to create a single tenant in a specified cluster.

Call description

Prerequisites

You have passed the authentication for the OCP application service.

Request path

POST /api/v2/ob/clusters/{id}/tenants/createTenant

Path parameters

Parameter Type Required Example value Description
id Integer Yes 1 The cluster ID.

Request parameters

Parameter Type Required Example value Description
name String Yes foo The name of the tenant, which is unique in the cluster.
mode String No MYSQL The compatibility mode of the tenant. Valid values:
  • ORACLE
  • MYSQL
  • primaryZone String No zone1,zone2;zone3 The zone priority.
    charset String No utf8mb4 The character set. Valid values:
    • Oracle mode:
      • utf8mb4
      • gbk
      • gb18030
    • MySQL mode:
      • binary
      • utf8mb4
      • gbk
      • gb18030
    Default value: utf8mb4.
    collation String No utf8mb4_general_ci The collation. Valid values:
    • binary
    • utf8mb4
    • gbk
    • gb18030
    Default value: utf8mb4_general_ci.
    Note
    This parameter is invalid for Oracle tenants.
    description String No bar The description of the tenant.
    whitelist String No % The whitelist of the tenant. Supported formats:
  • IP address, for example: xxx.xxx.xxx.1,xxx.xxx.xxx.2
  • Subnet/Mask, for example: xxx.xxx.xxx.3/24
  • Fuzzy match, for example: 10.10.10.% or 10.10.10.
  • Mixed format, for example: xxx.xxx.xxx.1,xxx.xxx.xxx.2,10.10.10.%,10.10.10.,xxx.xxx.xxx.3/24
  • Note
    % indicates that all clients can connect to this tenant. Default value: %.
    rootPassword String Yes The password of the administrator.
  • For an Oracle tenant, this parameter specifies the password of the sys user.
  • For a MySQL tenant, this parameter specifies the password of the root user.
  • The password must be 8 to 32 characters in length and contains at least three of the following character types: digits(0~9), uppercase letters(A~Z), lowercase letters(a~z), and special characters (ie: ~!@#%^&*_-+=|(){}[]:;,.?/).
  • saveToCredential Boolean No true Specifies whether to save the password of the tenant administrator to the password box of the current user logged on to OCP.
    zones Array Yes -- --
    ├─name String Yes zone1 The name of the zone in the cluster.
    ├─replicaType String Yes FULL Valid values:
  • FULL
  • LOGONLY
  • READONLY
  • ├─resourcePool Object Yes The resource pool.
    ├─unitSpecName String Yes S1 The unit specifications. You can view the unit specifications on the Unit Specification Management page.
    ├─unitCount Integer Yes 1 The number of units.

    Response parameters

    Basic data structure

    Parameter Type Description
    data Object The information about the asynchronous task. For more information, see Task information.
    successful Boolean Indicates whether the request is successful.
    timestamp Datetime The timestamp when the server completes the request.
    duration Integer The time taken by the server to process the request, in milliseconds.
    status Integer The HTTP status code.
    traceId String The trace ID of the request. This trace ID is used for troubleshooting.
    server String The address of the application server that responds to the request.

    Examples

    Sample request

    POST /api/v2/ob/clusters/1/tenants/createTenant

    body:

    {
      "name": "foo",
      "mode": "MYSQL",
      "primaryZone": "zone1,zone2;zone2",
      "charset": "utf8mb4",
      "collation": "utf8mb4_general_ci",
      "description": "bar",
      "whitelist": "%",
      "rootPassword": "xxxxx",
      "saveToCredential": true,
      "zones": [
        {
          "name": "zone1",
          "replicaType": "FULL",
          "resourcePool": {
            "unitSpecName": "S1",
            "unitCount": 1
          }
        },
        {
          "name": "zone2",
          "replicaType": "FULL",
          "resourcePool": {
            "unitSpecName": "S1",
            "unitCount": 1
          }
        },
        {
          "name": "zone3",
          "replicaType": "FULL",
          "resourcePool": {
            "unitSpecName": "S1",
            "unitCount": 1
          }
        }
      ]
    }
    

    Sample response

    {
      "data": {
        "clusterId": 2000017,
        "creator": "admin",
        "executor": "xxx.xxx.xxx.xxx",
        "id": 4000191,
        "name": "Create tenant",
        "operation": "EXECUTE",
        "prohibitRollback": false,
        "startTime": "2022-08-22T19:55:25.902+08:00",
        "status": "RUNNING",
        "subtasks": [
          {
            "description": "Create ob tenant",
            "downstreams": [
              4000198
            ],
            "id": 4000201,
            "name": "Create ob tenant",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 4,
            "status": "PENDING",
            "timeout": 1200,
            "upstreams": [
              4000204
            ]
          },
          {
            "description": "Set ob tenant parameters",
            "downstreams": [
              4000199
            ],
            "id": 4000202,
            "name": "Set ob tenant parameters",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 2,
            "status": "PENDING",
            "timeout": 300,
            "upstreams": [
              4000203
            ]
          },
          {
            "description": "Set whitelist",
            "downstreams": [
              4000203
            ],
            "id": 4000200,
            "name": "Set whitelist",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 3,
            "status": "PENDING",
            "timeout": 300,
            "upstreams": [
              4000195
            ]
          },
          {
            "description": "Update tenant status",
            "downstreams": [
              4000197
            ],
            "id": 4000199,
            "name": "Update tenant status",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 8,
            "status": "PENDING",
            "timeout": 300,
            "upstreams": [
              4000202
            ]
          },
          {
            "description": "Set super user password",
            "downstreams": [
              4000200
            ],
            "id": 4000195,
            "name": "Set super user password",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 0,
            "status": "PENDING",
            "timeout": 300,
            "upstreams": [
              4000198
            ]
          },
          {
            "description": "Sync tenant information",
            "downstreams": [
              4000195
            ],
            "id": 4000198,
            "name": "Sync tenant information",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 5,
            "status": "PENDING",
            "timeout": 300,
            "upstreams": [
              4000201
            ]
          },
          {
            "description": "Prepare create tenant",
            "downstreams": [
              4000201
            ],
            "id": 4000204,
            "name": "Prepare create tenant",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 6,
            "status": "READY",
            "timeout": 30,
            "upstreams": []
          },
          {
            "description": "Import tenant time zone info",
            "downstreams": [],
            "id": 4000196,
            "name": "Import tenant time zone info",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 1,
            "status": "PENDING",
            "timeout": 600,
            "upstreams": [
              4000197
            ]
          },
          {
            "description": "Import tenant srs info",
            "downstreams": [
              4000196
            ],
            "id": 4000197,
            "name": "Import tenant srs info",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 9,
            "status": "PENDING",
            "timeout": 600,
            "upstreams": [
              4000199
            ]
          },
          {
            "description": "Set system variables",
            "downstreams": [
              4000202
            ],
            "id": 4000203,
            "name": "Set system variables",
            "nodeType": "JAVA_TASK",
            "operation": "EXECUTE",
            "parallelIdx": -1,
            "prohibitRollback": false,
            "runTime": 1,
            "seriesId": 7,
            "status": "PENDING",
            "timeout": 300,
            "upstreams": [
              4000200
            ]
          }
        ],
        "taskDefinitionId": -1,
        "tenantId": 3000001,
        "type": "MANUAL"
      },
      "duration": 6390,
      "server": "a83ad33525",
      "status": 200,
      "successful": true,
      "timestamp": "2022-08-22T19:55:27.325+08:00",
      "traceId": "dadeade2e6894d46"
    }
    

    Contact Us