Error code 500. Creating server(instance) via openstack api

Asked by dimas zakky nalendra

i'm using stackops dis ver 0.5xxxx
i develop a web application like horizon
my nova work properly
creating instance via horizon work properly
but when i tried to test via curl with :
curl -k -D - -H "X-Auth-Token:5e427cc6-a93c-459c-92df-53e2b0f82d30" -H 'Content-type: application/json' -X 'POST' -d '{"server":{"name":"name","flavorRef":"1","imageRef":"1"}}' -v http://192.168.1.42:8774/v1.0/servers

i got an error code 500 :
The server has either erred or is incapable of performing\r\nthe requested operation

in nova log : /var/log/nova/nova-api.log

2012-10-02 16:46:12,012 DEBUG nova [-] HTTP PERF: 0.05363 seconds to GET 127.0.0.1:35357 /v2.0/tokens/5e427cc6-a93c-459c-92df-53e2b0f82d30) from (pid=1281) getresponse /var/lib/nova/keystone/common/bufferedhttp.py:99
2012-10-02 16:46:12,057 DEBUG nova [-] HTTP PERF: 0.04471 seconds to GET 127.0.0.1:35357 /v2.0/tokens/5e427cc6-a93c-459c-92df-53e2b0f82d30) from (pid=1281) getresponse /var/lib/nova/keystone/common/bufferedhttp.py:99
2012-10-02 16:46:12,060 DEBUG routes.middleware [a8dd1b4b-f328-4303-8287-752e30c880ab jono 2] Matched POST /servers from (pid=1281) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:100
2012-10-02 16:46:12,061 DEBUG routes.middleware [a8dd1b4b-f328-4303-8287-752e30c880ab jono 2] Route path: '/servers', defaults: {'action': u'create', 'controller': <nova.api.openstack.wsgi.Resource object at 0x4157e10>} from (pid=1281) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:102
2012-10-02 16:46:12,061 DEBUG routes.middleware [a8dd1b4b-f328-4303-8287-752e30c880ab jono 2] Match dict: {'action': u'create', 'controller': <nova.api.openstack.wsgi.Resource object at 0x4157e10>} from (pid=1281) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:103
2012-10-02 16:46:12,062 INFO nova.api.openstack.wsgi [a8dd1b4b-f328-4303-8287-752e30c880ab jono 2] POST http://192.168.1.42:8774/v1.0/servers
2012-10-02 16:46:12,069 ERROR nova.api.openstack [a8dd1b4b-f328-4303-8287-752e30c880ab jono 2] Caught error: 'imageId'
(nova.api.openstack): TRACE: Traceback (most recent call last):
(nova.api.openstack): TRACE: File "/var/lib/nova/nova/api/openstack/__init__.py", line 64, in __call__
(nova.api.openstack): TRACE: return req.get_response(self.application)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/request.py", line 919, in get_response
(nova.api.openstack): TRACE: application, catch_exc_info=False)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/request.py", line 887, in call_application
(nova.api.openstack): TRACE: app_iter = application(self.environ, start_response)
(nova.api.openstack): TRACE: File "/var/lib/nova/keystone/middleware/auth_token.py", line 212, in __call__
(nova.api.openstack): TRACE: return self._forward_request(env, start_response, proxy_headers)
(nova.api.openstack): TRACE: File "/var/lib/nova/keystone/middleware/auth_token.py", line 344, in _forward_request
(nova.api.openstack): TRACE: return self.app(env, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/routes/middleware.py", line 131, in __call__
(nova.api.openstack): TRACE: response = self.app(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 147, in __call__
(nova.api.openstack): TRACE: resp = self.call_func(req, *args, **self.kwargs)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 208, in call_func
(nova.api.openstack): TRACE: return self.func(req, *args, **kwargs)
(nova.api.openstack): TRACE: File "/var/lib/nova/nova/api/openstack/wsgi.py", line 496, in __call__
(nova.api.openstack): TRACE: action_result = self.dispatch(request, action, args)
(nova.api.openstack): TRACE: File "/var/lib/nova/nova/api/openstack/wsgi.py", line 527, in dispatch
(nova.api.openstack): TRACE: return controller_method(req=request, **action_args)
(nova.api.openstack): TRACE: File "/var/lib/nova/nova/api/openstack/servers.py", line 158, in create
(nova.api.openstack): TRACE: req, body, self.compute_api.create)
(nova.api.openstack): TRACE: File "/var/lib/nova/nova/api/openstack/create_instance_helper.py", line 88, in create_instance
(nova.api.openstack): TRACE: image_href = self.controller._image_ref_from_req_data(body)
(nova.api.openstack): TRACE: File "/var/lib/nova/nova/api/openstack/servers.py", line 588, in _image_ref_from_req_data
(nova.api.openstack): TRACE: return data['server']['imageId']
(nova.api.openstack): TRACE: KeyError: 'imageId'
(nova.api.openstack): TRACE:

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Compute (nova) Edit question
Assignee:
No assignee Edit question
Solved by:
dimas zakky nalendra
Solved:
Last query:
Last reply:
Revision history for this message
John Garbutt (johngarbutt) said :
#1

I think you want to send imageId not imageRef in your request.

It is not be best exception for a malformed response though, probably worth raising a bug?

An easier way to do this is to try the CLI "nova --debug <etc..>" and it will output all the requests it makes for you.

You can also see the CLI code for the correct string values, if that helps:
https://github.com/openstack/python-novaclient/blob/master/novaclient/base.py#L235

Revision history for this message
dimas zakky nalendra (dimas-zakky) said :
#2

thank a lot
it working for me
awesome