Using the vRealize Suite Lifecycle Manager (vRSLCM) API for vRSLCM Day 2 Operations - Managing Datacenters



vRealize Suite Lifecycle Manager vRSLCM API

Published on 30 November 2021 by Christopher Lewis. Words: 1411. Reading Time: 7 mins.

In this post, we will look at how we can use the VMware vRealize Suite Lifecycle Manager (vRSLCM) API to complete Day 2 Operations for managing Datacenter objects in vRSLCM.

Within vRSLCM, a Datacenter is a logical representation of a physical datacenter location and associated vCenter Servers. Without defining a Datacenter and vCenter Server we canot deploy application such as vRealise Automation.

We are going to be using cURL to complete API calls to complete the following operational tasks for managing Datacenters:

  • Viewing existing vRSLCM Datacenters
  • Creating a vRSLCM Datacenter
  • Adding a vCenter Server to the vRSLCM Datacenter
  • Viewing the vCenter Servers in a vRSLCM Datacenter
  • Deleting a vCenter Server from a vRSLCM Datacenter
  • Deleting a vRSLCM Datacenter

This post is a part of a series that covers how we can install, configure and manage the vRealize Suite using the vRSLCM API.

Prerequisites

The following prerequisites are required for this blog post:

Walkthrough

Viewing existing Datacenters

Overview

We can view existing Datacenter objects using the API. One of the main reason to do this is to make sure we are not using the same datacenter name twice!

If we do try to use the same name, we will get a LCM_DATACENTER_API_ERROR0002 - Data Center already exists error. This isn’t fatal, we just need to be mindful!

API Request

The following REST API request is required:

  • Request Type: GET
  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {admin@local credential hash}
  • Request Body Values:
    • None

API Example

An example cURL command for this REST API is:

curl --location --request GET 'https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}'

Note: The –insecure flag is also required if you are using self-signed SSL certificates.

API Response

The response returned from the REST API looks like this (when formatted in JSON):

[
    {
        "dataCenterVmid": "9ebafd91-7472-4cf6-b707-4bc6c4c58283",
        "dataCenterName": "Edinburgh",
        "primaryLocation": "Edinburgh;Scotland;GB;55.953251;-3.188267"
    }
]

As we can see, we currently have one existing Datacenter. Let us go ahead and create another one.

Creating a Datacenter

Overview

In this section we are going to use the vRSLCM API to create a datacenter object. This is a prerequisite to being able to deploy products in vRSLCM.

API Request

The following REST API request is required:

  • Request Type: POST
  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {insert credential hash}
  • Request Body Values:
    • dataCenterName - the user friendly name of the Datacenter.
    • primaryLocation - the physical location of the Datacenter, in the format of {Town};{Province/State};{Country Code};{Latitude};{Longitude}.

API Example

An example cURL command for this REST API is:

curl --location --request POST 'https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}' \
--data-raw '{
    "dataCenterName": "London",
    "primaryLocation": "London;England;GB;51.50853;-0.12574"
}'

Note: The –insecure flag is also required if you are using self-signed SSL certificates.

API Response

The expected response returned from a successful request (Status Code=200) will be something like:

{
    "dataCenterVmid": "94e796dd-c9ee-4a70-a1ab-13d3a1e27779",
    "dataCenterName": "London",
    "primaryLocation": "London;England;GB;51.50853;-0.12574"
}

If we logged into vRSLCM using the UI, we would now see the following Datacenter locations configured:

Adding a vCenter to a Datacenter

Overview

Once we have a vRSLCM Datacenter object, we also need to add a vCenter Server to that datacenter so we can deploy the vRealize Suite products.

API Request

The following REST API request is required to add a vCenter Server to an existing Datacenter:

  • Request Type: POST
  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters/{vmid}/vcenters
    • vmid - the unique id of the Datacenter that the vCenter Server will be added to.
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {admin@local credential hash}
  • Request Body Values:
    • vCenterName - the user friendly name of the vCenter Server.
    • vCenterHost - the FQDN of the vcenter server.
    • vcUsername - the vCenter username that has been assigned a role with sufficient priviliges in vCenter Server.
    • vcPassword - the password for the vCenter username. This can be specified as a credential stored in vRSLCM locker (using the format locker:password:{vmid}:{alias}) OR as a plain text password).
    • vcUsedAs - the type of vCenter Server, supported values are: MANAGEMENT, WORKLOAD or MANAGEMENT_AND_WORKLOAD.

API Example

An example cURL command for this REST API is:

curl --location --request POST 'https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters/94e796dd-c9ee-4a70-a1ab-13d3a1e27779/vcenters' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}' \
--data-raw '{
    "vCenterName": "vcs01",
    "vCenterHost": "vcs01.thecloudxpert.local",
    "vcUsername": "administrator@vsphere.local",
    "vcPassword": "locker:password:{vcenter.password.vmid}:{vcenter.password.alias}",
    "vcUsedAs": "MANAGEMENT_AND_WORKLOAD"
}'

Note: The –insecure flag is also required if you are using self-signed SSL certificates.

API Response

The expected response returned from a successful request (Status Code=200) will be a Request ID (vmid).

{
    "requestId": "4bb56445-3437-4751-9573-cac69a11243d"
}

We can track the progress of requests via the API. Check out Using the vRealize Suite Lifecycle Manager (vRSLCM) API to track vRSLCM Requests for more information.

Once the request has completed successfully, we can then use another API call to view the vCenter Servers that belong to a vRSLCM datacenter object.

Viewing the vCenter Servers in a Datacenter

Overview

We can use an API call to view the vCenter Servers that belong to a Datacenter.

API Request

The following REST API request is required to add a vCenter Server to an existing Datacenter:

  • Request Type: GET
  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters/{vmid}/vcenters
    • vmid - the unique id of the Datacenter.
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {admin@local credential hash}
  • Request Body Values:
    • None.

API Example

An example cURL command for this REST API is:

curl --location --request GET 'https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters/94e796dd-c9ee-4a70-a1ab-13d3a1e27779/vcenters' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}'

Note: The –insecure flag is also required if you are using self-signed SSL certificates.

API Response

The expected response returned from a successful request (Status Code=200) will be a Request ID (vmid).

{
    "requestId": "ec1f5640-c0a8-44b6-a703-f6bb0c9b42cb"
}

Deleting a vCenter Server from a Datacenter

Overview

Once we have a Datacenter object, we may need to delete a vCenter Server from that datacenter using the API.

API Request

The following REST API request is required to add a vCenter Server to an existing vRSLCM Datacenter:

  • Request Type: DELETE
  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters/{vmid}/vcenters/{vcenter.name}
    • vmid - the unique id of the vRSLCM datacenter.
    • vcenter.name - the user friendly name of the vcenter server.
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {admin@local credential hash}
  • Request Body Values:
    • None.

API Example

An example cURL command for this REST API is:

curl --location --request DELETE 'https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters/9ebafd91-7472-4cf6-b707-4bc6c4c58283/vcenters/vcs01' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}'

Note: The –insecure flag is also required if you are using self-signed SSL certificates.

API Response

The expected response returned from a successful request (Status Code=200) will be a Request ID (vmid).

{
    "requestId": "e46e7ab4-e8c8-40cc-a1c1-01c7ce6b6b05"
}

As mentioned above, we can track the progress of requests via the API too! Check out Using the vRealize Suite Lifecycle Manager (vRSLCM) API to track vRSLCM Requests for more information.

Deleting a vCenter Server from a vRSLCM Datacenter

Overview

Once we have a Datacenter object, we may need to delete a vCenter Server from that datacenter using the API.

API Request

The following REST API request is required to add a vCenter Server to an existing Datacenter:

  • Request Type: DELETE
  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v2/datacenters/{vmid}
    • vmid - the unique id of the vRSLCM datacenter.
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {admin@local credential hash}
  • Request Body Values:
    • None.

API Example

An example cURL command for this REST API is:

curl --location --request DELETE 'https://lcm.thecloudxpert.local/lcm/lcops/api/v2/datacenters/9ebafd91-7472-4cf6-b707-4bc6c4c58283' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}'

Note: The –insecure flag is also required if you are using self-signed SSL certificates.

API Response

The expected response returned from a successful request (Status Code=200) will be a Request ID (vmid).

{
    "requestId": "3fc98e6b-0a8a-4a2d-8fb7-bea42b8b1747"
}

If we logged into vRSLCM using the UI, we would now see the following Datacenters configured:

As mentioned above, we can track the progress of requests via the API. Check out Using the vRealize Suite Lifecycle Manager (vRSLCM) API to track vRSLCM Requests for more information.

Wrapping It All Up!

In this post we have explored the way we can manage Datacenter objects using the vRSLCM API.

If this API this snippet has been helpful, make sure you checkout the rest of the series !

Published on 30 November 2021 by Christopher Lewis. Words: 1411. Reading Time: 7 mins.