PySphere send_file HTTP 500错误

时间:2014-12-10 15:41:23

标签: python python-2.7 vsphere esxi pysphere

我正在使用pysphere与我的esxi服务器进行交互。

我尝试使用的函数之一是send_file(Explained here)。这导致以下异常:

  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

我启用了跟踪文件,它们看起来像这样(我正在显示响应)

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>

在esxi服务器本身上,我可以在Recent Tasks中看到已经请求传输文件。

在这个阶段,我很难过。我已经检查了所有设置至少五次。我已经测试过我能够执行其他操作,而且它们似乎都能正常工作。我该怎么办?我需要在esxi服务器中启用一些设置吗? VM?防火墙上的东西可能吗?

类似的问题:https://code.google.com/p/pysphere/issues/detail?id=53


编辑:我想要做的是能够将文件传输到VM。如果有一种替代且可靠的方法也会很好。

1 个答案:

答案 0 :(得分:0)

我试图在pysphere中使用send_file,这很痛苦而且很慢。 由于某些原因,发送文件有二进制文件的问题。 我的解决方法:用你的二进制文件创建iso文件,将它挂载到虚拟机(pysphere api存在),创建bat文件(它应该找到正确的cdrom并复制你的文件)。通过send_file发送批处理。通过start-process运行它。

Yapp,send_files有大文件的麻烦,需要使用小hack https://code.google.com/p/pysphere/issues/detail?id=16