Ask Your Question
2

Why doesn't this libcloud app connect?

asked 2015-09-12 13:05:02 -0500

nickchase gravatar image

updated 2015-09-18 00:42:45 -0500

i'm trying to use the firstapp tutorial and I'm sure I'm missing something obvious. here's my code:

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

auth_username = 'admin'
auth_password = 'admin'
auth_url = 'http://172.16.0.2:5000/v2.0/'
project_name = 'admin'
region_name = 'RegionOne'

provider = get_driver(Provider.OPENSTACK)
conn = provider(auth_username,
                auth_password,
                ex_force_auth_url=auth_url,
                ex_force_auth_version='2.0_password',
                ex_tenant_name=project_name,
                ex_force_service_region=region_name)

flavors = conn.list_sizes()
for flavor in flavors:
    print(flavor)

The credentials should work; I've tried them manually:

nick@virtualdocs:~/pythonfirstapp$ nova --os-username=admin --os-tenant-name=admin --os-auth-url=http://172.16.0.2:5000/v2.0 list
OS Password:
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+

And yet, when I run the python app, I'm getting an error:

Traceback (most recent call last):
  File "sample.py", line 18, in <module>
    flavors = conn.list_sizes()
  File "/usr/local/lib/python2.7/dist-packages/libcloud/compute/drivers/openstack.py", line 246, in list_sizes
    self.connection.request('/flavors/detail').object)
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 200, in request
    raw=raw)
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/base.py", line 657, in request
    action = self.morph_action_hook(action)
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 255, in morph_action_hook
    self._populate_hosts_and_request_paths()
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 288, in _populate_hosts_and_request_paths
    osa = osa.authenticate(**kwargs)  # may throw InvalidCreds
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack_identity.py", line 841, in authenticate
    return self._authenticate_2_0_with_password()
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack_identity.py", line 866, in _authenticate_2_0_with_password
    return self._authenticate_2_0_with_body(reqbody)
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack_identity.py", line 871, in _authenticate_2_0_with_body
    method='POST')
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/base.py", line 736, in request
    response = responseCls(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/base.py", line 117, in __init__
    raise Exception(self.parse_error())
Exception: {"error": {"message": "get_version_v2() got an unexpected keyword argument 'auth'", "code": 400, "title": "Bad Request"}}

I'm running this on Ubuntu 12.04 in VirtualBox, against Mirantis OpenStack 6.1. I'm sure I'm missing something obvious but for the life of me I can't see what it is.

Thanks in advance....

[UPDATE: I've since successfully connected using JClouds, so there's nothing wrong with the OpenStack install itself.]

[Second UPDATE: In response to the suggestion that I missed the "v" in the authentication URL -- thanks! -- I've updated the code and the response. Unfortunately it still doesn't work. :( ]

edit retag flag offensive close merge delete

Comments

you need to check Nova logs to get the full picture

smaffulli gravatar imagesmaffulli ( 2016-01-15 10:45:14 -0500 )edit

@nickchase Have you tried out it?

liaodalin19903 gravatar imageliaodalin19903 ( 2017-09-14 02:15:01 -0500 )edit

4 answers

Sort by ยป oldest newest most voted
0

answered 2015-09-14 10:56:52 -0500

miguelgrinberg gravatar image

Try setting your auth url as follows:

 auth_url = 'http://172.16.0.2:5000/v2.0/'

There is a missing 'v' in the last portion, I think.

edit flag offensive delete link more

Comments

Still no joy. I've updated the question to reflect the new code, as well as the new error. :(

nickchase gravatar imagenickchase ( 2015-09-18 01:21:37 -0500 )edit

Can we use v3? how to use v3?

liaodalin19903 gravatar imageliaodalin19903 ( 2017-09-14 02:09:50 -0500 )edit
0

answered 2016-02-12 11:06:27 -0500

macleanal gravatar image

I experienced this same error, but then by appending '/tokens' to the auth_url I connected successfully.

edit flag offensive delete link more
0

answered 2016-07-18 06:06:25 -0500

heena gravatar image

Getting the same error. Has there been an answer to this? Is python or openstack version an issue?

edit flag offensive delete link more

Comments

@heena Have you tried out it>\?

liaodalin19903 gravatar imageliaodalin19903 ( 2017-09-14 02:17:27 -0500 )edit
0

answered 2015-09-20 10:11:43 -0500

avi gravatar image

Using libcloud version 0.17.1-dev (libcloud/__init__.py defines __version__) against latest devstack -- works for me. Please note that if I append /v2.0/ to auth_url then I get identical error as you did.

Here is my libcloud snippet:

from pprint import pprint

from libcloud.compute.providers import get_driver \
    as compute_get_driver
from libcloud.compute.types import Provider as compute_provider

USER_NAME = 'admin'
PASSWORD = 'labstack'
TENANT_NAME = 'admin'
AUTH_URL = 'http://xx.xx.xx.xx:5000'
region_name = 'RegionOne'

driver = compute_get_driver(compute_provider.OPENSTACK)(
    USER_NAME, PASSWORD, ex_tenant_name=TENANT_NAME,
    ex_force_auth_url=AUTH_URL,
    ex_force_auth_version='2.0_password',
    ex_force_service_region=region_name)

images = driver.list_images()
sizes = driver.list_sizes()

pprint(images)
pprint(sizes)

Running it gives the below output:

[<NodeImage: id=56c1cdb1-1db2-45fc-9465-31c47e0aefab, name=cirros-0.3.4-x86_64-uec, driver=OpenStack  ...>,
 <NodeImage: id=28c0ee08-8986-43ee-b769-41d9103d9931, name=cirros-0.3.4-x86_64-uec-ramdisk, driver=OpenStack  ...>,
 <NodeImage: id=0365d096-f0a7-4eef-a0d0-a509f38f3008, name=cirros-0.3.4-x86_64-uec-kernel, driver=OpenStack  ...>]
[<OpenStackNodeSize: id=1, name=m1.tiny, ram=512, disk=1, bandwidth=None, price=0.0, driver=OpenStack, vcpus=1,  ...>,
 <OpenStackNodeSize: id=2, name=m1.small, ram=2048, disk=20, bandwidth=None, price=0.0, driver=OpenStack, vcpus=1,  ...>,
 <OpenStackNodeSize: id=3, name=m1.medium, ram=4096, disk=40, bandwidth=None, price=0.0, driver=OpenStack, vcpus=2,  ...>,
 <OpenStackNodeSize: id=4, name=m1.large, ram=8192, disk=80, bandwidth=None, price=0.0, driver=OpenStack, vcpus=4,  ...>,
 <OpenStackNodeSize: id=42, name=m1.nano, ram=64, disk=0, bandwidth=None, price=0.0, driver=OpenStack, vcpus=1,  ...>,
 <OpenStackNodeSize: id=5, name=m1.xlarge, ram=16384, disk=160, bandwidth=None, price=0.0, driver=OpenStack, vcpus=8,  ...>,
 <OpenStackNodeSize: id=84, name=m1.micro, ram=128, disk=0, bandwidth=None, price=0.0, driver=OpenStack, vcpus=1,  ...>]
edit flag offensive delete link more

Comments

But when I list_images() there comes object of type 'bool' has no len() error.

liaodalin19903 gravatar imageliaodalin19903 ( 2017-09-14 02:23:46 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2015-09-12 13:05:02 -0500

Seen: 643 times

Last updated: Jul 18 '16