Delete a VCF VI workload domain using vRealize Automation

In part four of our Automating VMware Cloud Foundation Series, we show you how leveraging vRealize Orchestrator (vRO) and VCF’s SDDC Manager APIs can benefit deleting VI Workload Domains using Automation.

 

In my previous post “Automating VMware Cloud Foundation: Creating a Workload Domain”, I highlighted some of the benefits of leveraging vRealize Orchestrator (vRO) and VCF’s SDDC Manager APIs to deploy a new VCF VI Workload Domain. Now we will see how using similar integrations can benefit deleting VI Workload Domains using Automation. 

 

Let’s first see what deletion of a domain from SDDC Manager looks like. 

As you see from the screenshot above, an admin has to login to SDDC Manager UI, select “Workload Domains” under “Inventory”, and in the right pane you choose the domain you would want to delete by clicking on those “Horizontal Dots” and selecting Delete Domain.

 

Well, this looks really simple and truly it is, but there are a few additional tasks an admin needs to perform post deletion such as:

  • Delete DNS records
  • Delete all end-point integrations done during “Create VI Workload Domain”, like –vRealize Operations (vROps) Adapter, vRealize Log Insight integration, vRealize Orchestrator (vRO) integration, vRealize Automation (vRA) Cloud Account
  • Login to SDDC Manager shell, run the SOS utility to clean up the host 
  • Decommission the hosts used in the deleted workload domain
  • Commission them back to repurpose them for subsequent “Create VI Workload Domain request”

My lab had 3 hosts (Which is the minimum for a VCF VI WLD), If you were to perform these tasks on multiple clusters, involving several hosts, the cleanup process mentioned above would be very tedious, specially SOS Host Cleanup, decommission and commission host. 

 

Now, as a cloud end user you will get this:

Enter a unique “Deployment Name” and select the WLD Domain you want to delete from the drop down and hit “SUBMIT”. You may have noticed that the user will not get to see the management domain. No one would ever delete a management domain unless you wanted to decommission a VCF environment or rebuild the entire VCF deployment.

 

Once you hit submit, automation will do the rest, including the manual steps listed above. No matter how many hosts and clusters you have. This catalog request would execute all of the following vRO workflows shown in the image below:

In summary, a catalog request performs the following tasks via automation:

  • GetCluster ID: Gets the cluster ID for the Workload Domain that will be deleted
  • GetHostofWLD: Gets the list of hosts before deletion
  • Get FQDN and IPs of WLD: Builds a list of IPs and FQDNs used in the Workload Domain which will be used in “VCF SOS Cleanup” and “Decommission the host” later
  • Delete associated endpoints: Deletes vRealize Operations Adapter, deletes vCenter from vRealize Orchestrator vCenter Plugins, Delete vRealize Automation Cloud – Cloud Account
  • Delete Domain: Deletes the Workload Domain from VMware Cloud Foundation
  • VCF SOS Cleanup: Connects to SDDC Manager Shell and performs host-cleanup using SOS utility on all hosts that are part of the domain that needs to be deleted
  • Decommission the hosts: Decommissions the hosts used in the domain 
  • Commission the hosts: Commissions the hosts back to VMware Cloud Foundation (VCF) inventory to repurpose the hosts for subsequent Workload Domain Creation 

 

Isn’t it really effective for IT to stay away from the keyboard and yet achieve all that it needs?

 

One of the challenges I faced while working on this use case is to automate “Host cleanup using SOS Utility”. SOS Utility is available from the SDDC Manager shell. As of today, there are no REST APIs natively available to invoke a shell command like SOS Utility against SDDC Manager shell.

 

The following are the approaches I tried to automate the host cleanup process as part of this use case

  • The 1st approach I took was to use the PowerVCF utility. This is a community developed utility that can be leveraged for VCF automation. 
    • For VCF 3.9.1 you need to use code in 1.2 branch of git-hub
    • Reset-VCFHost PowerShell cmdlet will perform a “sos host-cleanup”

For some reason, when this was used in vRO workflow, it would cause the workflow execution to run indefinitely as the script used would remain hung while waiting for a user to enter a “new line character” in order to finish executing the cmdlet and return the output.

  • The 2nd  and “THE” approach I used to overcome the PowerVCF challenge was to use “Guest Script Manager” a community developed vRealize Orchestrator Workflow package that can invoke shell commands against a shell host. In our case SDDC Manager is the shell host.

 

With this I end the “Automating VMware Cloud Foundation” series of blog posts and hope you now have a better idea on how VCF automation would benefit an IT Consumer / IT provider.

About the Authors

Rajesh Marella

Customer Success Architect at VMware

Rajesh Marella is Customer Success Architect at VMware. He has over 16 Years of experience in the IT industry in various roles. In his current role, his focus is on vRealize Suite of Products helping customers adopt the vRealize Products and maximizing the benefits out of it. He lives in Bengaluru with his wife and a wonderful son. In his free time, he likes cooking, playing music, and spending time with family.

Leave a Reply

Your email address will not be published. Required fields are marked *