Re: irule

50 views
Skip to first unread message
Message has been deleted

dmoore.renci

unread,
Dec 11, 2018, 3:21:15 PM12/11/18
to iRODS-Chat
Hello !

If I am understanding your question correctly, I think the simple answer would be in the negative. It isn't strictly possible to print to the console directly
in an action or rule function triggered in reponse to a PUT operation. In iRODS' in-memory rulebase (unlike with rule files that are run from command-line)
there's no ready connection to a console device.

Of course, a couple of approaches might be possible to get around this:
  -  Manual: Split your terminal window using 'screen' or 'tmux'; and, in the other subwindow, do "tail -0f ~irods/log/rodsLog.*" or similar.
  -  Automatic: Use the Python Rule Engine Plugin (https://github.com/irods/irods_rule_engine_plugin_python)
        and override the  core.py module's  "acPostProcForPut(rule_args,callback,rei)",  or import your rule via "from mymodule import *"

With the latter option, you have all the freedom offered by the Python interpreter, including - if you wish - including access to file and socket I/O  and other IPC's. If you choose
to do it this way, make sure that  any modules imported into core.py are writable only by the iRODS service account or Unix admin.

Also: look for future releases of iRODS to allow  messages to be routed to syslog.  You might then be able to use your own choice of a syslog parser to detect iRODS system events.

-Daniel Moore
Applications Engineer
iRODS Consortium

On Tuesday, December 11, 2018 at 2:20:42 PM UTC-5, P_Atreides wrote:


I was wondering how to create a rule that uses acPostProcForPut that writes a message to the console after a file is placed in a collection.  I understand how to uncomment it the core.re file and make it print to the rodsLog file, but how would I write a rule using it and then have a message printed to the screen when  a file is put in irods, and what would be the syntax to invoke it from the command line using irule?  Any help would be greatly appreciated.

Omar Morris

unread,
Dec 11, 2018, 5:28:11 PM12/11/18
to irod...@googlegroups.com
Thanks for your answer, I'll explore options with the python rule engine.  

--
--
"iRODS: the Integrated Rule-Oriented Data-management System; A community driven, open source, data grid software solution" https://www.irods.org
 
iROD-Chat: http://groups.google.com/group/iROD-Chat

---
You received this message because you are subscribed to the Google Groups "iRODS-Chat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to irod-chat+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Alan King

unread,
Dec 12, 2018, 9:20:34 AM12/12/18
to irod...@googlegroups.com
Hi Omar,

For your original question, I think Dan is right in saying that the output will have nowhere to go. However, you should be able to use 'stdout' instead of 'serverLog' in the writeLine to get output on the command line.
We have demonstrated this recently via this issue: https://github.com/irods/irods/issues/3998
Worth noting: I tried this out with acPostProcForPut and found that I am getting an error message in the log... This appears to be a manifestation of the issue linked above. Static PEPs may have a different codepath for handling the returned output...

As for msiDataObjCopy, the only thing I'm noticing here is the destination logical path: " /tempZone/home/rods/ERC_coll"
There appears to be a leading space (which arguably shouldn't matter, but the iRODS Rule Language may care). More importantly, it may be looking for an exact path for the data object to be copied to. From the iRODS Microservices Workbook:

acPostProcForPut {
    on($objPath like "*.txt") {
        msiDataObjCopy($objPath, "$objPath.copy");
    }
}


You may need to give it a destination data object name. I am not too familiar with this microservice so that's just a guess.
If you can, please provide the error that you're seeing and we might be able to pinpoint the problem.

Hope that helps!

Alan

On Tue, Dec 11, 2018 at 6:00 PM Omar Morris <oamo...@gmail.com> wrote:
One other question: if I uncomment  acPostProcForPut in core.re what is the sytax to use  msiDataObjCopy? I used :
acPostProcForPut { ON($objPath like "/tempZone/home/rods/hy_coll/*")  {msiDataObjCopy($objPath, " /tempZone/home/rods/ERC_coll");}}

The behavior I want is that when a data object is placed in the hy_coll collection the asPostProcForPut PEP fires and copies that object into the ERC_coll.  What happens is that I put the file in hy_coll and then the PEP fires but errors out, what am I doing wrong?

On Tue, Dec 11, 2018 at 2:21 PM dmoore.renci <dmoore...@gmail.com> wrote:
--
--
"iRODS: the Integrated Rule-Oriented Data-management System; A community driven, open source, data grid software solution" https://www.irods.org
 
iROD-Chat: http://groups.google.com/group/iROD-Chat

---
You received this message because you are subscribed to the Google Groups "iRODS-Chat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to irod-chat+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Omar Morris

unread,
Dec 12, 2018, 11:54:04 AM12/12/18
to irod...@googlegroups.com
DEBUG: msiDataObjCopy: rsDataObjCopy failed for /tempZone/path/to/collection where file is put/file.txt, status =511017

I think there is something going on with the syntax,  above that error it points to the microservice I'm working on at the end as if the end of the statement with the closing bracket is incorrect:
msiDataObjCopy($objPath, "/tempZone/.../");} }  
                                                                            ^

P_Atreides

unread,
Dec 12, 2018, 12:09:22 PM12/12/18
to iRODS-Chat
I thought that I gave it an exact path to copy to, also how do I give it a destination object name?


On Wednesday, December 12, 2018 at 8:20:34 AM UTC-6, Alan King wrote:
Hi Omar,

For your original question, I think Dan is right in saying that the output will have nowhere to go. However, you should be able to use 'stdout' instead of 'serverLog' in the writeLine to get output on the command line.
We have demonstrated this recently via this issue: https://github.com/irods/irods/issues/3998
Worth noting: I tried this out with acPostProcForPut and found that I am getting an error message in the log... This appears to be a manifestation of the issue linked above. Static PEPs may have a different codepath for handling the returned output...

As for msiDataObjCopy, the only thing I'm noticing here is the destination logical path: 
Reply all
Reply to author
Forward
0 new messages