One of my favorite updates in vSphere 6.5 is the support for array-based replication with Virtual Volumes (vVols). Now with VASA 3.0 storage vendors have the ability to configure array-based replication into their VASA providers allowing users to preconfigure VM Storage Policies that include replicating VMs for Disaster Recovery. Support for Array-based replication was by far biggest request we have seen from customers interested in using vVols See What's new in Virtual Volumes 2.0 for a closer look at how this works.

So what happens when I want to actually failover to these replicated VMs? Well, for vSphere 6.5 there are two choices. You can leverage the public API or you can use PowerCLI 6.5. That's right, new in PowerCLI 6.5 is the ability to manage vSphere policy-based storage. For detailed information and examples for managing vSphere Policy-Based Storage with PowerCLI check the VMware vSphere 6.5 Document Center.

Sample Scripts

A few examples of what you can now automate with PowerCLI are listed below:

Planned Failover Example

Below is an example of the sample script "invoking a planned failover on a replication group" and then "initiating reverse replication". In this example I am using Nimble Storage but the PowerCLI cmdlets will work on any VASA 3.0 certified VASA Provider. Be sure to check the VMware HCL for compatibility.

Prerequisites:

VASA 3.0 certified VASA Provider

Source and Destination vCenter servers for $siteA and $siteB

vSphere admin credentials

A VM in a vVols datastore configured with a VM storage policy containing replication

Disclaimer: This is only an example. It works great in my environment. That doesn't mean it will work in yours. VMware supports PowerCLI but custom scripts like this are not supported.

param([parameter(Mandatory = $true)] [string] $virtualmachine) ipmo VMware.VimAutomation.Core ipmo VMware.VimAutomation.Common ipmo VMware.VimAutomation.Storage $siteA = "yoursourceserver.com" $siteB = "yourdestserver.com" ############################################################ # Write Header ############################################################ Write-Host -ForegroundColor Yellow "`n==========================================================" Write-Host "Starting Failover for VM: $virtualmachine" Write-Host -ForegroundColor Yellow "==========================================================`n" ############################################################ # Connect VI Servers ############################################################ Write-Host "Connecting Site A... `n" Connect-VIServer -User 'administrator@vsphere.local' -Password 'Yourpw' -Server $siteA -WarningAction SilentlyContinue | Out-Null Write-Host "Connecting Site B... `n" Connect-VIServer -User 'administrator@vsphere.local' -Password 'Yourpw' -Server $siteB -WarningAction SilentlyContinue | Out-Null $vmhostA = get-vm -name $virtualmachine -server $sitea | Get-VMHost $vmhostB = get-vmhost -Server $siteB | select -First 1 ############################################################ # Prepare Source VVol Map - Used in Failover CMDLET ############################################################ # To-Do: Update this to work for VMs with multiple virtual disks $vm = get-vm $virtualmachine Start-Sleep -Seconds 10 $ds = $vm | get-datastore $hd = $vm | get-harddisk $dsUrl = $ds.ExtensionData.Info.Url $dsUrl = $dsUrl.Remove($dsUrl.Length - 1) $lastIndex = $dsUrl.LastIndexOf('/') $containerId = $dsUrl.Substring($lastIndex + 1) $vmVvolId = $vm.ExtensionData.Config.VmStorageObjectId $hdVvolId = $hd.ExtensionData.Backing.BackingObjectId $sourceVvolMap = @{ $vmVvolId = $containerId; $hdVvolId = $containerId } ############################################################ # Shut Down VM ############################################################ if ($vm.PowerState -eq "PoweredOn") { Write-Host "Shutting down VM: $vm ... `n" stop-vmguest -VM $vm -confirm:$false -ErrorAction silentlycontinue stop-vm $vm -Confirm:$false } ############################################################ # Find Replication Groups ############################################################ Write-Host "Getting Replication Group Information... `n" $rg = get-spbmreplicationgroup -server $siteA -VM $vm $rgPair = Get-SpbmReplicationPair -Source $rg Write-Host "Source Group is $rgpair.Source.Name `n" Write-Host "Destination Group is $rgpair.Target.Name `n" ############################################################ # Prepare for Failover ############################################################ Write-Host "Preparing for Failover... `n" $preparetask = start-spbmreplicationpreparefailover $rgPair.Source -Confirm:$false -RunAsync Wait-Task $preparetask ############################################################ # Start the Failover ############################################################ Write-Host "Starting the Failover... `n" $starttask = Start-SpbmReplicationFailover $rgPair.Target -SourceVvolIdMap $sourceVvolMap -Confirm:$false -RunAsync $vmxfile = Wait-Task $starttask Write-Host "VMX File is $vmxfile" ############################################################ # Remove the Original Source VM ############################################################ $vm | Remove-VM -ErrorAction SilentlyContinue -Confirm:$false ############################################################ # Register the VM ############################################################ Write-Host "Registering VM on Site B... `n" $newVM = New-VM -VMFilePath $vmxfile -VMHost $vmhostB ############################################################ # Start the VM ############################################################ $vmtask = start-vm $newVM -ErrorAction SilentlyContinue -Confirm:$false -RunAsync wait-task $vmtask -ErrorAction SilentlyContinue $newVM | Get-VMQuestion | Set-VMQuestion -Option ‘button.uuid.movedTheVM’ -Confirm:$false ############################################################ # Set VM Storage Policy and auto replication group ############################################################ $SP = get-spbmstoragepolicy -name "YourSPBMPolicy" -server $siteB $hdds = Get-HardDisk -VM $newVM -Server $siteB Set-SpbmEntityConfiguration -Configuration $newVM, $hdds -StoragePolicy $SP -ReplicationGroup $rgPair.Target ############################################################ # Reverse Protection ############################################################ Write-Host "Reversing Protection... `n" start-spbmreplicationreverse $rgPair.Target 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 param ( [ parameter ( Mandatory = $ true ) ] [ string ] $ virtualmachine ) ipmo VMware . VimAutomation . Core ipmo VMware . VimAutomation . Common ipmo VMware . VimAutomation . Storage $ siteA = "yoursourceserver.com" $ siteB = "yourdestserver.com" ############################################################ # Write Header ############################################################ Write - Host - ForegroundColor Yellow "`n==========================================================" Write - Host "Starting Failover for VM: $virtualmachine" Write - Host - ForegroundColor Yellow "==========================================================`n" ############################################################ # Connect VI Servers ############################################################ Write - Host "Connecting Site A... `n" Connect - VIServer - User 'administrator@vsphere.local' - Password 'Yourpw' - Server $ siteA - WarningAction SilentlyContinue | Out - Null Write - Host "Connecting Site B... `n" Connect - VIServer - User 'administrator@vsphere.local' - Password 'Yourpw' - Server $ siteB - WarningAction SilentlyContinue | Out - Null $ vmhostA = get - vm - name $ virtualmachine - server $ sitea | Get - VMHost $ vmhostB = get - vmhost - Server $ siteB | select - First 1 ############################################################ # Prepare Source VVol Map - Used in Failover CMDLET ############################################################ # To-Do: Update this to work for VMs with multiple virtual disks $ vm = get - vm $ virtualmachine Start - Sleep - Seconds 10 $ ds = $ vm | get - datastore $ hd = $ vm | get - harddisk $ dsUrl = $ ds . ExtensionData . Info . Url $ dsUrl = $ dsUrl . Remove ( $ dsUrl . Length - 1 ) $ lastIndex = $ dsUrl . LastIndexOf ( '/' ) $ containerId = $ dsUrl . Substring ( $ lastIndex + 1 ) $ vmVvolId = $ vm . ExtensionData . Config . VmStorageObjectId $ hdVvolId = $ hd . ExtensionData . Backing . BackingObjectId $ sourceVvolMap = @ { $ vmVvolId = $ containerId ; $ hdVvolId = $ containerId } ############################################################ # Shut Down VM ############################################################ if ( $ vm . PowerState - eq "PoweredOn" ) { Write - Host "Shutting down VM: $vm ... `n" stop - vmguest - VM $ vm - confirm : $ false - ErrorAction silentlycontinue stop - vm $ vm - Confirm : $ false } ############################################################ # Find Replication Groups ############################################################ Write - Host "Getting Replication Group Information... `n" $ rg = get - spbmreplicationgroup - server $ siteA - VM $ vm $ rgPair = Get - SpbmReplicationPair - Source $ rg Write - Host "Source Group is $rgpair.Source.Name `n" Write - Host "Destination Group is $rgpair.Target.Name `n" ############################################################ # Prepare for Failover ############################################################ Write - Host "Preparing for Failover... `n" $ preparetask = start - spbmreplicationpreparefailover $ rgPair . Source - Confirm : $ false - RunAsync Wait - Task $ preparetask ############################################################ # Start the Failover ############################################################ Write - Host "Starting the Failover... `n" $ starttask = Start - SpbmReplicationFailover $ rgPair . Target - SourceVvolIdMap $ sourceVvolMap - Confirm : $ false - RunAsync $ vmxfile = Wait - Task $ starttask Write - Host "VMX File is $vmxfile" ############################################################ # Remove the Original Source VM ############################################################ $ vm | Remove - VM - ErrorAction SilentlyContinue - Confirm : $ false ############################################################ # Register the VM ############################################################ Write - Host "Registering VM on Site B... `n" $ newVM = New - VM - VMFilePath $ vmxfile - VMHost $ vmhostB ############################################################ # Start the VM ############################################################ $ vmtask = start - vm $ newVM - ErrorAction SilentlyContinue - Confirm : $ false - RunAsync wait - task $ vmtask - ErrorAction SilentlyContinue $ newVM | Get - VMQuestion | Set - VMQuestion - Option ‘ button . uuid . movedTheVM ’ - Confirm : $ false ############################################################ # Set VM Storage Policy and auto replication group ############################################################ $ SP = get - spbmstoragepolicy - name "YourSPBMPolicy" - server $ siteB $ hdds = Get - HardDisk - VM $ newVM - Server $ siteB Set - SpbmEntityConfiguration - Configuration $ newVM , $ hdds - StoragePolicy $ SP - ReplicationGroup $ rgPair . Target ############################################################ # Reverse Protection ############################################################ Write - Host "Reversing Protection... `n" start - spbmreplicationreverse $ rgPair . Target

Huge shoutout to Nimble Rockstar Julian Cates for helping me with this script. I could not have done it without his expertise.

VM Failover with PowerCLI on Nimble Storage

In our VMworld 2016 session Julian Cates and I demonstrated a planned failover of a vVols VM. If you haven't already, be sure to check out Nimble's implementation of Virtual Volumes on Nimble OS 3. In this demo video you will see the following:

There is a VM on the source side called Barcelona Demo.

There is no replicated copy of this VM on the target side

The script kicks off.

The VM is removed from the source vCenter Inventory

The VM is brought online at the destination

Refreshing the view on the destination array shows that the previous replicas are now online volumes.

What about SRM?

So does this mean I can now use Site Recovery Manager (SRM) with vVols? Yes and no. Yes SRM 6.5 is the first version to offer support for Virtual Volumes but only using vSphere Replication. vSphere 6.5 addresses the largest DR use case we see with automated DR via either public API or Power CLI. Will SRM support vVols for Array-Based Replication you ask? Well I am not a Product Manager and have no official response to this question but I would definitely stay tuned for more info on that in a future release. 🙂

Summary

The long awaited vVols support for Array-Based Replication has made Virtual Volumes a real option for production workloads. Using PowerCLI organizations can now experience the true value of vVols and Storage Policy-Based Management with automated data protection and disaster recovery.