Creating Custom Properties in vROPs

Now this is by far the most interesting thing I have done or have written, about vROPs. This is in continuation of the previous post, once you have created custom properties you can create alerts for those properties and also send notifications, the data will be saved as per the Data retention policy of vROPs as well.

 

There are a Lot of Metrics and Properties for every object in VROPs, but That list is never enough for the Customers. They would want something which is not available via vROPs and then compare how the RVtools. How RVTools works is that it connects directly to the vCenter API and then populate the data in CSV files, Always hoped if vROPs could do that aswell.

But, There is a way we can create custom properties in vROPs for any object.

The Need for this Search :- The customer had a requirement, that for every VM there should be a report of number of snapshot available and date of snapshot created. Out Of the Box this metric or property is not available, And I we wanted to do something interesting. That is where the search for the option started.

Solution :- Using PowerCLI 6.3 we can connect to vROPs, But It gives a very limited set of commands.

Commands

But don’t worry, it is possible to access the entire vROps REST API!  PowerCLI gives us the ability to expand the capability of the module to perform many more tasks that aren’t available via the included cmdlets.

The API is available via the base URI of https://{vrops-IP}/suite-api and if you browse to this link the documentation is available.  For the most part, the API is pretty well documented with examples

for usage including payloads for XML and JSON.  Below is a screenshot of the XML request body example for the performAction method.

XML

 

Method to Add Property :-

  1. Create a VMware.VimAutomation.VRops.Views.PropertyContents,

 

Contents

  1. PropertyContents has a Property PropertyContent so we will have to create a the Object of type

VMware.VimAutomation.VROps.Views.PropertyContent

Content

 

  1. Once the Objects are created next step is to fill the values of the for the stats

 

obj2

  1. Once the Property.Content stats and values are filled we will add the object to Property.Contents

obj3

 

  1. Next step is to create object of VM Or ESXi host or any other virtual object we want. Here I am adding the property to a Virtual Machine

obj4

 

Lets check the List of Properties Available on the Object currently

obj5

 

  1. Now adding the New Property to the VM using AddProperty Command

addProps

 

You can get the list of all the functions from the API Page of vROPs

functionList

Once you have Added the New Property we can now see the new property in the VM object

obj6

The same can also be seen from the GUI

obj7

1 Comment

  1. Thank you great Article but on last step when running $vmTChange.ExtensionData.AddProperties($cprops)
    getting the following error. Can you help?
    Exception calling “AddProperties” with “1” argument(s): “Invalid request… #2 violations found.
    [propertyContents[0].matchingMembers] : The number of elements in timestamps and in either data or value must match.
    [propertyContents[0].validTimestamp] : timestamps is required and must contain at least one element.”
    At line:1 char:1
    + $vmTChange.ExtensionData.AddProperties($cprops)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ViewException

    Like

Leave a comment