As far as I can see, currently in a JOB_DONE event you can only run "email" and "notify-send".
It would be really nice if one could execute "any" command. A custom_data would then for example look like this:
Additionally the command should be able to "know something about the job it has come from".
Solutions:
a) the command could receive at least the job id as a command line arg
b) the command has access to new environment variables like, e.g. "AF_JOB_ID"
Taking option a), I would implement it like this:
diff --git a/afanasy/python/services/events.py b/afanasy/python/services/events.py
index 05253eec..8e287cc5 100644
--- a/afanasy/python/services/events.py
+++ b/afanasy/python/services/events.py
@@ -102,6 +102,11 @@ class events(service.service):
if 'notify-send' in methods:
self.taskInfo['command'] = "notify-send Afanasy 'Job " + task_info['job_name'].replace("'", "'\\''") + ": " + event + "'"
+ # execute any command and give job ID
+ for m in methods:
+ if m not in ["email", "notify-send"]:
+ self.taskInfo["command"] = "%s -jobid %s" % (m, objects['job']['id'])
+
if len(email_events):
cmd = cgruconfig.VARS['email_send_cmd']
cmd += ' -V' # Verbose mode
This variant errors if you just want to execute a command which does not accept "jobid" as a option, e.g. "rm -rf /path/to/some/file" (I know deletions are done in post_command, this is just an example)
What do you think, is this acceptable none the less?
As far as I can see, currently in a JOB_DONE event you can only run "email" and "notify-send". It would be really nice if one could execute "any" command. A custom_data would then for example look like this:
Additionally the command should be able to "know something about the job it has come from".
Solutions: a) the command could receive at least the job id as a command line arg b) the command has access to new environment variables like, e.g. "AF_JOB_ID"
Taking option a), I would implement it like this:
This variant errors if you just want to execute a command which does not accept "jobid" as a option, e.g. "rm -rf /path/to/some/file" (I know deletions are done in post_command, this is just an example)
What do you think, is this acceptable none the less?