Ejemplo n.º 1
0
def start():
    """ Start the data collector loop.

    :return: The final state.
     :rtype: dict(str: *)
    """
    config = read_and_validate_config([DEFAILT_CONFIG_PATH, CONFIG_PATH],
                                      REQUIRED_FIELDS)

    common.init_logging(
        config['log_directory'],
        'data-collector.log',
        int(config['log_level']))

    vm_path = common.build_local_vm_path(config['local_data_directory'])
    if not os.access(vm_path, os.F_OK):
        os.makedirs(vm_path)
        log.info('Created a local VM data directory: %s', vm_path)
    else:
        cleanup_all_local_data(config['local_data_directory'])
        log.info('Creaned up the local data directory: %s',
                 config['local_data_directory'])

    interval = config['data_collector_interval']
    log.info('Starting the data collector, ' +
             'iterations every %s seconds', interval)
    return common.start(
        init_state,
        execute,
        config,
        int(interval))
Ejemplo n.º 2
0
def start():
    """ Start the data collector loop.

    :return: The final state.
     :rtype: dict(str: *)
    """
    config = read_and_validate_config([DEFAILT_CONFIG_PATH, CONFIG_PATH],
                                      REQUIRED_FIELDS)

    common.init_logging(
        config['log_directory'],
        'data-collector.log',
        int(config['log_level']))

    vm_path = common.build_local_vm_path(config['local_data_directory'])
    if not os.access(vm_path, os.F_OK):
        os.makedirs(vm_path)
        log.info('Created a local VM data directory: %s', vm_path)
    else:
        cleanup_all_local_data(config['local_data_directory'])
        log.info('Creaned up the local data directory: %s',
                 config['local_data_directory'])

    interval = config['data_collector_interval']
    log.info('Starting the data collector, ' +
             'iterations every %s seconds', interval)
    return common.start(
        init_state,
        execute,
        config,
        int(interval))
Ejemplo n.º 3
0
 def start(iterations=int_(0, 10)):
     with MockTransaction:
         config = {'option': 'value'}
         state = {'property': 'value'}
         fn = mock('function container')
         expect(fn).init_state(any_dict).and_return(state).once()
         expect(fn).execute(any_dict, any_dict). \
             and_return(state).exactly(iterations).times()
         assert common.start(fn.init_state, fn.execute, config, 0,
                             iterations) == state
Ejemplo n.º 4
0
 def start(iterations=int_(0, 10)):
     with MockTransaction:
         config = {'option': 'value'}
         state = {'property': 'value'}
         fn = mock('function container')
         expect(fn).init_state(any_dict).and_return(state).once()
         expect(fn).execute(any_dict, any_dict). \
             and_return(state).exactly(iterations).times()
         assert common.start(fn.init_state,
                             fn.execute,
                             config,
                             0,
                             iterations) == state
Ejemplo n.º 5
0
def start():
    """ Start the database cleaner loop.

    :return: The final state.
     :rtype: dict(str: *)
    """
    config = read_and_validate_config([DEFAILT_CONFIG_PATH, CONFIG_PATH],
                                      REQUIRED_FIELDS)

    common.init_logging(config['log_directory'], 'db-cleaner.log',
                        int(config['log_level']))

    interval = config['db_cleaner_interval']
    if log.isEnabledFor(logging.INFO):
        log.info(
            'Starting the database cleaner, ' + 'iterations every %s seconds',
            interval)
    return common.start(init_state, execute, config, int(interval))
Ejemplo n.º 6
0
def start():
    """ Start the local manager loop.

    :return: The final state.
     :rtype: dict(str: *)
    """
    config = read_and_validate_config([DEFAILT_CONFIG_PATH, CONFIG_PATH],
                                      REQUIRED_FIELDS)

    common.init_logging(
        config['log_directory'],
        'local-manager.log',
        int(config['log_level']))

    interval = config['local_manager_interval']
    if log.isEnabledFor(logging.INFO):
        log.info('Starting the local manager, ' +
                 'iterations every %s seconds', interval)
    return common.start(
        init_state,
        execute,
        config,
        int(interval))