Provider::Chameleon

This tutorial will let you get started using EnOSlib and Chameleon. This will present you the bare minimum to install the library with the required dependencies.

Hint

For a complete schema reference see Openstack Schema

Installation

$ pip install enoslib[chameleon]

Note

It’s a good practice to use a virtualenv or a python version manager like pyenv.

Basic example

The following reserve 2 nodes on the chameleon baremetal infrastructure. Prior to the execution you must source your openrc file.

$ source CH-XXXXX.sh

You must also configure an access key in you project and replace with its name in the following.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from enoslib.api import discover_networks, play_on
from enoslib.infra.enos_chameleonbaremetal.provider import Chameleonbaremetal
from enoslib.infra.enos_chameleonbaremetal.configuration import Configuration

import logging

logging.basicConfig(level=logging.INFO)

provider_conf = {
    "key_name": "enos_matt",
    "lease_name": "mylease",
    "resources": {
        "machines": [{
            "roles": ["server"],
            "flavour": "compute_skylake",
            "number": 1,
        },{
            "roles": ["client"],
            "flavour": "compute_skylake",
            "number": 1,
        }],
        "networks": ["network_interface"]
    }
}

tc = {
    "enable": True,
    "default_delay": "20ms",
    "default_rate": "1gbit",
}
conf = Configuration.from_dictionnary(provider_conf)
provider = Chameleonbaremetal(conf)

roles, networks = provider.init()

roles = discover_networks(roles, networks)

# Experimentation logic starts here
with play_on(roles=roles) as p:
    # flent requires python3, so we default python to python3
    p.apt_repository(repo="deb http://deb.debian.org/debian stretch main    contrib non-free",
                     state="absent")
    p.apt(name=["flent", "netperf", "python3-setuptools", "python3-matplotlib"],
          allow_unauthenticated=True,
          state="present")

with play_on(pattern_hosts="server", roles=roles) as p:
    p.shell("nohup netperf &")

with play_on(pattern_hosts="client", roles=roles) as p:
    p.shell("flent rrul -p all_scaled "
            + "-l 60 "
            + "-H {{ hostvars[groups['server'][0]].ansible_default_ipv4.address }} "
            + "-t 'bufferbloat test' "
            + "-o result.png")
    p.fetch(src="result.png",
            dest="result")

Note

Similarly to other provider the configuration can be generated programmatically instead of using a dict.

The result of the above code is the following:

../_images/result1.png