VMware Cloud Community
tmalaher
Contributor
Contributor

Frustration with VCO chargeback plugin API/docs

The documentation for the VCO Chargeback plugin seems a bit thin. The PDF does say this about the Javascript API:

The mapping of the vCenter Chargeback Manager 2.0 plug-in API classes corresponds to the vCenter Chargeback Manager SDK for Java 2.0 class mapping. For reference about classes and methods, see http://communities.vmware.com/community/vmtn/developer/forums/cbmsdkjava

Unfortunately, the mapping does not seem complete. I cannot for the life of me find a sequence of API calls that would allow me to recursively browse through the entity hierarchy.

I'm able to retrieve the top level "hierarchy" entries (getAllHierarchies Action), then retrieve the entity ID of the "root" below each of those (getRootEntityIdByHierarchyId).

I'm also able to retrieve any item by name underneath a hierarchy (getEntityIdByHierarchyId) but that begs the question of how I would know the name of an entity. (I tried some wildcards, but nothing seemed to work)

Question: GIven an entity ID, how do I get the entity object so I can get its name?

Question: Given an entity, how do I get the children of that entity (either as a list of objects or ids).

The Java API has a "browse" method. But this doesn't seem to be exposed in the JavaScript API.

Also, there are errors/inconsistencies in the API documentation/browswer (examples available upon request).

And while I'm whingeing, the Java API documentation isn't much better. It's mostly just generated from the source code with very little additional commentary. The source code itself looks like it was generated with a code generator from the REST API (full of Interfaces, Implementations, and XxxxType objects). A more "business level" wrapper around the raw REST API wrapper classes would have been nice.

Another complaint:

There's some sample code that comes with the Java API download. One of the sample programs (HierarchyEntityTest) contains this line:

parentId = hierarchy.getHierarchyTypeObj().getEntities().getEntity().get(0).getId();

with no explanation.

And an attempt to do something similar in the VCO Javascript fails miserably because apparently the "entities" property is null.

Note that I've written some (Groovy) code to do this using the raw REST API myself and it works like a charm. I'm just trying to re-write it to use the VCO plugin, so it's easier to maintain.

Help! Thanks in advance.

0 Kudos
2 Replies
Savita
Contributor
Contributor

I am not sure by Entity ID u mean the ID assign to it by ChargeBack or vCenter. ID assign to to by vCenter is set as attribute "vCloudEntityId". You can check the valuse of this attribute to figure out the name of Entity.

0 Kudos
tmalaher
Contributor
Contributor

By "Entity ID" I mean the entity ID assigned by chargeback.

You're entirely correct that the vCloudEntityId attribute contains the VCD ID, however, that doesn't help either of my problems:

  1. Constructing/Retrieving an entity object or its name given its ID (chargeback Entity ID or VCD ID)
  2. Iterating through all child entities given an entity. (e.g. traverse the hierarchy below a top-level organization, find all the vApps belonging to an organization, find all the VMs within a vApp)
0 Kudos