Пример #1
0
def setup_server(irods_config):
    l = logging.getLogger(__name__)

    check_hostname()

    l.info(get_header('Stopping iRODS...'))
    IrodsController(irods_config).stop()

    setup_service_account(irods_config)

    #Do the rest of the setup as the irods user
    irods.lib.switch_user(irods_config.irods_user, irods_config.irods_group)

    if irods_config.is_catalog:
        setup_database_config(irods_config)
    setup_server_config(irods_config)
    setup_client_environment(irods_config)

    if irods_config.is_catalog:
        default_resource_directory = get_and_create_default_vault(irods_config)
        setup_catalog(irods_config,
                      default_resource_directory=default_resource_directory)

    l.info(get_header('Starting iRODS...'))
    IrodsController(irods_config).start()

    if irods_config.is_resource:
        default_resource_directory = get_and_create_default_vault(irods_config)
        irods.lib.execute_command([
            'iadmin', 'mkresc',
            irods_config.server_config['default_resource_name'],
            'unixfilesystem',
            ':'.join([irods.lib.get_hostname(),
                      default_resource_directory]), ''
        ])

    test_put(irods_config)

    l.info(get_header('iRODS is installed and running'))
Пример #2
0
def setup_server(irods_config, json_configuration_file=None):
    l = logging.getLogger(__name__)

    check_hostname()

    if json_configuration_file is not None:
        with open(json_configuration_file) as f:
            json_configuration_dict = json.load(f)
    else:
        json_configuration_dict = None

    if IrodsController().get_binary_to_pids_dict():
        l.info(irods.lib.get_header('Stopping iRODS...'))
        IrodsController(irods_config).stop()

    if not os.path.exists(irods_config.version_path):
        with open('.'.join([irods_config.version_path, 'dist'])) as f:
            version_json = json.load(f)
        version_json['installation_time'] = datetime.datetime.now().isoformat()
        irods_config.commit(version_json, irods.paths.version_path())

    if json_configuration_dict is not None:
        irods_user = json_configuration_dict['host_system_information']['service_account_user_name']
        irods_group = json_configuration_dict['host_system_information']['service_account_group_name']
    else:
        irods_user, irods_group = get_irods_user_and_group(irods_config)

    setup_service_account(irods_config, irods_user, irods_group)

    #Do the rest of the setup as the irods user
    if os.getuid() == 0:
        irods.lib.switch_user(irods_config.irods_user, irods_config.irods_group)

    if json_configuration_dict is not None:
        irods_config.commit(json_configuration_dict['server_config'], irods.paths.server_config_path())
        if irods_config.is_catalog:
            from irods import database_interface
            if database_interface.database_already_in_use_by_irods(irods_config):
                raise IrodsError('Database specified already in use by iRODS.')
        irods_config.commit(json_configuration_dict['hosts_config'], irods.paths.hosts_config_path())
        irods_config.commit(json_configuration_dict['host_access_control_config'], irods.paths.host_access_control_config_path())
        if not os.path.exists(os.path.dirname(irods_config.client_environment_path)):
            os.makedirs(os.path.dirname(irods_config.client_environment_path), mode=0o700)
        irods_config.commit(json_configuration_dict['service_account_environment'], irods_config.client_environment_path)
        irods_config.admin_password = json_configuration_dict['admin_password']
        default_resource_directory = json_configuration_dict.get('default_resource_directory', os.path.join(irods_config.irods_directory, 'Vault'))
    else:
        determine_server_role(irods_config)

        if irods_config.is_catalog:
            from irods import database_interface
            l.info(irods.lib.get_header('Configuring the database communications'))
            database_interface.setup_database_config(irods_config)

        setup_server_config(irods_config)
        setup_client_environment(irods_config)
        default_resource_directory = get_and_create_default_vault(irods_config)

    if irods_config.is_catalog:
        l.info(irods.lib.get_header('Setting up the database'))
        database_interface.setup_catalog(irods_config, default_resource_directory=default_resource_directory)

    l.info(irods.lib.get_header('Starting iRODS...'))
    IrodsController(irods_config).start()

    if irods_config.is_resource:
        irods.lib.execute_command(['iadmin', 'mkresc', irods_config.server_config['default_resource_name'], 'unixfilesystem', ':'.join([irods.lib.get_hostname(), default_resource_directory]), ''])

    test_put(irods_config)

    l.info(irods.lib.get_header('iRODS is installed and running'))
Пример #3
0
def setup_server(irods_config, json_configuration_file=None, test_mode=False):
    l = logging.getLogger(__name__)

    check_hostname()

    if json_configuration_file is not None:
        with open(json_configuration_file) as f:
            json_configuration_dict = json.load(f)
    else:
        json_configuration_dict = None

    if IrodsController().get_binary_to_pids_dict():
        l.info(irods.lib.get_header('Stopping iRODS...'))
        IrodsController(irods_config).stop()

    if not os.path.exists(irods_config.version_path):
        with open('.'.join([irods_config.version_path, 'dist'])) as f:
            version_json = json.load(f)
        version_json['installation_time'] = datetime.datetime.now().isoformat()
        irods_config.commit(version_json, irods.paths.version_path())

    if json_configuration_dict is not None:
        irods_user = json_configuration_dict['host_system_information'][
            'service_account_user_name']
        irods_group = json_configuration_dict['host_system_information'][
            'service_account_group_name']
    else:
        irods_user, irods_group = get_irods_user_and_group(irods_config)

    setup_service_account(irods_config, irods_user, irods_group)
    setup_rsyslog_and_logrotate(register_tty=False)

    # Do the rest of the setup as the irods user
    if os.getuid() == 0:
        irods.lib.switch_user(irods_config.irods_user,
                              irods_config.irods_group)

    if json_configuration_dict is not None:
        irods_config.commit(json_configuration_dict['server_config'],
                            irods.paths.server_config_path())
        if irods_config.is_catalog:
            from irods import database_interface
            if database_interface.database_already_in_use_by_irods(
                    irods_config):
                raise IrodsError('Database specified already in use by iRODS.')
        irods_config.commit(json_configuration_dict['hosts_config'],
                            irods.paths.hosts_config_path())
        irods_config.commit(
            json_configuration_dict['host_access_control_config'],
            irods.paths.host_access_control_config_path())
        if not os.path.exists(
                os.path.dirname(irods_config.client_environment_path)):
            os.makedirs(os.path.dirname(irods_config.client_environment_path),
                        mode=0o700)
        irods_config.commit(
            json_configuration_dict['service_account_environment'],
            irods_config.client_environment_path)
        irods_config.admin_password = json_configuration_dict['admin_password']
        default_resource_directory = json_configuration_dict.get(
            'default_resource_directory',
            os.path.join(irods_config.irods_directory, 'Vault'))
    else:
        determine_server_role(irods_config)

        if irods_config.is_catalog:
            from irods import database_interface
            l.info(
                irods.lib.get_header(
                    'Configuring the database communications'))
            database_interface.setup_database_config(irods_config)

        setup_server_config(irods_config)
        setup_client_environment(irods_config)
        default_resource_directory = get_and_create_default_vault(irods_config)

    if irods_config.is_catalog:
        l.info(irods.lib.get_header('Setting up the database'))
        database_interface.setup_catalog(
            irods_config,
            default_resource_directory=default_resource_directory)

    l.info(irods.lib.get_header('Starting iRODS...'))
    IrodsController(irods_config).start(test_mode=test_mode)

    if irods_config.is_resource:
        irods.lib.execute_command([
            'iadmin', 'mkresc',
            irods_config.server_config['default_resource_name'],
            'unixfilesystem',
            ':'.join([irods.lib.get_hostname(),
                      default_resource_directory]), ''
        ])

    test_put(irods_config)

    l.info(irods.lib.get_header('Log Configuration Notes'))
    l.info((
        'The iRODS log file is managed by rsyslog and logrotate.\n'
        'The locations of the log file and configuration files are listed below.\n\n'
        '  Log File Path               : ' + irods.paths.server_log_path() +
        '\n'
        '  Rsyslog Configuration Path  : ' + rsyslog_config_path() + '\n'
        '  Logrotate Configuration Path: ' + logrotate_config_path() + '\n\n'
        'iRODS will never touch these configuration files again.\n'
        'If you need to make adjustments, you must do so manually.'))

    l.info(irods.lib.get_header('Stopping iRODS...'))
    IrodsController(irods_config).stop()

    l.info(irods.lib.get_header('iRODS is configured and ready to be started'))
Пример #4
0
def main():
    logging.getLogger().setLevel(logging.NOTSET)
    l = logging.getLogger(__name__)

    irods.log.register_tty_handler(sys.stderr, logging.WARNING, None)

    if (os.geteuid() == 0):
        l.error('irodsctl should not be run by the root user.\n'
                'Exiting...')
        return 1

    operations_dict = {}
    operations_dict['start'] = lambda: irods_controller.start(write_to_stdout=options.write_to_stdout, test_mode=options.test_mode)
    operations_dict['graceful_start'] = lambda: irods_controller.start(write_to_stdout=options.write_to_stdout, test_mode=options.test_mode)
    operations_dict['stop'] = lambda: irods_controller.stop()
    operations_dict['restart'] = lambda: irods_controller.restart(write_to_stdout=options.write_to_stdout, test_mode=options.test_mode)
    operations_dict['graceful_restart'] = lambda: irods_controller.restart(write_to_stdout=options.write_to_stdout, test_mode=options.test_mode)
    operations_dict['status'] = lambda: irods_controller.status()
    operations_dict['get_environment'] = lambda: irods_config.print_execution_environment()

    (options, arguments) = parse_options()
    if len(arguments) != 1:
        l.error('irodsctl accepts exactly one positional argument, '
                'but {0} were provided.\n'
                'Exiting...' % (
                    len(arguments)))
        return 1

    operation = arguments[0]
    if operation not in operations_dict:
        l.error('irodsctl accepts the following positional arguments:\n'
                '%s\n'
                'but \'%s\' was provided.\n'
                'Exiting...' % (
                    irods.lib.indent(*operations_dict.keys()),
                    operation))
        return 1

    irods_config = IrodsConfig()

    if operation == 'status':
        options.verbose += 1

    irods.log.register_file_handler(irods_config.control_log_path)
    if options.verbose > 0:
        llevel = logging.NOTSET
        if options.verbose == 1:
            llevel = logging.INFO
        elif options.verbose == 2:
            llevel = logging.DEBUG
        irods.log.register_tty_handler(sys.stdout, llevel, logging.WARNING)

    if options.server_log_level != None:
        irods_config.injected_environment['spLogLevel'] = str(options.server_log_level)
    if options.sql_log_level != None:
        irods_config.injected_environment['spLogSql'] = str(options.sql_log_level)
    if options.days_per_log != None:
        irods_config.injected_environment['logfileInt'] = str(options.days_per_log)
    if options.rule_engine_server_options != None:
        irods_config.injected_environment['reServerOption'] = options.rule_engine_server_options
    if options.server_reconnect_flag:
        irods_config.injected_environment['irodsReconnect'] = ''

    irods_controller = IrodsController(irods_config)

    try:
        operations_dict[operation]()
    except IrodsError as e:
        l.error('Error encountered running irods_control %s:\n'
                % (operation), exc_info=True)
        l.info('Exiting...')
        return 1
    return 0
Пример #5
0
        os.chmod(univmss_testing, 0o544)

    test_identifiers = []
    if options.run_specific_test:
        test_identifiers.append(options.run_specific_test)
    if options.include_auth_tests:
        test_identifiers.append('test_auth')
    if options.include_timing_tests:
        test_identifiers.append('timing_tests')
    if options.run_python_suite:
        with open(
                os.path.join(IrodsConfig().scripts_directory,
                             'core_tests_list.json'), 'r') as f:
            test_identifiers.extend(json.loads(f.read()))
    if options.run_plugin_tests:
        test_identifiers.extend(get_plugin_tests())

    IrodsController().restart(test_mode=True)
    results = run_tests_from_names(test_identifiers,
                                   options.buffer_test_output,
                                   options.xml_output, options.skip_until)
    print(results)

    os.remove(univmss_testing)

    if not results.wasSuccessful():
        sys.exit(1)

    if options.run_devtesty:
        run_devtesty()
Пример #6
0
#!/usr/bin/python3
from __future__ import print_function

import sys

from irods.controller import IrodsController

#
# This script finds iRODS processes owned by the current user,
# confirms their full_path against this installation of iRODS,
# checks their executing state, then pauses and kills each one.
#

if __name__ == '__main__':
    try:
        control = IrodsController()
        control.stop()
    except BaseException as e:
        print(e, file=sys.stderr)
        sys.exit(1)
Пример #7
0
#!/usr/bin/python
from __future__ import print_function

import sys

from irods.controller import IrodsController

#
# This script finds iRODS processes owned by the current user,
# confirms their full_path against this installation of iRODS,
# checks their executing state, then pauses and kills each one.
#

if __name__ == '__main__':
    try:
        control = IrodsController()
        control.stop()
    except BaseException as e:
        print(e, file=sys.stderr)
        sys.exit(1)
Пример #8
0
def main():
    logging.getLogger().setLevel(logging.NOTSET)
    l = logging.getLogger(__name__)

    irods.log.register_tty_handler(sys.stderr, logging.WARNING, None)

    if (os.geteuid() == 0):
        l.error('irodsctl should not be run by the root user.\n'
                'Exiting...')
        return 1

    operations_dict = {}
    operations_dict['start'] = lambda: irods_controller.start()
    operations_dict['graceful_start'] = lambda: irods_controller.start()
    operations_dict['stop'] = lambda: irods_controller.stop()
    operations_dict['restart'] = lambda: irods_controller.restart()
    operations_dict['graceful_restart'] = lambda: irods_controller.restart()
    operations_dict['status'] = lambda: irods_controller.status()

    (options, arguments) = parse_options()
    if len(arguments) != 1:
        l.error('irodsctl accepts exactly one positional argument, '
                'but {0} were provided.\n'
                'Exiting...' % (
                    len(arguments)))
        return 1

    operation = arguments[0]
    if operation not in operations_dict:
        l.error('irodsctl accepts the following positional arguments:\n'
                '%s\n'
                'but \'%s\' was provided.\n'
                'Exiting...' % (
                    indent(*operations_dict.keys()),
                    operation))
        return 1

    irods_config = IrodsConfig(
        top_level_directory=options.top_level_directory,
        config_directory=options.config_directory)

    irods.log.register_file_handler(irods_config.control_log_path)
    if options.verbose:
        irods.log.register_tty_handler(sys.stdout, logging.INFO, logging.WARNING)

    if options.server_log_level != None:
        irods_config.injected_environment['spLogLevel'] = str(options.server_log_level)
    if options.sql_log_level != None:
        irods_config.injected_environment['spLogSql'] = str(options.sql_log_level)
    if options.days_per_log != None:
        irods_config.injected_environment['logfileInt'] = str(options.days_per_log)
    if options.rule_engine_server_options != None:
        irods_config.injected_environment['reServerOption'] = options.rule_engine_server_options
    if options.server_reconnect_flag:
        irods_config.injected_environment['irodsReconnect'] = ''

    irods_controller = IrodsController(irods_config)
    try:
        irods_controller.check_config()
    except IrodsError as e:
        l.error('Exception:', exc_info=True)
        l.error('%s\n'
                'Configuration files are missing or broken.\n'
                'Exiting...' % (
                    str(e)))
        return 1

    try:
        operations_dict[operation]()
    except IrodsError as e:
        l.error('Error encountered running irods_control %s:\n'
                % (operation), exc_info=True)
        l.info('Exiting...')
        return 1
    return 0