axxyhtrx / pysphere

Automatically exported from code.google.com/p/pysphere
0 stars 0 forks source link

send_file() times out #53

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Connect to server using pysphere
2. vm1.send_file('/root/test.txt', r'c:\temp\test.txt')
3. This times out.

What is the expected output? What do you see instead?
The test.txt file should be copied to the virtual machine's filesystem.
Instead, I get a stacktrace that the network call timed out.

What version of the product are you using? On what operating system?
pysphere 0.1.8 from pypi on CentOS 6.4 connecting to a Windows 2003 vm.
The vsphere host is running api version 5.0

Please provide any additional information below.

I can successfully execute make_directory(), delete_direcory() and 
list_files(), which is great!

But when I attempt to execute send_file() I get a timeout with a traceback.

Traceback (most recent call last):
  File "./clean-pushfile.py", line 15, in <module>
    saltvm.send_file('/root/test.txt', r'c:\salttemp\test.txt')
  File "/usr/lib/python2.6/site-packages/pysphere/vi_virtual_machine.py", line 1303, in send_file
    resp = urllib2.urlopen(request)
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1198, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 110] Connection timed out>

Doing some old school print debugging, I've discovered that the urllib2 request 
isn't going to the IP of the server running the vsphere api, it's going to the 
IP of the vmware host that is hosting the windows vm I'm trying to push this 
file to.

I couldn't track down in the code exactly where this switch is happening, or 
even if this is correct behavior. The vmware host isn't running the vsphere api.

Am I missing a configuration option? I think I have everything configured 
correctly because I can successfully use make_directory() and 
delete_directory() to create and delete a directory on the vm.

Here's the python script I've been testing with:

from pysphere import VIServer

server = VIServer()

server.connect('<vsphere ip address>', '<username>', '<password>', 
trace_file='/root/debug.txt')

print 'VMware api: ', server.get_api_version()

saltvm = server.get_vm_by_name('SaltTesting05')

print 'Server status: ', saltvm.get_status()

saltvm.login_in_guest('<username>', '<password>')

saltvm.send_file('/root/test.txt', r'c:\salttemp\test.txt')

Original issue reported on code.google.com by bou...@gmail.com on 19 Feb 2014 at 10:14