VMwareLib.Tools usage

Jul 1, 2009 at 8:06 AM

!Disclaimer - I'm a beginner!

Hi,

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

 

alex

 

Coordinator
Jul 1, 2009 at 11:57 AM
Edited Jul 1, 2009 at 11:59 AM

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 \\192.168.1.10\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
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();
// 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 7:26 AM

perfect, thanks!

Jul 2, 2009 at 7:43 AM

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

Coordinator
Jul 2, 2009 at 10: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 :)