VMware Cloud Community
darrenoid
Enthusiast
Enthusiast

How can I use vra workflow stubs to spin up and tear down a VM right away?

Hello,

I am currently trying to get a vra blueprint using the basic vm workflow to provision a blank VM, use a third party tool which installs windows and then captures the windows image (wim file). Once that is done I no longer need the VM in either VCenter or vRA. How do I force the lifecycle to go straight from MachineProvisioned stub to the UnprovisionMachine stub, without being dependent on the lease time of the VM?

I am having trouble figuring out how to use the workflow stubs to manage the entire lifecycle of this process. I use the MachineProvisioned stub to coordinate with the third party imaging solution (MDT) and mount the boot ISO for MDT. The problem is I cannot add a workflow item that waits for this process to finish inside the MachineProvisioned stub, because the VM has not been powered on yet. So for now, I just let the MachineProvisioned state finish, the VM boots up from ISO, and MDT does its thing. At this point the VM will stay in vRA for at least a days lease time before being expired and running through the UnprovisionMachine stub. I also have no way to know for sure if the MDT process was successful before the workflow finishes.

Is it possible to perform the following actions inside the MachineProvisioned workflow stub perhaps?

  • coordinate with the third party imaging solution (MDT) and mount the boot ISO for MDT
  • Power on the VM in vcenter
  • Run powershell script to check the status of MDT deployment
  • Once finished run certain cleanup tasks (Import the image into MDT system for example)
  • Delete the VM from both vcenter and vra

I wonder what would happen if the VM tries to start after the above MachineProvisioned state finishes? The VM has already been deleted. I imagine the vra request would fail.

What I think makes more sense is the following flow:

  1. Catalog Item requested from vRA
  2. MachinePovisioned runs WFStub custom vro workflow
    • Coordinate with MDT and mount the boot ISO
    • Powers on VM
    • Waits for MDT to finish
    • VM is powered off
  3. VM does not power on, but instead goes straight to UnprovisionMachine WFStub and runs custom vro workflow
    • Contacts MDT to finalize the image import process
  4. VM is then destroyed from vRA and VCenter after the UnprovisionMachine state finishes

I am not sure if that is possible. I would appreciate any advice on how to do this or any other ideas.

Regards,

Darrenoid

0 Kudos
0 Replies