diff options
author | Enbo Wang <wangenbo@huawei.com> | 2020-09-18 11:06:12 +0800 |
---|---|---|
committer | Enbo Wang <wangenbo@huawei.com> | 2020-09-19 17:25:04 +0800 |
commit | b764f221db38dd0d0fb3bad908e5d1329721730d (patch) | |
tree | 0a60d0bc8a3f9b6ac0a941a955ba0007fe57cd06 /test/mocks/ran-nssmf-simulator/RanNssmfSimulator/utils.py | |
parent | edbe50b80ce489b5ef9f30c9cd72f2dbcf2032d9 (diff) |
Add an External RAN NSSMF simulator
Change-Id: I770091159dd1f953d8a567ccd2bd7f6d21f27649
Issue-ID: INT-1707
Signed-off-by: Enbo Wang <wangenbo@huawei.com>
Diffstat (limited to 'test/mocks/ran-nssmf-simulator/RanNssmfSimulator/utils.py')
-rw-r--r-- | test/mocks/ran-nssmf-simulator/RanNssmfSimulator/utils.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/mocks/ran-nssmf-simulator/RanNssmfSimulator/utils.py b/test/mocks/ran-nssmf-simulator/RanNssmfSimulator/utils.py new file mode 100644 index 000000000..f0b99119a --- /dev/null +++ b/test/mocks/ran-nssmf-simulator/RanNssmfSimulator/utils.py @@ -0,0 +1,44 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +import os +import logging + +REST_PORT = int(os.getenv("RAN_NSSMF_REST_PORT", "8443")) +LOGGING_LEVEL = os.getenv("RAN_NSSMF_LOGGING_LEVEL", "INFO") + +TOKEN_EXPIRES_TIME = int(os.getenv("RAN_NSSMF_TOKEN_EXPIRES_TIME", "30")) +TOKEN_CLEAN_TIME = int(os.getenv("RAN_NSSMF_TOKEN_CLEAN_TIME", "180")) + +MAIN_DIR = os.path.dirname(os.path.abspath(__file__)) +AUTH_DB_FILE = os.path.join(MAIN_DIR, "etc", "auth.json") + +AUTH_DB = os.getenv("RAN_NSSMF_AUTH_DB", AUTH_DB_FILE) + + +LOGGER_FORMAT = "[%(asctime)-15s] %(levelname)s in %(name)s: %(message)s" + + +def getLogger(name, level=LOGGING_LEVEL, fmt=LOGGER_FORMAT): + logger = logging.getLogger(name) + logger.setLevel(level) + + formatter = logging.Formatter(fmt) + cmd_handler = logging.StreamHandler() + cmd_handler.setFormatter(formatter) + logger.addHandler(cmd_handler) + + return logger |