PySphere send_file HTTP 500 error

366 views Asked by At

I am using pysphere to interface with my esxi server.

One of the functions I am trying to use is send_file (Explained here). That results in the following exception:

  File "/usr/local/lib/python2.7/dist-packages/pysphere/vi_virtual_machine.py", line 1282, in send_file
    resp = opener.open(request)
  File "/usr/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 500: Internal Server Error

I have enabled trace files, and they look like this (I am showing the response)

RESPONSE:
200
OK
-------
Date: Wed, 10 Dec 2014 07:03:21 GMT
Cache-Control: no-cache
Connection: Keep-Alive
Content-Type: text/xml; charset=utf-8
Content-Length: 521

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<InitiateFileTransferToGuestResponse xmlns="urn:vim25"><returnval>https://*:443/guestFile?id=11&amp;token=52548475-79f4-6b02-a207-be5d1e3b0a8511</returnval></InitiateFileTransferToGuestResponse>
</soapenv:Body>
</soapenv:Envelope>

On the esxi server itself I can see in the Recent Tasks that a request has been made to transfer a file.

At this stage I am stumped. I have checked all my settings at least five times. I have tested that I am capable of performing other actions, and they all seem to work fine. What can I do about this? Is there some setting I need to enable in the esxi server? the VM? something on the firewall maybe?

A similar problem: https://code.google.com/p/pysphere/issues/detail?id=53


Edit: What I want to do is be able to transfer files to the VM. If there is an alternate and reliable method that would be good too.

1

There are 1 answers

0
Борис Иванов On

I tried to use send_file in pysphere, it was painfull and slow. For some reason sending files has problem with binary files. My workaround: create iso file with your binaries, mount it in virtual machine(pysphere api exists for it), create bat-file( it should find right cdrom and copy your files). Send batch by send_file. Run it by start-process.

Yapp, send_files has troubles with big files and need to use little hack https://code.google.com/p/pysphere/issues/detail?id=16