dswd/ToMaTo — Issue #136: Multiple languages for programmable devices
Author: dswd
Created: 2012-03-03 15:17:47+00:00
State: open
Labels: backend, enhancement

ToMaTo should allow multiple languages for programmable devices so developers can choose the best language for their device. Programmable devices could be realized in three different ways:

## Sandboxed programs
Sandboxes allow programs to be executed in their own environment unable to escape it. This environment should only include selected methods including some to access tun/tap interfaces made available to the program. The sandbox needs to consist of two phases. The first phase prepares the devices and loads the program with elevated permissions and then drop the permissions and establish restrictions for the script to run in the second phase. The following programming languages can be easily sandboxed:

* Lua, it has even be created for this use case
* Java, its permission system should allow a strong sandbox
* Python using the Repy

## Programs run in OpenVZ
Nearly all programming languages can be run in OpenVZ. To create a programmable device using OpenVZ a device image needs to be created that supports the programming language. For each device instance the image will be used in read-only mode (using `mount --bind -o ro`) to save space. The program will be added to the device instance with the same mechanism. This construct will have a low memory and disk space footprint.

## Programs run in KVM
KVM can be used to run custom kernels to process packages. The resources used by a device instance must be assigned beforehand so this option is not actually lightweight. Some kernels like [BareMetal OS](http://www.returninfinity.com/baremetal.html) however use only few resources so that a device can be limited to 16 MiB.