Closed tmclaugh closed 9 years ago
Can you pass me your definitions file? (The json file where the api is defined, it's usually downloaded from the server).
If the URL is malformed there then is a foreman issue, we can try to work around it, but the fix should go into foreman.
On May 8, 2015 2:56:18 PM GMT+02:00, Tom McLaughlin notifications@github.com wrote:
This is a followup here to the Foreman bug I filed. Filing here because I'm not sure if the issue I'm seeing is a Foreman or foreman-python bug.
http://projects.theforeman.org/issues/10421
Trying to add a parameter to a host fails due to a an error thrown in Foreman
foreman_client.update_hosts({'parameters' : [{'name':'k2', 'value':'v2'}]}, 'i-036c522c.example.com') ForemanException: Something went wrong: #################################### url = http://foreman.example.com/api/hosts/i-036c522c.example.com headers = {'Content-Length': '90', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'application/json; version=2', 'User-Agent': 'python-requests/2.7.0 CPython/2.7.6 Darwin/14.3.0', 'Connection': 'keep-alive', 'Cookie': '_session_id=1e5590f95e7ad51c9fc58f4ebf39d279', 'Content-type': 'application/json', 'Authorization': '*****'} -------- data sent ----------------- {"host": {"parameters": [{"name": "k2", "value": "v2"}]}, "id": "i-036c522c.example.com"} ------------------------------------ @@@@@ response @@@@@@@@@@@@@@@@ headers = {'status': '500 Internal Server Error', 'x-request-id': '3a96d989227057cc80cdb1424c256047', 'x-powered-by': 'Phusion Passenger 4.0.10', 'transfer-encoding': 'chunked', 'foreman_version': '1.7.4', 'connection': 'close', 'server': 'Apache/2.2.22 (Debian)', 'x-runtime': '0.052732', 'x-ua-compatible': 'IE=Edge,chrome=1', 'cache-control': 'no-cache', 'date': 'Fri, 08 May 2015 12:48:41 GMT', 'apipie-checksum': '812463b3f4cade98d0325612a8c8c2cd', 'content-type': 'application/json; charset=utf-8', 'x-rack-cache': 'invalidate, pass', 'foreman_api_version': '2'} code = 500 reason = Internal Server Error --------- data received ------------ { "error": {"message":"undefined method `id' for nil:NilClass"} } ------------------------------------ ####################################
This has to do with the formation of the request sent to Foreman. As noted in the Foreman bug report posting to /api/hosts/:id fails while posting to /api/hosts/:id/parameters works
fail: http://foreman.example.com/api/hosts/i-036c522c.example.com sccess: http://foreman.example.com/api/hosts/i-036c522c.example.com/parameters
Reply to this email directly or view it on GitHub: https://github.com/david-caro/python-foreman/issues/41
Sent from my Android device with K-9 Mail through Mykolab servers.
I looked at the definition files and found the following extra files compared to the 0.2.2 package.
-rw-r--r-- 1 tom staff 462133 Apr 10 15:48 1.7.3-v1.json (previous host)
-rw-r--r-- 1 tom staff 848417 Apr 13 19:28 1.7.3-v2.json "
-rw-r--r-- 1 tom staff 848417 May 7 17:14 1.7.4-v2.json (curret host)
-rw-r--r-- 1 tom staff 462133 Apr 10 15:53 2-v1.json (not a clue)
I deleted those files, recreated the virtualenv, and started a new python session. I noticed the doc now says to use host[host_parameters_attributes] and 1.7.4-v2.json was redownloaded. Everything works fine with 0.2.2. I seem to have found a bug in 0.3 for which I'll file a different issue.
This is a followup here to the Foreman bug I filed. Filing here because I'm not sure if the issue I'm seeing is a Foreman or foreman-python bug.
http://projects.theforeman.org/issues/10421
Trying to add a parameter to a host fails due to a an error thrown in Foreman
This has to do with the formation of the request sent to Foreman. As noted in the Foreman bug report posting to /api/hosts/:id fails while posting to /api/hosts/:id/parameters works
fail: http://foreman.example.com/api/hosts/i-036c522c.example.com sccess: http://foreman.example.com/api/hosts/i-036c522c.example.com/parameters