vmware-archive / rbvmomi

Ruby interface to the VMware vSphere API.
MIT License
302 stars 174 forks source link

StartProgramInGuest Fails connecting to VM with updated tools #111

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hello. We are having problems using rbvmomi function (StartProgramInGuest) to run simple commands on an VM, the problems occur after updating the version of VMwareTools. It is happening only on Windows guests.

When we use this method with older version of the tools everything works correctly, but afterwards we get an "Invalid Argument" error.

Here is the code we are using:

gom = vim.serviceContent.guestOperationsManager

emsvmauth = RbVmomi::VIM::NamePasswordAuthentication( interactiveSession: false, username: "user", password: "pass" )

emsvmprog = RbVmomi::VIM::GuestProgramSpec(programPath: "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe", arguments: "-Command echo test >C:\TEMP\out.txt")

startup = gom.processManager.StartProgramInGuest( vm: emsvm, auth: emsvmauth, spec: emsvmprog )

When we use the script with the VMwareTools version 9.0.12 everything work fine, but after updating (to 10.0.9) we get this error:

RbVmomi::Fault: InvalidArgument: A specified parameter was not correct:
from /opt/rh/cfme-gemset/gems/rbvmomi-1.8.2/lib/rbvmomi/connection.rb:61:in parse_response' from /opt/rh/cfme-gemset/gems/rbvmomi-1.8.2/lib/rbvmomi/connection.rb:90:incall' from /opt/rh/cfme-gemset/gems/rbvmomi-1.8.2/lib/rbvmomi/basic_types.rb:205:in _call' from /opt/rh/cfme-gemset/gems/rbvmomi-1.8.2/lib/rbvmomi/basic_types.rb:74:inblock (2 levels) in init' from (irb):374 from /opt/rh/cfme-gemset/gems/railties-5.0.2/lib/rails/commands/console.rb:65:in start' from /opt/rh/cfme-gemset/gems/railties-5.0.2/lib/rails/commands/console_helper.rb:9:instart' from /opt/rh/cfme-gemset/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:78:in console' from /opt/rh/cfme-gemset/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:inrun_command!' from /opt/rh/cfme-gemset/gems/railties-5.0.2/lib/rails/commands.rb:18:in <top (required)>' from bin/rails:4:inrequire' from bin/rails:4:in `

'

We have tried the same attempt with pyvmomi and we are getting the same error (We will open another issue on their git project).

Maybe it is due to any change on the SDK on the communication between vCenter and VMwareTools agent. Thanks advance. Best regards.

alv000h commented 7 years ago

+1

jrgarcia commented 7 years ago

I'm sorry to hear that caused an error! Unfortunately, that command is doing nothing more than making a SOAP call. There isn't anything rbvmomi can do to prevent this. I'll see if I can find someone that can answer why that may be happening, but I can't imagine this being fixed from within rbvmomi.

jrgarcia commented 7 years ago

It appears this may be an issue in VMware Tools and there isn't anything we can do on the RbVmomi side to handle this. Hopefully, there will be a fix for this soon and this won't be a problem for you anymore. I'm going to go ahead and close this since we can't do anything on our end. Thanks for reporting!

alv000h commented 7 years ago

There is a workaround, it should work if you define username like this : username: "WINDOWS_hostname\User",

PD.- change WINDOWS_hostname for the real windows configured hostname as per needed.