vRA Developer: Part 5 – Working with vCAC Virtual Machine Linked Entities


In my previous post vRA Developer: Part 4 – Working with vCAC Virtual Machine Entities, I demonstrated how you could find vCAC virtual machine entities and retrieve and update their properties. In this post I am going to focus on linked entities.

All code that I have provided or talked about in this post can be downloaded as a vRO package for your consumption here.

There are additional properties that can be retrieved which are part of other entities that the virtual machine has a relationship with. Here are some examples of information that can be retrieved through linked entities (the code for all of these examples is included in the package link provided at the beginning of this post).

  • Host/Cluster Name
  • Reservation Name
  • Owner Username
  • IPv4 Addresses
  • Snapshots
  • Networks

The virtual machine entity object has a method ‘.getLink(vcacHost, “linkKey_string”)‘ that can be used to get the linked entity objects. The ‘.getProperty(“key_string”)‘ can then be used on these entities to get a specific property value, such as the reservation name.

Get the Host or Cluster Name

The following code can be used to get the host or cluster name that the virtual machine (this is referred to as the compute resource within the vRA portal) is hosted on.

Log output:

Get the Reservation Name

The following code is used to get the reservation name that the virtual machine is provisioned on.

The above code also uses the below helper ‘getReservationEntityForVirtualMachineEntity’.

Log output:

Get the Owner Username

The following code can be used to get the username (UPN) of the user who owns the virtual machine.

Log output:

Get a List of IPv4 Addresses assigned to the VM

The following code can be used to get a list of IPv4 addresses that are assigned to the virtual machine.

Get a List of Snapshots Created on the VM

The following code can be used to get the details and list of snapshot names that have been created on the virtual machine.

Log output:

Get a List of Networks the VM is Attached to

The following code can be used to get a list of networks that are attached to the virtual machines’ network adaptors.

Log output:

I hope this has been useful. If you discover any bugs with any of my code, require some help or simply need an ad-hoc solution, then please drop me a message via the Drift app.

Series Navigation<< vRA Developer: Part 4 – Working with vCAC Virtual Machine EntitiesvRA Developer: Part 6 – Working with vCAC Virtual Machine Custom Properties >>

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
trackback

[…] vRealize Automation: Part 5 – Working with vCAC Virtual Machine Linked Entities […]