VMware Cloud Community
damonmanni
Contributor
Contributor

Move/migrate a VM to a new datastore and convert to eagerzerodthick

Hello,

I am struggling w/ this for some time.  I have tried many code snippets but I seem to be in a catch 22.  My goal is to:

        Move a VM from a standalone DS (DS-standalone-1) to a new Data Store Cluster (DSC-Silver) AND at the same time convert the Hard disk on that Vm from thick lazy zero to eagerzeroedthick..

I have used "move-vm" and/or "move-hardisk" cmdlets in many test one-liners, but I cannot get the proper cmd combination do to both in one shot


Example-1: 

>> move-vm mytestvm  -datastore dscluster-vmfarm2.2-silver -diskstorageformat 'EagerZeroedThick'

This cmd errors off with "property datastore is missing from data object of type VirtualMachineRelocateSpecDiskLocator using serialized DataObject of type vim.vm.RelocateSpec.DiskLocator"

I have no idea what this means or how to fix it.

Example-2:

move-vm  mytestvm  -datastore Datastore-VMFarm2.2-FC-R5-06 -diskstorageformat 'EagerZeroedThick'

This cmd works - performing BOTH a move AND a convert - BUT I am forced to specific a SPECIFIC DS within the Cluster - thus defeating the purpose of just dropping it into a cluster and let DRS manage it.  I NEED to point it to just the DS Cluster.

Example-3:

Get-HardDisk mytestvm | Move-HardDisk -Datastore Datastore-VMFarm2.2-FC-R5-01 -StorageFormat EagerZeroedThick

This cmd works also BUT AGAIN i must specify a specific DS - where I just want to drop it into Silver.

What am I missing?  Basically I want to do the same exact sequence that I do when I choose the UI:

r-click vm> Migrate > Change DS > Select virtual disk format to: eager zeroed > Select DSC-Silver > Finish

Also, when I do get a conversion to work (w/out doing a "move" cmdlet and then I go back to the UI (edit settings) to check what the disk drive reports as it still reports "thick lazy" even though I even used vmkfstools to convert it to eagerzero.  I cannot seem to find the correct sequence of commands to work.  And I cannot use vmkfstools toconvert if the vm is running - and we do not have ability to power off VMs.

I appreciate any guidance.  Stumped.

cheers,
Damon

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

I don't think the current PowerCLI build supports OBN for a datastorecluster on the Move-VM cmdlet.

Did you try with

$dsc = Get-DatastoreCluster -Name dscluster-vmfarm2.2-silver

Move-Vm mytestvm  -Datastore $dsc -DiskStorageFormat 'EagerZeroedThick'



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

Reply
0 Kudos
damonmanni
Contributor
Contributor

Hi LucD,

Thank you for your suggestion.

I did try your code but it also failed.  I think in the end it is the same error as I was getting, just w/ a differrent cmd line combo:

I got the following error:

$dsc = Get-DatastoreCluster -Name dscluster-vmfarm2.2-silver

move-vm mytestvm -Datastore $dsc -DiskStorageFormat 'EagerZeroedThick'

Move-VM : 9/11/2013 11:10:18 AM    Move-VM

Required property datastore is missing from data object of type VirtualMachineRelocateSpecDiskLocator

while parsing serialized DataObject of type vim.vm.RelocateSpec.DiskLocator

at line 1, column 699

while parsing property "disk" of static type ArrayOfVirtualMachineRelocateSpecDiskLocator

while parsing serialized DataObject of type vim.vm.RelocateSpec

at line 1, column 685

while parsing property "relocateSpec" of static type VirtualMachineRelocateSpec

while parsing serialized DataObject of type vim.storageDrs.StoragePlacementSpec

at line 1, column 324

while parsing call information for method RecommendDatastores

at line 1, column 218

while parsing SOAP body

at line 1, column 207

while parsing SOAP envelope

at line 1, column 38

while parsing HTTP request for method recommendDatastores

on object of type vim.StorageResourceManager

at line 1, column 0

At line:1 char:8

+ move-vm <<<<  mdc2vr1187 -Datastore $dsc -DiskStorageFormat 'EagerZeroedThick'

    + CategoryInfo          : NotSpecified: (:) [Move-VM], InvalidRequest

    + FullyQualifiedErrorId : Client20_VmServiceImpl_RelocateVmThroughSdrs_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

What I am just reading is that it looks like i MUST supply an Antiaffinity switch in order to do a move + convert.  I am referring to examples 5 & 6 on the move-vm page:

------------- Example 5 --------------

$myDatastoreCluster1 = Get-DatastoreCluster -Name 'MyDatastoreCluster1' $myVm2 = Get-VM -Name 'MyVM2' $vmAntiAffinityRule = New-Object -TypeName VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMAntiAffinityRule -ArgumentList $myVm2 Move-VM -VM 'MyVM1' -Datastore $myDatastoreCluster1 -AdvancedOption $vmAntiAffinityRule

Moves the MyVM1 virtual machine to the specified datastore cluster and sets a VM anti-affinity rule for the placement of the virtual machine. The MyVM1 virtual machine will be placed on any datastore in the specified datastore cluster that does not contain the MyVM2 virtual machine.

-------------- Example 6 --------------

$myVm1 = Get-VM -Name 'MyVM1' $vmdks = Get-Harddisk -VM $myVm1 $myDatastoreCluster1 = Get-DatastoreCluster -Name 'MyDatastoreCluster1' $vmdkAntiAffinityRule = New-Object -TypeName VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMDiskAntiAffinityRule -ArgumentList $vmdks Move-VM -VM '$myVm1' -Datastore $myDatastoreCluster1 -AdvancedOption $vmdkAntiAffinityRule

Moves the MyVM1 virtual machine to the specified datastore cluster and sets a VM disk anti-affinity rule for the placement of the virtual machine. The disks of the MyVM1 virtual machine will be stored on different datastores in the specified datastore cluster.

So, I will give it a try + the -diskstorageformat 'eag...'.  I guess control must be coordinated w/ the viautomation process

Reply
0 Kudos
damonmanni
Contributor
Contributor

I tried Again using the following code and incorporating an anti-affinity rule in hopes it would work.  But failed again:

$vmtomigrate = Get-VM -Name mytestvm

$vmtoavoid = Get-VM -Name 'mdczr1186'

$dsc = Get-DatastoreCluster -Name 'dscluster-vmfarm2.2-silver'

$vmaar= New-Object -TypeName VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMAntiAffinityRule -ArgumentList $vmtoavoid

Move-VM $vmtomigrate -Datastore $dsc -AdvancedOption $vmaar -DiskStorageFormat 'EagerZeroedThick'

Error msg:

Move-VM : 9/11/2013 1:19:38 PM    Move-VM

Required property datastore is missing from data object of type VirtualMachineRelocateSpecDiskLocator

while parsing serialized DataObject of type vim.vm.RelocateSpec.DiskLocator

at line 1, column 891

while parsing property "disk" of static type ArrayOfVirtualMachineRelocateSpecDiskLocator

while parsing serialized DataObject of type vim.vm.RelocateSpec

at line 1, column 877

while parsing property "relocateSpec" of static type VirtualMachineRelocateSpec

while parsing serialized DataObject of type vim.storageDrs.StoragePlacementSpec

at line 1, column 324

while parsing call information for method RecommendDatastores

at line 1, column 218

while parsing SOAP body

at line 1, column 207

while parsing SOAP envelope

at line 1, column 38

while parsing HTTP request for method recommendDatastores

on object of type vim.StorageResourceManager

at line 1, column 0

At line:1 char:8

+ Move-VM <<<<  $vmtomigrate -Datastore $dsc -AdvancedOption $vmaar -DiskStorageFormat 'EagerZeroedThick'

    + CategoryInfo          : NotSpecified: (:) [Move-VM], InvalidRequest

    + FullyQualifiedErrorId : Client20_VmServiceImpl_RelocateVmThroughSdrs_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

PowerCLI C:\cygwin\home\m437830\scripts_c_drive\powercli> hitory

The term 'hitory' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path

was included, verify that the path is correct and try again.

At line:1 char:7

+ hitory <<<<

    + CategoryInfo          : ObjectNotFound: (hitory:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

I am surprised that there is no way to do the exact same functionality in cli as is done thru the Migration Wizard UI.  What is the magic step that I am missing?  Help Help

Reply
0 Kudos