I think we need to understand the compatibility implications of these
kinds of changes before we commit this.
I'm going to try and get Ted on the phone this week to discuss.
On Sat, May 7, 2011 at 7:03 PM, Russell Bryant
<russell(a)russellbryant.net> wrote:
This patch adds a handle IO param to the status method for Services
and
the monitor and invoke methods of Resources. If a handle is provided,
it is added to the method response as well as all events raised as a
result of this method call in the future.
In passing, add a couple of \todo notes about things that need to be
done to this agent.
Signed-off-by: Russell Bryant <russell(a)russellbryant.net>
---
src/schema.xml | 8 ++++++--
src/service/service-qmf.cpp | 25 ++++++++++++++++++++++---
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/schema.xml b/src/schema.xml
index ea82e4f..217fa4c 100644
--- a/src/schema.xml
+++ b/src/schema.xml
@@ -10,6 +10,7 @@
<arg name="name" type="sstr" />
<arg name="action" type="sstr" />
<arg name="interval" type="uint32"/>
+ <arg name="handle" type="sstr"/>
<arg name="rc" type="uint32" />
@@ -104,8 +105,8 @@
<!-- Is sequence needed? How to tie to the async method call seq? -->
<!-- Is timestamp needed? Possibly available for all events already -->
- <event name="service_op"
args="name,action,interval,rc,sequence,timestamp" />
- <event name="resource_op"
args="name,action,interval,rc,sequence,timestamp,rsc_type,rsc_class,rsc_provider"
/>
+ <event name="service_op"
args="name,action,interval,rc,sequence,timestamp,handle" />
+ <event name="resource_op"
args="name,action,interval,rc,sequence,timestamp,rsc_type,rsc_class,rsc_provider,handle"
/>
<class name="Services">
<property name="uuid" type="sstr" access="RO"
desc="Host UUID" />
@@ -135,6 +136,7 @@
<arg name="interval" dir="IO" type="uint32"
/>
<arg name="timeout" dir="I" type="uint32"
/>
<arg name="rc" dir="O" type="uint32"
/>
+ <arg name="handle" dir="IO" type="sstr"
/>
</method>
<method name="cancel" desc="Cancel a pending or running
action on a system service">
<arg name="name" dir="I" type="sstr"
/>
@@ -204,6 +206,7 @@
<arg name="parameters" dir="I" type="map"
/>
<arg name="timeout" dir="I" type="uint32"
/>
<arg name="rc" dir="O" type="uint32"
/>
+ <arg name="handle" dir="IO" type="sstr"
/>
</method>
<method name="invoke" desc="Perform a custom action on a
resource">
<arg name="name" dir="IO" type="sstr"
/>
@@ -215,6 +218,7 @@
<arg name="parameters" dir="I" type="map"
/>
<arg name="timeout" dir="I" type="uint32"
/>
<arg name="rc" dir="O" type="uint32"
/>
+ <arg name="handle" dir="IO" type="sstr"
/>
</method>
<method name="cancel" desc="Cancel a pending or running
action on a resource">
<arg name="name" dir="IO" type="sstr"
/>
diff --git a/src/service/service-qmf.cpp b/src/service/service-qmf.cpp
index 37017c0..a69ceb0 100644
--- a/src/service/service-qmf.cpp
+++ b/src/service/service-qmf.cpp
@@ -16,6 +16,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/**
+ * \file
+ * \brief Matahari Services Agent
+ *
+ * \todo Add a way to cancel a method that is in progress and has not
+ * yet returned (not just one running periodically).
+ * \todo Add code to ensure that all IO parameters are being copied to
+ * responses.
+ */
+
#ifndef WIN32
#include "config.h"
#endif
@@ -63,7 +73,7 @@ class SrvAgent : public MatahariAgent
virtual int setup(qmf::AgentSession session);
virtual gboolean invoke(qmf::AgentSession session, qmf::AgentEvent event,
gpointer user_data);
- void raiseEvent(svc_action_t *op, enum service_id service);
+ void raiseEvent(svc_action_t *op, enum service_id service, qmf::AgentEvent&
method_call);
};
/**
@@ -108,6 +118,10 @@ AsyncCB::mh_async_callback(svc_action_t *op)
mh_trace("Completed: %s = %d\n", op->id, op->rc);
if (cb_data->first_result) {
+ qpid::types::Variant::Map& args = cb_data->event.getArguments();
+ if (args.count("handle") > 0) {
+ cb_data->event.addReturnArgument("handle",
args["handle"]);
+ }
if (cb_data->has_rc) {
cb_data->event.addReturnArgument("rc", op->rc);
}
@@ -116,7 +130,7 @@ AsyncCB::mh_async_callback(svc_action_t *op)
} else if (cb_data->last_rc != op->rc) {
mh_trace("Result changed on recurring action: was '%d', now
'%d'\n",
cb_data->last_rc, op->rc);
- cb_data->agent->raiseEvent(op, cb_data->service);
+ cb_data->agent->raiseEvent(op, cb_data->service, cb_data->event);
}
if (op->interval) { /* recurring action */
@@ -156,7 +170,7 @@ main(int argc, char **argv)
return rc;
}
-void SrvAgent::raiseEvent(svc_action_t *op, enum service_id service)
+void SrvAgent::raiseEvent(svc_action_t *op, enum service_id service,
qmf::AgentEvent& method_call)
{
uint64_t timestamp = 0L;
qmf::Data event;
@@ -171,6 +185,11 @@ void SrvAgent::raiseEvent(svc_action_t *op, enum service_id
service)
event = qmf::Data(_package.event_resource_op);
}
+ qpid::types::Variant::Map& args = method_call.getArguments();
+ if (args.count("handle") > 0) {
+ event.setProperty("handle", args["handle"]);
+ }
+
event.setProperty("name", op->rsc);
event.setProperty("action", op->action);
event.setProperty("interval", op->interval);
--
1.7.4.4
_______________________________________________
Matahari mailing list
Matahari(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/matahari