diff options
author | Magnus Ahltorp <map@kth.se> | 2017-06-30 11:01:52 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2017-07-06 17:48:30 +0200 |
commit | b09e878a21c09d8344ec8b2a896d7d1a8162387e (patch) | |
tree | bea544071d048abb9e4abc58e698940f3ef7eafa /tools/compileconfig.py | |
parent | 4e44c1e8a4ea6ec4c5eeb2a1a05d93e076c7fd50 (diff) |
Verify config files against schema
Diffstat (limited to 'tools/compileconfig.py')
-rwxr-xr-x | tools/compileconfig.py | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/tools/compileconfig.py b/tools/compileconfig.py index 94e0b51..87d46c6 100755 --- a/tools/compileconfig.py +++ b/tools/compileconfig.py @@ -561,6 +561,65 @@ def printnodenames(config): print " ".join(frontendnodenames|storagenodenames|signingnodenames|mergenodenames|statusservernodenames) +localconfigschema = [ + ("nodename", "string", "nodename"), + ("frontendaddress", "string", "ip address"), + ("ctapiaddress", "string", "ip address"), + ("storageaddress", "string", "ip address"), + ("signingaddress", "string", "ip address"), + ("mergeaddress", "string", "ip address"), + ("publichttpaddress", "string", "ip address"), + ("configurl", "string", "url"), + ("logadminkey", "string", "key"), + ("dbbackend", "string", ["permdb", "fsdb"]), + ("paths/configdir", "string", "path"), + ("paths/db", "string", "path"), + ("paths/https_cacertfile", "string", "path"), + ("paths/https_certfile", "string", "path"), + ("paths/https_keyfile", "string", "path"), + ("paths/knownroots", "string", "path"), + ("paths/logpublickey", "string", "path"), + ("paths/privatekeys", "string", "path"), + ("paths/public_cacertfile", "string", "path"), + ("paths/publickeys", "string", "path"), + ("paths/verifycert_bin", "string", "path"), + ("paths/mergedb", "string", "path"), + ("paths/logprivatekey", "string", "path"), + ("ratelimits/add_chain", "string", "rate"), + ("merge/min-delay", "integer", "seconds"), + ("merge/backup-window-size", "integer", "number of entries"), + ("merge/backup-sendlog-chunksize", "integer", "number of entries"), + ("merge/backup-sendentries-chunksize", "integer", "number of entries"), + ("merge/dist-window-size", "integer", "number of entries"), + ("merge/dist-sendlog-chunksize", "integer", "number of entries"), + ("merge/dist-sendentries-chunksize", "integer", "number of entries"), +] + +globalconfigschema = [ + ("frontendnodes/[]/name", "string", "nodename"), + ("frontendnodes/[]/address", "string", "ip address"), + ("frontendnodes/[]/publicaddress", "string", "ip address"), + ("mergenodes/[]/name", "string", "nodename"), + ("mergenodes/[]/address", "string", "ip address"), + ("signingnodes/[]/name", "string", "nodename"), + ("signingnodes/[]/address", "string", "ip address"), + ("storagenodes/[]/name", "string", "nodename"), + ("storagenodes/[]/address", "string", "ip address"), + ("statusservers/[]/name", "string", "nodename"), + ("statusservers/[]/address", "string", "ip address"), + ("statusservers/[]/publicaddress", "string", "ip address"), + ("apikeys/[]/nodename", "string", "nodename"), + ("apikeys/[]/publickey", "string", "key"), + ("baseurl", "string", "url"), + ("primarymergenode", "string", "nodename"), + ("storage-quorum-size", "integer", "number of nodes"), + ("backup-quorum-size", "integer", "number of nodes"), + ("logpublickey", "string", "key"), + ("cafingerprint", "string", "fingerprint"), + ("version", "integer", "version"), + ("mmd", "integer", "seconds"), +] + def main(): parser = argparse.ArgumentParser(description="") parser.add_argument('--config', help="System configuration") @@ -575,17 +634,17 @@ def main(): sys.exit(1) if args.testmakefile: - config = readconfig.read_config(args.config) + config = readconfig.read_config(args.config, schema=globalconfigschema) gen_testmakefile(config, args.testmakefile) elif args.testshellvars: - config = readconfig.read_config(args.config) + config = readconfig.read_config(args.config, schema=globalconfigschema) gen_testmakefile(config, args.testshellvars, shellvars=True) elif args.getnodenames: - config = readconfig.read_config(args.config) + config = readconfig.read_config(args.config, schema=globalconfigschema) printnodenames(config) elif args.localconfig: - localconfig = readconfig.read_config(args.localconfig) - config = readconfig.verify_and_read_config(args.config, localconfig["logadminkey"]) + localconfig = readconfig.read_config(args.localconfig, schema=localconfigschema) + config = readconfig.verify_and_read_config(args.config, localconfig["logadminkey"], schema=globalconfigschema) gen_config(localconfig["nodename"], config, localconfig) else: |