Extensions

VSAN and vSphere Flash Read Cache cmdlets

Today a new VMware fling has been released, and it’s fantastic!  By now I am sure you have probably heard all the buzz from VMworld and with the 5.5 release and announced betas.  Two of the most talked about technologies are vSphere Flash Read Cache (vFRC) released in the new vSphere 5.5 version and also VSAN which was announced as a beta.

Today a new VMware fling was added to the site called “PowerCLI Extensionshere which allows you to use both VSAN and vFRC from PowerCLI, this gives you the added cmdlets needed in your PowerCLI session to automate two of the latest and greatest features from VMware.

Installing the fling

The fling was released as a PowerShell module, this makes it easy to download and add to your session, if you already have PowerCLI then no extra install is needed, just follow these easy steps:

  1. Install PowerCLI 5.5 R1 from here.
  2. Download the PowerCLI Extensions module from the download button on the left.
  3. To install the PowerShell module – extract the downloaded ZIP file to your modules directory, for example (C:\Users\Documents\WindowsPowerShell\Modules). For additional information on how to install a PowerShell module, see here.
  4. Verify that in the above folder there is a sub-folder called VMware.VimAutomation.Extensions. The full path is: C:\Users\Documents\WindowsPowerShell\Modules\VMware.VimAutomation.Extensions

 

As you can see from the screenshot below I have copied the file to my home directory where PowerShell can pick up this module:

SNAGHTMLdef403

Listing the Cmdlets

Once we have the module installed we can easily add the module to our session and list the commands with the below code as seen in the screen capture:

Import-Module VMware.VimAutomation.Extensions
Get-Command -Module VMware.VimAutomation.Extensions

SNAGHTMLe2ba8c

VSAN Cmdlets

Once the module has been installed we can see the cmdlets for working with VSAN as part of this module but also some of the core cmdlets have been adjusted to work with the VSAN product, the cmdlets which allow you to work with VSAN are:

Get-VsanDisk
Get-VsanDiskGroup
New-VsanDisk
New-VsanDiskGroup
Remove-VsanDisk
Remove-VsanDiskGroup
New-Cluster
Set-Cluster
New-VMHostNetworkAdapter
Set-VMHostNetworkAdapter

VSAN Examples

Some examples of these cmdlets can be seen below:

Retrieve a disk with canonical name “mpx.vmhba2:C0:T1:L0” on a specific host:

Get-VsanDisk -VMHost MyVMHost -CanonicalName “mpx.vmhba2:C0:T1:L0”

Retrieve disks that are part of a VSAN disk group that has a disk with
canonical name “mpx.vmhba2:C0:T2:L1”

$dg = Get-VsanDiskGroup -VMHost MyVMHost –CanonicalName “mpx.vmhba2:C0:T2:L1”
Get-VsanDisk -CanonicalName “mpx.vmhba3:C0:T2:L0” -VsanDiskGroup $dg

Add a disk to a VSAN disk group

$dg = Get-VsanDiskGroup -VMHost MyVMHost –CanonicalName “mpx.vmhba2:C0:T2:L1”
$d = New-VsanDisk -VsanDiskGroup $dg -CanonicalName “mpx.vmhba3:C0:T2:L0”

Create a new VSAN disk group for a host.

New-VsanDiskGroup -VMHost MyVMHost -SolidStateCanonicalName
“mpx.vmhba2:C0:T1:L0” -HardDiskCanonicalName “mpx.vmhba3:C0:T1:L0”

Remove a disk with canonical name “mpx.vmhba3:C0:T2:L0” from a VSAN disk
group.

$dg = Get-VsanDiskGroup -VMHost MyVMHost –CanonicalName “mpx.vmhba2:C0:T2:L1”
Get-VsanDisk -VsanDiskGroup $dg -CanonicalName “mpx.vmhba3:C0:T2:L0” | Remove-VsanDisk

Remove a disk group with canonical name “mpx.vmhba2:C0:T2:L1” on host MyVMHost.

$dg = Get-VsanDiskGroup -VMHost MyVMHost –CanonicalName “mpx.vmhba2:C0:T2:L1”
Remove-VsanDiskGroup -VsanDiskGroup $dg

vFRC Cmdlets

Once the module has been installed we can see the cmdlets for working with vFRC, these are listed below:

Get-HardDiskVFlashConfiguration
Get-VMHostVFlashConfiguration
Set-HardDiskVFlashConfiguration
Set-VMHostVFlashConfiguration

vFRC Examples

Retrieve the vFlash configuration for all hard disks associated with a specified virtual machine.

$vm = Get-VM “MyVM”
$disk = Get-HardDisk -VM $vm
Get-HardDiskVFlashConfiguration -Disk $disk

Retrieve the vFlash configuration for a specified host.

Get-VMHostVFlashConfiguration -VMHost “MyVMHost”

Retrieve the vFlash configuration for all hosts in a specified cluster.

$hosts = Get-VMHost -Location “MyCluster”
Get-VMHostVFlashConfiguration -VMHost $hosts

Enable vFlash on a specified hard disk using vSphere default values.

$configuration = Get-HardDiskVFlashConfiguration -Disk $disk
Set-HardDiskVFlashConfiguration -VFlashConfiguration $configuration

Enable vFlash cache with a specified size on a specified hard disk.

$configuration = Get-HardDiskVFlashConfiguration -Disk $disk
Set-HardDiskVFlashConfiguration -VFlashConfiguration $conf -CacheSizeGB 1

Disable the vFlash cache on a specified hard disk.

$configuration = Get-HardDiskVFlashConfiguration -Disk $disk
Set-HardDiskVFlashConfiguration -VFlashConfiguration $configuration -CacheSizeGB 0

Modify the size of the vFlash swap cache for the host associated with the specified vFlash configuration.

Set-VMHostVFlashConfiguration -Configuration $vFlashConfig -SwapCacheReservationGB 1

Disable the vFlash swap cache for the host associated with the specified vFlash configuration.

Set-VMHostVFlashConfiguration -Configuration $vFlashConfig -SwapCacheReservationGB 0

Remove all vFlash resources from the specified vFlash host configuration.

Set-VMHostVFlashConfiguration -Configuration $vFlashConfig -RemoveVFlashResource