Tuesday, February 14, 2012

Running Advent Geneva RSL remotely through runrep

We have used for a while Advent Geneva SOAP Services to consume RSL reports as I posted before.

We noticed a problem with some reports running fast from runrep (a command prompt interactive tool supplied in the Advent Geneva distribution) but running really slow from SOAP so I decided to provide a remote tool to access runrep.

This is just Plain Old Bash* script that basically runs the command remotely using our old friend ssh.

Using this technique you should be able to run remote commands synchronously or asynchronously which comes handy for processes taking long time (like some long period accounting reports)

I have posted the script here. In order to run it you have to authorize your the client public keys in the geneva host. If you have no key then generate one:
if [ ! -f ~/.ssh/id_rsa.pub ]; then ssh-keygen -t rsa; fi
You can then push the key to the geneva server using a handy command called ssh-copy-id:
ssh-copy-id -i ~/.ssh/id_rsa.pub myuser@genevabox.domain.com
Here are some examples as to how to use it:

Use ASYNC_RUN to run the report and get a remote file in the server. Note the line starting with "$ 2012/02/14:16:50:09". The prompt means the command was started but in the background. As you can see just before the prompt the client script says it "Finished in 1 seconds" so the client program can now continue while the report is running in the server.
$ ./remote-runrep.sh geneva genevaint.nestorurquiza.com ASYNC_RUN my_report.xml myuser mypass my_report.rsl "-p MYPORTFOLIO -at Dynamic -ps 01/31/2012 -pe 01/31/2012 --SeparateLegalEntities 1 --FundLegalEntity \\\"MYPORTFOLIO MF\\\" -f xml"
ASYNC_RUN mode
Tue Feb 14 16:49:05 EST 2012
Finished in 1 seconds
$ 2012/02/14:16:50:09  INFO: runrep - Reading in RSL files
2012/02/14:16:50:11  INFO: runrep - Read in all RSL files
2012/02/14:16:50:11  INFO: runrep - Reading in GLM files
2012/02/14:16:50:11  INFO: runrep - Read in all GLM files
2012/02/14:16:50:11  INFO: Performing a(n) Dynamic accounting run for portfolio MYPORTFOLIO (MYPORTFOLIO MF) using a lockdown.
2012/02/14:16:50:11  INFO: ARM:00202: Generating new BIS, as either GIVEN or KBMS has changed.
2012/02/14:16:50:11  INFO: Using LockdownPool MYPORTFOLIO for Portfolio MYPORTFOLIO.
2012/02/14:16:50:11  INFO:       Loading Summary Positions from Fixed LockDown 12-31-2011.
runrep: Report run successful.

OK. Quitting.
Use ASYNC mode to move the file to the local drive
$ ./remote-runrep.sh geneva genevaint.nestorurquiza.com ASYNC my_report.xml myuser mypass my_report.rsl "-p MYPORTFOLIO -at Dynamic -ps 01/31/2012 -pe 01/31/2012 --SeparateLegalEntities 1 --FundLegalEntity \\\"MYPORTFOLIO MF\\\" -f xml"
ASYNC mode
receiving file list ... done
my_report.xml

sent 42 bytes  received 465311 bytes  103411.78 bytes/sec
total size is 22068250  speedup is 47.42
Tue Feb 14 16:50:34 EST 2012
Finished in 4 seconds
Use SYNC to wait for the execution of the report and get the resulting file locally
$ ./remote-runrep.sh geneva genevaint.nestorurquiza.com SYNC my_report.xml myuser mypass my_report.rsl "-p MYPORTFOLIO -at Dynamic -ps 01/31/2012 -pe 01/31/2012 --SeparateLegalEntities 1 --FundLegalEntity \\\"MYPORTFOLIO MF\\\" -f xml"
SYNC mode
2012/02/15:03:29:38  INFO: runrep - Reading in RSL files
2012/02/15:03:29:40  INFO: runrep - Read in all RSL files
2012/02/15:03:29:40  INFO: runrep - Reading in GLM files
2012/02/15:03:29:40  INFO: runrep - Read in all GLM files
2012/02/15:03:29:40  INFO: Performing a(n) Dynamic accounting run for portfolio MYPORTFOLIO (MYPORTFOLIO MF) using a lockdown.
2012/02/15:03:29:40  INFO: ARM:00202: Generating new BIS, as either GIVEN or KBMS has changed.
2012/02/15:03:29:40  INFO: Using LockdownPool MYPORTFOLIO for Portfolio MYPORTFOLIO.
2012/02/15:03:29:40  INFO:       loading Summary Positions from Fixed LockDown 12-31-2011.
runrep: Report run successful.

OK. Quitting.
Connection to genevaint.nestorurquiza.com closed.
receiving file list ... done
my_report.xml

sent 42 bytes  received 465311 bytes  186141.20 bytes/sec
total size is 22068250  speedup is 47.42
Wed Feb 15 03:29:39 EST 2012
Finished in 68 seconds
Test that indeed the resulting report is being moved to the client machine
$ ls -lh /tmp/my_report.xml
-rw-r--r--  1 nestor  wheel    21M Feb 14  2012 /tmp/my_report.xml
$ head -10 /tmp/my_report.xml


 
   
MYPORTFOLIO FUND L.P. nestorurquiza MASTER POSITIONS FILE 'January 31, 2012
...
While running all this from command prompt you will lose your prompt echo. Just run the below to recover it:
$ stty sane
It will make probably sense to implement a callback mode (ASYNC_CALLBACK) which basically will run the remote command asynchronously but on finalization it runs a callback service. That of course is left to the specific implementation.

Other useful bash geneva scripts

Here is another script that can be used to delete trades for a period of time for a give portfolio. It depends on an existing 6.2 RSL called newtransmaker.rsl which by default is missing support for deletion. The below diff should speak for itself so you can get the new version of the report available.
$ diff  /usr/advent/geneva-6.2.0/share/rslspecs/newtransmaker.rsl /usr/advent/geneva-6.2.0/share/rslspecs/newtransmaker_rev.rsl 
10c10
<  DATE KnowledgeDate = EndToday, STRING ManagementFirm, STRING  Uptransmaker = "No", STRING IDToUse ="ID", STRING StyleName = "d",
---
>  DATE KnowledgeDate = EndToday, STRING ManagementFirm, STRING  Uptransmaker = "No", STRING Deletetransmaker = "No", STRING IDToUse ="ID", STRING StyleName = "d",
499c499,501
<  DECODE(Lower(:Uptransmaker), "yes", "Update", "New") Action, //2
---
>  DECODE(Lower(:Uptransmaker), "yes", "Update", 
>  DECODE (Lower(:Deletetransmaker), "yes", "Delete",
>  "New")) Action, //2
1629a1632
>     if (Lower(:Deletetransmaker) == "yes") { :__reportName = "Delete Transaction Loader File"; }
1652a1656
>
You would the script as:
./remote-delete-trades.sh geneva genevaint.nestorurquiza.com anyRandomAndTemporaryFile.bcp genevaLoaderUser genevaLoaderPassword \\\"portfolioName\\\" 1/11/2012 1/11/2012
* I think I have coined POB for the first time BTW but of course many others have talked about Plain Old Bash before so I should not take credit for just an abbreviation. In fact in many cases like in the example I have brought today you have to be aware of other shells like the default CShell in a Solaris box. So it makes sense to actually talk about Plain Old Shell scripting or POS. I get exited when I see increased productivity just by using "old" concepts. It reminds me of what Plain Old Java Objects or POJO concepts meant to me by the time they showed up on the net. Simple is better.

No comments:

Followers