2012/2/15 Tomaž Muraus <to...@apache.org>

>
> Can you please attach the code which shows how you are instantiating the
> OpenStack driver (don't forget to mask / remove the credentials)?
>

The code was attached to my last message, but I'll put it here in the body
as well:

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

def eucalyptus_connect():
    Driver = get_driver(Provider.EUCALYPTUS)
    driver = Driver(USERNAME, PASSWORD, host=STACK_HOST, port=8773,
secure=False,
                  path="/services/Cloud")
    return driver

print eucalyptus_connect().list_images()
print openstack_connect().list_images()

It would be also be useful to paste the output of
> LIBCLOUD_DEBUG=/dev/stderr python stack_test.py.
>

jay@alu:~/proj/genforma/libcloud.git$ LIBCLOUD_DEBUG=/dev/stderr python
stack_test.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 19324600 request ----------
curl -i -X GET -H 'Host: 50.56.213.226:8773' -H 'X-LC-Request-ID: 19324600'
-H 'Content-Length: 0' -H 'Accept-Encoding: gzip,deflate' -H 'User-Agent:
libcloud/0.8.0 (Eucalyptus)' --compress '
https://50.56.213.226:8773/services/Cloud?SignatureVersion=2&AWSAccessKeyId=demo&Timestamp=2012-02-16T18%3A01%3A45Z&SignatureMethod=HmacSHA256&Version=2010-08-31&Signature=%2Fpmh1RDZacElc0hVwojf8rQvMCntjPAkTlg0bGv2woo%3D&Action=DescribeImages
'
# -------- begin 19324600:19296584 response ----------
HTTP/1.1 200 OK
Date: Thu, 16 Feb 2012 18:01:53 GMT
Content-Length: 911
Content-Type: text/xml

<?xml version="1.0" ?><DescribeImagesResponse xmlns="
http://ec2.amazonaws.com/doc/2010-08-31/";><requestId>req-f2405b03-2463-48a6-80fd-9af99e8de768</requestId><imagesSet><item><description/><imageOwnerId/><isPublic>true</isPublic><imageId>aki-00000001</imageId><imageState>available</imageState><architecture/><imageLocation>None
(oneiric-server-cloudimg-amd64-kernel)</imageLocation><rootDeviceType>instance-store</rootDeviceType><rootDeviceName>/dev/sda1</rootDeviceName><imageType>kernel</imageType></item><item><description/><imageOwnerId/><isPublic>true</isPublic><imageId>ami-00000002</imageId><imageState>available</imageState><rootDeviceType>instance-store</rootDeviceType><architecture/><imageLocation>None
(oneiric-server-cloudimg-amd64)</imageLocation><kernelId>aki-00000001</kernelId><rootDeviceName>/dev/sda1</rootDeviceName><imageType>machine</imageType></item></imagesSet></DescribeImagesResponse>
# -------- end 19324600:19296584 response ----------

[<NodeImage: id=aki-00000001, name=None
(oneiric-server-cloudimg-amd64-kernel), driver=Eucalyptus  ...>,
<NodeImage: id=ami-00000002, name=None (oneiric-server-cloudimg-amd64),
driver=Eucalyptus  ...>]
# -------- begin 19457048 request ----------
curl -i -X POST -H 'Host: 50.56.213.226:5000' -H 'Accept-Encoding:
gzip,deflate' -H 'X-LC-Request-ID: 19457048' -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 19457048:19481464 response ----------
HTTP/1.1 200 OK
Date: Thu, 16 Feb 2012 18:01:53 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 19457048:19481464 response ----------

Traceback (most recent call last):
  File "stack_test.py", line 25, in <module>
    print openstack_connect().list_images()
  File "stack_test.py", line 15, in openstack_connect
    ex_force_base_url='http://%s:8774' % STACK_HOST)
  File
"/Users/jay/proj/genforma/libcloud.git/libcloud/compute/drivers/openstack.py",
line 795, in __init__
    super(OpenStack_1_1_NodeDriver, self).__init__(*args, **kwargs)
  File "/Users/jay/proj/genforma/libcloud.git/libcloud/compute/base.py",
line 397, in __init__
    api_version=api_version)
  File "/Users/jay/proj/genforma/libcloud.git/libcloud/common/base.py",
line 802, in __init__
    self.connection.connect()
  File "/Users/jay/proj/genforma/libcloud.git/libcloud/common/base.py",
line 427, in connect
    if getattr(self, 'base_url', None) and base_url == None:
  File
"/Users/jay/proj/genforma/libcloud.git/libcloud/common/openstack.py", line
249, in base_url
    return self._get_base_url(url_key=self._url_key)
  File
"/Users/jay/proj/genforma/libcloud.git/libcloud/common/openstack.py", line
254, in _get_base_url
    self._populate_hosts_and_request_paths()
  File
"/Users/jay/proj/genforma/libcloud.git/libcloud/common/openstack.py", line
300, in _populate_hosts_and_request_paths
    self.tenant_ids[service_type] = service['endpoints'][0]['tenantId']
KeyError: 'tenantId'

>
> In any case, Brad Morgan has recently made some changes and improvements to
> the OpenStack authentication classes -
> https://github.com/apache/libcloud/pull/58. Now the tenantId is not
> automatically parsed from the auth API response anymore and this might fix
> your problem. His changes should be merged to trunk soon - probably today
> or tomorrow.
>

Great!  Thanks for the help.

Jay

>
> On Wed, Feb 15, 2012 at 9:06 PM, Jay Doane <j...@almery.com> wrote:
>
> > Greetings,
> >
> > I followed the directions at http://devstack.org/guides/single-vm.htmlto
> > deploy OpenStack on a single host, and everything works as expected from
> > the web interface.
> >
> > I would like to access my OpenStack dev environment with (a recent dev
> > version oflibcloud, but seem to only be able to do so using the
> Eucalyptus
> > driver; the OpenStack driver gives me the following error (running the
> > attached code):
> >
> > jay@alu:~/proj/genforma/libcloud.git$ python stack_test.py
> > [<NodeImage: id=aki-00000001, name=None
> > (oneiric-server-cloudimg-amd64-kernel), driver=Eucalyptus  ...>,
> > <NodeImage: id=ami-00000002, name=None (oneiric-server-cloudimg-amd64),
> > driver=Eucalyptus  ...>]
> > Traceback (most recent call last):
> >   File "stack_test.py", line 23, in <module>
> >     print openstack_connect().list_images()
> >   File "stack_test.py", line 13, in openstack_connect
> >     ex_force_base_url='http://%s:8774' % STACK_HOST)
> >   File
> >
> "/Users/jay/proj/genforma/libcloud.git/libcloud/compute/drivers/openstack.py",
> > line 795, in __init__
> >     super(OpenStack_1_1_NodeDriver, self).__init__(*args, **kwargs)
> >   File "/Users/jay/proj/genforma/libcloud.git/libcloud/compute/base.py",
> > line 397, in __init__
> >     api_version=api_version)
> >   File "/Users/jay/proj/genforma/libcloud.git/libcloud/common/base.py",
> > line 802, in __init__
> >     self.connection.connect()
> >   File "/Users/jay/proj/genforma/libcloud.git/libcloud/common/base.py",
> > line 427, in connect
> >     if getattr(self, 'base_url', None) and base_url == None:
> >   File
> > "/Users/jay/proj/genforma/libcloud.git/libcloud/common/openstack.py",
> line
> > 249, in base_url
> >     return self._get_base_url(url_key=self._url_key)
> >   File
> > "/Users/jay/proj/genforma/libcloud.git/libcloud/common/openstack.py",
> line
> > 254, in _get_base_url
> >     self._populate_hosts_and_request_paths()
> >   File
> > "/Users/jay/proj/genforma/libcloud.git/libcloud/common/openstack.py",
> line
> > 300, in _populate_hosts_and_request_paths
> >     self.tenant_ids[service_type] = service['endpoints'][0]['tenantId']
> > KeyError: 'tenantId'
> >
> > Has anyone else successfully used the libcloud OpenStack driver to access
> > a recent devstack deployment?  Or is there something obviously wrong with
> > how I'm instantiating my OpenStack driver?
> >
> > Thanks,
> > Jay
> >
> >
> >
> >
>

Reply via email to