[Openstack] Get tenant by name
Peter Scott
Peter.J.Scott at jpl.nasa.gov
Fri Jan 16 01:33:23 UTC 2015
I spoke too fast. I looked at the API again and saw that it said
name... not Name. In fact, both of these work to return a single tenant
by name:
...tenants?{name=Jet-Home}
../tenants?name=Jet-Home
So, case-sensitive. I don't think there is a way to generate that URL
through the Python binding, though. I will see if I can create a patch.
On 1/15/2015 5:27 PM, Peter Scott wrote:
> I wasn't reading the debug output closely enough and didn't see before
> that my keystone command generates a URL of ...tenants/{Name=Jet-Home}
> instead of the suggested one of ...tenants?{Name=Jet-Home}. I also
> received a suggestion in direct email to try .../tenants?Name=Jet-Home.
>
> I resorted to curl to try both of those, and each one returns the
> entire list of tenants.
>
> I also tried putting the name in a request body (I didn't think you
> could send data in a GET request, but apparently you can, and it is
> expecting and parsing JSON):
>
> curl -i -X GET 'https://proxy.nebula-dev:35357/v2.0/tenants' -d
> '{"Name":"Jet-Home"}' -H "User-Agent: python-keystoneclient" -H
> "Content-type: application/json" -H "X-Auth-Token: REDACTED"
>
> and that just returns the entire list of tenants also.
>
> (If I don't set the Content-type, I get "Expecting to find
> application/json in Content-Type header".)
>
> This isn't exactly a deal breaker, but the API doc does say that a
> lookup by name should work, and I'd like to know if there's a way to
> do that or whether the doc or the implementation are in error.
>
> On 1/15/2015 2:41 PM, Peter Scott wrote:
>> I tried this approach with the following command line:
>>
>> $ keystone --debug tenant-get '{name=Jet-Home}'
>>
>> It didn't work; it seems that it doesn't work because it doesn't like
>> the proposed syntax:
>>
>> DEBUG:keystoneclient.auth.identity.v2:Making authentication request
>> to https://proxy.nebula-dev:8770/v2.0/tokens
>> INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS
>> connection (1): proxy.nebula-dev
>> DEBUG:requests.packages.urllib3.connectionpool:"POST /v2.0/tokens
>> HTTP/1.1" 200 2966
>>
>> Looks like it generated the right call:
>>
>> DEBUG:keystoneclient.session:REQ: curl -i -X GET
>> https://proxy.nebula-dev:35357/v2.0/tenants/{name=Jet-Home} -H
>> "User-Agent: python-keystoneclient" -H "X-Auth-Token: TOKEN_REDACTED"
>> INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS
>> connection (1): proxy.nebula-dev
>> DEBUG:requests.packages.urllib3.connectionpool:"GET
>> /v2.0/tenants/%7Bname=Jet-Home%7D HTTP/1.1" 404 101
>>
>> But it didn't like that (404 not found):
>>
>> DEBUG:keystoneclient.session:RESP:
>> DEBUG:keystoneclient.session:Request returned failure status: 404
>>
>> This is where it falls back to fetching all tenants to search within
>> the list client-side:
>>
>> DEBUG:keystoneclient.session:REQ: curl -i -X GET
>> https://proxy.nebula-dev:35357/v2.0/tenants -H "User-Agent:
>> python-keystoneclient" -H "X-Auth-Token: TOKEN_REDACTED"
>> INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS
>> connection (1): proxy.nebula-dev
>> DEBUG:requests.packages.urllib3.connectionpool:"GET /v2.0/tenants
>> HTTP/1.1" 200 963
>> [...]
>>
>> On 1/9/2015 *李旦* lidan17 at jd.com
>> <mailto:openstack%40lists.openstack.org?Subject=Re%3A%20%5BOpenstack%5D%20Get%20tenant%20by%20name&In-Reply-To=%3CA0257811F020DE4698F0891EF93864DB0132E5A1%40mbx04.360buyAD.local%3E>
>> wrote:
>>> Maybe you need:
>>> curl -i -X GEThttp://IPAddr:35357/v2.0/tenants?{name=XXXX <http://IPAddr:35357/v2.0/tenants?%7Bname=XXXX>} -H "User-Agent: python-keystoneclient" -H "X-Auth-Token: XXXXXXXXXXXXXXXXXXXXXX"
>>>
>>> Hope this helps.
>>>
>>> Best Regards,
>>> Daniel
>>>
>>> On 1/8/2015 5:42 PM, Peter Scott wrote:
>>>> Hello. The v2.0 API documentation at
>>>> http://developer.openstack.org/api-ref-identity-v2.html says that
>>>> it is possible to look up a tenant by name. It comes right after
>>>> the "list all tenants" call and looks the same, although if I
>>>> understand it correctly it takes a request body with a 'name'
>>>> parameter.
>>>>
>>>> However, I can't find any Python support for that lookup nor a curl
>>>> example. Can someone supply either a curl example or a python call
>>>> that looks up a tenant by name please?
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20150115/30912ee6/attachment.html>
More information about the Openstack
mailing list