Let’s talk today about vRealize Automation Objects and Properties, those can be quite hard to manipulate from the orchestrator but I wanna show you the different method I use. Those objects I am talking about are listed here:
When developing a new workflow you might need information regarding many objects of the picture above like its name, id, properties and so on, so let’s go deep dive in VRO and see how we achieve that.
Retreive vRealize Automation Cafe Objects
To get object and object’s properties part of the « CAFE », the orchestrator’s VRA plugin has an interesting Singleton object called VCACCAFEEntitiesManager. This object has multiple methods that can help you to get the object/property you desired:
As you can see, many objects can be retrieve using those methods, they have different features:
- « Find » functions: Returns a list of the selected object type based on a criteria. It takes as parameter a VCACCAFE Host and the query which maybe the name of the object you are looking for.
- « Get Objects » functions: Return all objects of the selected type. It takes as parameter only the VCACCAFE Host.
- « Get Object » functions: Return a single object of selected object type matching the object’s ID. It takes as parameter a VCACCAFE Host and the ID of the object you are looking for.
Here is an example:
After you find the right object, you can get its properties or methods from the API explorer, let’s take a look to the « BusinessGroup » object:
Retreive vRealize Automation IaaS Objects
Regarding IaaS objects, the orchestrator’s IaaS plugin does not fully expose the IaaS objects. For example, VRA « Reservations » does not appear in the orchestrator eventhough it may be useful for an admin to orchestrate/read this kind of object. Instead, the plugin allow us to manipulate « Entities », which are IaaS objects associated to a specific model. In order to be efficient when playing with entity objects, you have to install a little soft called LinqPad: https://www.linqpad.net/
Once installed, you can connect LinqPad with your IaaS server:
- URL: https://iaas.domain.com/Repository/Data/ManagementModelEntities.svc
- Type: ODATA3
- Credential: IaaS Service Account
After clicking ok you should see something like this:
In the left, you can see the complete list of objects (Entities) managed by the IaaS server. Right click on « VirtualMachines » and click on « Take 100 » to get the first hundred virtual machines:
You will see the list of virtual machines in your infrastructure, each row is an entity of type « virtualMachine » and column are properties (a property can be a string or another entity). For example, an entity of type virtual machine as a property called « StaticIPv4Addresses » which return an array of entity of type « StaticIPv4Addresses » composed of entities (row) and properties (column). You can use the method « Expand » to explore those subentities and retrieve interesting properties like IP addresses of a virtual machine as shown in the following picture:
In VRO, the vRealize Automation plugin allow you to play with Entities in the same way than LinqPad. This is done using the VCACEntitiesManager and the method « readModelEntity »:
The method « readModelEntity » takes as parameters the VCACHost ID, the model name which will always be the same, the « entitySetName » VirtualMachines (name of the object type in LinqPad), « entityId » is a properties containing the property name and value on which to filter (in the example below it is at line 1 and 2), and the header is set to null. Here is an example:
With those 3 samples of code you can easily retreive objects and properties as you would do in linqPad, using getProperties() to retreive properties/entities and getLink() which is equivalent to the « Expand » method in LinqPad that allows you to find subproperties.
A little bit of practice is mandatory to really understand the mechanic of the EntityFinder and the EntitiesManager but if you are doing a lot of customization, trust me you will use them a lot!
Have fun programming and please share if you liked this article!