fog / fog-openstack

Fog for OpenStack Platform
MIT License
69 stars 130 forks source link

Baremetal defaults to Ironic version 1.1, unable to set microversion #197

Open rwsu opened 8 years ago

rwsu commented 8 years ago

The Baremetal service defaults to Ironic version 1.1. I see the provision_state comes in as "null" for nodes that are shown as "available" through the python ironic client (which defaults to version 1.6).

I was unable to find a way to set the microversion in the headers. (microversions: http://docs.openstack.org/developer/ironic/dev/webapi-version-history.html)

For example, setting the headers in the connection_options

@connection_options[:headers] = {"X-OpenStack-Ironic-API-Version" => "1.6"}

resulted in

/home/rwsu/.rvm/gems/ruby-2.1.2@fog-openstack/gems/excon-0.50.1/lib/excon/middlewares/expects.rb:6:in response_call': Expected(202) <=> Actual(406 Not Acceptable) (Excon::Error::NotAcceptable) excon.error.response :body => "{\"error_message\": \"{\\\"code\\\": 406, \\\"description\\\": \\\"Invalid value for X-OpenStack-Ironic-API-Version header\\\", \\\"title\\\": \\\"Not Acceptable\\\"}\"}" :cookies => [ ] :headers => { "Content-Length" => "145" "Content-Type" => "application/json" "Date" => "Thu, 22 Sep 2016 21:30:36 GMT" } :host => "192.0.2.1" :local_address => "10.0.1.3" :local_port => 40696 :path => "/nodes/751fa993-4495-4b4e-b07e-17f5a41a50d7/states/provision" :port => 6385 :reason_phrase => "Not Acceptable" :remote_ip => "192.0.2.1" :status => 406 :status_line => "HTTP/1.1 406 Not Acceptable\r\n" from /home/rwsu/.rvm/gems/ruby-2.1.2@fog-openstack/gems/excon-0.50.1/lib/excon/middlewares/response_parser.rb:8:inresponse_call' from /home/rwsu/.rvm/gems/ruby-2.1.2@fog-openstack/gems/excon-0.50.1/lib/excon/connection.rb:389:in response' from /home/rwsu/.rvm/gems/ruby-2.1.2@fog-openstack/gems/excon-0.50.1/lib/excon/connection.rb:253:inrequest' from /home/rwsu/.rvm/gems/ruby-2.1.2@fog-openstack/gems/fog-core-1.40.1/lib/fog/core/connection.rb:81:in request' from /home/rwsu/.rvm/gems/ruby-2.1.2@fog-openstack/gems/fog-openstack-0.1.12/lib/fog/openstack/core.rb:81:inrequest' from /home/rwsu/.rvm/gems/ruby-2.1.2@fog-openstack/gems/fog-openstack-0.1.12/lib/fog/baremetal/openstack/requests/set_node_provision_state.rb:10:in set_node_provision_state' from test.rb:22:in

'

It is unclear to me why the value is invalid.

gildub commented 8 years ago

@rwsu, I can't see any microversion either in the undercloud I'm testing against (Liberty - OSP8).

{"media_types": [{"base": "application/json", "type": "application/vnd.openstack.ironic.v1+json"}], "links": [{"href": "http://192.0.2.1:6385/v1/", "rel": "self"}, {"href": "http://docs.openstack.org/developer/ironic/dev/api-spec-v1.html", "type": "text/html", "rel": "describedby"}], "drivers": [{"href": "http://192.0.2.1:6385/v1/drivers/", "rel": "self"}, {"href": "http://192.0.2.1:6385/drivers/", "rel": "bookmark"}], "ports": [{"href": "http://192.0.2.1:6385/v1/ports/", "rel": "self"}, {"href": "http://192.0.2.1:6385/ports/", "rel": "bookmark"}], "chassis": [{"href": "http://192.0.2.1:6385/v1/chassis/", "rel": "self"}, {"href": "http://192.0.2.1:6385/chassis/", "rel": "bookmark"}], "nodes": [{"href": "http://192.0.2.1:6385/v1/nodes/", "rel": "self"}, {"href": "http://192.0.2.1:6385/nodes/", "rel": "bookmark"}], "id": "v1"}
rwsu commented 8 years ago

@gildub, I am able to see them in upstream undercloud. Try

[stack@instack ~]$ token=$(openstack token issue -f value -c id)
WARNING: openstackclient.common.utils is deprecated and will be removed after Jun 2017. Please use osc_lib.utils
[stack@instack ~]$ curl -H "X-Auth-Token: $token" curl http://192.0.2.1:6385/
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
{"default_version": {"status": "CURRENT", "min_version": "1.1", "version": "1.22", "id": "v1", "links": [{"href": "http://192.0.2.1:6385/v1/", "rel": "self"}]}, "versions": [{"status": "CURRENT", "min_version": "1.1", "version": "1.22", "id": "v1", "links": [{"href": "http://192.0.2.1:6385/v1/", "rel": "self"}]}], "name": "OpenStack Ironic API", "description": "Ironic is an OpenStack project which aims to provision baremetal machines."}[stack@instack ~]$ 

It reported that versions 1.1 to 1.22 are available.

gildub commented 8 years ago

@rwsu, ok so OSP8 issue is another issue (out of scope here) then. Thanks

gildub commented 8 years ago

@rwsu,

In your example it seems. - I might be wrong, this is why I'm checking :) - that the headers contains only the "X-OpenStack-Ironic-API-Version", what about the rest of the header (token, application/json and so?

Also, and that's probably the main issue for fog-openstack, what about the url and path? My microversion tests (using compute/nova) show the url must corresponds ('href' in your curl example fetching the versions).

For instance http://192.0.2.1:6385 won't work with the X-OpenStack-Ironic-API-Version header set as it needs http://192.0.2.1:6385/v1

My understanding is when not using microversion then the endpoint returned by the catalog must be used. Meanwhile when using the microversion then versions must be retrieved (GET => '/' ) and then use the appropriate endpoint from the latter.

So basically fog-openstack doesn't support microversion.