VMware Cloud Community
Basavaraj_S
Contributor
Contributor

How to delete VM disk entities from virtual machine through api's ?

Can someone please let me know how to delete disk entities from virtual machine through api's ?

Tried with below api but still able to see disk entity in vRA

System.getModule("com.vmware.library.vcac").deleteEntity(linkEntity[i]);

0 Kudos
4 Replies
stevedrummond
Hot Shot
Hot Shot

You submit a ​Reconfigure​ and remove the disks you want deleted from the payload.

0 Kudos
Basavaraj_S
Contributor
Contributor

Thanks Steve for the response.

Reconfigure is not allowing me to delete disk entities from VM. Is there any vmware api which we can use to delete disk entities from vRA iaas VM entity? Since data collection is a heavy operation in huge scale environment so we wanted to manually delete disk entries from vRA VM object through some api's before data collection sync's disk entities.

We are able to create/update disk entities using vCACEntityManager.createModelEntity and vCACEntityManager.updateModelEntity api's but not sure which api to use to delete disk entities.

0 Kudos
stevedrummond
Hot Shot
Hot Shot

Reconfigure is not allowing me to delete disk entities from VM

Can you be more specific? Are you getting an error or you can't do something for some reason?

Are you trying to delete actual disks from a machine/cloud, or are you just wanting to remove an entity reference that gets updated with data collections anyway (aka, what's the point)?

0 Kudos
Basavaraj_S
Contributor
Contributor

Basically we provide VM backup and restore solution. When we restore Virtual machine along with vmx config files, few disk entities might be deleted and as a result there is inconsistency in showing the number of disk entities associated with VM in vRA till the time data collection is done. Say for example before restore if VM is having 3 disk entities and after restore if its having only 2 disk entities then in vRA it will still continue to show 3 disk entities instead of 2 until data collection is invoked.

Since data collection is a heavy operation in large scale environments, so we are trying to update the vCAC Entity manually.

We tried to delete disk entities and to disassociate links from VM entity but no luck, in vRA it still shows the disk entity and we are not getting any exceptions. Below is the code

var linkEntity = entity.getLink(vcacHost, "VMDiskHardware");

for (var i = 0; i < linkEntity.length; i++) {

vCACEntityManager.deleteLink(vcacHost.id, "ManagementModelEntities.svc",  "VirtualMachines",  entity,  "VMDiskHardware", linkEntity[i].keyString, null);

System.getModule("com.vmware.library.vcac").deleteEntity(linkEntity[i]);

}

var linkEntity = entity.getLink(vcacHost, "VMDiskHardware");

for (var i = 0; i < linkEntity.length; i++) {

vCACEntityManager.deleteLink(vcacHost.id, "ManagementModelEntities.svc",  "VirtualMachines",  entity,  "VMDiskHardware", linkEntity[i].keyString, null);

System.getModule("com.vmware.library.vcac").deleteEntity(linkEntity[i]);

}

0 Kudos