2012/2/16 Tomaž Muraus <[email protected]>
>
> In any case, it does look like an auth API issue. I have merged Brad's Auth
> API changes yesterday so please update your trunk and try again - I think
> his changes should fix your problem.
>
I pulled the latest code, and you were right: it fixed the tenantId
KeyError.
Unfortunately, I'm now getting a different error. My interpretation is
that openstack is giving a 300 response because there is a choice of
response formats, but the libcloud driver is treating that as an error,
since OpenStackResponse.success is implemented to do so. Details below.
I've simplified my demo code by removing the (working) Eucalyptus driver
example, and changed the name to stack_demo.py. Here's the listing:
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
STACK_HOST = '50.56.213.226'
USERNAME = 'demo'
PASSWORD = 'password'
def openstack_connect():
Driver = get_driver(Provider.OPENSTACK)
driver = Driver(USERNAME, PASSWORD, host=STACK_HOST, port=8774,
secure=False,
ex_force_auth_url='http://%s:5000' % STACK_HOST,
ex_force_auth_version='2.0_password',
ex_force_base_url='http://%s:8774' % STACK_HOST)
return driver
driver = openstack_connect()
print driver.list_images()
Here's the output:
$ LIBCLOUD_DEBUG=/dev/stderr python stack_demo.py
/Users/jay/Library/Python/2.6/site-packages/Crypto/Util/randpool.py:40:
RandomPool_DeprecationWarning: This application uses RandomPool, which is
BROKEN in older releases. See http://www.pycrypto.org/randpool-broken
RandomPool_DeprecationWarning)
# -------- begin 19425240 request ----------
curl -i -X POST -H 'Host: 50.56.213.226:5000' -H 'Accept-Encoding:
gzip,deflate' -H 'X-LC-Request-ID: 19425240' -H 'Content-Type:
application/json; charset=UTF-8' -H 'Content-Length: 79' -H 'Accept:
application/json' -H 'User-Agent: libcloud/0.8.0 (OpenStack)' --data-binary
'{"auth": {"passwordCredentials": {"username": "demo", "password":
"password"}}}' --compress https://50.56.213.226:5000/v2.0/tokens/
# -------- begin 19425240:19425400 response ----------
HTTP/1.1 200 OK
Date: Fri, 17 Feb 2012 01:45:20 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 772
Vary: X-Auth-Token
{"access": {"token": {"expires": "2012-02-16T17:54:14", "id":
"f436424e-6c7d-43e4-ae7c-30f5553c79f3"}, "serviceCatalog": [{"endpoints":
[{"id": "2", "region": "RegionOne", "internalURL": "
http://50.56.213.226:8773/services/Cloud", "publicURL": "
http://50.56.213.226:8773/services/Cloud"}], "type": "ec2", "name": "ec2"},
{"endpoints": [{"id": "3", "region": "RegionOne", "internalURL": "
http://50.56.213.226:9292/v1", "publicURL": "http://50.56.213.226:9292/v1"}],
"type": "image", "name": "glance"}, {"endpoints": [{"id": "4", "region":
"RegionOne", "internalURL": "http://50.56.213.226:5000/v2.0", "publicURL": "
http://50.56.213.226:5000/v2.0"}], "type": "identity", "name":
"keystone"}], "user": {"id": "a438ea90e1da43e4b895874fdaf83a2d", "roles":
[], "name": "demo"}}}
# -------- end 19425240:19425400 response ----------
# -------- begin 19425240 request ----------
curl -i -X GET -H 'Host: 50.56.213.226:8774' -H 'X-LC-Request-ID: 19425240'
-H 'Accept-Encoding: gzip,deflate' -H 'X-Auth-Token:
f436424e-6c7d-43e4-ae7c-30f5553c79f3' -H 'Content-Length: 0' -H 'Accept:
application/json' -H 'User-Agent: libcloud/0.8.0 (OpenStack)' --compress '
https://50.56.213.226:8774/images/detail?cache-busting=faeee245cd437497'
# -------- begin 19425240:19295688 response ----------
HTTP/1.1 300 Multiple Choices
Date: Fri, 17 Feb 2012 01:45:20 GMT
Content-Length: 327
Content-Type: application/json
{"choices": [{"status": "CURRENT", "media-types": [{"base":
"application/xml", "type":
"application/vnd.openstack.compute+xml;version=2"}, {"base":
"application/json", "type":
"application/vnd.openstack.compute+json;version=2"}], "id": "v2.0",
"links": [{"href": "http://50.56.213.226:8774/v2/images/detail", "rel":
"self"}]}]}
# -------- end 19425240:19295688 response ----------
Traceback (most recent call last):
File "stack_demo.py", line 17, in <module>
print driver.list_images()
File
"/Users/jay/proj/genforma/libcloud.git/libcloud/compute/drivers/openstack.py",
line 209, in list_images
return self._to_images(self.connection.request('/images/detail')
File
"/Users/jay/proj/genforma/libcloud.git/libcloud/compute/drivers/openstack.py",
line 151, in request
method=method, headers=headers)
File
"/Users/jay/proj/genforma/libcloud.git/libcloud/common/openstack.py", line
328, in request
return super(OpenStackBaseConnection, self).request(**kwargs)
File "/Users/jay/proj/genforma/libcloud.git/libcloud/common/base.py",
line 564, in request
connection=self)
File
"/Users/jay/proj/genforma/libcloud.git/libcloud/compute/drivers/openstack.py",
line 774, in __init__
super(OpenStack_1_1_Response, self).__init__(*args, **kwargs)
File "/Users/jay/proj/genforma/libcloud.git/libcloud/common/base.py",
line 77, in __init__
raise Exception(self.parse_error())
File
"/Users/jay/proj/genforma/libcloud.git/libcloud/compute/drivers/openstack.py",
line 111, in parse_error
in body.values()])
TypeError: list indices must be integers, not str