1 # implements https://github.com/scionproto/scion/blob/27983125bccac6b84d1f96f406853aab0e460405/doc/tutorials/deploy.rst
2 import ../../make-test-python.nix ({ pkgs, ... }:
4 trust-root-configuration-keys = pkgs.runCommand "generate-trc-keys.sh" {
8 } (builtins.readFile ./bootstrap.sh);
14 bypassBootstrapWarning = true;
20 systemd.network.networks."01-eth1" = {
22 networkConfig.Address = "192.168.1.${toString hostId}/24";
25 "scion/topology.json".source = ./topology${toString hostId}.json;
26 "scion/crypto/as".source = trust-root-configuration-keys + "/AS${toString hostId}";
27 "scion/certs/ISD42-B1-S1.trc".source = trust-root-configuration-keys + "/ISD42-B1-S1.trc";
28 "scion/keys/master0.key".text = "U${toString hostId}v4k23ZXjGDwDofg/Eevw==";
29 "scion/keys/master1.key".text = "dBMko${toString hostId}qMS8DfrN/zP2OUdA==";
31 environment.systemPackages = [
41 imports = (imports 1);
44 imports = (imports 2);
47 imports = (imports 3);
50 imports = (imports 4);
51 networking.interfaces."lo".ipv4.addresses = [{ address = "172.16.1.1"; prefixLength = 32; }];
52 services.scion.scion-ip-gateway = {
56 src_ipv4 = "172.16.1.1";
72 imports = (imports 5);
73 networking.interfaces."lo".ipv4.addresses = [{ address = "172.16.100.1"; prefixLength = 32; }];
74 services.scion.scion-ip-gateway = {
78 src_ipv4 = "172.16.100.1";
95 pingAll = pkgs.writeShellScript "ping-all-scion.sh" ''
96 addresses="42-ffaa:1:1 42-ffaa:1:2 42-ffaa:1:3 42-ffaa:1:4 42-ffaa:1:5"
102 scion showpaths $as --no-probe > /dev/null
104 if [ "$ret" -ne "0" ]; then
114 scion ping "$as,127.0.0.1" -c 3
116 if [ "$ret" -ne "0" ]; then
122 for i in $(seq 0 $timeout); do
124 wait_for_all $addresses || continue
125 ping_all $addresses && exit 0
131 # List of AS instances
132 machines = [scion01, scion02, scion03, scion04, scion05]
134 # Functions to avoid many for loops
135 def start(allow_reboot=False):
137 i.start(allow_reboot=allow_reboot)
139 def wait_for_unit(service_name):
141 i.wait_for_unit(service_name)
143 def succeed(command):
155 # Start all machines, allowing reboot for later
156 start(allow_reboot=True)
158 # Wait for scion-control.service on all instances
159 wait_for_unit("scion-control.service")
161 # Ensure cert is valid against TRC
162 succeed("scion-pki certificate verify --trc /etc/scion/certs/*.trc /etc/scion/crypto/as/*.pem >&2")
164 # Execute pingAll command on all instances
165 succeed("${pingAll} >&2")
167 # Execute ICMP pings across scion-ip-gateway
168 scion04.succeed("ping -c 3 172.16.100.1 >&2")
169 scion05.succeed("ping -c 3 172.16.1.1 >&2")
171 # Restart all scion services and ping again to test robustness
172 succeed("systemctl restart scion-* >&2")
173 succeed("${pingAll} >&2")
175 # Reboot machines, wait for service, and ping again
177 wait_for_unit("scion-control.service")
178 succeed("${pingAll} >&2")
180 # Crash, start, wait for service, and ping again
183 wait_for_unit("scion-control.service")
184 succeed("pkill -9 scion-* >&2")
185 wait_for_unit("scion-control.service")
186 succeed("${pingAll} >&2")