示例#1
0
def get_config_directory(configs):
    agg = AggregateConfig(configs=configs)

    for key in agg.keys():
        if key not in ['CurrencyHome', 'ConfigDirectory']:
            del agg[key]

    return agg.resolve({'home': 'CurrencyHome'})['ConfigDirectory']
示例#2
0
def get_config_directory(configs):
    agg = AggregateConfig(configs=configs)

    for key in agg.keys():
        if key not in ['CurrencyHome', 'ConfigDirectory']:
            del agg[key]

    return agg.resolve({'home': 'CurrencyHome'})['ConfigDirectory']
示例#3
0
def get_validator_configuration(config_files,
                                options_config,
                                os_name=os.name,
                                config_files_required=None):
    env_config = CurrencyEnvConfig()

    default_config = ValidatorDefaultConfig(os_name=os_name)

    conf_dir = get_config_directory(
        [default_config, env_config, options_config])

    # Determine the configuration file search path
    search_path = [
        conf_dir, '.',
        os.path.join(os.path.dirname(__file__), "..", "etc")
    ]

    # Require the config files unless it is an empty list or the
    # default of txnvalidator.js.
    if config_files_required is None:
        config_files_required = len(config_files) != 0 and \
            not (len(config_files) == 1 and
                 config_files[0] == 'txnvalidator.js')

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'key_dir': 'KeyDirectory',
        'run_dir': 'RunDirectory'
    })
    return resolved
示例#4
0
def get_validator_configuration(config_files,
                                options_config,
                                os_name=os.name,
                                config_files_required=None):
    env_config = CurrencyEnvConfig()

    default_config = ValidatorDefaultConfig(os_name=os_name)

    conf_dir = get_config_directory(
        [default_config, env_config, options_config])

    # Determine the configuration file search path
    search_path = [conf_dir, '.', os.path.join(
        os.path.dirname(__file__), "..", "etc")]

    # Require the config files unless it is an empty list or the
    # default of txnvalidator.js.
    if config_files_required is None:
        config_files_required = len(config_files) != 0 and \
            not (len(config_files) == 1 and
                 config_files[0] == 'txnvalidator.js')

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'key_dir': 'KeyDirectory',
        'run_dir': 'RunDirectory'
    })
    return resolved
示例#5
0
def get_mktplace_configuration(config_files,
                               options_config,
                               os_name=os.name,
                               config_files_required=True):
    env_config = MarketPlaceEnvConfig()

    default_config = MarketPlaceDefaultConfig(os_name=os_name)

    conf_dir = AggregateConfig(
        configs=[default_config, env_config, options_config]).resolve(
            {'home': 'CurrencyHome'})['ConfigDirectory']

    user_conf_dir = os.path.join(os.path.expanduser("~"), ".sawtooth")

    # Determine the configuration file search path
    search_path = [
        conf_dir, user_conf_dir, '.',
        os.path.join(os.path.dirname(__file__), "..", "etc")
    ]

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'name': 'ParticipantName',
        'user': '******',
        'user_conf_dir': 'UserConfigDirectory'
    })
    return resolved
def get_mktplace_configuration(config_files,
                               options_config,
                               os_name=os.name,
                               config_files_required=True):
    env_config = MarketPlaceEnvConfig()

    default_config = MarketPlaceDefaultConfig(os_name=os_name)

    conf_dir = AggregateConfig(
        configs=[default_config, env_config, options_config]).resolve(
            {'home': 'CurrencyHome'})['ConfigDirectory']

    user_conf_dir = os.path.join(os.path.expanduser("~"), ".sawtooth")

    # Determine the configuration file search path
    search_path = [conf_dir, user_conf_dir, '.', os.path.join(
        os.path.dirname(__file__), "..", "etc")]

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'name': 'ParticipantName',
        'user': '******',
        'user_conf_dir': 'UserConfigDirectory'
    })
    return resolved
示例#7
0
def get_validator_configuration(config_files,
                                options_config,
                                os_name=os.name,
                                config_files_required=True):
    env_config = CurrencyEnvConfig()

    default_config = ValidatorDefaultConfig(os_name=os_name)

    conf_dir = get_config_directory(
        [default_config, env_config, options_config])

    # Determine the configuration file search path
    search_path = [
        conf_dir, '.',
        os.path.join(os.path.dirname(__file__), "..", "etc")
    ]

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'key_dir': 'KeyDirectory',
        'run_dir': 'RunDirectory'
    })
    return resolved
示例#8
0
    def test_aggregate_config(self):
        """Test that resolution of values and sources operate as expected."""

        config1 = Config(source="config1name")
        config1["keya"] = "value1"
        config1["keyb"] = "value1"

        config2 = Config(source="config2name")
        config2["keyb"] = "value2"
        config2["keyc"] = "value2"

        config3 = Config(source="config3name")
        config3["keyc"] = "value3"

        multi = AggregateConfig([config1, config2, config3])

        self.assertEquals(multi["keya"], "value1")
        self.assertEquals(multi["keyb"], "value2")
        self.assertEquals(multi["keyc"], "value3")

        self.assertEquals(multi.get_source("keya"), "config1name")
        self.assertEquals(multi.get_source("keyb"), "config2name")
        self.assertEquals(multi.get_source("keyc"), "config3name")
示例#9
0
    def test_aggregate_config(self):
        """Test that resolution of values and sources operate as expected."""

        config1 = Config(source="config1name")
        config1["keya"] = "value1"
        config1["keyb"] = "value1"

        config2 = Config(source="config2name")
        config2["keyb"] = "value2"
        config2["keyc"] = "value2"

        config3 = Config(source="config3name")
        config3["keyc"] = "value3"

        multi = AggregateConfig([config1, config2, config3])

        self.assertEqual(multi["keya"], "value1")
        self.assertEqual(multi["keyb"], "value2")
        self.assertEqual(multi["keyc"], "value3")

        self.assertEqual(multi.get_source("keya"), "config1name")
        self.assertEqual(multi.get_source("keyb"), "config2name")
        self.assertEqual(multi.get_source("keyc"), "config3name")
示例#10
0
def get_validator_configuration(config_files,
                                options_config,
                                os_name=os.name,
                                config_files_required=True):
    env_config = CurrencyEnvConfig()

    default_config = ValidatorDefaultConfig(os_name=os_name)

    conf_dir = AggregateConfig(
        configs=[default_config, env_config, options_config]).resolve(
            {'home': 'CurrencyHome'})['ConfigDirectory']

    # Determine the configuration file search path
    search_path = [conf_dir, '.', os.path.join(
        os.path.dirname(__file__), "..", "etc")]

    file_configs = load_config_files(config_files, search_path,
                                     config_files_required)

    config_list = [default_config]
    config_list.extend(file_configs)
    config_list.append(env_config)
    config_list.append(options_config)

    cfg = AggregateConfig(configs=config_list)
    resolved = cfg.resolve({
        'home': 'CurrencyHome',
        'host': 'CurrencyHost',
        'node': 'NodeName',
        'base': 'BaseDirectory',
        'conf_dir': 'ConfigDirectory',
        'data_dir': 'DataDirectory',
        'log_dir': 'LogDirectory',
        'key_dir': 'KeyDirectory'
    })
    return resolved