Thursday, 4 April 2013

Orchestrator & VMware vSphere – Quiesce Snapshots

While there is an official VMware vSphere Integration Pack for Orchestrator available from Microsoft (here) I was working for a customer the other week where they had an extra need that the Create Snapshot activity didn’t seem to provide.

The customer as part of their SoP (Standard Operating Proceedure) have the requirement that all snapshots are quiesced for both memory and file operations during a snapshot activity.

While the vSphere IP activity allows you to set the option for capturing the memory state with the snapshot, there is no reference as to whether it quiesces the file system by default or not.

So the quickest way to achieve this, fall back to PowerShell and script it.

VMware have a PowerShell module available for vSphere known as PowerCLI.
Once I had downloaded and installed this on both the Runbook Designer workstations and the SCORCH server I started working on the script.

The script:
$VC = "<Insert vCenter Server>"

$VMName = "<Insert VM Name>"

$Snapshot = "<Insert VM Name>"

if(-not (Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue))



{
 
Add-PSSnapin VMware.VimAutomation.Core



}
 
Set-PowerCLIConfiguration -DefaultVIServerMode Single -InvalidCertificateAction Ignore -confirm:$false

Connect-VIServer -Server $VC -ErrorAction SilentlyContinue

Get-VM $VMName | New-Snapshot -Name $Snapshot -Memory:$true -Quiesce:$true -Description "Snapshot for protection while running automated process" -Confirm:$false



Basically this script will take the input of a virtual machine name and a name for the snapshot then perform a snapshot of the VM but with the options set to quiesce both the memory and file system.

No comments: