Recently, I was looking for a scripted method for cold snapshotting of vRA in enterprise deployment. First, I wanted to confirm the shutdown order. VMware’s product documentation is quite limited regarding this topic, but it describes the right shutdown order. Looking further I found a better explanation here, where the documentation talks about vRA backup order. Of course, I wanted to check the proper starting procedure as well. I found it quickly here.
Well equipped with all information needed, I decided to write a script. Usually I use PowerCLI for tasks related to VMware software. I was sure that someone had the same idea before me so in order not to reinvent the wheel I started to check what Google will find.
I found a few elegant approaches, but one was the most interesting and inspiring. Distributed vRealize Automation 7.x Orchestrated Shutdown, Snapshot and Startup using PowerCLI Razz made it the way that I found I could use in my environment. I adjusted the script to my needs and it worked quite well. Of course, there is a lot to polish, but it works for me.
I decided to share Razz’s script adjusted by me. Maybe it will help someone with their administration tasks related to vRA.
Starting from vSphere 7U1 we have got a new tool to generate and download a support log bundle from vCenter Server. It is REST API call used to achieve these tasks. It broadens an already wide range of methods of gathering vm-support log bundle. It has several interesting features.
First, it works even if the vCSA service is offline, whereas a vCSA management interface should be up and running.
Second, once started it generates a support bundle and stores it on vCSA disk. A downloaded bundle is deleted after 30 minutes. As you know, even in a small vSphere environment downloading a log bundle could be time consuming, therefor, if a generated bundle download task is in progress, the bundle deletion will be postponed for 30 minutes.
To be able to use this new method a user authenticated in SSO must be a member of a new SSO group – SystemConfiguration.SupportUsers. Users belonging to this group are entitled only to call support bundle REST API. They don’t have any other privileges to the environment. SSO Administrator role is a member of this group by default.
Now, let’s play with the API calls.
To enumerate every component which is gathered by support bundle REST API, you can use the following GET command:
To generate a bundle you can use this POST statement:
This statement takes a few parameters:
Description – A text description of a the started task
Components (optional) – You can provide a list of previously listed components. If you leave this parameter empty, then logs from all components will be gathered.
Partition (optional) – You can define a place where generated log bundle will be stored, for example /storage/core. If you leave it blank, a default storage location (/storage/log) will be used.
This statement will return a task ID. You can use this task ID to get the information about a status of a task.
To return the status of a task you have started, issue this command providing a task ID at the end:
If you need more detailed information, use this command to return the complete information about the generation task:
You will get all the information (description, status, generation time, expiration time, bundle size) including URL, which you can use to download the generated support bundle.
If the support bundle REST API fails, you will be informed with an error message providing information about a failure reason.
I recommend using Postman to issue these commands because you can prepare an Environment, a Collection, named for example vCSA Support Bundle where you can store the commands above mentioned. You can use curl as well, if it’s your favourite multi-tool.