1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-11 04:58:16 +03:00

F #3380: Lock conflicting api calls (#3747)

This commit is contained in:
Christian González 2019-09-23 15:18:49 +02:00 committed by Ruben S. Montero
parent dd7f564553
commit 90bf20b4f6
2 changed files with 23 additions and 3 deletions

View File

@ -88,6 +88,8 @@ private:
* String representation of the API call
*/
std::string call;
const static std::string unsupported_calls[];
};
#endif

View File

@ -21,6 +21,11 @@
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
const string HookAPI::unsupported_calls[] = {"one.hook.info", "one.hookpool.info"};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
std::string * HookAPI::format_message(std::string method, ParamList& paramList,
const RequestAttributes& att)
{
@ -63,7 +68,7 @@ int HookAPI::parse_template(Template * tmpl, string& error_str)
if (!call_exist(call))
{
error_str = "API call does not exist: " + call;
error_str = "API call does not exist or is not supported: " + call;
return -1;
}
@ -81,7 +86,7 @@ int HookAPI::from_template(const Template * tmpl, string& error_str)
if (!call_exist(call))
{
error_str = "API call does not exist: " + call;
error_str = "API call does not exist or is not supported: " + call;
return -1;
}
@ -119,5 +124,18 @@ bool HookAPI::call_exist(const string& api_call)
{
RequestManager * rm = Nebula::instance().get_rm();
return rm->exist_method(api_call);
if (!rm->exist_method(api_call))
{
return false;
}
for (const auto& call : unsupported_calls)
{
if (api_call == call)
{
return false;
}
}
return true;
}