← Back to team overview

openstack team mailing list archive

Re: Programming OpenStack Compute API - 1.1 Mistake

 

Hi Nicolas -
Glad you like the book! Jacek Artymiak gets all the credit for it, and
he wrote and tested it against TryStack. So for now, it uses old-style
Keystone requests as those will work against TryStack.

TryStack plans an upgrade in April, not to steal thunder or anything
from them, but I'd expect we can do updates to the guide after that.

If you wouldn't mind, could you log a doc bug to track that effort,
basically requesting Auth content updates to go with Keystone
light/redux? Log it in http://bugs.launchpad.net/openstack-manuals.

Thanks,
Anne

On Wed, Mar 28, 2012 at 4:10 AM, Nicolas Odermatt <odermattn@xxxxxxxxx> wrote:
> Hello Anne
>
> I am playing with the OpenStack API on my StackOps environment to get an
> idea of how to use it for scripts to programm some little scripts.
> I read the documentation "Programming OpenStack Compute API - 1.1" and tried
> the code examples but at one specific script the machine threw me an error.
> The mentioned script is found in Chapter "2. The Basics" in the section
> "Using Python to Obtain the Authentication Token". If you copy-paste the
> script in a file, adjust the variables like username, password, etc. and
> then execute the file, you will receive a parse error from python:
>
> "root@nova-controller:~# ./gettoken.py
> {"badRequest": {"message": "Cannot parse auth", "code": "400", "details":
> "Expecting object: line 1 column 43 (char 43)"}}
> Traceback (most recent call last):
>   File "./gettoken.py", line 41, in <module>
>     apitoken = dd['auth']['token']['id']
> KeyError: 'auth'"
>
> This is due to the fact that line 39 tries to extract the api token from the
> response ['auth']['token']['id'], which rather ought to be
> ['access']['token']['id']
>
> old: apitoken = dd['auth']['token']['id']
> new: apitoken = dd['access']['token']['id']
>
> As you might have noticed you receive an answer, which states "badRequest".
> From former experience with the API, I remembered that this means that there
> is something wrong with the credentials provided to keystone. I checked the
> params variable and realized that there was no information about the
> tenantid. Therefore I edited the line like this:
>
> old:params = '{"passwordCredentials":{"username":osuser,
> "password":ospassword}}'
> new: params = '{"auth":{"passwordCredentials":{"username": osuser,
> "password":"ospassword"}, "tenantId":ostenant}}'
>
> After that the script worked like a charm. Could it be that this error only
> occurs on StackOps environments or is it a spelling error?
>
> PS: I learned a lot from the "Programming OpenStack Compute API"
> documentation. Thank you very much for this superb how to!
>
> Best regards,
> Nicolas
>
> --
> Freundliche Grüsse,
> Nicolas Odermatt
>


References