VMware Cloud Community
JimmySK
Contributor
Contributor
Jump to solution

Properly remove resources when removing the VM

Hi,

I have created a service blueprint to power off the VM and delete it from the vCenter.  The workflow works fine, but it does not seem to released the resources from vRA.

So it said, the VM has actually deleted from vSphere, but from the vRA admin portal, Managed machines, I found the VM that I have decommissioned using the mentioned service blue print now shows as "Missing"


My question is how do I decommission the VM and also removed its reserved resources properly?

Thanks,

Jimmy

Tags (1)
1 Solution

Accepted Solutions
spride
Enthusiast
Enthusiast
Jump to solution

Hi Jimmy - I ran into the same issue recently, and did the following:

1. Get the VC:VirtualMachine object.  This can be done several ways, but for my particular case I use the com.vmware.library.vc.vm.getAllVMsMatchingRegexp module.

2. Get the VCAC:VirtualMachine object from the VC:VirtualMachine object.  Again, there are different ways of doing this.  I created a getVCACVm action, which takes the VC:VirtualMachine object from #1:

var vCACVm = null;

var uuid = vcVM.config.instanceUuid;

var vCACVms = Server.findAllForType("vCAC:VirtualMachine", "VMUniqueID eq '" + uuid + "'");

if( vCACVms.length == 1 )

    vCACVm = vCACVms[0];

return vCACVm;

3. Delete the VCAC:VirtualMachine entity.  You can use the com.vmware.library.vcac.deleteEntity module to handle this.

KEEP IN MIND ... This only removes the entity from vCAC/vRA.  You still need to power off the VM (if applicable, see: Library/vCenter/Virtual Machine management/Power Management/Power off virtual machine and wait) and delete it from vCenter (see: Library/vCenter/Virtual Machine management/Basic/Delete virtual machine).  I do this before executing the above three steps.  There may be better, easier, faster, etc., ways of doing this.  Hope this helps.

View solution in original post

5 Replies
stvkpln
Virtuoso
Virtuoso
Jump to solution

Is there a reason you can't use the destroy day 2 operation built into vRA?

-Steve
0 Kudos
JimmySK
Contributor
Contributor
Jump to solution

The reason why we are using the blueprint to take care of the VM decommission is

1.  Approval process - (tied to change management as well)

2.  Scheduled run - (that happens after hour)

0 Kudos
stvkpln
Virtuoso
Virtuoso
Jump to solution

You can't tie an approval workflow to the day 2 operation? I thought that was an out of the box feature (we aren't using them -- yet). Since you want it to be scheduled, though, your only option would be to have the vRO workflow call the day 2 operation on the VM and enact the destroy through there... Or manually go back and destroy the VM. Not much else you can do, if you want to clean up properly.

-Steve
spride
Enthusiast
Enthusiast
Jump to solution

Hi Jimmy - I ran into the same issue recently, and did the following:

1. Get the VC:VirtualMachine object.  This can be done several ways, but for my particular case I use the com.vmware.library.vc.vm.getAllVMsMatchingRegexp module.

2. Get the VCAC:VirtualMachine object from the VC:VirtualMachine object.  Again, there are different ways of doing this.  I created a getVCACVm action, which takes the VC:VirtualMachine object from #1:

var vCACVm = null;

var uuid = vcVM.config.instanceUuid;

var vCACVms = Server.findAllForType("vCAC:VirtualMachine", "VMUniqueID eq '" + uuid + "'");

if( vCACVms.length == 1 )

    vCACVm = vCACVms[0];

return vCACVm;

3. Delete the VCAC:VirtualMachine entity.  You can use the com.vmware.library.vcac.deleteEntity module to handle this.

KEEP IN MIND ... This only removes the entity from vCAC/vRA.  You still need to power off the VM (if applicable, see: Library/vCenter/Virtual Machine management/Power Management/Power off virtual machine and wait) and delete it from vCenter (see: Library/vCenter/Virtual Machine management/Basic/Delete virtual machine).  I do this before executing the above three steps.  There may be better, easier, faster, etc., ways of doing this.  Hope this helps.

JimmySK
Contributor
Contributor
Jump to solution

Hi spride,

I took your advice and adjusted my workflow to include the mentioned modules - com.vmware.library.vcac.deleteEntity module.

It removed the entity from the vRA.  I have verified this by going to Infrastructure -> Managed Machines.  However, I still see a dormant entry under Items -> machines and I can't do any action on it.  The detail tab shows "MachineID parameter missing".

Have I missed steps?

Thanks,

Jimmy

0 Kudos