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



vRealize Suite Lifecycle Manager vRSLCM API

Published on 31 January 2022 by Christopher Lewis. Words: 1661. Reading Time: 8 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 in vRSLCM. In this instance we’re going to upgrade the vRSLCM Appliance.

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

  • Snapshot the vRSLCM Appliance.
  • Checking for Available vRSLCM Product Updates (OPTIONAL).
  • Upgrading vRSLCM to the latest version.
  • Checking on the vRSLCM upgrade progress.

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

Snapshot the vRSLCM Appliance

Overview

It is always recommended to snapshot the vRSLCM appliance prior to completing an upgrade. In this section we are going to be looking at the API call we need to make to create that snapshot through vRSLCM.

API Request

The following REST API request is required:

  • Request Type: POST
  • Request URL: https://{vrslcm.fqdn}/lcm/lcops/api/v2/system-snapshot
  • 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/system-snapshot' \
--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:
Remember, the –insecure flag is also required in the cURL command if you are using self-signed SSL certificates.

API Response

When submitting a successful request (Status Code = 200 OK), you should receive a response that shows the request id:

{
    "requestId": "be6f102b-7132-457e-a435-bffacaa87644"
}

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

Once the state of the vRSLCM request is COMPLETED we can then continue on to complete the upgrade.

Checking for Available Product Updates (OPTIONAL)

Overview

In this section we are going to be using an API request to check to see if there is an upgrade available for vRSLCM. Typically we get a notification when we log in via the UI but we do not get that when using the API.

API Request

The following REST API request is required:

  • Request Type: POST
  • Request URL: `https://{vrslcm.fqdn}/lcm/lcops/api/v2/system-upgrade
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {insert credential hash}
  • Request Body Values:
    • actionType - This is the action we want to perform, including “check” or “upgrade”.
    • repositoryType - The three supported values are:
      • Default is the default online repository but this requires internet access from the vRSLCM appliance.
      • url is when you want to use a local or non-default URL (this also requires the additional information for repositoryURL, repositoryUserName and repositoryPassword).
      • CDROM is if you have downloaded the upgrade ISO file and already attached it via a virtual cd-rom in vcenter.
    • repositoryURL - The URL of the private repository that hosts the vRSLCM update ISO.
    • repositoryUserName - The username of the user required to access the private repository.
    • repositoryPassword - The password of the user required to access the private repository.

API Example

An example cURL command for this REST API is using the default repository is:

curl --location --request POST 'https://{vrslcm.fqdn}/lcm/lcops/api/v2/system-upgrade' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}' \
--data-raw ' {
     "actionType": "check",
     "repositoryPassword": "",
     "repositoryType": "Default",
     "repositoryURL": "",
     "repositoryUserName": ""
 }'

Note:
Remember, the –insecure flag is also required in the cURL command if you are using self-signed SSL certificates.

Note:_
When using the default repository option, there is no way to select which version to upgrade to. It always upgrades to the latest version.

API Response

When submitting that request, whilst a vRSLCM request is generated, you are not provided with the request to track. You just get an information message, as seen below:

{
    "upgradeResponse": "Checking for available updates, this process can take a few minutes...\n.\nAvailable Updates - \n   8.6.2.0 Build 19221620"
}

Upgrading vRSLCM to the latest version

Overview

In this section we are going to be using an API request to upgrade vRSLCM to the latest available version using the default repository.

API Request

The following REST API request is required:

  • Request Type: POST
  • Request URL: `https://{vrslcm.fqdn}/lcm/lcops/api/v2/system-upgrade
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {insert credential hash}
  • Request Body Values:
    • actionType - This is the action we want to perform, including “check” or “upgrade”.
    • repositoryType - The three supported values are:
      • Default is the default online repository but this requires internet access from the vRSLCM appliance.
      • url is when you want to use a local or non-default URL (this also requires the additional information for repositoryURL, repositoryUserName and repositoryPassword).
      • CDROM is if you have downloaded the upgrade ISO file and already attached it via a virtual cd-rom in vcenter.
    • repositoryURL - The URL of the private repository that hosts the vRSLCM update ISO.
    • repositoryUserName - The username of the user required to access the private repository.
    • repositoryPassword - The password of the user required to access the private repository.

API Example

An example cURL command for this REST API is:

curl --location --request POST 'https://{vrslcm.fqdn}/lcm/lcops/api/v2/system-upgrade' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}' \
--data-raw ' {
     "actionType": "upgrade",
     "repositoryPassword": "",
     "repositoryType": "Default",
     "repositoryURL": "",
     "repositoryUserName": ""
 }'

Note:
Remember, the –insecure flag is also required in the cURL command if you are using self-signed SSL certificates.

API Response

When submitting the request, we should get a response back syaing the upgrade is in progress.

Checking for Available Product Updates (OPTIONAL)

Overview

In this section we are going to be using an API request to check to see if there is an upgrade available for vRSLCM. Typically we get a notification when we log in via the UI but we do not get that when using the API.

POST API Request

The following REST API request is required:

  • Request Type: POST
  • Request URL: `https://{vrslcm.fqdn}/lcm/lcops/api/v2/system-upgrade
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {insert credential hash}
  • Request Body Values:
    • actionType - This is the action we want to perform, including “check” or “upgrade”.
    • repositoryType - The three supported values are:
      • Default is the default online repository but this requires internet access from the vRSLCM appliance.
      • url is when you want to use a local or non-default URL (this also requires the additional information for repositoryURL, repositoryUserName and repositoryPassword).
      • CDROM is if you have downloaded the upgrade ISO file and already attached it via a virtual cd-rom in vcenter.
    • repositoryURL - The URL of the private repository that hosts the vRSLCM update ISO.
    • repositoryUserName - The username of the user required to access the private repository.
    • repositoryPassword - The password of the user required to access the private repository.

API Example

An example cURL command for this REST API is using the default repository is:

curl --location --request POST 'https://{vrslcm.fqdn}/lcm/lcops/api/v2/system-upgrade' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}' \
--data-raw ' {
     "actionType": "check",
     "repositoryPassword": "",
     "repositoryType": "Default",
     "repositoryURL": "",
     "repositoryUserName": ""
 }'

Note:
Remember, the –insecure flag is also required in the cURL command if you are using self-signed SSL certificates.

Note:_
When using the default repository option, there is no way to select which version to upgrade to. It always upgrades to the latest version.

API Response

When submitting that request, whilst a vRSLCM request is generated, you are not provided with the request to track. You just get an information message, as seen below:

Checking the progress of the vRSLCM upgrade

Overview

In this section we are going to be using an API request to check on the progress of the vRSLCM upgrade.

POST API Request

The following REST API request is required:

  • Request Type: GET
  • Request URL: `https://{vrslcm.fqdn}/lcm/lcops/api/v2/system-upgrade
  • Request Header(s):
    • Accept: application/json
    • Content-Type: application/json
    • Authorization: Basic {insert 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/system-upgrade' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {admin@local credential hash}' 

Note:
Remember, the –insecure flag is also required in the cURL command if you are using self-signed SSL certificates.

API Response

When submitting the request, we should now get a response back similar to below (depending on the times obviously!)

{
    "status": "SUCCESS",
    "progressDetails": null,
    "rebootRequired": false
}

If we logged into vRSLCM using the UI (and navigate to Lifecycle Operations > Settings > System Upgrades), we would now see that vRSLCM has been upgraded:

Note:
You may need to clear your browser cache if, in the UI, when you click Lifecycle Operations an error is reported).

Wrapping It All Up!

In this post we used the vRSLCM to upgrade the appliance to the latest version. Following recommended best practice, we also used the vRSLCM API to snapshot the appliance before performing any of the upgrades.

The slight fly in the oinment is that there is no way (using the vRSLCM API) to remove that vCenter snapshot. So we’ll either need to query the vCenter API or just log into vCenter to remove the snapshot!

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

Published on 31 January 2022 by Christopher Lewis. Words: 1661. Reading Time: 8 mins.