Melice
Contributor
Contributor

MigrateVM_Task Example

Hi,

I just started using WebSphere SDKs and I get stuck on this trivial task: how to get reference to a VMware Host knowing its dnsname?

I want then to use it in a migration like

ManagedObjectReference task = sc.Service.MigrateVM_Task(

VirtualMachine.Create(sc, byVnUUID).getMor(),

null,

?,

VirtualMachineMovePriority.highPriority,

VirtualMachinePowerState.poweredOff, true);

Is there any snippet on how to use it?

Thanks,

Melice

0 Kudos
4 Replies
Steve_Jin
Expert
Expert

Check out this sample code:

http://vijava.svn.sourceforge.net/viewvc/vijava/trunk/src/com/vmware/vim25/mo/samples/vm/MigrateVM.j...

You want to read the 5 minute tutorial as well:

http://vijava.sourceforge.net/doc/getstarted/tutorial.htm

Good luck



Steve JIN

Author of VMware VI and vSphere SDK (Prentice Hall)

Creator of open source vSphere (VI) Java API(Tutorial, Testimonials, Download, Samples, Forum)

Blog: DoubleCloud.ORG ( Top 10 Best Practices,[Object Model|http://www.doublecloud.org/2010/02/object-model-of-vmware-vsphere-api-a-big-picture-in-2-minutes/],[Common Mistakes|http://www.doublecloud.org/2010/01/31/common-mistakes-using-vmware-vi-and-vsphere-sdk/], Tiny REST API, Cloud Application Architecture)

Twitter: @sjin2008

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
Melice
Contributor
Contributor

Hi Jin thanks for the answer.

I have already seen the code on your fantastic book Smiley Wink

I'll try to generalize my question a little bit , maybe a bit more useful:

- among all the different ways to interact with vSphere (WS SDK, PowerCLI, ?) which one is suggeste, pro vs cons, especially by thinking that C# is the target language (no java, sorry!)

- advantages / differences between direct method call (i.e vm.PowerOffVM()) vs Task (i.e vm.PowerOffVM_Task())

Hope it could be interesting in general.

Melice

0 Kudos
Steve_Jin
Expert
Expert

1. Depends what want to achieve. For scripting, you want PowerCLI because it's more task oriented. For building application especially large system, you want C#. In the PowerCLI document page, you will find a doc for developer introducing .NET binding.

2. a great question. I will write a blog about this in details/depth. Stay tuned to my blog for next post.



Steve JIN

Author of VMware VI and vSphere SDK (Prentice Hall)

Creator of open source vSphere (VI) Java API(Tutorial, Testimonials, Download, Samples, Forum)

Blog: DoubleCloud.ORG ( Top 10 Best Practices,[Object Model|http://www.doublecloud.org/2010/02/object-model-of-vmware-vsphere-api-a-big-picture-in-2-minutes/],[Common Mistakes|http://www.doublecloud.org/2010/01/31/common-mistakes-using-vmware-vi-and-vsphere-sdk/], Tiny REST API, Cloud Application Architecture)

Twitter: @sjin2008

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos
Melice
Contributor
Contributor

1. What about ws-sdk? Is there any advantage on using it over powercli?

2. I'll stay tuned

Just a small question:

in Java you have the possibility to cast directly

ComputeResource cr = (ComputeResource) newHost.getParent();

in C# you have the ManagedHostReference (newHost.Parent)

how to get the actual object in general?

Thanks

Melice

0 Kudos