VMware Cloud Community
Harkamals
Contributor
Contributor

Powershell sVmotion issue

I am trying S-Vmotion using powershell/vitoolkit. Intention is to be able to move selective disks to various other datastores as per needs.

The code is adaptation from http://poshcode.org/584 by halr9000

1) If I try to move selective DISK to another datastore with vm powered ON, the task is created, but it fails in vc console with error

"The requested storage vmotion would move a virtual machine's disks without assigning the virtual machine a new home, but such a move is not supported on the source host EsxBox1"

2) The same code works well if I power OFF my vm. I am able to move selective disks to anoter datastore. This is not my requirement.

Setup: My VM has 4 disks in datastore1, 1GB each, and I am trying to relocate or S-Vmotion1 of them to datastore2, and not touching others.

DiskID is retrieved from path - (GetView $_).Config.Layout.Disk

Code

$targetDataStore = Get-View -VIObject (Get-Datastore "PB_TEST_IT_ET_3")

$vmdk = new-object VMware.Vim.VirtualMachineRelocateSpecDiskLocator

$vmdk.DiskID = 2001

$vmdk.DataStore = $targetDataStore.MoRef

$relocationSpec = New-Object Vmware.Vim.VirtualMachineRelocateSpec

$relocationSpec.Disk = $vmdk

$vmView = Get-View -VIObject (Get-VM "HK1_isMyVM")

$vmView.RelocateVM_Task($relocationSpec)

Appreciate of someone can help me with this.

Happy weekend. HK

0 Kudos
9 Replies
LucD
Leadership
Leadership

First of all I can confirm I see the same behavior when I run a similar script in VC 2.5u4 and ESX 3.5u4 on a poweredon guest.

This is the script I used.


$vmName = <VM-name>
$targetDS = <DS-name>
$targetvmdk = "Hard Disk 1"

$targetDataStore = Get-Datastore $targetDS | Get-View
$vm = Get-VM $vmName | Get-View

$relocationSpec = New-Object Vmware.Vim.VirtualMachineRelocateSpec
foreach($dev in $vm.Config.Hardware.Device){
	if($dev.DeviceInfo.Label -eq $targetvmdk){
		$vmdk = new-object VMware.Vim.VirtualMachineRelocateSpecDiskLocator
		$vmdk.DataStore = $targetDataStore.MoRef
		$vmdk.DiskID = $dev.Key
		$relocationSpec.disk += $vmdk
	}
}

$taskMoRef = $vm.RelocateVM_Task($relocationSpec)

$task = Get-View $taskMoRef
while($task.info.state -eq "running" -or $task.info.state -eq "queued"){
	$task = Get-View $taskMoRef
}
Write-Host "Fault:" ($task.Info.Error.Fault.GetType()).Name
Write-Host "Msg:" $task.Info.Error.LocalizedMessage

What is really strange is the type of fault that the method returns.


Fault: IndependentDiskVMotionNotSupported
Msg: The requested Storage VMotion would move a virtual machine's disks without assigning the virtual machine a new home, but such a move is not supported on the source host 'ESX-hostname'.

I double-checked and "Hard Disk 1" is not an independent disk like the fault type seems to suggest.

So at least the returned type of fault is incorrect.

Btw I found some mentions that the same happens when you use RCLI or the Vip-SvMotion plugin.

I will open a call for this with VMware!


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership

Fyi I found a bypass for this problem, see .

The trick is to add the datastore moref in both objects.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Mythologie
Contributor
Contributor

Hi LucD,

I checked this commandline with errors.

- $task = Get-View ($vm.RelocateVM_Task($spec, "lowpriority"))Â Â

Cannot find an overload for "RelocateVM_Task" and the argument count: "2".

At :line:39 char:38

+ $task = Get-View ($vm.RelocateVM_Task(&lt;&lt;&lt;&lt; $spec, "lowpriority"))

Without second parameter the complete server was moved from datastore 1 to datastore 2.

Thanks for your help.

Norbert

0 Kudos
LucD
Leadership
Leadership

That's because you are using API 2.5 (or lower).

In API 4.0 the method has 2 parameters


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Mythologie
Contributor
Contributor

Hi LucD,

thanks for your email.

The question now is: Must I use the API 4.0 ?

Or the next step: Why I can't move one disk without the second parameter ?

Can you help me please again ?

Thanks

Norbert

0 Kudos
LucD
Leadership
Leadership

API 4.0 comes with vSphere.

And apparently the latest PowerCLI build 162509, only seems to know the API 4.0 overloads.

But it looks as if you call the method with the API 4.0 parameters in a VC2.5/ESX3.5 environment.

What PowerCLI build are you running ?

Get-ViToolkitVersion


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Mythologie
Contributor
Contributor

Hi LucD,

we use only the VMware VI Toolkit for Windows 1.5 build 142961 version.

In our environment we cann't now change to the new API 4.0 or in the next months.

So I hope, that we can solve our problem with the old API ?

Best regards,

Norbert

0 Kudos
LucD
Leadership
Leadership

Norbert, the latest build 162509 works with vSphere (API 4.0) and VC2.5/esx3.5 (API 2.5).

Most of the recent scripts in here are written for that latest build.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
houghtp
Contributor
Contributor

Hi All,

following this thread and acouple of others regardng svmotion issues and was wondering wether we are at a point where we can move individual disks with the VM with the latest version of the toolkit and the 2.5 API ? I followed LUCD's link to his workaround but it looks like thats not quite working either?

0 Kudos