VMwareLib.Tools usage

Jul 1, 2009 at 9:06 AM

!Disclaimer - I'm a beginner!


first off the wrapper has been a great help getting the basic info out of our VI, but I'm haveing trouble understanding the usage of .Tools.IpAddress

could you provide any sample or snippet?

thanks again




Jul 1, 2009 at 12:57 PM
Edited Jul 1, 2009 at 12:59 PM

First, the class called Vestris.VMWareLib.Tools.GuestOS encapsulates all kinds of guest operating system "stuff". It is capable of reading a file from the guest operating system, etc. It maps a network drive to do so, for example \\\c$, where the address comes from the "ip" property of the virtual machine. So that's what the IpAddress is, the IP of the powered on box.

Since there's no supported list of properties in the VixCOM API (some virtual machines may or may not return you the IP address, even if most do as long as the vm is networked), IpAddress is not a property of VirtualMachine.

If you just need an IP, you can get it in two ways.

// declare a virtual host
VMWareVirtualHost virtualHost = new VMWareVirtualHost();
// connect to a local VMWare Workstation virtual host
// open an existing virtual machine
VMWareVirtualMachine virtualMachine = virtualHost.Open("C:\Virtual Machines\xp\xp.vmx");
// power on this virtual machine
// wait for VMWare Tools
// get the ip 
string ip = virtualMachine.GuestVariables["ip"];

And if you want to use GuestOS for more than just getting the IP, eg. read file contents from the remote guest operating system.

guestOS = new GuestOS(virtualMachine);
string ip = guestOS.IpAddress;

Hope this helps.

Jul 2, 2009 at 8:26 AM

perfect, thanks!

Jul 2, 2009 at 8:43 AM

there doesn't seem to be a known list of those variables anywhere?  how did you find 'ip'?

Jul 2, 2009 at 11:33 AM

In Russian we call it the 'poking method'. You're right, there's no list. Someone should really run a dictionary through GuestVariables :)