[Openstack] 401 Not Authorized from glance - How to fix ?

Rafael Durán Castañeda rafadurancastaneda at gmail.com
Fri Jun 1 20:04:14 UTC 2012


El 01/06/12 19:43, Anne Gentle escribió:
> Several thoughts to ponder. One is, the nova image-list command is
> using the Compute API, not the Image API. You can turn on --debug to
> see the curl statement issued from the nova client (very handy, that).
> Do:
> nova --debug image-list
> to see what I mean.
>
> Also note there's a new bugfix for python-novaclient
> (https://review.openstack.org/#/c/7200/) that fixes a problem with
> prettyprint 0.6 removing printt (so it uses get_string now with the
> latest version).
>
> Also, I'd definitely point you to this guide as it has drop-in python
> code for requesting a token:
> http://docs.openstack.org/api/openstack-compute/programmer/content/using-python-to-obtain-the-authentication-token.html
>
> Usually when I get an error from the Image API (Glance) it's because I
> didn't put the proper paste-deploy filter in one of the Glance conf
> files. If you're the cloud admin in this case, double-check your
> glance config with:
> http://docs.openstack.org/trunk/openstack-compute/install/content/configure-glance-files.html
>
> If you're not the cloud admin, also know that the Image API isn't
> publicly available on many public clouds such as TryStack.
>
> Hope this is helpful.
> Anne
>
> On Fri, Jun 1, 2012 at 12:20 PM, Mandar Vaze / मंदार वझे
> <mandarvaze at gmail.com>  wrote:
>> Hi,
>>
>> I'm working on python program that needs to get images detail from glance.
>> I was using "get_admin_context" earlier to do all the work in nova side, but
>> this doesn't seem to work when I query glance.
>> I get "401 Not Authorized" error.
>>
>> I think I need to get auth_token from keystone, and use it when creating
>> RequestContext object - then glance query might work. (Is this assumption
>> correct, in the first place)  But I do not know how to do this
>> programatically, I looked at "nova image-list" command, but I didn't get
>> clear picture on how this should be done.
>>
>> Can you point to any existing code that authenticates with keystone and then
>> uses the auth-token to talk to glance ?
>>
>> Thanks,
>> -Mandar
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~openstack
>> Post to     : openstack at lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~openstack
>> More help   : https://help.launchpad.net/ListHelp
>>
> _______________________________________________
> Mailing list: https://launchpad.net/~openstack
> Post to     : openstack at lists.launchpad.net
> Unsubscribe : https://launchpad.net/~openstack
> More help   : https://help.launchpad.net/ListHelp
Using python-keystoneclient on glance server:

 >>> import keystoneclient.v2_0.client as k_client
 >>> kc = 
k_client.Client(username='user',password='pass',tenant_name='tenant',auth_url="http://url:35357/v2.0")
 >>> kc.auth_token
u'07faf8d1e2b140aa9da3079949af7de6'
 >>> import glance.client as g_client
 >>> gc = g_client.Client(host='localhost', auth_tok=kc.auth_token)
 >>> gc.get_images()
[{u'name': u'tty-linux-kernel', u'container_format': u'aki', 
u'disk_format': u'aki', u'checksum': 
u'79427f585fcc90792ea2df8f476df79e', u'id': 
u'ad11d686-d893-4379-a89f-1dd3e8ee79a2', u'size': 4438032}, {u'name': 
u'tty-linux', u'container_format': u'ami', u'disk_format': u'ami', 
u'checksum': u'911439879a8f1fdb83aa7e2480520661', u'id': 
u'5ce20d5d-4dee-492f-be87-e66dc2a84290', u'size': 25165824}, {u'name': 
u'ubuntu-12.04-server-cloudimg-amd64-official', u'container_format': 
u'bare', u'disk_format': u'qcow2', u'checksum': 
u'df4256e6c361380cb7613c74130feca9', u'id': 
u'34599355-bed1-4e16-b0c0-2695d92a3e22', u'size': 226426880}, {u'name': 
u'ubuntu-precise-40GB-amd64', u'container_format': u'bare', 
u'disk_format': u'qcow2', u'checksum': 
u'91a014dd7483eaaabe55074342c748f3', u'id': 
u'57bcd266-8831-465f-b76f-2aeb8736584c', u'size': 622460928}, {u'name': 
u'tty-linux-kernel', u'container_format': u'aki', u'disk_format': 
u'aki', u'checksum': u'79427f585fcc90792ea2df8f476df79e', u'id': 
u'4744184b-e7c3-4ee1-af2f-f77a9ef65e5b', u'size': 4438032}, {u'name': 
u'tty-linux', u'container_format': u'ami', u'disk_format': u'ami', 
u'checksum': u'911439879a8f1fdb83aa7e2480520661', u'id': 
u'01a5bdb2-b41b-48ee-a571-7c517f1fde07', u'size': 25165824}, {u'name': 
u'tty-linux', u'container_format': u'ami', u'disk_format': u'ami', 
u'checksum': u'911439879a8f1fdb83aa7e2480520661', u'id': 
u'df244f77-e868-4473-bee6-fe5f1f513c5f', u'size': 25165824}, {u'name': 
u'tty-linux-kernel', u'container_format': u'aki', u'disk_format': 
u'aki', u'checksum': u'79427f585fcc90792ea2df8f476df79e', u'id': 
u'2902fc1d-cb32-4cf2-ac69-fecf611a620d', u'size': 4438032}]




More information about the Openstack mailing list