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



vRealize Suite Lifecycle Manager vRSLCM API

Published on 1 December 2021 by Christopher Lewis. Words: 785. Reading Time: 4 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 the configuration of Global Network Time Protocol (NTP) Servers to be used by vRSLCM.

Within vRSLCM, we can optionally configure NTP Servers that can be shared across environments and product deployments. We are going to be using cURL to run API calls to complete the following operational tasks for managing global NTP servers:

  • View existing Global NTP Server(s)
  • Adding a Global NTP Server
  • Deleting a Global NTP Server

Note: The REST API call for deleting NTP servers is a deprecated function.

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:

  • vRSLCM 8.6.x (or above) has been deployed successfully within the environment.
  • vRSLCM local administrator (admin@local) credentials.

Walkthrough

View existing Global NTP Servers

Overview

Using the vRSLCM REST API, we can view the vRSLCM configuration to see if there are any existing NTP Servers configured for use with the Product deployments.

API Request

The following REST API request is required:

  • Request Type: GET
  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v2/settings/ntp-servers
  • 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/settings/ntp-servers' \
--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

If you have no NTP Servers set, the response returned will be:

[]

If you have previously set a NTP Server, the response will be similar to:

[
    {
        "name": "NTP Server 1",
        "hostName": "1.europe.pool.ntp.org"
    }
]

As we can see, we currently have one existing Global NTP server configured and if we logged into vRSLCM using the UI (and navigate to Lifecycle Operations > Settings > NTP Servers), we would now see:

Let us go ahead and add another NTP Server to give us some availability as correct time is SO important!

Adding a Global NTP Server

Overview

In this section we are going to use the vRSLCM API to add another Global NTP Server.

API Request

The following REST API request is required:

  • Request Type: POST
  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v2/settings/ntp-servers
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {insert credential hash}
  • Request Body Values:
    • hostName - the IP address/hostname of the NTP Server.
    • name - the user friendly name of the NTP Server in the UI.

API Example

An example cURL command for this REST API is:

curl --location --request POST 'https://{vrslcm.fqdn}/lcm/lcops/api/v2/settings/ntp-servers' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}' \
--data-raw '{
    "hostName": "2.europe.pool.ntp.org",
    "name": "NTP Server 2"
}'

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

API Response

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

{
    "name": "NTP Server 2",
    "hostName": "2.europe.pool.ntp.org"
}

If we logged into vRSLCM using the UI (and navigate to Lifecycle Operations > Settings > NTP Servers), we would now see the following NTP servers configured:

Delete a Global DNS Server

Overview

Over time, there maybe cause to replace NTP Servers (or maybe someone just configured the wrong ones to start with). In this section we will look at the API call required to delete an existing Global NTP Server.

Note:
The v2 API to delete NTP Servers is deprecated. Hence we will be using the new v3 API!

API Request

The following REST API request is required:

  • Request Type: DELETE

  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v3/settings/ntp-servers?ntpHostname={ntp.server}

    • ntpHostname - hostname/ip address of the configured NTP server (represented by the hostName value in the GET request).
  • Request Header(s):

    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {insert credential hash}
  • Request Parameters:

  • 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/v3/settings/ntp-servers?ntpHostname={ntp.server}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}' 

API Response

The expected response returned from a successful request (Status Code=200) will be the information on the NTP server that has been removed:

{
    "name": "NTP Server 2",
    "hostName": "2.europe.pool.ntp.org"
}

If we logged into vRSLCM using the UI (and navigate to Lifecycle Operations > Settings > NTP Servers), we would see a single NTP Server configured:

Wrapping It All Up!

In this short post we have explored the way we can manage Global NTP Servers in vRSLCM using the API.

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

Published on 1 December 2021 by Christopher Lewis. Words: 785. Reading Time: 4 mins.