diff options
author | asteroide <thomas.duval@orange.com> | 2017-07-25 17:46:31 +0200 |
---|---|---|
committer | asteroide <thomas.duval@orange.com> | 2017-07-25 17:46:31 +0200 |
commit | 000ba3d0d4ac08a59a3f8a78faa450e565bae0c3 (patch) | |
tree | 8389b35d5b0dfb08514ade86b236989576c6c8d1 /moonv4/moon_interface/tests/apitests/utils/policies.py | |
parent | 8cbf11c78259540f9a2b0661842bb82558ea2648 (diff) |
Get the configuration from moon.conf
Change-Id: I27c86af24adc5ee4661943a9cab5e4a54ca02b3d
Diffstat (limited to 'moonv4/moon_interface/tests/apitests/utils/policies.py')
-rw-r--r-- | moonv4/moon_interface/tests/apitests/utils/policies.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/moonv4/moon_interface/tests/apitests/utils/policies.py b/moonv4/moon_interface/tests/apitests/utils/policies.py index 444f34d7..fdde92ef 100644 --- a/moonv4/moon_interface/tests/apitests/utils/policies.py +++ b/moonv4/moon_interface/tests/apitests/utils/policies.py @@ -1,11 +1,25 @@ +import os +import yaml import requests -import configparser -config = configparser.ConfigParser() -if not config.read("moon.conf"): - config.read("/etc/moon/moon.conf") +for path in ( + "moon.conf", + "../moon.conf", + "{}/moon_orchestrator/conf/moon.conf".format(os.getenv("MOON_HOME")), + "/etc/moon/moon.conf" +): + try: + config = yaml.safe_load(open(path)) + except FileNotFoundError: + config = None + continue + else: + print("Using {}".format(path)) + break +if not config: + raise Exception("Configuration file not found...") -URL = "http://{}:{}".format(config['interface']['host'], config['interface']['port']) +URL = "http://{}:{}".format(config['components']['interface']['hostname'], config['components']['interface']['port']) URL = URL + "{}" HEADERS = {"content-type": "application/json"} FILE = open("/tmp/test.log", "w") |