next up previous
Next: Programmatic invocation of Vsys Up: Using Vsys Previous: Administrators

Script authors

A script author develops vsys scripts. You might want to introduce a new facility on the system for your users (e.g. the ability to bind to a particular privileged port), or to develop a script for your own use if you are a slice user on PlanetLab. In the latter case, naturally, your script will be reviewed by the administrators of the PlanetLab deployment in question.

Here is the source code of the login script mentioned previously.


\begin{lstlisting}
\char93 !/bin/sh
SLICENAME=$1
grep SLICENAME /var/log/secure
\end{lstlisting}

Vsys scripts receive as their first argument the name of the client slice. In this case, the script outputs the lines in the file /var/log/secure that contain the name of the slice, indicating login events involving the slice user. This output is sent to the slice via the corresponding output entry (login.out).

Input is received via STDIN. Consider the following script, written in C, for fetching pathnames based on an in-kernel tag called a directory cookie, used to temporarily save a filename and to restore it afterwards.


\begin{lstlisting}
int main(int argc,char *argv[]) {
char path_buf[16384],dcoo...
...,path_buf);
}
else {
printf(\lq\lq % Not found\n'');
}
}
}
\end{lstlisting}

The script reads the values of the cookies via standard input, looks up the corresponding pathnames and sends them to the slice via standard output.

VSys scripts can be of two types: stateless and stateful. The example scripts defined thus far are stateless, in that they are instantiated anew for each request and do not retain any state between invocations. Scripts can also be persistent if need be. Writing a persistent script is easy - run in a loop and do not terminate. Instead, go to sleep, waiting for subsequent input. For such scripts, VSys keeps track of the pid of the first instance of the script and reuses this instance for subsequent interactions. Stateful scripts need to be prefixed with the string daem_ to indicate to Vsys that they are stateful. Here is an example of a stateful script (``daem_counter''):


\begin{lstlisting}
\char93 !/usr/bin/perl
\par
use strict;
\par
my $counter=0;
\...
... $counter++;
print \lq\lq Current value of counter: $counter\n'';
}
\end{lstlisting}

In order to deploy such scripts, please make sure that the PERSISTENT flag is set in the Makefile at compilation time.


next up previous
Next: Programmatic invocation of Vsys Up: Using Vsys Previous: Administrators
2008-09-16