API Use Case: Cloud Setup

Tenancy Model

This example walks you through an end-to-end cloud configuration using CloudCenter APIs.

Create Cloud

This example creates an OpenStack cloud under the root tenant.

Request

curl -k -H "Accept:application/json" -H "Content-Type:application/json" 
-u cliqradmin:FAFD1FB17817C4A1 -X POST -d @/tmp/createcloud.json 
"https://m/v1/tenants/1/clouds/"

Request Body

{
    "name": "CliQrOpenStackCloud",
    "description": "CliQr's OS based private cloud",
    "cloudFamily": "Openstack",
    "tenantId": 1
}

Response

{
    "id": "2",
    "resource": "https://m/v1/tenants/1/clouds/2",
    "perms": [],
    "name": "CliQrOpenStackCloud",
    "cloudFamily": "Openstack",
    "description": "CliQr's OS based private cloud",
    "publicCloud": false
}

Create Cloud Account

This example creates a cloud account under the OpenStack cloud created above.

Request

curl -k -H "Accept:application/json" -H "Content-Type:application/json" -u cliqradmin:FAFD1FB17817C4A1 -X POST -d @/tmp/createcloudaccount.json "https://m/v1/tenants/1/clouds/2/accounts"

Request Body

The payload for the create cloud account API varies based on the cloud family of the cloud under which the account is created.
{
    "accountId": "DefaultAccount",
    "displayName": "Default Account",
    "manageCost": true,
    "accessPermission": "USERS_AND_SUBTENANT_USERS",
    "userId": 2,
    "cloudId": "2",
    "accountPassword": "===redacted===",
    "accountName": "gautam",
    "accountProperties": [
        {
            "name": "Region",
            "value": "regionOne"
        },
        {
            "name": "TenantName",
            "value": " gautam "
        },
        {
            "name": "NeutronEndpoint",
            "value": ""
        },
        {
            "name": "NovaEndpoint",
            "value": ""
        },
        {
            "name": "Endpoint",
            "value": "http://10.100.1.75:5000/v2.0"
        },
        {
            "name": "PreferredNetwork",
            "value": ""
        }
    ]
}

Response

Cloud creation is an asynchronous operation. As part of account creation, image permissions are also granted to this new account for certain clouds. Creation of cloud account completes only after image permissions have been granted. Granting of launch permissions to images at the time of cloud account creation is currently only supported for clouds based on AWS cloud family.

The cloud account creation process is asynchronous for clouds based on all cloud families (see Synchronous and Asynchronous APIs for additional context). The response contains reference to a status-tracking object, which can be polled to get the status of Create Cloud Account API.

This is the response while account creation is still in progress.

{
    "operationId": "f098bc40-2298-480a-82c1-f7834733c830",
    "status": "RUNNING",
    "msg": "Saving cloud account...",
    "progress": 90,
    "timestamp": 1438933287241,
    "additionalParameters": null,
    "operationHistory": [],
    "subtaskResults": null,
    "resourceUrl": "https://m/v1/operationStatus/f098bc40-2298-480a-82c1-f7834733c830"
}

This is the response once the account creation is complete.

{
    "status": "SUCCESS",
    "msg": "Cloud Account is saved successfully.",
    "resource": "https://m/v1/operationStatus/f098bc40-2298-480a-82c1-f7834733c830",
    "additionalParameters": []
}
At this point, the API does not return a reference to the newly-created cloud account resource. The View Cloud Accounts API provides a list of all accounts for a cloud.
curl-k-H "Accept:application/json"-H "Content-Type:application/json"
-ucliqradmin: FAFD1FB17817C4A1 "https://m/v1/tenants/1/clouds/2/accounts"
{
    "cloudAccounts": [
        {
            "id": "2",
            "resource": null,
            "perms": [],
            "displayName": "Default Account",
            "cloudId": "2",
            "userId": "2",
            "accountName": "gautam",
            "accountId": "DefaultAccount",
            "accountPassword": "===redacted===",
            "accountDescription": null,
            "manageCost": true,
            "publicVisible": false,
            "allowedUsers": [],
            "accessPermission": "USERS_AND_SUBTENANT_USERS",
            "accountProperties": [
                {
                    "name": "Region",
                    "value": "regionOne"
                },
                {
                    "name": "TenantName",
                    "value": "gautam"
                },
                {
                    "name": "NeutronEndpoint",
                    "value": ""
                },
                {
                    "name": "NovaEndpoint",
                    "value": ""
                },
                {
                    "name": "Endpoint",
                    "value": "http://10.100.1.75:5000/v2.0"
                },
                {
                    "name": "PreferredNetwork",
                    "value": ""
                }
            ]
        }
    ]
}

Add Cloud Region

This example adds a new cloud region to the OpenStack cloud.

Request

curl-k-H "Accept:application/json"-H "Content-Type:application/json"
-ucliqradmin: FAFD1FB17817C4A1-XPOST-d @/tmp/createcloudregion.json 
"https://m/v1/tenants/1/clouds/2/regions"

Request Body

As shown in the following example, the region name:
  • Should not have any spaces
  • Should be prepended with the cloud name

This example demonstrates setting up a region for a private cloud like OpenStack.

For public clouds like AWS, the cloud region definition is bundled in the product and can be imported.

{
    "cloudId": 2,
    "regionName": "CliQrOpenStackCloud-SantaClara",
    "displayName": "Santa Clara"
}

Response

{
    "id": "2",
    "resource": "https://m/v1/tenants/1/clouds/2/regions/2",
    "perms": [],
    "cloudId": "2",
    "displayName": "Santa Clara",
    "regionName": "CliQrOpenStackCloud-SantaClara",
    "description": null,
    "importRegion": null,
    "gateway": {
        "address": null,
        "dnsName": null,
        "status": null,
        "cloudId": null,
        "cloudAccountId": null
    },
    "storage": null,
    "enabled": false,
    "activated": false,
    "numUsers": 0,
    "status": "STOPPED",
    "statusDetail": "GATEWAY_NOT_ACTIVATED",
    "regionProperties": []
}


Configure CCO for Each Region

A CCO must be installed in the cloud and registered with the cloud region on CCM.

Request

curl-k-H"Accept:application/json"-H "Content-Type:application/json"
-u cliqradmin: FAFD1FB17817C4A1-X PUT-d@/tmp/registercco.json 
"https://m/v1/tenants/1/clouds/2/regions/2/gateway"

Request Body

{
    "address": "10.110.13.54",
    "dnsName": "",
    "cloudAccountId": 2,
    "cloudId": 2
}

Response

{
    "address": "10.110.13.54",
    "dnsName": null,
    "status": "RUNNING",
    "cloudId": "2",
    "cloudAccountId": "2"
}

Add Instance Types

Instance types are required at the time of application VM deployment to determine the specifications of the VM that is being launched. Most clouds provide a standard set of instance type definitions. The desired instance type definitions need to be added to the cloud region.

This step is not required for public clouds like AWS. Instance types for a public cloud are imported upon region creation.


Request

curl-k-H "Accept:application/json"-H "Content-Type:application/json"
-ucliqradmin:FAFD1FB17817C4A1-X POST -d @/tmp/createinstancetype.json
"https://m/v1/tenants/1/clouds/2/regions/2/instanceTypes"

Request Body

{
    "type": "m1.medium.db",
    "costPerHour": 0.1,
    "numOfCPUs": 1,
    "name": "m1.medium.m1",
    "memorySize": 1024,
    "numOfNICs": 2,
    "localStorageSize": 100,
    "supportsCuda": false,
    "supportsSsd": false,
    "regionId": 2,
    "supports32Bit": true,
    "supports64Bit": false
}
The type attribute in the payload above should match the instance type ID or flavor ID of the corresponding instance type in the cloud/datacenter environment.

Response

{
    "id": "10",
    "resource": "https://m/v1/tenants/1/clouds/2/regions/2/instanceTypes/10",
    "perms": [],
    "name": "m1.medium.m1",
    "description": null,
    "type": "m1.medium.db",
    "regionId": "2",
    "costPerHour": 0.1,
    "memorySize": 1024,
    "numOfCpus": 0,
    "numOfNics": 0,
 }

Add Image Mapping

Logical Image definitions in CloudCenter are used to identify the image that should be launched in the cloud environment when application’s VMs are deployed. Application profiles contain a reference to logical image definition that is required for every application tier. Each logical image definition in CloudCenter is mapped to each cloud region. The mapping consists of the image ID from the cloud/datacenter environment, which corresponds to a cloud region.

CloudCenter provides several logical image definitions like Ubuntu 12.0.4, CentOS 6.5 (see Base OS Images)  The following example demonstrates adding an image mapping to a cloud region for the Ubuntu 12.0.4 logical image. First retrieve the ID for the Ubuntu 12.0.4 image by listing all logical images.

Request

curl-k-H "Accept:application/json"-H "Content-Type:application/json"
-ucliqradmin:FAFD1FB17817C4A1 "https://m/v1/tenants/1/images"

Response

{
    "resource": "https://m/v1/tenants/1/images",
    "size": 15,
    "pageNumber": 0,
    "totalElements": 15,
    "totalPages": 1,
    "images": [
        {
            "id": "2",
            "resource": null,
            "perms": [
                
            ],
            "name": "Ubuntu 12.04",
            "internalImageName": "CloudWorker-Ubuntu12.04",
            "description": "Ubuntu 12.04",
            "visibility": "PUBLIC",
            "imageType": "CLOUD_WORKER",
            "osName": "LINUX",
            "tags": [
                
            ],
            "numOfNics": 1,
            "tenantId": 1,
            "enabled": true,
            "systemImage": true,
            "detail": null,
            "count": 1
        },
        {
            "id": "4",
            "resource": null,
            "perms": [
                
            ],
            "name": "CentOS 6.x",
            "internalImageName": "CloudWorker-CentOS6.x",
            "description": "CentOS 6.x",
            "visibility": "PUBLIC",
            "imageType": "CLOUD_WORKER",
            "osName": "LINUX",
            "tags": [
                
            ],
            "numOfNics": 1,
            "tenantId": 1,
            "enabled": true,
            "systemImage": true,
            "detail": null,
            "count": 1
        },
        ……
    ]
}

From the list of images, retrieve the ID for the image Ubuntu12.0.4 (id=2). Use this ID to add image mapping for a cloud region

Request

curl-k-H "Accept:application/json"-H "Content-Type:application/json"
-ucliqradmin:FAFD1FB17817C4A1-X POST -d @/tmp/createimagemapping.json 
"https://m/v1/tenants/1/clouds/2/regions/2/images"

Request Body

{
    "regionId": "2",
    "cloudProviderImageId": "959c6532-1e24-4149-bf2f-9042d0635007",
    "launchUserName": "ubuntu",
    "imageId": "2",
    "mappings": [
        {
            "cloudInstanceType": {
                "id": "10",
                "regionId": "2"
            },
            "costOverride": null,
            "cloudProviderImageIdOverride": null
        }
    ]
}

Response

{
    "id": "5",
    "resource": "https://m/v1/tenants/1/clouds/2/regions/2/images/5",
    "perms": [],
    "regionId": "2",
    "cloudProviderImageId": "959c6532-1e24-4149-bf2f-9042d0635007",
    "launchUserName": "ubuntu",
    "imageId": "2",
    "grantAndRevoke": false,
    "imageCloudAccountId": 0,
    "resources": [],
    "mappings": [
        {
            "id": "22",
            "cloudInstanceType": {
                "id": "10",
                "resource": null,
                "perms": [],
                "name": "m1.medium.m1",
                "description": null,
                "type": "m1.medium.db",
                "regionId": "2",
                "costPerHour": 0.1,
                "memorySize": 1024,
                "numOfCpus": 0,
                "numOfNics": 0,
                "localStorageSize": 100,
                "supportsCuda": false,
                "supportsSsd": false,
                "supports32Bit": true,
                "supports64Bit": false
            },
            "costOverride": 0,
            "cloudProviderImageIdOverride": null
        }
    ]
}

The following table identifies the parallel cloud configuration process using the UI and the API:

StepUI ProcessAPI ProcessDescription
1Add CloudCreate Cloud
2Configure Cloud(s) accountCreate Cloud AccountA cloud account contains credentials and other required details to communicate with the clouds supported by CloudCenter (use the View Cloud Families API to view an exhaustive list).
3Configure Cloud(s) regionCreate Cloud RegionFor each cloud (cloudFamilies), you can configure multiple regions.
4Register the CCO with the CCMUpdate CCO ConfigurationPerform this step for each region.
5Configure Cloud(s) (see the Configure an OpenStack Cloud section – Step 10)Create Cloud Instance TypeAdd instance types (instanceTypeMapping) for the cloud region.
6Map Images (see the OpenStack Image ID section)Create Cloud Image Mapping

Add image mappings for the cloud region.