...
The following example shows a simple rule with each section separated by pipes (|):
...
Code Block |
---|
rule1 | whileOnBatt() |
...
whileBattLessThan(0 30) | logString(“Pausing VM!”) |
...
pauseVm(“ubuntu”) |
...
| |
...
unpauseVm(“ubuntu”) |
This rule breaks down as follows:
...
In a text file, variables are defined, one per line, using the syntax “varName(value).” For example, the line “batteryLow(20)” defines a variable named batteryLow, whose value is 20, and whose type is inferred as integer. Once defined, variables can be used in rules by referring to them with a dollar sign ($). Our variable could be used in a rule like so:
...
Code Block |
---|
rule2 | whileBattLessThan(0 $batteryLow) | logString(“Battery getting low!”) |
This rule simply prints the message “Battery getting low!” to the system log when battery 0’s remaining capacity drops below 20%.
...
Variables are defined, one per line, with the variable’s name followed by its value within parentheses:
Code Block |
---|
var_name(“value”) |
Rules are defined, one per line, with the four sections described above separated by pipe characters (|):
...
Code Block |
---|
name | conditions | actions | undo_actions |
A policy file may also contain comments. Any line beginning with a pound sign (#) will be interpreted as a comment and ignored by the parser. Currently, comments at the end of a line are not supported.
...