VMware Cloud Community
marcolenzo
Contributor
Contributor
Jump to solution

Mapping IDs between vCloud Director and vCenter Chargeback through APIs

I currently have a setup where vCenter Chargeback imports automatically hierarchies from vCloud Director through a Data Collector. I am finding difficulties in mapping a vCloud Director Entity ID into a vCenter Chargeback one.

I will give a pratical example:

In vCloud Director I have organization ORGNAME and vm VMNAME.

I want to generate a report in Chargeback for the VMNAME entity. How do I figure which entity ID I should pass in the report request if the only information I have comes from the vCloud Director?

Thank you beforehand,

Marco

Reply
0 Kudos
1 Solution

Accepted Solutions
amrainders
Enthusiast
Enthusiast
Jump to solution

Hi Marco,

To get entity Id of the VM to pass into report request, you have following option:-

  • Go step by step to VM, in this approach you need to call following APIs
    1. Get All Hierarchies, GET <Base_Url>/hierarchies --> from this API response, get the id of the hierarchy based on name of hierarchy (name of hierarchy will be same as name of organization in vCloud Director)
    2. Browse Hierarchy, GET <Base URL>/hierarchy/{hierarchyId}/browse --> from this API response, you will get the entity id of the root of the hierarchy
    3. Browse Entity, GET <Base URL>/hierarchy/{hierarchyId}/entity/{entityId}/browse --> from this API response, you will the get the entity ids for immediate children of the root entity of the hierarchy
    4. Go on calling Browse Entity API recursively till you reach your desired VM (or entity).

Please note that Browse entity API returns very few details about the entity (name and entity id). If you want to filter out your VM (or any other entity) based on name this might be sufficient for you.

But if you want to filter out your VM (or any other entity) on some other criteria, you may have to call "Get Entity, GET <Base URL>/hierarchy/{hierarchyId}/entity/{entityId}" API to get more details about the entity.

If you to filter out you VM(or any other entity) based on custom attribute you may want to use "Get Attributes of an Entity, GET <Base_Url>/hierarchy/{hierarchyId}/entity/{entityId}/attribute" API

  • If your hierarchy size is not very huge (you do not have too many entities in hierarchy), the you can follow following approach:-
    1. Get All Hierarchies, GET <Base_Url>/hierarchies --> from this API response, get the id of the hierarchy based on name of hierarchy (name of hierarchy will be same as name of organization in vCloud Director)
    2. Get Hierarchy, GET <Base URL>/hierarchy/{hierarchyId} --> this API response returns you all the entities in the hierarchy in one shot. Again very few details about the entity are returned (name and entity id), If you want to narrow down on your entity on some other criteria other than name, then you might have to use "Get Entity" or "Get Attributes of an Entity" as explained above.

Please note that in case of vCloud director hierarchies in vCenter Chargeback which are auto populated, there is a custom attributes named "vCloudEntityId" set on chargeback entities corresponding to vCloud Director entities. The value of "vCloudEntityId" custom attribute represents the type and vCloud entity id of the vCloud Director entity.

For example if an vApp named "helloVapp" has id 123456 in vCloud Director. Then in vCenter chargeback the value of custom attribute "vCloudEntityId" will be "VcloudVappEntity-123456" for this "helloVapp" vApp.

I hope this helps.

-Amrainder

View solution in original post

Reply
0 Kudos
2 Replies
amrainders
Enthusiast
Enthusiast
Jump to solution

Hi Marco,

To get entity Id of the VM to pass into report request, you have following option:-

  • Go step by step to VM, in this approach you need to call following APIs
    1. Get All Hierarchies, GET <Base_Url>/hierarchies --> from this API response, get the id of the hierarchy based on name of hierarchy (name of hierarchy will be same as name of organization in vCloud Director)
    2. Browse Hierarchy, GET <Base URL>/hierarchy/{hierarchyId}/browse --> from this API response, you will get the entity id of the root of the hierarchy
    3. Browse Entity, GET <Base URL>/hierarchy/{hierarchyId}/entity/{entityId}/browse --> from this API response, you will the get the entity ids for immediate children of the root entity of the hierarchy
    4. Go on calling Browse Entity API recursively till you reach your desired VM (or entity).

Please note that Browse entity API returns very few details about the entity (name and entity id). If you want to filter out your VM (or any other entity) based on name this might be sufficient for you.

But if you want to filter out your VM (or any other entity) on some other criteria, you may have to call "Get Entity, GET <Base URL>/hierarchy/{hierarchyId}/entity/{entityId}" API to get more details about the entity.

If you to filter out you VM(or any other entity) based on custom attribute you may want to use "Get Attributes of an Entity, GET <Base_Url>/hierarchy/{hierarchyId}/entity/{entityId}/attribute" API

  • If your hierarchy size is not very huge (you do not have too many entities in hierarchy), the you can follow following approach:-
    1. Get All Hierarchies, GET <Base_Url>/hierarchies --> from this API response, get the id of the hierarchy based on name of hierarchy (name of hierarchy will be same as name of organization in vCloud Director)
    2. Get Hierarchy, GET <Base URL>/hierarchy/{hierarchyId} --> this API response returns you all the entities in the hierarchy in one shot. Again very few details about the entity are returned (name and entity id), If you want to narrow down on your entity on some other criteria other than name, then you might have to use "Get Entity" or "Get Attributes of an Entity" as explained above.

Please note that in case of vCloud director hierarchies in vCenter Chargeback which are auto populated, there is a custom attributes named "vCloudEntityId" set on chargeback entities corresponding to vCloud Director entities. The value of "vCloudEntityId" custom attribute represents the type and vCloud entity id of the vCloud Director entity.

For example if an vApp named "helloVapp" has id 123456 in vCloud Director. Then in vCenter chargeback the value of custom attribute "vCloudEntityId" will be "VcloudVappEntity-123456" for this "helloVapp" vApp.

I hope this helps.

-Amrainder

Reply
0 Kudos
marcolenzo
Contributor
Contributor
Jump to solution

Thanks for the reply.

I was actually using the second approach you described. I will give a try to the first one, especially if it is more efficient in case of complex hierarchies.

Marco

Reply
0 Kudos