F #3380: return object body on API hooks (#3705)

This commit is contained in:
Christian González authored and Ruben S. Montero committed 2019-09-16 14:50:33 +02:00
1 parent 7b03f719d6
commit eb7df9e901
5 files changed
+40 -2

No files matched your search

+2 -2
View File
@@ -84,7 +84,7 @@ module HEMHook
case event_type
when 'API'
api = event.xpath('//PARAMETERS')[0].to_s
api = event.xpath('//CALL_INFO')[0].to_s
api = Base64.strict_encode64(api)
when 'STATE'
object = event.xpath('//HOOK_OBJECT')[0].text.upcase
@@ -523,7 +523,7 @@ class HookExecutionManager
@am.trigger_action(ACTIONS[0], 0, hook, body) unless hook.nil?
reload_hooks(key, body_xml) if UPDATE_CALLS.include? key
reload_hooks(key, body) if UPDATE_CALLS.include? key
when :RETRY
body = Base64.decode64(content.split(' ')[0])
body = Nokogiri::XML(body)
+3
View File
@@ -44,6 +44,9 @@ std::string * HookAPI::format_message(std::string method, ParamList& paramList,
oss << att.retval_xml
<< "</PARAMETERS>"
<< "<EXTRA>"
<< att.extra_xml
<< "</EXTRA>"
<< "</CALL_INFO>"
<< "</HOOK_MESSAGE>";
+20
View File
@@ -266,6 +266,16 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params,
cluster->unlock();
}
//Take object body for hooks.
PoolObjectSQL * obj = pool->get(id);
if (obj != nullptr)
{
obj->to_xml(att.extra_xml);
obj->unlock();
}
att.resp_id = id;
success_response(id, att);
}
@@ -650,6 +660,16 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
ds->unlock();
}
// Take image body for Hooks
Image * img = ipool->get(id);
if (img != nullptr)
{
img->to_xml(att.extra_xml);
img->unlock();
}
att.resp_id = id;
success_response(id, att);
}
+14
View File
@@ -64,6 +64,16 @@ void RequestManagerDelete::request_execute(xmlrpc_c::paramList const& paramList,
recursive = xmlrpc_c::value_boolean(paramList.getBoolean(2));
}
// Save body before deleting it for hooks
PoolObjectSQL * obj = pool->get(oid);
if (obj != nullptr)
{
obj->to_xml(att.extra_xml);
obj->unlock();
}
ErrorCode ec = delete_object(oid, recursive, att);
if ( ec == SUCCESS )
@@ -95,6 +105,10 @@ void ImageDelete::request_execute(xmlrpc_c::paramList const& paramList,
att.auth_op = AuthRequest::ADMIN;
}
//Save body before deleting for hooks.
img->to_xml(att.extra_xml);
img->unlock();
ErrorCode ec = delete_object(oid, false, att);