In this article we will see how Symbolic runs a pre-configured user script in asynchronous mode.
Why we say pre-configured?
In Symbolic application, the administrator can "upload" on the server a specific "well-formed" script, written in Pyhton, Groovy, Bash or Perl. After this procedure Symbolic recognizes the list of installed scripts and proposes them to enable users. (As we have seen in a previous article)
This schema illustrates the main steps follow to execute script and propose result to the user.
- First of all, a logged user has to select a script from the list
- This selection produces an entry in Symbolic Database with script information and state READY (like in a MicroProcessor state ready means that operation is waiting the execution).
- A "runner-process" (Quartz Job for Java Developers), launched at the application start-up, queries database in polling looking for new ready-state scripts. By default it is configured to wake up each 5 seconds, but the administrator could decide to change this polling time with a simple modification to Symbolic configuration file
- When the "runner-process" find a new ready-state script, runs it using a new "System" process (a process external to Symbolic application) and set the state to RUNNING. Whereas the script is to run in async mode, the runner-process job is finished.
- The script can communicate with Symbolic application through a provided Xml-RPC Server (embedded in Symbolic and reachable at "symbolic/api/xmlrpc" address).
The access to the server xml-rpc is protected with username and password. This provides an other step in Symbolic security, making only well-formed script able to communicate with Symbolic application.
By default a user "externalscript" is created during the Symbolic installation (with default password externalscript); the administrator could change this credentials so only "really-certified" scripts could communicate with that Symbolic instance.
At the moment Xml-Rpc server exposes only two methods: getAllMachines and postInformation. The first one is used to get list of Symbolic certified and controlled machines; the second one is used to communicate the script execution result to Symbolic.
- When postInformation is invoked, xml-rpc server get the result and saved the correct status in the database. Each ran script knows the database ID that must be posted with the result information. This is the only way that make symbolic able to recognized information posted.
- If user try to get ran script status in this moment, it find script result information (with associated error or success result).