This repository has been archived by the owner on Jan 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathopenbenchmark.py
91 lines (77 loc) · 2.43 KB
/
openbenchmark.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import argparse
from experiment_provisioner.main import Main as ExpProvisioner
class OpenBenchmark:
def __init__(self):
pass
def add_parser_args(self, parser):
parser.add_argument('--user-id', # User ID is tied to the OpenBenchmark account
dest = 'user_id',
default = 0,
required = False,
action = 'store'
)
parser.add_argument('--simulator',
dest = 'simulator',
default = False,
action = 'store_true'
)
parser.add_argument('--action',
dest = 'action',
choices = ['check', 'reserve', 'terminate', 'flash', 'sut-start', 'ov', 'orchestrator'],
required = True,
action = 'store'
)
parser.add_argument('--testbed',
dest = 'testbed',
choices = ['iotlab', 'wilab', 'opensim'],
default = 'iotlab',
action = 'store'
)
parser.add_argument('--firmware',
dest = 'firmware',
required = False,
action = 'store',
)
parser.add_argument('--branch',
dest = 'branch',
required = False,
action = 'store',
)
parser.add_argument('--scenario',
dest = 'scenario',
choices = ['demo-scenario', 'building-automation', 'home-automation', 'industrial-monitoring'],
default = 'demo-scenario',
action = 'store'
)
def get_args(self):
parser = argparse.ArgumentParser()
self.add_parser_args(parser)
args = parser.parse_args()
self._validate(args, parser)
return {
'user_id' : args.user_id,
'simulator' : args.simulator,
'action' : args.action,
'testbed' : args.testbed,
'firmware' : args.firmware,
'branch' : args.branch,
'scenario' : args.scenario
}
def _validate(self, args, parser):
if args.action != 'sut-start' and args.simulator:
parser.error('--simulator is only a valid parameter for --action=sut-start')
if args.testbed == 'opensim' and args.action not in ['flash', 'sut-start', 'ov', 'orchestrator', 'terminate']:
parser.error('OpenSim testbed simulator supports only `sut-start`, `ov`, `orchestrator`, and `terminate` actions')
def main():
openbenchmark = OpenBenchmark()
args = openbenchmark.get_args()
user_id = args['user_id']
simulator = args['simulator']
action = args['action']
testbed = args['testbed']
scenario = args['scenario']
firmware = args['firmware']
branch = args['branch']
ExpProvisioner(user_id, simulator, action, testbed, scenario, firmware, branch)
if __name__ == '__main__':
main()