VMware {code} Community
babysham
Contributor
Contributor
Jump to solution

CS1501 "No Overload Error" when trying to use MigrateVM_Task

This might be a newbie question as I am new to C#. I'm trying to make a Windows CLI that would allow someone to VMotion a VM similar to the sample VMPowerOPs command. I have used it as a template but everytime I try to invoke the MigrateVM_Task I get a CS1501/No Overload error from Visual C# 2005:

Error 4 No overload for method 'MigrateVM_Task' takes '4' arguments D:\Temp\VI-SDK\einstitution\VMotion\VMotion.cs 75 23 VMotion

The same code workes fine with the PowerOnVM_Task.

Any thoughts, directions, schools for learning C#, etc. would be appreciated. Smiley Happy

Reply
0 Kudos
1 Solution

Accepted Solutions
jrackliffe
Hot Shot
Hot Shot
Jump to solution

Looking at your code you still only have 4 params defined for a 5 param function. C# is not like VB where "optional" params could be left out of the function call. They still need to be represented by a null or proper value type.

Instead of...

taskmor = clientInfo.Connection.Service.MigrateVM_Task(vmmor, null, hostmor, VirtualMachineMovePriority.highPriority);

try...

taskmor = clientInfo.Connection.Service.MigrateVM_Task(vmmor, null, hostmor, VirtualMachineMovePriority.highPriority, null);

If that doesn't work because of the powerstate I would select one, but I think that will at least get you past the compiler error.

J

View solution in original post

Reply
0 Kudos
5 Replies
jrackliffe
Hot Shot
Hot Shot
Jump to solution

Well your method params for PowerOn and MigrateVM are different.

http://pubs.vmware.com/vi301/sdk/ReferenceGuide/index.html

You can look up the two headers.

A Migrate will take (the MOR of the VM to migrate, the MOR of the Pool to target, a Host MOR if this is not a DRS enabled cluster or standalone ESX, the VirtualMachineMovePriority, the VirtualMachinePowerState)

Not all are required, but you will need most. The PowerOn only needs the VM MOR and optionally the Host for the VM.

If it comes to learning C# there are tons of books out there you could get, but I don't have experience w any specific texts.

J

Reply
0 Kudos
babysham
Contributor
Contributor
Jump to solution

Thanks jrackliffe.

I used the VMPowerOn sample program and I modified it a bit for the params

of the MigrateVM_Task. Here's an excerpt:

ManagedObjectReference taskmor = null;

// taskmor = clientInfo.Connection.Service.PowerOnVM_Task(vmmor, hostmor);

taskmor = clientInfo.Connection.Service.MigrateVM_Task(vmmor, null, hostmor,

VirtualMachineMovePriority.highPriority);

I have defined the hostmor and poolmor similarily to way vmmor is in the

example. Here I'm trying to leave the pool null since the VM will remain in

the same pool which the doco says in not required. However, defined or not

defined I get the same @#$@#%@ error which seems to show that something is

wrong with my setup or something. But I do have all the right refences and

most of these options are taken right from the IDE Microsoft Visual Express

C# so I'm at a loss.

Thanks for the response and the help

Reply
0 Kudos
jrackliffe
Hot Shot
Hot Shot
Jump to solution

Looking at your code you still only have 4 params defined for a 5 param function. C# is not like VB where "optional" params could be left out of the function call. They still need to be represented by a null or proper value type.

Instead of...

taskmor = clientInfo.Connection.Service.MigrateVM_Task(vmmor, null, hostmor, VirtualMachineMovePriority.highPriority);

try...

taskmor = clientInfo.Connection.Service.MigrateVM_Task(vmmor, null, hostmor, VirtualMachineMovePriority.highPriority, null);

If that doesn't work because of the powerstate I would select one, but I think that will at least get you past the compiler error.

J

Reply
0 Kudos
babysham
Contributor
Contributor
Jump to solution

jrackliffe, you were correct. However, it appears to be a 6 param

function. It wouldn't build untill the bool param in as well. It runs not

but I think there something wrong with the host reference since it just

keeps migrating to the same host even though a different is passed.

Thanks a lot. I haven't had a lot of good luck with forums. If you would

send me a private message with some contact info i would like to send

something in appreciation.

Reply
0 Kudos
jrackliffe
Hot Shot
Hot Shot
Jump to solution

Ehh... must have run out of fingers on the hand I was counting with. Smiley Wink

The forums can be good if you have specific problems, but sometimes general programming ones will go under the radar for most. The support org is pretty solid as well and I believe they will be looking to improve the SDK support process over the next year. I don't know what your support agreement is, but that can always be another, albeit potentially more expensive solution.

No presents needed... nor could I accept in any case.

As a note. Use your ManagedObjBrowser to get the specific mors for your targets and then just call the function. May expose something.

You can just construct them like any other object in C#

MAnagedObject vm = new ManagedObject();

vm.id = "vm-9999" //your string mor id from the mob

vm.type = "VirtualMachine"

Do that for the Host, Pool or any other Mor and then you can test very specific functionality.

Reply
0 Kudos