VMware {code} Community
jdyankel
Contributor
Contributor

Cannot execute VIX API command on a Powered On Virtual Machine - vCenter

I cannot execute any VIX API vmrun command once the Virtual Machine is powered on.

The setup is a vCenter server with a number of esx hosts.  I can list all virtual machines, and power the machines on, but once the machine is powered on, every vmrun command fails with the error "Cannot open VM: [datastore] VMname/vmname.vmx, There was an error in communication"

When executing the vmrun 'start' command from a command prompt, the command does start the Virtual Machine, but it does not return control immediately.  Instead it hangs for a few minutes before returning with the above error.  In other words it appears that as soon as a Virtual Machine is powered on, the vmrun command cannot communicate with the guest VM.  When powered off, I am able to run many vmrun commands such as revertToSnapshot, snapshot, etc.

I tried to execute the vmrun command against the specific esx host and this was successful.  Unfortunately, this is not a great option as the Virtual Machines could reside on any number of esx hosts.

Has anyone experienced this?  I'm hoping for a solution other than placing groups of vm's that I need to control via VIX on a particular esx host.

Thanks,

Joe Yankel

0 Kudos
11 Replies
CookieJarvis
Contributor
Contributor

hey Joel, are you sure you are contacting the vcenter in ESXi?   I'm having the exact same problem -- same symptoms....but ONLY when I try to connect directly to the ESXi Host.  I'm not having this problem when I connect to the vcenter server.  I wanted to get clarification from you that your vmrun command is targeting the IP-Address and username/password of the vcenter server...and not the actual ESXi Host.  If this were the case...you may be able to solve your problem by targetting your commands through vcenter. In my case...I really WANT to send my commands DIRECTLY to the HOST --- and I'm having the exact problem you describe.


0 Kudos
lemke
VMware Employee
VMware Employee

Its likely that it failed to connect to the automation socket.  VIX needs to talk to port 902 on the ESX system in order to execute guest operations, and it tries to get that connection when poweringOn.  Be sure there's no firewalls in place.

We also recently found a bug where there was some case-sensitivity in the URL used for the connection.  'https://<ip>/sdk' worked fine, but 'Https://<ip>/sdk' did not, because some code couldn't handle the upper case.

CookieJarvis
Contributor
Contributor

I am indeed using the IP to connect to, and checked my case.  If I try to contact the host directly and perform a suspend on a vm... I get "There was an error in communication"  --  If i manually suspend the vm and then use my script to perform a "start" instead.... the vm starts up just fine....but my script hangs anyway and eventually "times out" with an "...error in communication".

Since the VM started...I know my command is getting through --- I'm only trying to perform a simple "suspend" operation (not some complicated guest operation).  Seems I can start a vm...but not suspend one via the host.  Once the vm is running...it seems I can not longer send commands to...(or receive confirmation from) the vm.  That seems to explain why the machine does start up....but my script never hears back that the operation was successful.

0 Kudos
lemke
VMware Employee
VMware Employee

VIX needs two communication channels.  One is specified by the URL, the other uses that same hostname and port 902.

If only the first works, you'll get exactly what you're seeing -- any operations that don't involve a powered on or powering on VM will work, others will fail with a communication error because port 902 cannot be contacted.

0 Kudos
jdyankel
Contributor
Contributor

I wish I had your problem... I cannot talk directly to the vCenter machine, but I can connect to the individual ESX host.  I ended up losing the nice failover/migration features of vCenter in order to use the VIX api for my purposes.

0 Kudos
jdyankel
Contributor
Contributor

Thanks, I'll look into this.  I do not have any firewalls in between anything, but this helps me know where to 'poke' around.

-Joe

0 Kudos
CookieJarvis
Contributor
Contributor

I issued the command : telnet  123.456.789.10  902   and I get a response back telling me I'm connected...VMware authentication Daemon Version 1.10: SSL Required, ServerDaemonProtocol : SOAP, MKSDisplayProtocol:VNC, VMSARGS supported.   So... to me it looks like I can get a connection to port 902?  Seems like that also discounts a firewall issue?   I cannot suspend a running VM (error in communication) ...but I can start a non-running one.

0 Kudos
CookieJarvis
Contributor
Contributor

Note:  I also can browse the datastore on my ESXi servers via a browser...so....it seems my Web https communications are working just fine too.

0 Kudos
CookieJarvis
Contributor
Contributor

I just tried to perform a "readVariable" with vmrun to get the "guestOS" value.  It works perfectly when I target VCenter...but fails with a communications error when I contact the host directly.  I really would like to send these commands directly to the host system.  One of the systems I need to suspend is the vCenter server....so I can't exactly expect a reply when the command completes....if I'm routing the command through the system I'm suspending right?

0 Kudos
secgr
Contributor
Contributor

Hi friend,

Even if you use vmrun with the vCenter IP, the actual communication goes through the ESXi where the target VM resides.

You are having this problem because you probably cannot resolve/ping the FQDN of your ESXi from the machine where vmrun is installed/run.

Use your local hosts file under Windows\system32\drivers\etc or use a nameserver that resolves the domain where your ESXi is registered.

- Petros

0 Kudos
NVieira
Contributor
Contributor

Hi,

I'm having the same problem.

I've Vix API installed on a diferent machine of the host.

Both firewalls are turned off, I can ping the host by name...

Thanks for the help.

Nuno

0 Kudos