Skip to content

Commit

Permalink
B #4154: marks info call as unsupported (#4157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Gonz谩lez committed Feb 5, 2020
1 parent b44a4c7 commit 5ba128e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
10 changes: 9 additions & 1 deletion include/HookAPI.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
57 changes: 56 additions & 1 deletion src/hm/HookAPI.cc
Expand Up @@ -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"};

/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
Expand All @@ -31,6 +73,11 @@ std::string * HookAPI::format_message(std::string method, ParamList& paramList,
{
ostringstream oss;

if (!supported_call(method))
{
return nullptr;
}

oss << "<HOOK_MESSAGE>"
<< "<HOOK_TYPE>API</HOOK_TYPE>"
<< "<CALL>" << method << "</CALL>"
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/hm/HookLog.cc
Expand Up @@ -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;
}

Expand Down
7 changes: 5 additions & 2 deletions src/rm/Request.cc
Expand Up @@ -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 )
{
Expand Down

0 comments on commit 5ba128e

Please sign in to comment.