Пример #1
0
def setup_logging(args):
    """
    Configure logging.
    """
    log_level = logging.INFO
    # get loglevel from environment or --loglevel
    log_level_str = os.environ.get("LOGLEVEL", "INFO")
    if args.log_level:  # overwrite if present
        log_level_str = args.log_level
    # parse
    log_level_str = str(log_level_str).lower()
    if log_level_str == "debug":
        log_level = logging.DEBUG
    elif log_level_str == "info":
        log_level = logging.INFO
    elif log_level_str == "warning":
        log_level = logging.WARNING
    elif log_level_str == "error":
        log_level = logging.ERROR
    else:
        print("Loglevel '{}' unknown.".format(log_level_str))
    # if "-v" is there set to debug
    if args.verbose:
        log_level = logging.DEBUG
    # select logging mode
    log_json = os.environ.get("LOGJSON", args.logjson)
    # configure all TangoLoggers
    TangoLogger.reconfigure_all_tango_loggers(log_level=log_level,
                                              log_json=log_json)
Пример #2
0
    def __init__(self, args):
        self.logger = TangoLogger.getLogger(__name__)
        self.start_time = time.time()
        self.service_experiments = list()
        self.function_experiments = list()
        self.args = args
        self.args.debug = self.args.verbose
        self.args.ped = os.path.join(os.getcwd(), self.args.ped)
        # load config file: try different paths
        for path in [
                os.path.abspath(os.path.expanduser(args.configfile)),
                os.path.abspath(".tng-bench.conf"),
                os.path.abspath("config.yml")
        ]:
            try:
                self.args.config = self._load_config(path)
                break
            except BaseException as ex:
                self.logger.error(ex)
                self.args.config = None
        if self.args.config is None:
            print("Connot run without configuration.")
            exit(1)

        # logging setup
        coloredlogs.install(level="DEBUG" if args.verbose else "INFO")
        self.logger.info("5GTANGO benchmarking/profiling tool initialized")
        self.logger.debug("Arguments: %r" % self.args)
Пример #3
0
 def __init__(self, args):
     self.logger = TangoLogger.getLogger(__name__)
     self.start_time = time.time()
     self.service_experiments = list()
     self.function_experiments = list()
     self.args = args
     self.args.debug = self.args.verbose
     self.args.ped = os.path.join(os.getcwd(), self.args.ped)
     self.args.config = self._load_config(os.path.abspath(args.configfile))
     # logging setup
     coloredlogs.install(level="DEBUG" if args.verbose else "INFO")
     self.logger.info("5GTANGO benchmarking/profiling tool initialized")
     self.logger.debug("Arguments: %r" % self.args)
Пример #4
0
# acknowledge the contributions of their colleagues of the SONATA
# partner consortium (www.5gtango.eu).

import time
import shutil
import os
import yaml
import tarfile
from io import BytesIO
from tngsdk.benchmark.generator import ServiceConfigurationGenerator
from tngsdk.benchmark.helper import ensure_dir, read_yaml, write_yaml
from tngsdk.benchmark.helper import parse_ec_parameter_key
import tngsdk.package as tngpkg
from tngsdk.benchmark.logger import TangoLogger

LOG = TangoLogger.getLogger(__name__)

BASE_PKG_PATH = "base_pkg/"
BASE_PROJECT_PATH = "base_project/"
GEN_PROJECT_PATH = "gen_projects/"
GEN_PKG_PATH = "gen_pkgs/"
TEMPLATE_VNFD_MP = "template/tango_vnfd_mp.yml"


class OSMServiceConfigurationGenerator(ServiceConfigurationGenerator):
    """
    5GTANGO Service Configuration Generator.
    Input: 5GTANGO service package.
    Output: 5GTANGO service packages w. applied
    experiment configurations, e.g., resource limits.
    """