Thursday, February 5, 2015

PowerCLI and Virtual SANs Fling Information



Managing your VSAN with PowerCLI

If you are interested in managing your VSAN using automation tools, go to labs.vmware.com and find and download the recent VSAN "fling". Flings are pet projects for VMware engineers. Lots of very useful ones, including this one. After downloading and installing this fling, run the following commands to get help on getting started.

Import-Module VMware.VimAutomation.Extensions

Get-Command -Module VMware.VimAutomation.Extensions



Here are a few examples that I was able to find in no time whatsoever:

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

No comments:

Post a Comment