0

lib cloud を使用して Vcloud に接続しようとしています。認証は firefox の REST API を使用して正常に動作しますが、python では失敗します。私は何かを逃していますか?

__author__ = 'kshk'
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

import libcloud.security



def testConnection():
    #libcloud.security.VERIFY_SSL_CERT = False
    vcloud = get_driver(Provider.VCLOUD)
    driver = vcloud("login", "passwd", host = "https://portal.vcloud")

    nodes = driver.list_nodes()
    print nodes

def main():
    testConnection()

if __name__ == "__main__":
    main()

出力:

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/krishnaa/PycharmProjects/VCloud-API/vcloud_test.py
Traceback (most recent call last):
  File "/Users/krishnaa/PycharmProjects/VCloud-API/vcloud_test.py", line 21, in <module>
    main()
  File "/Users/krishnaa/PycharmProjects/VCloud-API/vcloud_test.py", line 18, in main
    testConnection()
  File "/Users/krishnaa/PycharmProjects/VCloud-API/vcloud_test.py", line 14, in testConnection
    nodes = driver.list_nodes()
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 559, in list_nodes
    return self.ex_list_nodes()
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 573, in ex_list_nodes
    vdcs = self.vdcs
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 407, in vdcs
    self.connection.check_org()  # make sure the org is set.
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 325, in check_org
    self._get_auth_token()
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 835, in _get_auth_token
    headers=self._get_auth_headers())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 973, in request
    self._send_request(method, url, body, headers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1007, in _send_request
    self.endheaders(body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 969, in endheaders
    self._send_output(message_body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 829, in _send_output
    self.send(msg)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 791, in send
    self.connect()
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/httplib_ssl.py", line 96, in connect
    self.timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
4

1 に答える 1

2

「ホスト」引数はURLではなくホスト名のみを想定しているため、コードは機能しません。

次のように変更した場合:

driver = vcloud("login", "passwd", host="portal.vcloud")

それはうまくいくはずです。

于 2014-08-02T15:45:09.403 に答える