mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-22 20:54:49 +09:00
(cherry picked from commit 5ba128ee70)
This commit is contained in:
1 parent
faf8cf4067
commit
d98f55e0c6
4 files changed
+71
-4
No files matched your search
+9
-1
@@ -35,6 +35,14 @@ public:
|
||||
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 @@ private:
|
||||
* 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);
|
||||
|
||||
|
||||
+56
-1
@@ -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 << "<HOOK_MESSAGE>"
|
||||
<< "<HOOK_TYPE>API</HOOK_TYPE>"
|
||||
<< "<CALL>" << method << "</CALL>"
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -444,9 +444,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 )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user