From 5ba128ee7044f8b5e61772f03dcbcb89cfe3c2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Wed, 5 Feb 2020 19:03:28 +0100 Subject: [PATCH] B #4154: marks info call as unsupported (#4157) --- include/HookAPI.h | 10 ++++++++- src/hm/HookAPI.cc | 57 ++++++++++++++++++++++++++++++++++++++++++++++- src/hm/HookLog.cc | 1 + src/rm/Request.cc | 7 ++++-- 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/include/HookAPI.h b/include/HookAPI.h index ba0c9441d5c..4e1673e1ae3 100644 --- a/include/HookAPI.h +++ b/include/HookAPI.h @@ -35,6 +35,14 @@ class HookAPI : public HookImplementation static std::string * format_message(std::string method, ParamList& paramList, const RequestAttributes& att); + /** + * Check if an api call is supported or not. + * @param api call + * + * @return true if the call exists, false otherwise + */ + static bool supported_call(const std::string& api_call); + private: friend class HookPool; friend class Hook; @@ -76,7 +84,7 @@ class HookAPI : public HookImplementation * Check if an api call does exist in the XMLRPC server. * @param api call * - * @return 0 if the call exists, -1 otherwise + * @return true if the call exists, false otherwise */ bool call_exist(const std::string& api_call); diff --git a/src/hm/HookAPI.cc b/src/hm/HookAPI.cc index 87103ce558e..3f28bc1667c 100644 --- a/src/hm/HookAPI.cc +++ b/src/hm/HookAPI.cc @@ -21,7 +21,49 @@ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -const string HookAPI::unsupported_calls[] = {"one.hook.info", "one.hookpool.info"}; +const string HookAPI::unsupported_calls[] = {"one.vm.info", + "one.vmpool.info", + "one.vmpool.infoextended", + "one.template.info", + "one.templatepool.info", + "one.host.info", + "one.hostpool.info", + "one.group.info", + "one.grouppool.info", + "one.groupquota.info", + "one.vn.info", + "one.vnpool.info", + "one.user.info", + "one.userpool.info", + "one.userquota.info", + "one.datastore.info", + "one.datastorepool.info", + "one.image.info", + "one.imagepool.info", + "one.acl.info", + "one.vntemplate.info", + "one.vntemplatepool.info", + "one.cluster.info", + "one.clusterpool.info", + "one.document.info", + "one.documentpool.info", + "one.zone.info", + "one.zonepool.info", + "one.secgroup.info", + "one.secgrouppool.info", + "one.vmgroup.info", + "one.vmgrouppool.info", + "one.vdc.info", + "one.vdcpool.info", + "one.vrouter.info", + "one.vrouterpool.info", + "one.market.info", + "one.marketpool.info", + "one.marketapp.info", + "one.marketapppool.info", + "one.hook.info", + "one.hookpool.info", + "one.hooklog.info"}; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -31,6 +73,11 @@ std::string * HookAPI::format_message(std::string method, ParamList& paramList, { ostringstream oss; + if (!supported_call(method)) + { + return nullptr; + } + oss << "" << "API" << "" << method << "" @@ -129,6 +176,14 @@ bool HookAPI::call_exist(const string& api_call) return false; } + return supported_call(api_call); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +bool HookAPI::supported_call(const string& api_call) +{ for (const auto& call : unsupported_calls) { if (api_call == call) diff --git a/src/hm/HookLog.cc b/src/hm/HookLog.cc index 4e7d02eb1c1..471cdcc77ae 100644 --- a/src/hm/HookLog.cc +++ b/src/hm/HookLog.cc @@ -198,6 +198,7 @@ int HookLog::add(int hkid, int hkrc, std::string &xml_result) if ( ObjectXML::validate_xml(sql_xml) != 0 ) { + db->free_str(sql_xml); return -1; } diff --git a/src/rm/Request.cc b/src/rm/Request.cc index 14fd0aeb96c..7129307c8e0 100644 --- a/src/rm/Request.cc +++ b/src/rm/Request.cc @@ -447,9 +447,12 @@ void Request::execute( std::string * event = HookAPI::format_message(method_name, pl, att); - hm->trigger(HMAction::SEND_EVENT, *event); + if (event != nullptr) + { + hm->trigger(HMAction::SEND_EVENT, *event); - delete event; + delete event; + } if ( log_method_call ) {