X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=solution%2Fnetwork%2Fconfig.py;h=3bee9be6556245e8be1356cf8419af13f869707b;hb=a469cde0cecad330f311c5a1777e9d61fa8129af;hp=57aab93634e891b977dcc2117ecd551a9f31fc3f;hpb=990de7205645f827a36429006f7e5529b5fb6866;p=oam.git diff --git a/solution/network/config.py b/solution/network/config.py index 57aab93..3bee9be 100644 --- a/solution/network/config.py +++ b/solution/network/config.py @@ -19,6 +19,7 @@ import os import sys import json +import re import requests import subprocess import pathlib @@ -26,20 +27,29 @@ from jproperties import Properties def get_environment_variable(name): configs = Properties() - path = pathlib.Path( os.path.dirname(os.path.abspath(__file__)) ) + path = pathlib.Path(os.path.dirname(os.path.abspath(__file__))) env_file = str(path.absolute()) + '/.env' with open(env_file, "rb") as read_prop: configs.load(read_prop) - return configs.get(name).data + value = configs.get(name).data + + regex = r"\$\{([^\}]+)\}" + matches = re.finditer(regex, value) + while True: + match = next(matches, None) + if match is None: + break + inner = get_environment_variable(match.group(1)) + value = value.replace("${" + match.group(1) + "}", inner ) + return value dockerFilter = subprocess.check_output("docker ps --format '{{.Names}}'", shell=True) containers = dockerFilter.splitlines() mapping = dict({"ntsim-ng-o-ru": "O-RU", "ntsim-ng-o-du": "O-DU"}) -# base = 'https://sdnc-web:8453' base = get_environment_variable('SDN_CONTROLLER_PROTOCOL') + '://' + get_environment_variable('SDNC_OAM_HOST') -username = 'admin' -password = 'Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U' +username = get_environment_variable('ADMIN_USERNAME') +password = get_environment_variable('ADMIN_PASSWORD') # REST to set event settings def configEventSettings(nfName, nfType):