This document describes initial setup and administration of LXD together with NSFarm.
NSFarm has to simulate various separate computers connected to router ports. This
is for example ISP or client. The way this is done is by running different
containers with physical access on specific router interface. Every container is
spawned from some image that is defined in img
directory in root of NSFarm
repository. Please read readme there to see how to define
image.
It is not enough to just have LXD service running to make NSFarm work with it. NSFarm required additional profiles to be configured by admin. Exact profiles and expected behavior is specified in following sections.
The reason why we use profiles for this is to give administrator of hosting PC ability to configure LXD daemon without touching NSFarm source code.
nsfarm-root
profile has to provide container with device of type disk
with
path /
. This is where containers root file-system is stored.
This profile is applied on every single container spawned by NSFarm.
Example configuration:
$ lxc profile show nsfarm-root
config: {}
description: NSFarm root disk device
devices:
root:
path: /
pool: default
type: disk
name: nsfarm-root
used_by: []
nsfarm-internet
profile has to provide internet access. This is device of type
nic
with name internet
. Any additional configuration is up to administrator.
The only requirement is that IP address on this interface is assigned by DHCP.
Currently this should provide at minimum IPv4. IPv6 is not supported and with introduction of it there might be modifications to this profile.
This profile is applied on every container bootstrap and on containers requesting Internet access.
Example configuration:
$ lxc profile show nsfarm-internet
config: {}
description: NSFarm the Internet access
devices:
internet:
name: internet
nictype: bridged
parent: lxdbr
type: nic
name: nsfarm-internet
used_by: []
NSFarm generates a lot of images during its run. Those can pile up and it is good practice to remove them later on. For this you can use prepared nsfarm utility.
python3 -m nsfarm lxd clean
It is advised to run this every day or so to remove old images. In default (without argument) it removes all images not used for at least week. You can change this by providing different delta.
NSFarm can sometimes also terribly crash and in such case the can be some old containers running or not even started. The automatic tool to remove that is not implemented but we should do so. In default execution NSFarm removes all generated images after itself.
All images generated by NSFarm in LXD are named with nsfarm/
prefix. The only
other images NSFarm can introduce to LXD are cached images from linuximages.org.
NSFarm created images have following name:
nsfarm/NAME/HASH
Where NAME
is name of image as defined in /imgs
directory in NSFarm
repository. And HASH
is calculated hash from all sources for this image. This is
definition script it self, files-tree in /imgs/NAME
and also hash of base image.
This means that when anything in this chain changes, like base image or definition
file, then it changes hash and new image is generated.
All containers created by NSFarm in LXD have prefix nsfarm-
. This means that
you can use lxc list nsfarm-
to see only containers created by NSFarm.
There are two primary types of containers created by NSFarm. There are containers for bootstrapping image and later container it self based on some image.
nsfarm-bootstrap-NAME-HASH
This is container used to bootstrap image of NAME
with hash HASH
. The
resulting image should be nsfarm/NAME/HASH
.
nsfarm-NAME-PID(-INC)
This is standard container created by NSFarm to serve as endpoint for some
connection to board. NAME
is name of image used to spawn this container. PID
is process ID of NSFarm instance. There is also additional -INC
that is
incremental number used when there is more than one container from same image at
the same time spawned in single NSFarm instance.