nova list doesn't work with tenant name, only tenant id

Bug #1233492 reported by Haw Loeung
38
This bug affects 4 people
Affects Status Importance Assigned to Milestone
python-novaclient
Opinion
Wishlist
Xiao Li Xu

Bug Description

Hi,

I'm having issues listing all instances for a given tenant/project. It seems that the v2 Compute API ignores the tenant_id.

$ nova --debug --no-cache list
REQ: curl -i https://nova-lcy02.canonistack.canonical.com/v2/XXX/servers/detail -X GET -H "X-Auth-Project-Id: hloeung_project" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: YYYY"
+--------------------------------------+--------------------------------------+--------+------------+-------------+-------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+--------------------------------------+--------+------------+-------------+-------------------------+
| e8bb176c-e5b2-4f8e-a776-18e466e81a04 | juju-canonistack-haw-lcy02-machine-0 | ACTIVE | None | Running | canonistack=10.55.32.45 |
+--------------------------------------+--------------------------------------+--------+------------+-------------+-------------------------+

That looks fine, and so does this:

$ nova --debug --no-cache --os-tenant-name hloeung_project list --tenant hloeung_project
REQ: curl -i https://nova-lcy02.canonistack.canonical.com/v2/XXX/servers/detail?tenant_id=hloeung_project -X GET -H "X-Auth-Project-Id: hloeung_project" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: YYY"
+--------------------------------------+--------------------------------------+--------+------------+-------------+-------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+--------------------------------------+--------+------------+-------------+-------------------------+
| e8bb176c-e5b2-4f8e-a776-18e466e81a04 | juju-canonistack-haw-lcy02-machine-0 | ACTIVE | None | Running | canonistack=10.55.32.45 |
+--------------------------------------+--------------------------------------+--------+------------+-------------+-------------------------+

But when I try using the admin tenant, it seems to return a different list of servers/instances:

$ nova --debug --no-cache --os-tenant-name admin list --tenant hloeung_project
REQ: curl -i https://nova-lcy02.canonistack.canonical.com/v2/XXX/servers/detail?tenant_id=hloeung_project -X GET -H "X-Auth-Project-Id: admin" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: YYY"
+--------------------------------------+-----------------------------+---------+------------+-------------+--------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-----------------------------+---------+------------+-------------+--------------------------+
| 931bf3c2-1bce-439b-861f-735dcc64be16 | juju canonistack instance 0 | SHUTOFF | None | Shutdown | canonistack=10.55.32.125 |
+--------------------------------------+-----------------------------+---------+------------+-------------+--------------------------+

ii python-novaclient 1:2.15.0-0ubuntu1 all client library for OpenStack Compute API
ii nova-api 1:2013.1.3-0ubuntu1~cloud0 OpenStack Compute - API frontend

Any ideas?

Regards,

Haw

Tags: api
Haw Loeung (hloeung)
tags: added: api
Changed in nova:
assignee: nobody → Mauro Sergio Martins Rodrigues (maurosr)
Revision history for this message
Haw Loeung (hloeung) wrote :

Hi,

As suggested in LP: #1185290, I've tried with '--all-tenants 1' and it still doesn't seem to show all instances for a given tenant.

e.g. The instances that I currently have are as follows:

[hloeung@darkon tmp]$ nova --os-tenant-name hloeung_project list --tenant hloeung_project --all-tenants 1
+--------------------------------------+--------------------------------------+--------+------------+-------------+-----------------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+--------------------------------------+--------+------------+-------------+-----------------------------------------+
| c2b33d0a-9a19-4d97-b459-1dfb3aa3a48f | juju-canonistack-haw-lcy02-machine-0 | ACTIVE | None | Running | canonistack=10.55.32.107 |
| b5052d85-97ae-4145-ba32-e1b325479d04 | juju-canonistack-haw-lcy02-machine-1 | ACTIVE | None | Running | canonistack=10.55.32.45 |
| 50162d63-d7cc-45d6-a59f-378fe293a3f6 | juju-canonistack-haw-lcy02-machine-3 | ACTIVE | None | Running | canonistack=10.55.32.58 |
| f6ffc9ca-e5c9-4238-b3d6-e7b327af0a49 | juju-canonistack-haw-lcy02-machine-6 | ACTIVE | None | Running | canonistack=10.55.32.73, 162.213.35.42 |
| 9afbe3b5-2a57-4a0e-a8db-95dad0ed71cf | juju-canonistack-haw-lcy02-machine-7 | ACTIVE | None | Running | canonistack=10.55.32.106, 162.213.35.38 |
+--------------------------------------+--------------------------------------+--------+------------+-------------+-----------------------------------------+

But with the admin tenant and --all-tenants, no instances are shown:

[hloeung@darkon tmp]$ nova --os-tenant-name admin list --tenant hloeung_project --all-tenants 1

[hloeung@darkon tmp]$

Regards,

Haw

Revision history for this message
Christopher Yeoh (cyeoh-0) wrote :

This is a python-novaclient bug - the client is not looking the tenant id by name and converting it to a tenant_id before passing it to the nova api. If you list the instances and specify the tenant_id by id (use keystone list) then it will work as a workaround

affects: nova → python-novaclient
Revision history for this message
Haw Loeung (hloeung) wrote :

Christopher,

That works:

$ nova --os-tenant-name admin list --tenant bc2989e3c2e44c0ba966cd9a17c32386 --all-tenants 1
+--------------------------------------+--------------------------------------+--------+------------+-------------+-----------------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+--------------------------------------+--------+------------+-------------+-----------------------------------------+
| 58ed81c2-183f-4b72-a64a-428ba4c21bd8 | hloeung-test | ACTIVE | None | Running | canonistack=10.55.32.165 |
| c2b33d0a-9a19-4d97-b459-1dfb3aa3a48f | juju-canonistack-haw-lcy02-machine-0 | ACTIVE | None | Running | canonistack=10.55.32.107 |
| b5052d85-97ae-4145-ba32-e1b325479d04 | juju-canonistack-haw-lcy02-machine-1 | ACTIVE | None | Running | canonistack=10.55.32.45 |
| 50162d63-d7cc-45d6-a59f-378fe293a3f6 | juju-canonistack-haw-lcy02-machine-3 | ACTIVE | None | Running | canonistack=10.55.32.58 |
| f6ffc9ca-e5c9-4238-b3d6-e7b327af0a49 | juju-canonistack-haw-lcy02-machine-6 | ACTIVE | None | Running | canonistack=10.55.32.73, 162.213.35.42 |
| 9afbe3b5-2a57-4a0e-a8db-95dad0ed71cf | juju-canonistack-haw-lcy02-machine-7 | ACTIVE | None | Running | canonistack=10.55.32.106, 162.213.35.38 |
+--------------------------------------+--------------------------------------+--------+------------+-------------+-----------------------------------------+

Revision history for this message
melanie witt (melwitt) wrote :

This is a feature ask to accept tenant names as well as tenant id for --tenant option.

Changed in python-novaclient:
assignee: Mauro Sergio Martins Rodrigues (maurosr) → nobody
importance: Undecided → Wishlist
status: New → Triaged
melanie witt (melwitt)
summary: - v2 API bug - list servers ignores tenant_id?
+ nova list doesn't work with tenant name, only tenant id
Jyotsna (jyotsna-priya1)
Changed in python-novaclient:
assignee: nobody → tcs_openstack_group (tcs-openstack-group)
Revision history for this message
sachi (sachi-gupta) wrote :

nova --os-tenant-name demo list --tenant demo --all-tenants 1 - Works Fine and returns the servers available for demo user

nova --os-tenant-name admin list --tenant c40ad5830e194f2296ad11a96cefc487 --all-tenants 1 - Works Fine and returns all the servers available

nova --os-tenant-name admin list --tenant demo --all-tenants 1 - Returns nothing.

As suggested by Christopher, It seems that the bug is for the nova-pythonclient. The client is not looking the tenant id by name and converting it to a tenant_id before passing it to the nova api.

Possible Solution: Need to convert the tenant name to tenant_id before it is passed to nova api so that the list of servers can be shown up by both tenant_name or tenant_id

sachi (sachi-gupta)
Changed in python-novaclient:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/109496

Changed in python-novaclient:
assignee: tcs_openstack_group (tcs-openstack-group) → sachi (sachi-gupta)
Changed in python-novaclient:
assignee: sachi (sachi-gupta) → Abhishek Talwar (abhishek-talwar)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/133151

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-novaclient (master)

Change abandoned by Sean Dague (<email address hidden>) on branch: master
Review: https://review.openstack.org/109496
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

Revision history for this message
melanie witt (melwitt) wrote :

Patch was abandoned.

Changed in python-novaclient:
assignee: Abhishek Talwar (abhishek-talwar) → nobody
status: In Progress → Confirmed
Revision history for this message
melanie witt (melwitt) wrote :

It's worth mentioning that an additional call to keystone would need to be added (admin only) to lookup the tenant id from tenant name, and then call the nova api after that with the id (nova has no knowledge of tenant names, only tenant ids).

The reason the --os-tenant-name and OS_TENANT_NAME work is the /tokens call to keystone accepts a tenant name returns the tenant id along with the auth token.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Joe Gordon (<email address hidden>) on branch: master
Review: https://review.openstack.org/133151
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

Xiao Li Xu (xiao-li-xu)
Changed in python-novaclient:
assignee: nobody → IBM-Cloud-SH (ibm-cloud-sh)
Revision history for this message
Takashi Natsume (natsume-takashi) wrote :

This wishlist bug has been open one and a half years without any activity.
I'm going to move it to "Opinion / Wishlist", which is an easily-obtainable queue of older requests that have come on.
This bug can be reopened (set back to "New") if someone decides to work on this.

Changed in python-novaclient:
status: Confirmed → Opinion
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.