nova keypair-add help doesn't work with keystone v3

Bug #1572633 reported by Matthew Edmonds
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
Undecided
Unassigned

Bug Description

nova keypair-add help (yes, even just asking for help... though presumably actually trying to add a keypair would have the same issue) fails with "ERROR (NotFound): The resource could not be found. (HTTP 404)". Adding --debug reveals the following:

# nova --debug keypair-add help
DEBUG (extension:156) found extension EntryPoint.parse('v2token = keystoneauth1.loading._plugins.identity.v2:Token')
DEBUG (extension:156) found extension EntryPoint.parse('admin_token = keystoneauth1.loading._plugins.admin_token:AdminToken')
DEBUG (extension:156) found extension EntryPoint.parse('v3oidcauthcode = keystoneauth1.loading._plugins.identity.v3:OpenIDConnectAuthorizationCode')
DEBUG (extension:156) found extension EntryPoint.parse('v2password = keystoneauth1.loading._plugins.identity.v2:Password')
DEBUG (extension:156) found extension EntryPoint.parse('v3password = keystoneauth1.loading._plugins.identity.v3:Password')
DEBUG (extension:156) found extension EntryPoint.parse('v3oidcpassword = keystoneauth1.loading._plugins.identity.v3:OpenIDConnectPassword')
DEBUG (extension:156) found extension EntryPoint.parse('token = keystoneauth1.loading._plugins.identity.generic:Token')
DEBUG (extension:156) found extension EntryPoint.parse('v3token = keystoneauth1.loading._plugins.identity.v3:Token')
DEBUG (extension:156) found extension EntryPoint.parse('password = keystoneauth1.loading._plugins.identity.generic:Password')
DEBUG (extension:156) found extension EntryPoint.parse('password-ceilometer-legacy = ceilometer.keystone_client:LegacyCeilometerKeystoneLoader')
REQ: curl -g -i 'https://myhostname:5000/v3' -X GET -H "Accept: application/json" -H "User-Agent: python-novaclient" -H "X-Auth-Key: passw0rd" -H "X-Auth-Project-Id: ibm-default" -H "X-Auth-User: admin1" -H "X-OpenStack-Nova-API-Version: 2.1"
RESP: [200] {'Content-Length': '274', 'Vary': 'X-Auth-Token', 'Keep-Alive': 'timeout=5, max=100', 'Server': 'Apache', 'Connection': 'Keep-Alive', 'Date': 'Wed, 20 Apr 2016 15:18:21 GMT', 'Content-Type': 'application/json', 'x-openstack-request-id': 'req-1a863590-0658-4aeb-aa0e-f5ad34db7bb3'}
RESP BODY: {"version": {"status": "stable", "updated": "2016-04-04T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v3+json"}], "id": "v3.6", "links": [{"href": "https://myhostname:5000/v3/", "rel": "self"}]}}

REQ: curl -g -i 'https://myhostname:5000/v3/v2.0/tokens' -X POST -H "Accept: application/json" -H "Content-Type: application/json" -H "User-Agent: python-novaclient" -H "X-OpenStack-Nova-API-Version: 2.1" -d '{"auth": {"tenantName": "myproject", "passwordCredentials": {"username": "admin1", "password": "{SHA1}7c6a61c68ef8b9b6b061b28c348bc1ed7921cb53"}}}'
RESP: [404] {'Content-Length': '93', 'Vary': 'X-Auth-Token', 'Keep-Alive': 'timeout=5, max=100', 'Server': 'Apache', 'Connection': 'Keep-Alive', 'Date': 'Wed, 20 Apr 2016 15:18:22 GMT', 'Content-Type': 'application/json', 'x-openstack-request-id': 'req-db336a00-185a-4d12-a2ef-f8c3f04c4802'}
RESP BODY: {"error": {"message": "The resource could not be found.", "code": 404, "title": "Not Found"}}

DEBUG (shell:1082) The resource could not be found. (HTTP 404)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/novaclient/shell.py", line 1080, in main
    OpenStackComputeShell().main(argv)
  File "/usr/lib/python2.7/site-packages/novaclient/shell.py", line 1007, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.7/site-packages/novaclient/v2/shell.py", line 3234, in do_keypair_add
    keypair = _keypair_create(cs, args, name, pub_key)
  File "/usr/lib/python2.7/site-packages/novaclient/api_versions.py", line 370, in substitution
    return methods[-1].func(obj, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/v2/shell.py", line 3179, in _keypair_create
    return cs.keypairs.create(name, pub_key)
  File "/usr/lib/python2.7/site-packages/novaclient/api_versions.py", line 370, in substitution
    return methods[-1].func(obj, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/v2/keypairs.py", line 100, in create
    return self._create('/%s' % self.keypair_prefix, body, 'keypair')
  File "/usr/lib/python2.7/site-packages/novaclient/base.py", line 345, in _create
    resp, body = self.api.client.post(url, body=body)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 455, in post
    return self._cs_request(url, 'POST', **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 408, in _cs_request
    self.authenticate()
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 591, in authenticate
    self._v2_auth(auth_url)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 656, in _v2_auth
    return self._authenticate(url, body)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 669, in _authenticate
    **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 403, in _time_request
    resp, body = self.request(url, method, **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 397, in request
    raise exceptions.from_response(resp, body, url, method)
NotFound: The resource could not be found. (HTTP 404)

1) it doesn't seem to make any sense to be talking to keystone just to print the help...
2) it is clearly assuming keystone v2.0, but appending v2.0 onto an OS_AUTH_URL that ends in v3 is never going to work.

# env | grep OS_
OS_REGION_NAME=RegionOne
OS_USER_DOMAIN_NAME=Default
OS_IMAGE_API_VERSION=2
OS_PROJECT_NAME=myproject
OS_IDENTITY_API_VERSION=3
OS_PASSWORD=passw0rd
OS_AUTH_URL=https://myhostname:5000/v3/
OS_COMPUTE_API_VERSION=2.1
OS_USERNAME=admin1
OS_TENANT_NAME=myproject
OS_VOLUME_API_VERSION=2
OS_CACERT=/etc/pki/tls/certs/powervc.crt
OS_PROJECT_DOMAIN_NAME=Default

Other nova commands don't have the same problem... e.g. "nova list" works just fine listing servers.

Revision history for this message
Matthew Edmonds (edmondsw) wrote :

this was found with novaclient 3.3.0 and mitaka

Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

the correct way to get help info: nova help keypair-add

Revision history for this message
Matthew Edmonds (edmondsw) wrote :

"nova help keypair-add" works and returns the help. And "nova keypair-add test" works as well. But "nova keypair-add help" has the problem described above. I'm not sure why that is running down a different flow... ?

ZhiQiang Fan (aji-zqfan)
Changed in python-novaclient:
status: New → Incomplete
Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

because novaclient doesn't handle such weird case

novaclient see a keyword help in argvs, then think it is a help command, then skip all the authentication and api version discover steps, but later when parsing subcommand argument, help treat as a positional argument, and try to run the subcommand then failed because there is no api version discovered

if you want to fix it, open a precise bug, not such kind of misleading description, I think novaclient can work with keystone api v3

Revision history for this message
Matthew Edmonds (edmondsw) wrote :

I updated the title. I think this is pretty precise and clearly a bug. Would be silly to open a new bug here.

summary: - nova keypair-add doesn't work with keystone v3
+ nova keypair-add help doesn't work with keystone v3
Changed in python-novaclient:
status: Incomplete → New
Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

the problem is not cannot work with keystone vxxx, it is the way how to determine if help is a help command or a subcommand normal argument

Ali Jabbar (jabbar-ali)
Changed in python-novaclient:
assignee: nobody → Ali Jabbar (jabbar-ali)
Ali Jabbar (jabbar-ali)
Changed in python-novaclient:
assignee: Ali Jabbar (jabbar-ali) → nobody
Ali Jabbar (jabbar-ali)
Changed in python-novaclient:
assignee: nobody → Ali Jabbar (jabbar-ali)
Revision history for this message
wingwj (wingwj) wrote :

I test the issue on newest (pike) devstack with python_novaclient 9.0.1, the problem is not reproduced.

Revision history for this message
Matthew Edmonds (edmondsw) wrote :

I'm not sure when this was fixed, but it doesn't indeed seem to have been. I can't reproduce with novaclient 7.1.0 either.

Changed in python-novaclient:
status: New → Fix Released
Revision history for this message
Matthew Edmonds (edmondsw) wrote :

s/doesn't/does/

Changed in python-novaclient:
assignee: Ali Jabbar (jabbar-ali) → nobody
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.