example_os-images.md 1.63 KB
Newer Older
Ryan Goodfellow's avatar
Ryan Goodfellow committed
1
---
Ryan Goodfellow's avatar
Ryan Goodfellow committed
2
id: images
Ryan Goodfellow's avatar
Ryan Goodfellow committed
3
4
5
6
7
8
9
title: Operating System Images
---

Merge allows you to choose from a number of standard operating system images.
The example below shows a 5 node experiment where each node has a different OS
image.

Ryan Goodfellow's avatar
Ryan Goodfellow committed
10
![](/img/topo/rainbow.png)
Ryan Goodfellow's avatar
Ryan Goodfellow committed
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
58
59
60
61
62
63
64

Images are specified as constraints on a node when the node is defined.

```python
from mergexp.machine import image

net.device(name, image == "debian:10")
```

The standard format for images is `os-family:version`. The versions used are
numeric, and not the code name of the distribution. For example `debian:10`
instead of `debian:buster` and `ubuntu:2004` instead of `ubuntu:focal`.

This is so you can use inequality constraints against images. For example

```python
from mergexp.machine import image

net.device(name, image >= "ubuntu:1804")
```

### Available Images

The images that are currently available on all Merge testbeds are the following

|Image Id| Distro Codename |
|:---|:---| 
|`debian:10`   | Debian Buster |
|`debian:11`   | Debian Bullseye |
|`ubuntu:1804` | Ubuntu Bionic |
|`ubuntu:2004` | Ubuntu Focal |


### Complete Example

```python
import mergexp as mx
from mergexp.machine import image
from mergexp.net import addressing, ipv4

def ubuntu(name, version):
    dev = net.device(name, image == "ubuntu:"+version)
    dev.props['group'] = version
    return dev

def debian(name, version):
    dev = net.device(name, image == "debian:"+version)
    dev.props['group'] = version
    return dev

net = mx.Topology('rainbow', addressing == ipv4)

nodes = [
    ubuntu('a','1804'),
Ryan Goodfellow's avatar
Ryan Goodfellow committed
65
66
67
    ubuntu('b','2004'),
    debian('c', '10'),
    debian('d', '11')
Ryan Goodfellow's avatar
Ryan Goodfellow committed
68
69
70
71
72
]
lan = net.connect(nodes)

mx.experiment(net)
```