Sitemap
Press enter or click to view image in full size

Validate Virtual Machine From VMware vRealize Orchestrator Action

3 min readSep 12, 2022

--

Hello everyone, today I’m going to demonstrate how to verify a virtual computer.
I’d want to start by explaining validation. And the reason we check our code.

Validation is the process of examining or confirming data before allowing it into a computer system. This procedure aids in preventing data corruption or compromise during transmission.

Data validation guarantees that the information received is correct, complete, and correct (valid).

Incorrect or incomplete (invalid) data can lead to faulty analysis or processing.

If some data is invalid, all analysis performed on the entire data set may be invalid.

So I am going to give you an example.

Get Yagmur Ozden’s stories in your inbox

Join Medium for free to get updates from this writer.

In this code, we check lots of things.

First thing first, in line 6, we get the virtual machine by its hostname, and then we check if it matches. if it's not, we throw an error.

In line 15, we check that if the virtual machine length is equal to 0. If it is it means that we couldn't find the VM, so we throw an error (“VM with name “ + hostname +“ not found”).

In line 19, we check if the virtual machine is powered on. If it is not, we throw an error (“VM “ + hostname + “ is not in Powered On state”)

In line 22, we check if the guest information exists. If it is not, we throw an error (“No guest information accessible for VM “ + hostname)

In line 25, we check the VM network adapters. we want the VMs with two cards, so we sat if it's different then 2 throw an error. (“Unsupported amount of network adapter for VM “ + hostname)

In lines 29 and 33, we check if the hostname and virtual machine hostname and virtual machine name match. if it is not, we throw an error. (“No exact Match found for Hostname “ + hostname)

In line 37, we check if the virtual machine has VMware tools. If it is not, we throw an error (“VMware tools not in a healthy state on VM “ + hostname).

In line 41, we check if the VMware tool is running inside of the VM. if it’s not, we throw an error. (“VMware tools are not in a running state on VM “ + hostname)

In line 45, we check if the VM guest os is Red Hat Enterprise Linux 7 (64-bit) (Because we want RHEL7. If you want it different, just change the string). If not, we throw an error (“Unsupported OS found on VM “ + hostname).

In line 49, we check if the VM has an IP address. If it’s not, we throw an error (“No primary IP address found for VM “ + hostname).

And lastly, in lines 52 and 57, we check if we can make an ssh connection to a VM from vRO. If we can’t, we throw an error (“No SSH connection possible to VM “ + hostname)}

( executeSSHCommand is an action it simply allows us to run commands inside the virtual machine )

There are some specific codes that I write for my project. If you don’t want to have an IP address or powered on VM, you can change it.

Thank you for being so interested!!

Additionally, my GitHub profile has a ton of scripts concerning vRO and vRA.

My Linkedin profile: https://www.linkedin.com/in/yağmur-özden-5094b0173/

My GitHub profile: https://gist.github.com/YagmurOzden

You can check my other blogs: https://medium.com/@yagmurozden

--

--