Connection to VI - VirtualMachine returning Powered Off

Jun 2, 2009 at 4:32 AM

Hello,

I am trying to use your library to automate some tasks inside a virtual machine with vb.net.  I am able to make a successful connection to vCenter and get a list of VMs with the following code:

 

 

 

<font size="2">

 

</font>

 

Dim virtualHost As VMWareVirtualHost = New VMWareVirtualHost()
' connect to vCenter
virtualHost.ConnectToVMWareVIServer("localhost", "Administrator", "vmware1!")<font size="2">

 

</font>

 

Dim virtualMachine As VMWareVirtualMachine<font size="2">

 

</font>

 

For Each VMWareVirtualMachine In virtualHost.RunningVirtualMachines

MsgBox(virtualMachine.PathName & "Running: " & virtualMachine.IsRunning)

 

Next

This successfully shows my running VMs but the .IsRunning propery comes back as False.  This is causing me problems when I go to execute:

 

 

<font size="2">

virtualMachine.LoginInGuest(

</font>

"Administrator", "password")

<font size="2">

virtualMachine.RunProgramInGuest(

</font>

"notepad.exe", String.Empty)


I get an exception that the Virtual Machine must be running when it tries to execute the LoginInGuest command.

Any suggestions what I might be doing wrong here.  I am going to try your c# code as well to see if that might be the issue but I don't think so, I have converted the c# to VB properly.

Thanks,
Curtis

Coordinator
Jun 2, 2009 at 1:17 PM

It's like a physical server. You know it's there, but if it's not powered on, you can't login to it. You need to PowerOn and WaitForToolsInGuest.

Jun 2, 2009 at 1:25 PM

Thanks for the response, I actually just figured out what was going on.  I was connecting to VC that was behind a NAT firewall and my program didn't have access to the ESX servers themselves.  I guess this API, once it figures out where the VM lives, talks to the ESX host not VC after that.