Project

General

Profile

Actions

Bug #13713

closed

Create compute resource with API fails

Added by Anonymous over 8 years ago. Updated over 8 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Hello,

Since I've updated to Foreman 1.10.1, creating a compute resource using the API produces this error:
"error": {"message":"ERF42-1330 [Foreman::Exception]: must provide a provider"}

Log:

# curl -L -k -u user:password -H Content-Type:application/json -H Accept:application/json,version=2 -X POST http://foreman/api/compute_resources/ -d '{ "compute_resource": { "name": "Openstack",  "provider": "Openstack", "user": "admin", "password": "changeme", "url": "http://1.2.3.4:5000/v2.0/tokens", "tenant": "admin", "description": "test" }}' -vvv
* About to connect() to foreman port 80 (#0)
*   Trying foreman... connected
* Connected to foreman (1.2.3.3) port 80 (#0)
* Server auth using Basic with user 'user'
> POST /api/compute_resources/ HTTP/1.1
> Authorization: Basic YXBpYWRtaW46YTEzaUFEbUlOUGE1NVcwcmQ=
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 1.2.3.3
> Content-Type:application/json
> Accept:application/json,version=2
> Content-Length: 221
> 
< HTTP/1.1 301 Moved Permanently
< Date: Mon, 15 Feb 2016 15:29:15 GMT
< Server: Apache/2.2.15 (Red Hat)
< Apipie-Checksum: 471e67ed3baf2103277866da41f4c006
< X-UA-Compatible: IE=Edge,chrome=1
< Cache-Control: no-cache
< X-Request-Id: 076f82c9004ce38b87f420066ec8a558
< X-Runtime: 0.011892
< X-Rack-Cache: invalidate, pass
< X-Powered-By: Phusion Passenger 4.0.18
< Set-Cookie: request_method=POST; path=/
< Location: https://foreman/api/compute_resources
< Status: 301 Moved Permanently
< Vary: Accept-Encoding
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=utf-8
< 
* Closing connection #0
* Issue another request to this URL: 'https://foreman/api/compute_resources'
* Violate RFC 2616/10.3.2 and switch from POST to GET
* About to connect() to foreman port 443 (#0)
*   Trying foreman... connected
* Connected to foreman (1.2.3.3) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* warning: ignoring value of ssl.verifyhost
* skipping SSL peer certificate verification
* NSS: client certificate not found (nickname not specified)
* SSL connection using TLS_DHE_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
*     subject: CN=foreman.test
*     start date: févr. 14 14:21:23 2016 GMT
*     expire date: févr. 13 14:21:23 2021 GMT
*     common name: foreman.test
*     issuer: CN=Puppet CA: foreman.test
* Server auth using Basic with user 'user'
> POST /api/compute_resources HTTP/1.1
> Authorization: Basic YXBpYWRtaW46YTEzaUFEbUlOUGE1NVcwcmQ=
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 10.0.232.59
> Content-Type:application/json
> Accept:application/json,version=2
> 
< HTTP/1.1 500 Internal Server Error
< Date: Mon, 15 Feb 2016 15:29:15 GMT
< Server: Apache/2.2.15 (Red Hat)
< Foreman_version: 1.10.1
< Foreman_api_version: 2
< Apipie-Checksum: 471e67ed3baf2103277866da41f4c006
< X-UA-Compatible: IE=Edge,chrome=1
< Cache-Control: no-cache
< X-Request-Id: 327b938888c5b99a5c82c93a3c1db35c
< X-Runtime: 0.028014
< X-Rack-Cache: invalidate, pass
< X-Powered-By: Phusion Passenger 4.0.18
< Set-Cookie: request_method=POST; path=/
< Set-Cookie: _session_id=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTk2OWQxNTgwOTk3YjkxMzQ3Nzk4MDkzZjQwZmZlMGM4BjsAVEkiC2xvY2FsZQY7AEZJIgdlbgY7AEY%3D--8578d3d2d5137b8cdd8ec04f1983bbc0584e9168; path=/; HttpOnly
< Status: 500 Internal Server Error
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: application/json; charset=utf-8
< 
{
  "error": {"message":"ERF42-1330 [Foreman::Exception]: must provide a provider"}
}
* Closing connection #0
Actions #1

Updated by Dominic Cleal over 8 years ago

Could you try using the HTTPS URL in your request, not HTTP?

It kind of indicates that curl isn't sending the JSON body (-d) again after being redirected as there's no Content-Length header on the second request.

The API was changed to require HTTPS to match the UI in 1.9, see http://theforeman.org/manuals/1.9/index.html#Releasenotesfor1.9.0 under Security.

Actions #2

Updated by Dominic Cleal over 8 years ago

  • Description updated (diff)
  • Category set to API
  • Status changed from New to Feedback
Actions #3

Updated by Anonymous over 8 years ago

same result with https and no redirection (without -L flag)

# curl -k -u user:password -H Content-Type:application/json -H Accept:application/json,version=2 -X POST https://1.2.3.3/api/compute_resources/ -d '{ "compute_resource": { "name": "Openstack", "provider": "Openstack",  "provider_friendly_name": "OpenStack", "user": "admin", "password": "changeme", "url": "http://1.2.3.4:5000/v2.0/tokens", "tenant": "admin", "description": "test" }}'
{
  "error": {"message":"ERF42-1330 [Foreman::Exception]: must provide a provider"}
}

Actions #4

Updated by Anonymous over 8 years ago

Actually the provider "*Openstack*" must be written "*openstack*" to make it work.
But after the creation, a GET returns "provider=*Openstack*"

Actions #5

Updated by Dominic Cleal over 8 years ago

I'm not sure I can reproduce that, and the error suggests the provider is missing entirely.

Anyway, it's working for you now?

Actions #6

Updated by Anonymous over 8 years ago

Yes, it's working. There is just a mismatch between POST (that accepts only 'openstack') and GET (that returns 'Openstack').
As you said, I get the same error with 'provider=Openstack' or without the 'provider' parameter.
Thanks

Actions

Also available in: Atom PDF