XML-RPC API has inconsistent response structure

(Kevin Massey) #1


I’m in the process of upgrading from OpenNebula 4.6 to 5.4.6 and I use the XML-RPC interface via Python. I seem to have hit an undocumented change in the XML-RPC response structure for failing calls.

According to https://docs.opennebula.org/5.4/integration/system_interfaces/api.html, the XML-RPC response structure consists of 3 elements:

Type Data Type Description
OUT Boolean True or false whenever is successful or not.
OUT String If an error occurs this is the error message.
OUT Int Error code.

I’m seeing that behavior on successful calls, but I get 4 elements on failing calls.

In opennebula-5.4.6/src/rm/Request.cc, I see 3 elements returned on success:

void Request::success_response(int id, RequestAttributes& att)
vector<xmlrpc_c::value> arrayData;


xmlrpc_c::value_array arrayresult(arrayData);

*(att.retval) = arrayresult;


But 4 elements returned on failure:

void Request::failure_response(ErrorCode ec, const string& str_val,
RequestAttributes& att)
vector<xmlrpc_c::value> arrayData;


xmlrpc_c::value_array arrayresult(arrayData);

*(att.retval) = arrayresult;


Not sure if you consider this a doc or code bug. But it would be easier to script against the API if it wasn’t necessary to test the number of elements returned.


(Juan Jose Montiel Cano) #2


Sorry was a doc bug, we have resolved this problem with the documentation, thanks for the report.


(Juan Jose Montiel Cano) #3

The change in the documentation (changes) is already done, but we are going to start with a campaign to change all the methods where this new output is used.

OpenNebula always return 3 main parameters in case of success or failure but we decided introduce a new parameter to give extra information.