-
Notifications
You must be signed in to change notification settings - Fork 1
/
fig10.py
55 lines (42 loc) · 1.21 KB
/
fig10.py
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
# -*- coding: utf-8 -*-
# Imports/Type defs
from enoslib.task import enostask
from enoslib.host import Host
from execo_engine import ParamSweeper, sweep
import traceback
from pathlib import Path
from utils import LOG
@enostask(new=True)
def deploy(env=None):
roles, networks = {"role1": Host("1.2.3.4")}, []
# Save the roles and networks in the environment
env["roles"] = roles
env["networks"] = networks
@enostask()
def bench(parameter, env=None):
LOG.info(f"Running bench with {parameter} on {env['roles']}")
@enostask()
def backup(env=None):
LOG.info(f"Running backup on {env['roles']}")
@enostask()
def destroy(env=None):
LOG.info(f"Running destroy on {env['roles']}")
# Iterate over a set of parameters
parameters = {"param1": [1, 4], "param2": ["a", "b"]}
sweeps = sweep(parameters)
sweeper = ParamSweeper(
persistence_dir=str(Path("sweeps")), sweeps=sweeps, save_sweeps=True
)
parameter = sweeper.get_next()
while parameter:
try:
deploy()
bench(parameter)
backup()
sweeper.done(parameter)
except Exception as e:
traceback.print_exc()
sweeper.skip(parameter)
finally:
destroy()
parameter = sweeper.get_next()