TAG: day2

vCAC Day 2: Un-Archive VM

So, for a recent project of mine, I was requested with a cool ‘vCAC feature’ being able to archive, and un-archive a vCAC managed VM. I’ll explain the meaning behind the request.
Basically, the customer wanted to have his old VMs moved to low tier storage (SATA spindles), as part of the archiving process, in order to save on expensive storage, and of course for them to be able to back up ‘archived’ VMs in a certain manner, etc.
In order to achieve this, I leveraged two of vCAC’s abilities:

  • Use / Create a “Machine Expired” workflow stub.
  • Created a Day 2 Operation with vCO , to do a couple of things:
    • Storage vMotion the VM to its original datastore
    • Submit a lease extend request so the user won’t have to do two operations.

An “Expired” state workflow already exists in the vCAC stub workflow library, so its pretty simple to utilize it in order to trigger a storage vMotion operation to move an expired VM to a predefined storage location.
All we have to do next is to keep the original storage location in a custom property, for later use, to be able to get the VM to its original location.

I’ve created a custom property called “VirtualMachine.OriginalDatastore” and assigned it to my vSphere blueprints. What we need to do next is to write a vCO workflow to update that property with the VMs datastore ID when the machine’s expired, and also trigger a simple Storage vMotion to a predefined location (or an archive storage location that is decided by what ever logic you choose.

To trigger the expired vCO workflow, we can either use the vCAC Designer , or the vCO vCAC plugin (Extensibility pack.
I’ll cover doing this with the extensibiltiy pack. Simply copy the workflow template from the vCAC Extensibility package (vCAC -> Infrastructure Administration – > Extensibility) and generate a new workflow off of it.

Archive Flow


(Action is ‘addUpdatePropertyFromVirtualMachineEntity’)
As for the scriptable code:
Basically i’m just preparing variables needed to update the property on the expired VM.
After that, i’m updating the blueprints property to store it’s original location, and the I svMotion it to Archive Storage.

Now for the cooler part – Un-Archiving / Un-Expiring the VM. Here, we will create an ASD day 2 operation, that will:

  • Read the previous datastore data for that VM, locate the datastore object.
  • Storage vMotion the VM to its original datastore
  • Request a lease time extension on behalf of the user, so the VM won’t be ‘Expired’ anymore.

And here is how the workflow for it looks like:



First off, i’m receiving a VC:VirtualMachine object from the day 2 operation (the VM the user is requesting the operation on) so in the first activity I find the vCAC IaaS object that is that vCenter VM, with an action.
After that, I need to check if the machine is actually expired, since this day 2 is meant for ‘Expired’ VMs. This , BTW, can be avoided with vCAC 6.1, since I can expose the ‘Un-Archive’ Day 2 operation only when the VM status equals ‘expired’.

If the VM is in an ‘Expired’ state, I continue to read the ‘Pre Archive Datastore’ cusom property I put earlier on in the VM. After that, I get the VC:Datastore object of that datastore. Now, you can notice that if I don’t find that datastore, I ask the administrator what to do. He can opt to cancel the entire thing, or to continue extending the lease on the current VM ‘Archive’ datastore and let it power-on there.
If I find the datastore, I svMotion the virtual machine to its correct datastore. vCAC will pick this change on the next data collection cycle.

Lastly, I generate an action request to change the lease, to the user’s chosen date. This workflow, also takes a date variable as an input. This will prompt the user for a date, with a nice calendar UI in the Day 2 operation form.

Since I won’t be able to really show you how this is actually done in this context, i’ll link you to a very helpful community article written by one of our vCAC vCO plugin lead developers, that will help you to understand how to submit a request in vCAC using vCO.

I hope you enjoyed this article, leave your comments below!

There are no more results.