There's a CHM with the build with examples and detailed documentation. Please download the library.

vmwaretasksdoc.jpg

Example: Connect to VMWare Workstation, etc.

// declare a virtual host
VMWareVirtualHost virtualHost = new VMWareVirtualHost();
// connect to a local VMWare Workstation virtual host
virtualHost.ConnectToVMWareWorkstation();
// open an existing virtual machine
VMWareVirtualMachine virtualMachine = virtualHost.Open("C:\Virtual Machines\xp\xp.vmx");
// power on this virtual machine
virtualMachine.PowerOn();
// wait for VMWare Tools
virtualMachine.WaitForToolsInGuest();
// login to the virtual machine
virtualMachine.Login("Administrator", "password");
// run notepad
virtualMachine.RunProgramInGuest("notepad.exe", string.Empty);
// create a new snapshot
string name = "New Snapshot";
// take a snapshot at the current state
virtualMachine.Snapshots.CreateSnapshot(name, "test snapshot");
// power off
virtualMachine.PowerOff();
// find the newly created snapshot
VMWareSnapshot snapshot = virtualMachine.Snapshots.GetNamedSnapshot(name);
// revert to the new snapshot
snapshot.RevertToSnapshot();
// delete snapshot
snapshot.RemoveSnapshot();

Example: Connect to a local VMWare Server 1.x

// declare a virtual host
VMWareVirtualHost virtualHost = new VMWareVirtualHost();
// connect to a local VMWare Server 1.x virtual host
virtualHost.ConnectToVMWareServer();
// open an existing virtual machine
VMWareVirtualMachine virtualMachine = virtualHost.Open("[standard] testvm/testvm.vmx");
...

Example: Connect to a local VMWare Server 2.x

// declare a virtual host
VMWareVirtualHost virtualHost = new VMWareVirtualHost();
// connect to a local VMWare Server 2.x virtual machine
virtualHost.ConnectToVMWareVIServer("localhost:8333", "vmuser", "password");
// open an existing virtual machine
VMWareVirtualMachine virtualMachine = virtualHost.Open("[standard] testvm/testvm.vmx");
...

A VMWare Server 2.x behaves like an ESX server. Replace localhost by a server name for remote connections.

Example: Connect to VMWare VI (ESX)

// declare a virtual host
VMWareVirtualHost virtualHost = new VMWareVirtualHost();
// connect to a remote (VMWare ESX) virtual machine
virtualHost.ConnectToVMWareVIServer("esx.mycompany.com", "vmuser", "password");
// open an existing virtual machine
VMWareVirtualMachine virtualMachine = virtualHost.Open("[storage] testvm/testvm.vmx");
...


Last edited Nov 25, 2009 at 1:02 PM by dblock, version 2

Comments

No comments yet.