From 35375724d9657de99adb8e530e1be21305555a40 Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Thu, 17 Sep 2020 13:04:35 -0700 Subject: [VVP] Updating onap-client Removing dependency on distutils moving etc/ to package resource Adding support for volume creation and delete Removing module level imports Adding delete capability to spec-engine Adding kwarg to pass Client instance to functions Issue-ID: VVP-469 Signed-off-by: stark, steven Change-Id: Ie00065f54411c8ff40ea20c35fe919ce15f65e6a --- onap-client/onap_client/config.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'onap-client/onap_client/config.py') diff --git a/onap-client/onap_client/config.py b/onap-client/onap_client/config.py index 6fe43e9..3b85bf8 100644 --- a/onap-client/onap_client/config.py +++ b/onap-client/onap_client/config.py @@ -34,11 +34,12 @@ # limitations under the License. # # ============LICENSE_END============================================ - -import distutils.sysconfig import logging import os import yaml +from importlib_resources import files + +from onap_client import etc class Config: @@ -75,24 +76,24 @@ class Config: ) if not config_data: - with open("{}/config.example.yaml".format(PATH), "r") as f: + with open(os.path.join(files(etc), "config.example.yaml"), "r") as f: config_data = yaml.safe_load(f) self.config = config_data for key in keys: self.config = self.config.get(key, {}) + @property + def payload_directory(self): + return os.path.join(files(etc), "payloads") + + @property + def application_id(self): + return "robot-ete" + def load_config(config_file, *config_args): config = Config(config_file) config.load(*config_args) return config - - -PATH = "{}/onap_client".format(distutils.sysconfig.PREFIX) -PAYLOADS_DIR = "{}/payloads".format(PATH) -APPLICATION_ID = "robot-ete" -CONFIG_ENV = os.environ.get("OC_CONFIG") -CONFIG_FILE = CONFIG_ENV or "/etc/onap_client/config.yaml" -APP_CONFIG = load_config(CONFIG_FILE, "onap_client") -- cgit 1.2.3-korg