Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

POWERCLI: VIRTUAL MACHINE STORAGE MIGRATE/SVMOTION AND DATASTORE PORT BINDING MULTIPATHING

July 20, 2017 08:45AM

Series Parts
MICROSOFT WINDOWS 2012 R2 ISCSI TARGET STORAGE SERVER FOR ESXI AND HYPERV 
POWERSHELL INSTALLING AND CONFIGURING MICROSOFT ISCSI TARGET SERVER
VMWARE ESXI CONFIGURE (VSWITCH) VMKERNEL NETWORK PORT FOR ISCSI STORAGE
POWERCLI: VMWARE ESXI CONFIGURE (VSWITCH) VMKERNEL NETWORK PORT FOR ISCSI STORAGE
VMWARE ESXI INSTALL AND CONFIGURE SOFTWARE ISCSI STORAGE ADAPTER FOR VMFS VERSION 6 DATASTORE
POWERCLI VMWARE: CONFIGURE SOFTWARE ISCSI STORAGE ADAPTER AND ADD VMFS DATASTORE
VMWARE VCENTER STORAGE MIGRATE/SVMOTION VM AND PORT BINDING MULTIPATHING TESTING
POWERCLI: VIRTUAL MACHINE STORAGE MIGRATE/SVMOTION AND DATASTORE PORT BINDING MULTIPATHING

In earlier chapter I shown how to migrate VM and test storage multipath using vSphere web client, here I will perform same task using commands using VMware Powercli. For this I have reverted all the setting. To setup powercli check my earlier article VMWARE VSPHERE POWERCLI INSTALLATION AND CONFIGURATION STEP BY STEP

Here I have stored specific information about esxi host, virtual machine, and datastore in the there respective powershell variable. (I can view information about all inventory by running just Get-VMhost, Get-VM, Get-Datastore)
$vmhost = Get-VMhost Esxi001.vcloud-lab.com
$vm = Get-VM winxp001
$Datastore = $VMhost | Get-Datastore Disk1_Tier3

I want to know how much is the free space left and multipath policy about selected datastore Disk1_Tier3 can be fetched using next one liner commands.
$SCSILun = $VMhost | Get-ScsiLun -LunType Disk | Where-Object {$_.CanonicalName -eq $Datastore.extensiondata.info.vmfs.extent.Diskname}
$SCSILun | Select-Object @{N='Name'; E={$Datastore.Name}}, CanonicalName, CapacityGB,@{N='FreeSpaceGB'; E={$Datastore.FreeSpaceGB}}, @{N='MountPath'; E={$Datastore.extensiondata.Info.Url}}, MultipathPolicy

vmware vcenter vsphere powercli get-vmhost, get-vm, Get-datastore, Get-scsilun multipathPolicy, CanonicalName, extent, extensiondata, freespacegb, capacityGB datastore storage, vmfs example

I am changing multipath policy of selected datastore using command.
$SCSILun | Set-ScsiLun -MultipathPolicy RoundRobin

To view multipath status of vmhost datastore use next command, and they looks good and all active.
($SCSILun | Get-ScsiLunPath).ExtensionData | Select-Object Name, PathState

vmware powercli vsphere vcenter esxi, datastore storage lun, set-scsilun multipathpolicy roundrobin rr, fixed, mru, most recently used, psp, path selection policy satp, Get-ScsilunPath, pathstate, runtime, devicename, naa

To know IP address of virtual machine using powercli and virtual harddisk location use commands, If you see all the commands from top to bottom of this articles are connected.
$vm.ExtensionData.Guest.IpAddress
$vm | Get-HardDisk

vmware vcenter esxi powercli vm extensiondata guest ipaddress, get-harddisk, filename datastore location

I have gathered all the information and changed multipathing information as well, Now for final step I am storage vmotion VM with thin provisioned disk. Once my command is executed successfully, I can verify VM location with command $vm | Get-HardDisk.
$vm | Move-VM -Datastore Disk1_Tier3 -DiskStorageFormat Thin

Side by side while storage migration I started ping (Test-connection) to VM, I didn't get any ping loss, also I simulated physical adapter connected to storage failure by removing cable from esxi server. and checked the multipathing status as expected VM is intact and 2 paths are dead, No downtime on the VM.
($SCSILun | Get-ScsiLunPath).ExtensionData | Select-Object Name, PathState

vmware vsphere esxi vcenter powercli, move-vm datastore storage vmotion, diskstorageformat thin, migrate, Get-ScsiLunPath, extensiondata, Pathstate dead, active, test-connection -count ping vm, port binding

Go Back

Comment