rackspace/ruby-openstack-compute — Issue #10: Keystone api expects tenant id or tenant name
Author: flaviamissi
Created: 2012-01-11 14:03:59+00:00
State: open

In order to list the service catalog as expected, keystone api needs to receive which tenant the user used belongs to.
Look:
Without a tenant
request:
`$ curl -d '{"auth":{"passwordCredentials":{"username": "admin", "password": "openstack"}}}' -H "Content-type: application/json" http://10.2.122.150:35357/v2.0/tokens`

response:
`{"access": {"token": {"expires": "2012-01-12T11:28:33", "id": "8ad5d095-c2f3-4f9d-ad80-736573be6401"}, "user": {"id": "1", "roles": [{"id": "1", "name": "Admin"}, {"id": "3", "name": "KeystoneAdmin"}, {"id": "4", "name": "KeystoneServiceAdmin"}], "name": "admin"}}}`

With a tenant
request:
`$ curl -d '{"auth":{"passwordCredentials":{"username": "admin", "password": "openstack"}, "tenantName": "admin"}}' -H "Content-type: application/json" http://10.2.122.150:35357/v2.0/tokens`

response:
`{"access": {"token": {"expires": "2015-02-05T00:00:00", "id": "openstack", "tenant": {"id": "1", "name": "admin"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://10.2.122.150:8774/v1.1/1", "region": "RegionOne", "internalURL": "http://10.2.122.150:8774/v1.1/1", "publicURL": "http://10.2.122.150:8774/v1.1/1"}], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": "http://10.2.122.150:8773/services/Admin", "region": "RegionOne", "internalURL": "http://10.2.122.150:8773/services/Cloud", "publicURL": "http://10.2.122.150:8773/services/Cloud"}], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://10.2.122.150:9292/v1", "region": "RegionOne", "internalURL": "http://10.2.122.150:9292/v1", "publicURL": "http://10.2.122.150:9292/v1"}], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "http://10.2.122.150:35357/v2.0", "region": "RegionOne", "internalURL": "http://10.2.122.150:5000/v2.0", "publicURL": "http://10.2.122.150:5000/v2.0"}], "type": "identity", "name": "keystone"}], "user": {"id": "1", "roles": [{"tenantId": "1", "id": "1", "name": "Admin"}, {"id": "1", "name": "Admin"}, {"id": "3", "name": "KeystoneAdmin"}, {"id": "4", "name": "KeystoneServiceAdmin"}], "name": "admin"}}}`

As you can see, there is no serviceCatalog in the response without a tenant, what causes an error when following the example in your readme, the error is in the following line, when attempting to to iterate an inexistente key:

``` ruby
resp_data['access']['serviceCatalog'].each do |service|
```

Are you aware of it? Am I missing something? Because as far as I can see in the code, there's no way to pass the tenant id, as I did in the curl example, to the json sent to the server.

I know it is easy to solve, and I will do it, but I need to be sure that I am not missing something stupid before to start.