pysphere VIServer connect method to different protocol, port

1,064 views
Skip to first unread message

patrick

unread,
Jul 20, 2012, 9:37:09 AM7/20/12
to pysp...@googlegroups.com
Hi, 
I would like to connect to vCenter using the http port 8080. Here's my sample code, but it's returning an error. I believe it's because of the "http://" part of the address. If I leave that off, pysphere assumes it's ssl and that doesn't work either. Is there a way to tell pysphere to use https or not? 
Thanks

with protocol as part of the vCenter address ....

from pysphere import VIServer
server = VIServer()
server.connect("http://192.168.0.104:8080", "root", "vmware")

Traceback (most recent call last):
  File "test_pysphere.py", line 3, in <module>
    server.connect("http://192.168.0.104:8080", "root", "vmware")
  File "build/bdist.macosx-10.7-intel/egg/pysphere/vi_server.py", line 85, in connect
  File "build/bdist.macosx-10.7-intel/egg/pysphere/resources/VimService_services.py", line 2175, in RetrieveServiceContent
  File "build/bdist.macosx-10.7-intel/egg/pysphere/ZSI/client.py", line 544, in Receive
  File "build/bdist.macosx-10.7-intel/egg/pysphere/ZSI/client.py", line 429, in ReceiveSOAP
TypeError: Response is "text/html", not "text/xml"


without protocol hitting 8080 ...

from pysphere import VIServer
server = VIServer()
server.connect("192.168.0.104:8080", "root", "vmware")

Traceback (most recent call last):
  File "test_pysphere.py", line 3, in <module>
    server.connect("192.168.0.104:8080", "root", "vmware")
  File "build/bdist.macosx-10.7-intel/egg/pysphere/vi_server.py", line 85, in connect
  File "build/bdist.macosx-10.7-intel/egg/pysphere/resources/VimService_services.py", line 2173, in RetrieveServiceContent
  File "build/bdist.macosx-10.7-intel/egg/pysphere/ZSI/client.py", line 296, in Send
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1144, in connect
    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 344, in wrap_socket
    ciphers=ciphers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 121, in __init__
    self.do_handshake()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 283, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [Errno 1] _ssl.c:499: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Seba

unread,
Jul 30, 2012, 7:51:55 AM7/30/12
to pysp...@googlegroups.com
Hi Patrik,

   Try with this URL instead: "http://192.168.0.104:8080/sdk", when providing just the IP address or hostname, pysphere looks the default localtion "https://[IP or HOSTNAME]:443/sdk". The webservice is in the "/sdk" resource (the root url is the HTML page from which you can download the VIClient tool) you were missing that.

Regards,

Seba.
Reply all
Reply to author
Forward
0 new messages