can't get authentication with os-token and os-url

Bug #1450414 reported by BaoLiang Cui
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
python-neutronclient
Fix Released
High
Jas

Bug Description

Hi, I can't get authentication with os-token and os-url on Juno pythone-neutronclient.

On Icehouse, with os-token and os-url, we can get authentication.
[root@compute01 ~]# neutron --os-token $token --os-url http://controller:9696 net-list
+--------------------------------------+--------------+------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+--------------+------------------------------------------------------+
| 06c5d426-ec2c-4a19-a5c9-cfd21cfb5a0c | ext-net | 38d87619-9c76-481f-bfe8-b301e05693d9 193.160.15.0/24 |
+--------------------------------------+--------------+------------------------------------------------------+

But on Juno, it failed. The detail :
[root@compute01 ~]# neutron --os-token $token --os-url http://controller:9696 net-list --debug
ERROR: neutronclient.shell Unable to determine the Keystone version to authenticate with using the given auth_url. Identity service may not support API version discovery. Please provide a versioned auth_url instead.
Traceback (most recent call last):
   File "/usr/lib/python2.6/site-packages/neutronclient/shell.py", line 666, in run
     self.initialize_app(remainder)
   File "/usr/lib/python2.6/site-packages/neutronclient/shell.py", line 808, in initialize_app
     self.authenticate_user()
   File "/usr/lib/python2.6/site-packages/neutronclient/shell.py", line 761, in authenticate_user
     auth_session = self._get_keystone_session()
   File "/usr/lib/python2.6/site-packages/neutronclient/shell.py", line 904, in _get_keystone_session
     auth_url=self.options.os_auth_url)
   File "/usr/lib/python2.6/site-packages/neutronclient/shell.py", line 889, in _discover_auth_versions
     raise exc.CommandError(msg)
 CommandError: Unable to determine the Keystone version to authenticate with using the given auth_url. Identity service may not support API version discovery. Please provide a versioned auth_url instead.
Unable to determine the Keystone version to authenticate with using the given auth_url. Identity service may not support API version discovery. Please provide a versioned auth_url instead.

my solution is this:
On /usr/lib/python2.6/site-packages/neutronclient/shell.py, modify the authenticate_user(self) method.

 Origin:
 auth_session = self._get_keystone_session()

Modified:
        auth_session = None
        auth = None
        if not self.options.os_token:
            auth_session = self._get_keystone_session()
            auth = auth_session.auth

Revision history for this message
Eugene Nikanorov (enikanorov) wrote :

what auth_url are you providing when making the call?

affects: neutron → python-neutronclient
Changed in python-neutronclient:
status: New → Incomplete
Revision history for this message
BaoLiang Cui (cuibl) wrote :

>what auth_url are you providing when making the call?
->why do you ask this question? When I made the call. I didn' use the auth_url.

 before I executed [neutron --os-token $token --os-url http://controller:9696 net-list], I got token and set it to $token.
 I got token by the next
 [root@compute01 ~l]# token=`curl -si -d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"domain":{"name":"Default"},"name":"admin","password":"fnst1234"}}}}}' -H "Content-type: application/json" http://controller:35357/v3/auth/tokens| awk '/X-Subject-Token/ {print $2}'`

In fact,When I read the code of /usr/lib/python2.6/site-packages/neutronclient/shell.py, I found the problem :
On juno neutronclient,it does not support to get authentication only with os-token and os-url because no matter whether we set os-token or not, it woud try to get token by username and password. but in my call I didn't set the username and password, so it failed.

however, on icehouse neutronclient, this problem does not exist.

Revision history for this message
Yaoweilei (yaoweilei) wrote :

RE: Eugene Nikanorov (enikanorov) wrote on 2015-05-04:

juno version neutronclient neutronclient/shell.py
-------------------------------------
    def authenticate_user(self):
 if self.options.os_auth_strategy == 'keystone':
            if self.options.os_token or self.options.os_url:
                # Token flow auth takes priority
                if not self.options.os_token:
                    raise exc.CommandError(
                        _("You must provide a token via"
                          " either --os-token or env[OS_TOKEN]"))

                if not self.options.os_url:
                    raise exc.CommandError(
                        _("You must provide a service URL via"
                          " either --os-url or env[OS_URL]"))
            else:
                ........
        else: # not keystone
            ......

        auth_session = self._get_keystone_session()
-------------------------------------

icehouse version neutronclient neutronclient/shell.py
-------------------------------------
    def authenticate_user(self):
        if self.options.os_auth_strategy == 'keystone':
            if self.options.os_token or self.options.os_url:
                # Token flow auth takes priority
                if not self.options.os_token:
                    raise exc.CommandError(
                        _("You must provide a token via"
                          " either --os-token or env[OS_TOKEN]"))

                if not self.options.os_url:
                    raise exc.CommandError(
                        _("You must provide a service URL via"
                          " either --os-url or env[OS_URL]"))
            else:
                ......
        else: # not keystone
            ......

        auth_session = None
        auth = None
        if self.options.os_token:
            auth_session = None
            auth = None
        else:
            auth_session = self._get_keystone_session()
            auth = auth_session.auth
-------------------------------------

in icehouse version, if os_token has been given, auth_session is no longer need to get.

but in juno version, have not this judge, so call the '_get_keystone_session''_discover_auth_versions', but parameter value(auth_url) is not provided, so the error happens.

the key is whether or not we should have the judge "if self.options.os_token:".

Revision history for this message
Akihiro Motoki (amotoki) wrote :

This is a regression when we introduced SessionClient from keystoneclient.
When "neutron" command is invoked from CLI, SessionClient is used.
At now we only use keystoneclient.auth.identity.v2.Password and this identity class uses only password/auth_url information.
We need to use keystonclient.auth.identity.v2.Token (or generic.Token) if os_token and os_url are provided.
This is what novaclient does for the same case.

Revision history for this message
Akihiro Motoki (amotoki) wrote :

Note that this does not affect python neutronclient library in most cases.
At the moment, in most cases, neutronclient library still uses HTTPClient instead of SessionClient.

Changed in python-neutronclient:
status: Incomplete → Triaged
importance: Undecided → High
milestone: none → 2.5.0
tags: added: kilo-backport-potential
Revision history for this message
BaoLiang Cui (cuibl) wrote :

Ok,Thank you very much

Ukesh (ukeshkumar)
Changed in python-neutronclient:
assignee: nobody → Ukesh (ukeshkumar)
Kyle Mestery (mestery)
Changed in python-neutronclient:
milestone: 2.5.1 → none
BaoLiang Cui (cuibl)
Changed in python-neutronclient:
assignee: Ukesh (ukeshkumar) → BaoLiang Cui (cuibl)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-neutronclient (master)

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

Revision history for this message
Akihiro Motoki (amotoki) wrote :

I contacted the current author and he has no time to move it forward.
If you take this, the proposed review would be helpful.

I will take it if nobody picks it up.

Changed in python-neutronclient:
assignee: BaoLiang Cui (cuibl) → nobody
status: In Progress → Triaged
tags: added: liberty-backport-potential
Jas (singhj)
Changed in python-neutronclient:
assignee: nobody → Jas (singhj)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Changed in python-neutronclient:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-neutronclient (master)

Change abandoned by Doug Wiegley (<email address hidden>) on branch: master
Review: https://review.openstack.org/221594
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
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-neutronclient (master)

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-neutronclient (master)

Reviewed: https://review.openstack.org/263337
Committed: https://git.openstack.org/cgit/openstack/python-neutronclient/commit/?id=0740766467a3c8de0bf9d03689158a86591bd506
Submitter: Jenkins
Branch: master

commit 0740766467a3c8de0bf9d03689158a86591bd506
Author: Jaspinder <email address hidden>
Date: Mon Jan 4 05:08:41 2016 -0600

    fix: can't get authentication with os-token and os-url

    Currently, there is no way to authenticate a user
    through Neutron CLI by just using endpoint and token
    authentication. This simple fix will at least allow
    for that to be permitted.

    Change-Id: Ia7d285af224ef225aa20f83d7d4c87b81aac58ed
    Closes-Bug: 1450414

Changed in python-neutronclient:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/python-neutronclient 4.1.0

This issue was fixed in the openstack/python-neutronclient 4.1.0 release.

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

Change abandoned by Kevin Benton (<email address hidden>) on branch: master
Review: https://review.openstack.org/267020
Reason: Please address this issue in the openstackclient (if it's not already fixed there). The neutronclient is deprecated.

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.