Esempio n. 1
0
def test_jails_cannot_have_no_members(invalid_jail_members_config):
    with pytest.raises(ValidationError):
        validate_config(invalid_jail_members_config)
Esempio n. 2
0
def test_dhcp_is_optional(valid_dhcp_optional_config):
    validate_config(valid_dhcp_optional_config)
Esempio n. 3
0
def test_duplicate_jails_is_invalid(invalid_jails_config):
    with pytest.raises(ValidationError):
        validate_config(invalid_jails_config)
Esempio n. 4
0
def test_dhcp_and_ip_gw_exclusive(invalid_dhcp_ip_gw_config):
    with pytest.raises(ValidationError):
        validate_config(invalid_dhcp_ip_gw_config)
Esempio n. 5
0
def test_dhcp_is_ok(valid_dhcp_config):
    validate_config(valid_dhcp_config)
Esempio n. 6
0
def test_validate_config_with_schema(valid_yaml_config):
    schema = read_schema(CONFIG_SCHEMA)

    validate_config(valid_yaml_config, schema)
Esempio n. 7
0
def test_invalid_config(invalid_config):
    with pytest.raises(ValidationError):
        validate_config(invalid_config)
Esempio n. 8
0
def test_valid_config(valid_yaml_config) -> None:
    validate_config(valid_yaml_config)
Esempio n. 9
0
def test_current_config_is_valid(current_config) -> None:
    validate_config(current_config)
Esempio n. 10
0
def test_blueprint_is_not_valid_config(valid_blueprint):
    with pytest.raises(ValidationError):
        validate_config(valid_blueprint)
Esempio n. 11
0
def test_no_blueprint_instantiated(invalid_jail_members_config):
    with pytest.raises(ValidationError):
        validate_config(invalid_jail_members_config)
Esempio n. 12
0
    read_blueprints,
    read_config,
    validate_blueprint,
    validate_config,
)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(prog="pailman")
    define_cli(parser)
    opts = parser.parse_args()

    print("using config {}".format(config_file(opts)))
    cfg = read_config(config_file(opts))

    try:
        validate_config(cfg)
    except ValidationError as error:
        print("config is invalid: {}".format(error.message))
        sys.exit(1)

    blueprints = read_blueprints()

    for p, blueprint in blueprints.items():
        try:
            validate_blueprint(blueprint)
        except ValidationError as error:
            print("blueprint {} is invalid: {}".format(p, error.message))
            sys.exit(1)
    print("{} blueprints available".format(len(blueprints)))

    print("to install: {}".format(to_install(opts)))