vagrant-openstack-provider icon indicating copy to clipboard operation
vagrant-openstack-provider copied to clipboard

get_version_v2() got an unexpected keyword argument auth code 400 Bad Request

Open ksingh7 opened this issue 9 years ago • 8 comments

Hi @ggiamarchi @julienvey and Everyone

Today is the first time i installed this plugin ( hope i got the latest version of it )

While running vagrant up or vagrant openstack i am facing this error

$ vagrant openstack image-list
2015-06-19 02:51 |  INFO | Authenticating on Keystone
2015-06-19 02:51 |  INFO | Authentication on project cephtest with user ksingh
2015-06-19 02:51 | DEBUG | request  => method  : POST
2015-06-19 02:51 | DEBUG | request  => url     : https://*****:5001/v2.0
2015-06-19 02:51 | DEBUG | request  => headers : {"auth":{"tenantName":"cephtest","passwordCredentials":{"username":"ksingh","password":"****"}}}
2015-06-19 02:51 | DEBUG | response => code    : 400
2015-06-19 02:51 | DEBUG | response => headers : {:vary=>"X-Auth-Token", :content_type=>"application/json", :content_length=>"121", :date=>"Thu, 18 Jun 2015 23:51:03 GMT"}
2015-06-19 02:51 | DEBUG | response => body    : {"error": {"message": "get_version_v2() got an unexpected keyword argument 'auth'", "code": 400, "title": "Bad Request"}}
{"error": {"message": "get_version_v2() got an unexpected keyword argument 'auth'", "code": 400, "title": "Bad Request"}}
$

Here is my Vagrantfile

Vagrant.configure('2') do |config|

  config.vm.box       = 'vagrantbox1'
  config.ssh.username = 'ksingh'

  config.vm.provider :openstack do |os|
    os.openstack_auth_url = ENV['OS_AUTH_URL']
    os.username           = ENV['OS_USERNAME']
    os.password           = ENV['OS_PASSWORD']
    os.tenant_name        = ENV['OS_TENANT_NAME']
    os.flavor             = 'tiny'
    os.image              = 'karan-centos7'
    os.floating_ip_pool   = 'public'
    os.floating_ip        = '***'
    os.sync_method        = 'none'
   # os.networks           = ['net1','net2','net3']
   # os.keypair_name       = 'karan-new'

  end
end

Could you suggest what can be the possible error

Host operating system : OSX Vagrant Version : 1.7.2 I can connect with the same auth_url,username and pwd using openstack cli tools.

ksingh7 avatar Jun 19 '15 00:06 ksingh7

Hi, in your auth_url you should add /tokens at the end. A fix to allow user to set an auth_url to the keystone base URL is done on the master branch but not yet released (https://github.com/ggiamarchi/vagrant-openstack-provider/commit/45bd9355a6617b001076f340e0106d791b6b04e1).

ggiamarchi avatar Jun 20 '15 15:06 ggiamarchi

@ggiamarchi Thanks i added /tokens and the command progressed . But now getting some unknown error

ksingh$
ksingh$ export VAGRANT_OPENSTACK_LOG=debug
ksingh$
ksingh$ vagrant openstack image-list
2015-06-20 20:53 |  INFO | Authenticating on Keystone
2015-06-20 20:53 |  INFO | Authentication on project cephtest with user ksingh
2015-06-20 20:53 | DEBUG | request  => method  : POST
2015-06-20 20:53 | DEBUG | request  => url     : https://xxx.xxx.fi:5001/v2.0/tokens
2015-06-20 20:53 | DEBUG | request  => headers : {"auth":{"tenantName":"cephtest","passwordCredentials":{"username":"ksingh","password":"****"}}}
2015-06-20 20:53 | DEBUG | response => code    : 200
2015-06-20 20:53 | DEBUG | response => headers : {:vary=>"X-Auth-Token", :content_type=>"application/json", :content_length=>"7617", :date=>"Sat, 20 Jun 2015 17:53:16 GMT"}
2015-06-20 20:53 | DEBUG | response => body    : {"access": {"token": {"issued_at": "2015-06-20T17:53:16.662271", "expires": "2015-06-20T20:53:16Z", "id": "MIINgQYJKoZIhvcNAQcCoIINcjCCDW4CAQExCTAHBgUrDgMCGjCCC9cGCSqGSIb3DQEHAaCCC8gEggvEeyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxNS0wNi0yMFQxNzo1MzoxNi42NjIyNzEiLCAiZXhwaXJlcyI6ICIyMDE1LTA2LTIwVDIwOjUzOjE2WiIsICJpZCI6ICJwbGFjZWhvbGRlciIsICJ0ZW5hbnQiOiB7ImVuYWJsZWQiOiB0cnVlLCAiaWQiOiAiY2VwaHRlc3QiLCAibmFtZSI6ICJjZXBodGVzdCJ9fSwgInNlcnZpY2VDYXRhbG9nIjogW3siZW5kcG9pbnRzIjogW3siYWRtaW5VUkwiOiAiaHR0cHM6Ly9wb3V0YS5jc2MuZmk6ODc3Ny92Mi9jZXBodGVzdCIsICJyZWdpb24iOiAicmVnaW9uT25lIiwgImludGVybmFsVVJMIjogImh0dHA6Ly8xMC4xMDAuMC4xOjg3NzQvdjIvY2VwaHRlc3QiLCAiaWQiOiAiMGRlM2YzZDgzMjQ2NDIwY2E0NWU3ZjFjYmE0ODNlZWYiLCAicHVibGljVVJMIjogImh0dHBzOi8vcG91dGEuY3NjLmZpOjg3NzcvdjIvY2VwaHRlc3QifV0sICJlbmRwb2ludHNfbGlua3MiOiBbXSwgInR5cGUiOiAiY29tcHV0ZSIsICJuYW1lIjogIm5vdmEifSwgeyJlbmRwb2ludHMiOiBbeyJhZG1pbl
2015-06-20 20:53 | DEBUG | response => body    : {"versions": [{"status": "CURRENT", "id": "v2.2", "links": [{"href": "http://xxx.xxx.fi:9293/v2/", "rel": "self"}]}, {"status": "SUPPORTED", "id": "v2.1", "links": [{"href": "http://xxx.xxx.fi:9293/v2/", "rel": "self"}]}, {"status": "SUPPORTED", "id": "v2.0", "links": [{"href": "http://xxx.xxx.fi:9293/v2/", "rel": "self"}]}, {"status": "CURRENT", "id": "v1.1", "links": [{"href": "http://xxx.xxx.fi:9293/v1/", "rel": "self"}]}, {"status": "SUPPORTED", "id": "v1.0", "links": [{"href": "http://xxx.xxx.fi:9293/v1/", "rel": "self"}]}]}
2015-06-20 20:53 |  INFO |  -- compute        : https://xxx.xxx.fi:8777/v2/cephtest
2015-06-20 20:53 |  INFO |  -- network        : http://xxx.xxx.fi:9697/v2.0
2015-06-20 20:53 |  INFO |  -- volumev2       : https://xxx.xxx.fi:8780/v2/cephtest
2015-06-20 20:53 |  INFO |  -- computev3      : https://xxx.xxx.fi:8777/v3
2015-06-20 20:53 |  INFO |  -- image          : http://xxx.xxx.fi:9293/v2/
2015-06-20 20:53 |  INFO |  -- volume         : https://xxx.xxx.fi:8780/v1/cephtest
2015-06-20 20:53 |  INFO |  -- ec2            : https://xxx.xxx.fi:8772/services/Cloud
2015-06-20 20:53 |  INFO |  -- identity_v3    : https://xxx.xxx.fi:5001/v3
2015-06-20 20:53 |  INFO |  -- identity       : https://xxx.xxx.fi:5001/v2.0
2015-06-20 20:53 | DEBUG | get_all_images - start
2015-06-20 20:53 | DEBUG | request  => method  : GET
2015-06-20 20:53 | DEBUG | request  => url     : http://xxx.xxx.fi:9293/v2//images

So till now vagrant-openstack-provider plugin can connect to my openstack cloud but after that i throws errors.

An unknow error happened in Vagrant OpenStack provider

To easily debug what happened, we recommend to set the environment
variable VAGRANT_OPENSTACK_LOG to debug

    $ export VAGRANT_OPENSTACK_LOG=debug

If doing this does not help fixing your issue, there may be a bug
in the provider. Please submit an issue on Github at
https://github.com/ggiamarchi/vagrant-openstack-provider
with the stracktrace and the logs.

We are looking for feedback, so feel free to ask questions or
describe features you would like to see in this provider.
/Users/ksingh/.vagrant.d/gems/gems/rest-client-1.6.9/lib/restclient/request.rb:216:in `rescue in transmit': Server broke connection (RestClient::ServerBrokeConnection)
    from /Users/ksingh/.vagrant.d/gems/gems/rest-client-1.6.9/lib/restclient/request.rb:158:in `transmit'
    from /Users/ksingh/.vagrant.d/gems/gems/rest-client-1.6.9/lib/restclient/request.rb:68:in `execute'
    from /Users/ksingh/.vagrant.d/gems/gems/rest-client-1.6.9/lib/restclient/request.rb:35:in `execute'
    from /Users/ksingh/.vagrant.d/gems/gems/vagrant-openstack-provider-0.6.1/lib/vagrant-openstack-provider/client/rest_utils.rb:8:in `get'
    from /Users/ksingh/.vagrant.d/gems/gems/vagrant-openstack-provider-0.6.1/lib/vagrant-openstack-provider/client/http_utils.rb:22:in `block in get'
    from /Users/ksingh/.vagrant.d/gems/gems/vagrant-openstack-provider-0.6.1/lib/vagrant-openstack-provider/client/http_utils.rb:104:in `authenticated'
    from /Users/ksingh/.vagrant.d/gems/gems/vagrant-openstack-provider-0.6.1/lib/vagrant-openstack-provider/client/http_utils.rb:21:in `get'
    from /Users/ksingh/.vagrant.d/gems/gems/vagrant-openstack-provider-0.6.1/lib/vagrant-openstack-provider/client/glance.rb:46:in `get_all_images'
    from /Users/ksingh/.vagrant.d/gems/gems/vagrant-openstack-provider-0.6.1/lib/vagrant-openstack-provider/command/image_list.rb:16:in `cmd'
    from /Users/ksingh/.vagrant.d/gems/gems/vagrant-openstack-provider-0.6.1/lib/vagrant-openstack-provider/command/abstract_command.rb:21:in `execute'
    from /Users/ksingh/.vagrant.d/gems/gems/vagrant-openstack-provider-0.6.1/lib/vagrant-openstack-provider/command/main.rb:39:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/cli.rb:42:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:301:in `cli'
    from /opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.2/bin/vagrant:174:in `<main>'
ksingh$

Has anyone seen this before ? @ggiamarchi your expert help is needed.

ksingh7 avatar Jun 20 '15 18:06 ksingh7

@ggiamarchi

FYI , to make sure it's not host specific problem , just now i installed vagrant-openstack-plugin on a Ubuntu machine and it failed with exactly same error i posted above.

So , now this problem is on OSX + UBUNTU

root@mj:~/vagrant# uname -a
Linux mj 3.13.0-46-generic #79-Ubuntu SMP Tue Mar 10 20:06:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
root@mj:~/vagrant#
root@mj:~/vagrant#
root@mj:~/vagrant# vagrant --version
Vagrant 1.7.2
root@mj:~/vagrant#

ksingh7 avatar Jun 20 '15 18:06 ksingh7

Yep. I believe I just hit this exact problem.

If you have the python-keystoneclient client installed you can check what your image and network endpoints are with the commands and compare them to the debug output above.

keystone endpoint-get --service network
keystone endpoint-get --service image

The problem I had was that the endpoints I was trying to reach were https urls but did not explicitly specify the API version in the (This maybe be an error on your provider's side. You might want to send them an email to check.)

Without the explicit api version in the endpoint, the plugin's function choose_api_version in openstack_catalog.rb appears to try and construct a url with the api version but incorrectly uses http instead of https, causing the error.

A workaround I discovered is to explicitly declare the api endpoints in the Vagrantfile with an api version so the plugin doesn't barf.

os.openstack_network_url
os.openstack_image_url

I believe this to be a similar issue with the vagrant-openstack-plugin (which I also tried, resulting in a 400 bad request)

philbert avatar Jun 27 '15 18:06 philbert

The problem is the potential announcement of experimental API endpoints. This is an example for a current (Liberty) OpenStack environment:

2015-08-23 19:09 | DEBUG | response => body    : {"versions": [{"status": "EXPERIMENTAL", "id": "v3.0", "links": [{"href": "http://10.100.0.1:9292/v3/", "rel": "self"}]}, {"status": "CURRENT", "id": "v2.3", "links": [{"href": "http://10.100.0.1:9292/v2/", "rel": "self"}]}, {"status": "SUPPORTED", "id": "v2.2", "links": [{"href": "http://10.100.0.1:9292/v2/", "rel": "self"}]}, {"status": "SUPPORTED", "id": "v2.1", "links": [{"href": "http://10.100.0.1:9292/v2/", "rel": "self"}]}, {"status": "SUPPORTED", "id": "v2.0", "links": [{"href": "http://10.100.0.1:9292/v2/", "rel": "self"}]}, {"status": "SUPPORTED", "id": "v1.1", "links": [{"href": "http://10.100.0.1:9292/v1/", "rel": "self"}]}, {"status": "SUPPORTED", "id": "v1.0", "links": [{"href": "http://10.100.0.1:9292/v1/", "rel": "self"}]}]}

The get_all_images now chooses API v3 (EXPERIMENTAL). But it should choose v2.3 (CURRENT).

2015-08-23 19:11 | DEBUG | get_all_images - start
2015-08-23 19:11 | DEBUG | request  => method  : GET
2015-08-23 19:11 | DEBUG | request  => url     : http://10.100.0.1:9292/v3//images

berendt avatar Aug 23 '15 19:08 berendt

I have the same issue. @philbert's workaround works fine though.

noresjo avatar Feb 23 '16 09:02 noresjo

I just ran into this issue as well, just to be a bit more explicit about the workaround. I had to add v2.0 to the end of the URLs for "Network", "Volumev2", and "Image" listed in the API Access page in openstack.

ianabc avatar May 17 '16 18:05 ianabc

Exception: {"error": {"message": "authenticate() got an unexpected keyword argument 'credentials'", "code": 400, "title": "Bad Request"}}

I am getting this error with all the list_* functions.

Could anyone please help ?

Thanks in advance

avnish30jn avatar Oct 03 '16 12:10 avnish30jn