I have successfully tested a powerCLI script for cross vCenter vmotion with two vCenters on the same SSO domain but I'm having trouble getting it to work with two vCenter servers that are not on the same SSO domain. The error "A specified parameter was not correct: ServiceLocator.instanceUuid"
Both vCenter servers and hosts are at version 6.0. The source vc is running on windows and the remote is running the linux appliance. The script successfully starts the task but the task fails immediately. What log files should I be looking at to get more info or a stack trace?
The original source of the script was authored by William Lam (Thanks!)
param(
[parameter(Mandatory=$true)] $vm_name,
[parameter(Mandatory=$true)] $source_cluster,
[parameter(Mandatory=$true)] $source_vcenter,
[parameter(Mandatory=$true)] $target_cluster,
[parameter(Mandatory=$true)] $target_vcenter,
[parameter(Mandatory=$true)] $target_storage_pod,
[parameter(Mandatory=$true)] $pools_to_move,
[parameter(Mandatory=$true)] $folder
)
$sc_test_thumb = "xx:xx:xx:xx:xx:xx"
$thumbprint = $sc_test_thumb
$source_vc = connect-viserver $source_vcenter
$source_cl = get-cluster -server $source_vc -name $source_cluster
$source_pool = get-resourcepool -server $source_vc -name $pools_to_move
$target_vc = connect-viserver $target_vcenter
$target_cl = get-cluster -server $target_vc -name $target_cluster
$target_hosts = get-vmhost -server $target_vc -location $target_cl
$target_pool = get-resourcepool -server $target_vc -location $target_cl -name $pools_to_move
$target_datastores = get-datastore -server $target_vc -location $target_storage_pod
$vm = get-vm -server $source_vc -name $vm_name -location $source_pool
$destFolder = get-folder -server $target_vc -name $folder
$rspec = New-Object VMware.Vim.VirtualMachineRelocateSpec
$rspec.folder = $destFolder.id
$rspec.datastore = $target_datastores[0].extensiondata.moref
$rspec.host = $target_hosts[0].extensiondata.moref
$rspec.pool = $target_pool.extensiondata.moref
# New Service Locator required for Destination vCenter Server when not part of same SSO Domain
$service = New-Object VMware.Vim.ServiceLocator
$credential = New-Object VMware.Vim.ServiceLocatorNamePassword
$credential.username = (Get-VICredentialStoreItem -Host $target_vcenter).user
$credential.password = (Get-VICredentialStoreItem -Host $target_vcenter).password
$service.credential = $credential
$service.InstanceUuid = $target_vc.InstanceUuid
$service.sslThumbprint = $thumbprint
$service.url = ("https://" + $target_vcenter)
$rspec.service = $service
$rspec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[]($vm.networkadapters.count)
$devices = $vm.extensiondata.Config.Hardware.Device
$i = 0
foreach ($device in $devices) {
if($device -is [VMware.Vim.VirtualEthernetCard]) {
$rspec.deviceChange[$i] = New-Object VMware.Vim.VirtualDeviceConfigSpec
$rspec.deviceChange[$i].Operation = "edit"
$rspec.deviceChange[$i].Device = $device
$nic = get-networkadapter -vm $vm -name $device.DeviceInfo.label
$destPG = get-vdportgroup -server $target_vc -name $nic.networkname
$dvSwitchUuid = (Get-View -server $target_vc -Id $destPG.extensiondata.Config.DistributedVirtualSwitch).Summary.Uuid
$rspec.deviceChange[$i].Device.Backing = New-Object VMware.Vim.VirtualEthernetCardDistributedVirtualPortBackingInfo
$rspec.deviceChange[$i].Device.Backing.Port = New-Object VMware.Vim.DistributedVirtualSwitchPortConnection
$rspec.deviceChange[$i].Device.Backing.Port.PortgroupKey = $destPG.key
$rspec.deviceChange[$i].Device.Backing.Port.SwitchUuid = $dvSwitchUuid
$i++
}
}
Write-Host "`nMigrating $vm from $source_vc to $target_vc ...`n"
# Issue Cross VC-vMotion
$task = $vm.extensiondata.RelocateVM_Task($rspec,"defaultPriority")
Disconnect-VIServer $source_vc -Force -confirm:$false
Disconnect-VIServer $target_vc -Force -confirm:$false
return $task
I found an error in the vpxd log. The instanceUuid needs to be converted to upper case before it packaged.
This line fixed it:
$service.InstanceUuid = $target_vc.InstanceUuid.toUpper()
Thanks LucD!
Are you sure that is possible over 2 different SSO domains ?
KB2106952 seems to say it isn't (third bullet)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I did see that article. I found some other non-official information stating that it was possible.
Would you mind posting a link to that info ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the quick reply. Here's the link:
Did you know of an additional cool vMotion capability in vSphere 6.0? | virtuallyGhetto
Will added the script to that post.
Did you use that script ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
We tested with that script as well. We have a ticket open with VMWare now. I'm wondering if there is a way to increase the log level on the server to get more detail.
There should be a verbose and trivia setting under the vCenter Server Manage - Settings - Logging Options
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I found an error in the vpxd log. The instanceUuid needs to be converted to upper case before it packaged.
This line fixed it:
$service.InstanceUuid = $target_vc.InstanceUuid.toUpper()
Thanks LucD!
Wouldn't have thought of that :smileyblush:
Thanks for sharing that info
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The strange thing is the script was tested and working before with a different environment.
PowerCLi script had worked for me without any change.
Recently I have written Java SDK script for the same requirement: Refer my blog post: http://vthinkbeyondvm.com/want-to-vmotion-a-vm-from-one-vcenter-server-to-another-vcenter-using-vsph...