Beispiel #1
0
def start_processes():
    processes = ['api', 'task', 'alert']
    # Start cmd processes
    for process in processes:
        env_var = 'DELFIN_' + process.upper() + '_INSTANCES'
        try:
            instances = os.environ.get(env_var)
            # Ignore multiple instance of api
            if not instances or process == 'api':
                instances = '1'
            start_process(process, int(instances))
        except CalledProcessError as cpe:
            logger.error("Got CPE error [%s]:[%s]" % (cpe, tb.print_exc()))
            return
        except ValueError as e:
            logger.error(
                "Got invalid [%s] environment variable:[%s]" % (env_var, e))
            return

    # Start exporter server process
    proc_path = os.path.join(delfin_source_path, 'delfin', 'exporter',
                             'prometheus', 'exporter_server.py')
    command = 'python3 ' + proc_path + ' --config-file ' + \
              conf_file + ' >' + DEVNULL + ' 2>&1 &'
    logger.info("Executing command [%s]", command)
    os.system(command)
    logger.info("Exporter process_started")
Beispiel #2
0
def create_delfin_db():
    try:
        db_path = os.path.join(delfin_source_path, 'script', 'create_db.py')
        subprocess.check_call(['python3', db_path, '--config-file', conf_file])
    except CalledProcessError as cpe:
        logger.error("Got CPE error [%s]:[%s]" % (cpe, tb.print_exc()))
        return
    logger.info('db created ')
Beispiel #3
0
def install_delfin():
    python_setup_comm = ['build', 'install']
    req_logs = os.path.join(delfin_log_dir, 'requirements.log')
    command = 'pip3 install -r requirements.txt >' + req_logs + ' 2>&1'
    logger.info("Executing [%s]", command)
    os.system(command)

    setup_file = os.path.join(delfin_source_path, 'setup.py')
    for command in python_setup_comm:
        try:
            command = 'python3 ' + setup_file + ' ' +\
                      command + ' >>' + logfile
            logger.info("Executing [%s]", command)
            os.system(command)
        except CalledProcessError as cpe:
            logger.error("Got CPE error [%s]:[%s]" % (cpe, tb.print_exc()))
            return