VMware Cloud Community
Dumptruck
Contributor
Contributor
Jump to solution

cross vCenter vmotion error

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

0 Kudos
1 Solution

Accepted Solutions
Dumptruck
Contributor
Contributor
Jump to solution

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!

View solution in original post

0 Kudos
11 Replies
LucD
Leadership
Leadership
Jump to solution

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

Dumptruck
Contributor
Contributor
Jump to solution

I did see that article. I found some other non-official information stating that it was possible.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Would you mind posting a link to that info ?


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

0 Kudos
Dumptruck
Contributor
Contributor
Jump to solution

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Will added the script to that post.

Did you use that script ?


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

0 Kudos
Dumptruck
Contributor
Contributor
Jump to solution

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.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
Dumptruck
Contributor
Contributor
Jump to solution

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!

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Wouldn't have thought of that :smileyblush:

Thanks for sharing that info


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

0 Kudos
Dumptruck
Contributor
Contributor
Jump to solution

The strange thing is the script was tested and working before with a different environment. 

0 Kudos
vThinkBeyondVM
VMware Employee
VMware Employee
Jump to solution

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...


----------------------------------------------------------------
Thanks & Regards
Vikas, VCP70, MCTS on AD, SCJP6.0, VCF, vSphere with Tanzu specialist.
https://vThinkBeyondVM.com/about
-----------------------------------------------------------------
Disclaimer: Any views or opinions expressed here are strictly my own. I am solely responsible for all content published here. Content published here is not read, reviewed or approved in advance by VMware and does not necessarily represent or reflect the views or opinions of VMware.

0 Kudos