Distem tutorials#

This tutorial leverages the Distem provider: a provider that creates containers for you on Grid’5000.

Note

More details on : https://distem.gitlabpages.inria.fr/

Hint

For a complete schema reference see Distem Schema

Installation#

To use Grid’5000 with Enoslib, you can go with a virtualenv :

$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip install -U pip

$ pip install enoslib

Configuration#

Since python-grid5000 is used behind the scene, the configuration is read from a configuration file located in the home directory. It can be created with the following:

echo '
username: MYLOGIN
password: MYPASSWORD
' > ~/.python-grid5000.yaml

chmod 600 ~/.python-grid5000.yaml

The above configuration should work both from a Grid’5000 frontend machine and from your local machine as well.

External access (from your laptop)#

If you are running your experiment from outside Grid’5000 (e.g. from your local machine), using a SSH jump host is required.

Enoslib (version 8.1.0 and above) will automatically setup such a SSH jump host connection through access.grid5000.fr when it detects you are working outside of the Grid’5000 network. See Global configuration if you need to configure this behaviour.

Hint

Using a SSH jump host does not provide the best performance when controlling a large number of nodes. This is because the number of simultaneous SSH connection is limited on the jump host. See Performance tuning for many tips and tricks to improve performance.

Basic example#

We’ll imagine a system that requires 50 compute machines and 1 controller machines. We express this using the Distem provider:

Hint

 1from pathlib import Path
 2
 3import enoslib as en
 4
 5FORCE = False
 6CLUSTER = "parasilo"
 7
 8en.init_logging()
 9en.check()
10
11job_name = Path(__file__).name
12
13
14# claim the resources
15conf = (
16    en.DistemConf.from_settings(
17        job_name=job_name,
18        force_deploy=FORCE,
19        image="file:///home/msimonin/public/distem-stretch.tgz",
20    )
21    .add_machine(roles=["server"], cluster=CLUSTER, number=1, flavour="large")
22    .add_machine(roles=["client"], cluster=CLUSTER, number=1, flavour="large")
23)
24
25provider = en.Distem(conf)
26
27roles, networks = provider.init()
28
29print(roles)
30print(networks)
31gateway = networks[0].gateway
32print("Gateway : %s" % gateway)
33
34roles = en.sync_info(roles, networks)
35
36with en.actions(roles=roles, gather_facts=False) as p:
37    # We first need internet connectivity
38    # Netmask for a subnet in g5k is a /14 netmask
39    p.shell("ifconfig if0 $(hostname -I) netmask 255.252.0.0")
40    p.shell("route add default gw %s dev if0" % gateway)
41
42
43# Experimentation logic starts here
44with en.actions(roles=roles) as p:
45    # flent requires python3, so we default python to python3
46    p.apt_repository(
47        repo="deb http://deb.debian.org/debian stretch main contrib non-free",
48        state="present",
49    )
50    p.apt(name=["flent", "netperf", "python3-setuptools"], state="present")
51
52with en.actions(pattern_hosts="server", roles=roles) as p:
53    p.shell("nohup netperf &")
54
55with en.actions(pattern_hosts="client", roles=roles) as p:
56    p.shell(
57        "flent rrul -p all_scaled "
58        + "-l 60 "
59        + "-H {{ hostvars[groups['server'][0]].inventory_hostname }} "
60        + "-t 'bufferbloat test' "
61        + "-o result.png"
62    )
63    p.fetch(src="result.png", dest="result")

Note

lxc-create -n myimg -t download --  --dist debian --release stretch --arch amd64
mount -o bind /dev /var/lib/lxc/myimg/rootfs/dev
chroot /var/lib/lxc/myimg/rootfs
rm /etc/resolv.conf
echo "nameserver 9.9.9.9" > /etc/resolv.conf
# distem requirements: sshd
apt install openssh-server
# enoslib requirements: python
apt install -y python3
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
# your configuration goes here
exit
umount /var/lib/lxc/myimg/rootfs/dev
cd /var/lib/lxc/myimg/rootfs
tar -czvf ../distem-stretch.tgz .

EnOSlib bootsraps distem server and agents on your nodes and start the container for you. In particular: