problem defined: trying to cold migrate vms from one datacenter to another datacenter within same vcenter - no matter what code i try to use, i get an error or "half baked" results - i.e. some vms cold migrate, others do not with an error
example001:
PowerCLI C:\> import-csv c:\maint.csv | %{ get-vm -name $_.ServerName -Location (get-datacenter "dtc001") | move-vm -Datastore (get-datastore -name "DATASTORE_008") -RunAsync -Confirm:$false }
maint.csv contents:
ServerName
SERVER001
error in vcenter:
"a specified parameter was not correct. datastore"
example002 - using Lucd's relocatevm method:
foreach($row in (Import-Csv c:\serverlistmigrate.csv -UseCulture)){
$vm = ''
$esx = ''
$spec = ''
$spec.datastore = ''
$spec.host = ''
$spec.resourcepool = ''
CLS
$vmname = $row.vmname
$vmhost = $row.vmhost
$datastore = $row.datastore
$vm = Get-VM -Name $vmname
$spec = New-Object VMware.Vim.VirtualMachineRelocateSpec
$spec.datastore = (Get-Datastore -Name $datastore).ExtensionData.MoRef
$spec.pool = (Get-ResourcePool -Name $resourcepool).ExtensionData.MoRef
$spec.host = (Get-VMHost -Name $vmhost).ExtensionData.MoRef
$vmObj = Get-VM -Name $vmname | Get-View
$vmObj.RelocateVM_Task($spec, "defaultPriority")
c:\serverlistmigrate.csv contents:
vmname,vmhost,resourcepool,datastore
"SERVER001,esxhost07,rpl01_High,DATASTORE_008
error in vcenter:
"a specified parameter was not correct. host"
**** USING above method, I will get some to migrate, but some fail with same error as above.
NEEDED: All I want is to cold migrate multiple vms from one datacenter to another datacenter (different datastore) within same vcenter with 100% success - I don't care what method is used - I just need solid, reliable, consistent success.
Many thanks in advance!!!!
NOTES - POWERCLI VERSION, etc.
I have moved this thread to a more approroiate forum
Are all the datastores shared between the 2 vCenters ?
Btw when on vSphere 5.1, this requirement is dropped. You don't need shared storage anymore to do a vMotion.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
datastores are separate in the separate datacenters. so I would say they are "not" shared between datacenters
vcenter version: 4.1 build: 491557
typical host versions:
That means your cold migration would only use the network. And that should work in vSphere 4.*
There can be several reasons why the cold migration fails.
Just to name a few:
Does the cold migration work when you do it from the vSphere client ?
Btw, why don't you use the Move-VM cmdlet ?
That has been seriously improved since I wrote that script.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
re: connectivity - it will work sometimes and fails on other times, even going to same host, so there shouldn't be a port block issue, otherwise it would never work
re: ISO - n/a - no connection to ISO, etc.
re: 64 bit - non-issue - these are 32 bit vms in question
re: using move-vm, do you have any new snazzy code ? using below I get the error "a specified parameter was not correct. datastore"
import-csv c:\maint.csv | %{ get-vm -name $_.ServerName -Location (get-datacenter "dtc001") | move-vm -Datastore (get-datastore -name "DATASTORE_008") -RunAsync -Confirm:$false }
maint.csv contents:
ServerName
SERVER001
re: using move-vm - I'm getting the old "must be in same datacenter" error:
Luc - more info
I found an old blurb from you.....see BOTTOM of page/thread (adding the one line $spec )
http://communities.vmware.com/thread/267514
........and implemented it on another "rev" of a script I had - added the one line "$spec" as shown below...........
it is now "working" - yippy!! - I will test and let you know if I am getting consistent success
That is very strange :smileyconfused:
In that thread I asked to insert the "$spec" line to dunmp the contents of that object to the console (for debugging purposes).
That shouldn't make a difference to the call to the RelocateVM method.
Is the cold migration failing if you remove that line ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc - running out of time today - will report back tomorrow - thanks!!
Luc - it was very strange - ran without $spec and it ran successfully - latest codes snippet supplied previously seems to be working - you can mark/I will mark as answered - the process of getting the script to work was resulting in inconsistent failures/successes - seems to be working now