Exemplo n.º 1
0
def check_root_symlinks():
    """
    symlinks creation for directories externalised from opsim run dir
    i.e. OPSIMRUN_DIR/var/log will be symlinked to config['opsim']['log_dir']
    if needed
    """
    log = logging.getLogger()
    config = commons.getConfig()

    for (section, option, symlink_suffix) in (('opsim', 'log_dir', 'var/log'),
                                              ('opsim', 'tmp_dir',
                                               'tmp'), ('mysqld', 'data_dir',
                                                        'var/lib/mysql')):
        symlink_target = config[section][option]
        default_dir = os.path.join(config['opsim']['run_base_dir'],
                                   symlink_suffix)

        # A symlink is needed if the target directory is not set to its
        # default value
        if not os.path.samefile(symlink_target, os.path.realpath(default_dir)):
            if os.path.exists(default_dir):
                if os.path.islink(default_dir):
                    os.unlink(default_dir)
                else:
                    log.fatal("Please remove {0} and restart the "
                              "configuration procedure".format(default_dir))
                    sys.exit(1)
            _symlink(symlink_target, default_dir)

    log.info("opsim symlinks creation for externalized directories succeeded")
Exemplo n.º 2
0
def check_root_dirs():

    logger = logging.getLogger()

    config = commons.getConfig()

    for (section, option) in (('qserv', 'base_dir'), ('qserv', 'log_dir'), ('qserv', 'tmp_dir'),
                             ('mysqld', 'data_dir')):
        dir = config[section][option]
        if not exists_and_is_writable(dir):
            logging.fatal("%s is not writable check/update permissions or"
                            " change config['%s']['%s']", dir, section, option)
            sys.exit(1)

    for suffix in ('etc', 'var', 'var/lib', 'var/run', 'var/run/mysqld', 'var/lock/subsys'):
        dir = os.path.join(config['qserv']['run_base_dir'], suffix)
        if not exists_and_is_writable(dir):
            logging.fatal("%s is not writable check/update permissions", dir)
            sys.exit(1)

    # user config
    user_config_dir = os.path.join(os.getenv("HOME"), ".lsst")
    if not exists_and_is_writable(user_config_dir):
        logging.fatal("%s is not writable check/update permissions", dir)
        sys.exit(1)
    logger.info("Qserv directory structure creation succeeded")
Exemplo n.º 3
0
def check_root_symlinks():
    """
    symlinks creation for directories externalised from opsim run dir
    i.e. OPSIMRUN_DIR/var/log will be symlinked to config['opsim']['log_dir']
    if needed
    """
    log = logging.getLogger()
    config = commons.getConfig()

    for (section, option, symlink_suffix) in (('opsim', 'log_dir', 'var/log'),
                                              ('opsim', 'tmp_dir', 'tmp'),
                                              ('mysqld', 'data_dir',
                                               'var/lib/mysql')):
        symlink_target = config[section][option]
        default_dir = os.path.join(config['opsim']['run_base_dir'],
                                   symlink_suffix)

        # A symlink is needed if the target directory is not set to its
        # default value
        if not os.path.samefile(symlink_target,
                                os.path.realpath(default_dir)):
            if os.path.exists(default_dir):
                if os.path.islink(default_dir):
                    os.unlink(default_dir)
                else:
                    log.fatal("Please remove {0} and restart the "
                              "configuration procedure".format(default_dir))
                    sys.exit(1)
            _symlink(symlink_target, default_dir)

    log.info("opsim symlinks creation for externalized directories succeeded")
Exemplo n.º 4
0
def check_root_dirs():

    logger = logging.getLogger()

    config = commons.getConfig()

    for (section, option) in (('opsim', 'base_dir'), ('opsim', 'log_dir'),
                              ('opsim', 'tmp_dir'), ('mysqld', 'data_dir')):
        dir = config[section][option]
        if not exists_and_is_writable(dir):
            logging.fatal(
                "%s is not writable check/update permissions or"
                " change config['%s']['%s']", dir, section, option)
            sys.exit(1)

    for suffix in ('etc', 'var', 'var/lib', 'var/run', 'var/run/mysqld',
                   'var/lock/subsys'):
        dir = os.path.join(config['opsim']['run_base_dir'], suffix)
        if not exists_and_is_writable(dir):
            logging.fatal("%s is not writable check/update permissions", dir)
            sys.exit(1)

    # user config
    user_config_dir = os.path.join(os.getenv("HOME"), ".lsst")
    if not exists_and_is_writable(user_config_dir):
        logging.fatal("%s is not writable check/update permissions", dir)
        sys.exit(1)
    logger.info("opsim directory structure creation succeeded")
Exemplo n.º 5
0
def _get_template_params():
    """ Compute templates parameters from configuration file
    """
    logger = logging.getLogger()
    config = commons.getConfig()

    if config['qserv']['node_type'] == 'mono':
        comment_mono_node = '#MONO-NODE# '
    else:
        comment_mono_node = ''

    if 'testdata_dir' in config['qserv']:
        testdata_dir = config['qserv']['testdata_dir']
    else:
        testdata_dir = os.environ.get('QSERV_TESTDATA_DIR')

    params_dict = {
    'COMMENT_MONO_NODE' : comment_mono_node,
    'PATH': os.environ.get('PATH'),
    'LD_LIBRARY_PATH': os.environ.get('LD_LIBRARY_PATH'),
    'PYTHON_BIN': which("python"),
    'PYTHONPATH': os.environ['PYTHONPATH'],
    'QSERV_MASTER': config['qserv']['master'],
    'QSERV_DIR': config['qserv']['base_dir'],
    'QSERV_RUN_DIR': config['qserv']['run_base_dir'],
    'QSERV_UNIX_USER': os.getlogin(),
    'QSERV_LOG_DIR': config['qserv']['log_dir'],
    'QSERV_PID_DIR': os.path.join(config['qserv']['run_base_dir'], "var", "run"),
    'QSERV_TESTDATA_DIR': testdata_dir,
    'QSERV_RPC_PORT': config['qserv']['rpc_port'],
    'QSERV_USER': config['qserv']['user'],
    'QSERV_LUA_SHARE': os.path.join(config['lua']['base_dir'], "share", "lua", "5.1"),
    'QSERV_LUA_LIB': os.path.join(config['lua']['base_dir'], "lib", "lua", "5.1"),
    'QSERV_SCRATCH_DIR': config['qserv']['scratch_dir'],
    'MYSQL_DIR': config['mysqld']['base_dir'],
    'MYSQLD_DATA_DIR': config['mysqld']['data_dir'],
    'MYSQLD_PORT': config['mysqld']['port'],
    # used for mysql-proxy in mono-node
    'MYSQLD_HOST': '127.0.0.1',
    'MYSQLD_SOCK': config['mysqld']['sock'],
    'MYSQLD_USER': config['mysqld']['user'],
    'MYSQLD_PASS': config['mysqld']['pass'],
    'MYSQL_PROXY_PORT': config['mysql_proxy']['port'],
    'XROOTD_DIR': config['xrootd']['base_dir'],
    'XROOTD_MANAGER_HOST': config['qserv']['master'],
    'XROOTD_PORT': config['xrootd']['xrootd_port'],
    'XROOTD_RUN_DIR': os.path.join(config['qserv']['run_base_dir'], "xrootd-run"),
    'XROOTD_ADMIN_DIR': os.path.join(config['qserv']['run_base_dir'], 'tmp'),
    'CMSD_MANAGER_PORT': config['xrootd']['cmsd_manager_port'],
    'ZOOKEEPER_PORT': config['zookeeper']['port'],
    'HOME': os.path.expanduser("~"),
    'NODE_TYPE': config['qserv']['node_type'],
    }

    logger.debug("Input parameters :\n {0}".format(params_dict))

    return params_dict
Exemplo n.º 6
0
def uninstall(target, source, env):
    logger = logging.getLogger()
    config = commons.getConfig()
    uninstall_paths = [os.path.join(config['opsim']['log_dir']),
                       os.path.join(config['mysqld']['data_dir']),
                       os.path.join(config['opsim']['scratch_dir']), ]
    for upath in uninstall_paths:
        if not os.path.exists(upath):
            logger.info("Not uninstalling %s because it doesn't exists.",
                        upath)
        else:
            shutil.rmtree(upath)
Exemplo n.º 7
0
def uninstall(target, source, env):
    logger = logging.getLogger()
    config = commons.getConfig()
    uninstall_paths = [
        os.path.join(config['opsim']['log_dir']),
        os.path.join(config['mysqld']['data_dir']),
        os.path.join(config['opsim']['scratch_dir']),
    ]
    for upath in uninstall_paths:
        if not os.path.exists(upath):
            logger.info("Not uninstalling %s because it doesn't exists.",
                        upath)
        else:
            shutil.rmtree(upath)
Exemplo n.º 8
0
def _get_template_params():
    """
    Compute templates parameters from opsim meta-configuration file from PATH
    or from environment variables for products not needed during build
    """
    logger = logging.getLogger()
    config = commons.getConfig()

    global template_params_dict

    if template_params_dict is None:

        testdata_dir = os.getenv('OPSIMTESTDATA_DIR',
                                 "NOT-AVAILABLE # please set environment "
                                 "variable OPSIMTESTDATA_DIR if needed")

        params_dict = {
            'PATH': os.environ.get('PATH'),
            'LD_LIBRARY_PATH': os.environ.get('LD_LIBRARY_PATH'),
            'OPSIM_MASTER': config['opsim']['master'],
            'OPSIM_DIR': config['opsim']['base_dir'],
            'OPSIM_RUN_DIR': config['opsim']['run_base_dir'],
            'OPSIM_UNIX_USER': getpass.getuser(),
            'OPSIM_LOG_DIR': config['opsim']['log_dir'],
            'OPSIM_META_CONFIG_FILE': config['opsim']['meta_config_file'],
            'OPSIM_PID_DIR': os.path.join(config['opsim']['run_base_dir'],
                                          "var", "run"),
            'OPSIM_USER': config['opsim']['user'],
            'OPSIM_PASS': config['opsim']['pass'],
            'OPSIM_SCRATCH_DIR': config['opsim']['scratch_dir'],
            'MYSQL_DIR': config['mysqld']['base_dir'],
            'MYSQLD_DATA_DIR': config['mysqld']['data_dir'],
            'MYSQLD_PORT': config['mysqld']['port'],
            # used for mysql-proxy in mono-node
            'MYSQLD_HOST': '127.0.0.1',
            'MYSQLD_SOCK': config['mysqld']['sock'],
            'MYSQLD_USER': config['mysqld']['user'],
            'MYSQLD_PASS': config['mysqld']['pass'],
            'HOME': os.path.expanduser("~"), }

        logger.debug("Template input parameters:\n {0}".format(params_dict))
        template_params_dict = params_dict
    else:
        params_dict = template_params_dict

    return params_dict
Exemplo n.º 9
0
def _get_template_params():
    """
    Compute templates parameters from opsim meta-configuration file from PATH
    or from environment variables for products not needed during build
    """
    logger = logging.getLogger()
    config = commons.getConfig()

    global template_params_dict

    if template_params_dict is None:

        testdata_dir = os.getenv(
            'OPSIMTESTDATA_DIR', "NOT-AVAILABLE # please set environment "
            "variable OPSIMTESTDATA_DIR if needed")

        params_dict = {
            'PATH':
            os.environ.get('PATH'),
            'LD_LIBRARY_PATH':
            os.environ.get('LD_LIBRARY_PATH'),
            'OPSIM_MASTER':
            config['opsim']['master'],
            'OPSIM_DIR':
            config['opsim']['base_dir'],
            'OPSIM_RUN_DIR':
            config['opsim']['run_base_dir'],
            'OPSIM_UNIX_USER':
            getpass.getuser(),
            'OPSIM_LOG_DIR':
            config['opsim']['log_dir'],
            'OPSIM_META_CONFIG_FILE':
            config['opsim']['meta_config_file'],
            'OPSIM_PID_DIR':
            os.path.join(config['opsim']['run_base_dir'], "var", "run"),
            'OPSIM_USER':
            config['opsim']['user'],
            'OPSIM_PASS':
            config['opsim']['password'],
            'OPSIM_SCRATCH_DIR':
            config['opsim']['scratch_dir'],
            'MYSQL_DIR':
            config['mysqld']['base_dir'],
            'MYSQLD_DATA_DIR':
            config['mysqld']['data_dir'],
            'MYSQLD_PORT':
            config['mysqld']['port'],
            # used for mysql-proxy in mono-node
            'MYSQLD_HOST':
            '127.0.0.1',
            'MYSQLD_SOCK':
            config['mysqld']['sock'],
            'MYSQLD_USER':
            config['mysqld']['user'],
            'MYSQLD_PASS':
            config['mysqld']['password'],
            'HOME':
            os.path.expanduser("~"),
        }

        logger.debug("Template input parameters:\n {0}".format(params_dict))
        template_params_dict = params_dict
    else:
        params_dict = template_params_dict

    return params_dict