Example #1
0
def load_configuration(yaml_string, kw=None, missing_fmt=None):
    environ = rec_env.load_configuration(yaml_string, kw, missing_fmt)
    environ = update_model_type(environ)

    #if environ.get('API', 0) != API_VERSION:
    #    print fc.red('Error: Configuration outdated')
    #    ref = yaml.safe_load(
    #      os.path.join(os.path.dirname(__file__), 'api.yaml'))
    #    report_differences(environ, ref)
    #    raise APIVersionException

    if 'ensemble' in environ:
        environs = []
        ensemble = environ['ensemble']
        environ.pop('ensemble')
        for member in ensemble.keys():
            new_env = update_environ(environ, ensemble, member)
            new_env = update_model_type(environ)
            environs.append(new_env)

        # TODO: ignoring for now, but need to think on how to run
        # multiple environs (one for each ensemble member).
        # Maybe use the Fabric JobQueue, which abstracts
        # multiprocessing?

    return environ
Example #2
0
def load_configuration(yaml_string, kw=None, missing_fmt=None):
    environ = rec_env.load_configuration(yaml_string, kw, missing_fmt)
    environ = update_model_type(environ)

    #if environ.get('API', 0) != API_VERSION:
    #    print fc.red('Error: Configuration outdated')
    #    ref = yaml.safe_load(
    #      os.path.join(os.path.dirname(__file__), 'api.yaml'))
    #    report_differences(environ, ref)
    #    raise APIVersionException

    if 'ensemble' in environ:
        environs = []
        ensemble = environ['ensemble']
        environ.pop('ensemble')
        for member in ensemble.keys():
            new_env = update_environ(environ, ensemble, member)
            new_env = update_model_type(environ)
            environs.append(new_env)

        # TODO: ignoring for now, but need to think on how to run
        # multiple environs (one for each ensemble member).
        # Maybe use the Fabric JobQueue, which abstracts
        # multiprocessing?

    return environ
Example #3
0
def test_recursive_circular_variables():
    # Notice: if this fails we probably made an AI or a parallel universe.
    with pytest.raises(RuntimeError):
        env = load_configuration(CIRCULAR_YAML)
Example #4
0
def test_int_values():
    env = load_configuration(TEST_YAML)
    assert env['api_version'] == 1
Example #5
0
def test_recursive_replace_nested_complex():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['auth'] == "uat.urltest.net/auth"
Example #6
0
def test_recursive_replace_nested_simple():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['provision'] == "mycarrier.uat.urltest.net"
Example #7
0
def test_recursive_replace_boolean_values():
    env = load_configuration(TEST_YAML)
    assert env['features']['contacts'] is True
    assert env['features']['backup'] is False
Example #8
0
def test_recursive_replace_with_keywords():
    env = load_configuration(TEST_YAML, {'environment': 'dev'})
    assert env['url'] == "mycarrier.localhost"
Example #9
0
def test_recursive_replace():
    env = load_configuration(TEST_YAML)
    assert env['url'] == "mycarrier.uat.urltest.net"
Example #10
0
def test_recursive_circular_variables():
    # Notice: if this fails we probably made an AI or a parallel universe.
    with pytest.raises(RuntimeError):
        env = load_configuration(CIRCULAR_YAML)
Example #11
0
def test_int_values():
    env = load_configuration(TEST_YAML)
    assert env['api_version'] == 1
Example #12
0
def test_recursive_replace_nested_complex():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['auth'] == "uat.urltest.net/auth"
Example #13
0
def test_recursive_replace_nested_simple():
    env = load_configuration(TEST_YAML)
    assert env['clients']['ios']['provision'] == "mycarrier.uat.urltest.net"
Example #14
0
def test_recursive_replace_boolean_values():
    env = load_configuration(TEST_YAML)
    assert env['features']['contacts'] is True
    assert env['features']['backup'] is False
Example #15
0
def test_recursive_replace_with_keywords():
    env = load_configuration(TEST_YAML, {'environment': 'dev'})
    assert env['url'] == "mycarrier.localhost"
Example #16
0
def test_recursive_replace():
    env = load_configuration(TEST_YAML)
    assert env['url'] == "mycarrier.uat.urltest.net"