/usr/lib/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/packages/urllib3/connectionpool.py:768: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html看起來就是因為連線要使用 HTTPS,但是沒有給予憑證的問題~。
不過簡單地搜尋一下,就看到 [1] 的解法,只要把 requests 這個套件的警告關掉就可以了。
import atexit import requests from pyVim import connect # Disable the checking of certification. requests.packages.urllib3.disable_warnings() # Initiate the connection to VMware vSphere. service_instance = connect.SmartConnect( host="192.168.200.200", user="administrator@vsphere.local", pwd="qwer", port=443) atexit.register(connect.Disconnect, service_instance) # Get the session ID from the connection. session_id = service_instance.content.sessionManager.currentSession.key print("Session ID: %s" % session_id)
程式印出的回覆如下:
Session ID: 521eab6e-7ef1-d7e6-1f67-ba38dd7e2487
參考資料:
沒有留言:
張貼留言