-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
55 lines (39 loc) · 1.34 KB
/
conftest.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
import os
import yaml
from common.local_agent_managers import *
from common.remote_agent_managers import *
__author__ = "Piotr Gawlowicz"
__copyright__ = "Copyright (c) 2017, Technische Universitat Berlin"
__version__ = "0.1.0"
__email__ = "[email protected]"
def get_controller_config_dict():
config = {}
dir_path = os.path.dirname(os.path.realpath(__file__))
f = open(dir_path + "/remote_hosts.yaml")
data = yaml.load(f)
if "controller_config" in data:
config = data["controller_config"]
return config
def skip_if_no_controller_config():
config = get_controller_config_dict()
if bool(config):
return False
else:
print("Global Controller config is missing!")
return True
def get_remote_hosts_dict():
remote_hosts = {}
dir_path = os.path.dirname(os.path.realpath(__file__))
f = open(dir_path + "/remote_hosts.yaml")
remote_hosts = yaml.load(f)
return remote_hosts
def skip_if_not_enough_remote_nodes(nodeType, requiredNodeNum):
remote_hosts_yaml = get_remote_hosts_dict()
nodeNum = 0
if remote_hosts_yaml and nodeType in remote_hosts_yaml:
nodeNum = len(remote_hosts_yaml[nodeType])
print("Number of available '{}' nodes: {}".format(nodeType, nodeNum))
if nodeNum < requiredNodeNum:
return True
else:
return False