summaryrefslogtreecommitdiff
path: root/tools/compileconfig.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/compileconfig.py')
-rwxr-xr-xtools/compileconfig.py66
1 files changed, 42 insertions, 24 deletions
diff --git a/tools/compileconfig.py b/tools/compileconfig.py
index 9973a95..a12e762 100755
--- a/tools/compileconfig.py
+++ b/tools/compileconfig.py
@@ -432,7 +432,27 @@ def gen_config(nodename, config, localconfig):
plopconfigfile.close()
-def gen_testmakefile(config, testmakefile, machines, shellvars=False):
+def print_nodevar(configfile, delimiter, nodetype, bootname, names, testaddresses, gennodes=True, gentesturl=True):
+ if gennodes:
+ print >>configfile, nodetype + "NODES=" + delimiter + " ".join(['%s:%s' % (name, bootname) for name in names]) + delimiter
+ for name in names:
+ print >>configfile, name.upper().replace("-", "_") + "ONLY" + "NODES=" + delimiter + '%s:%s' % (name, bootname) + delimiter
+ if gentesturl:
+ print >>configfile, name.upper().replace("-", "_") + "ONLY" + "TESTURLS=" + delimiter + " ".join(testaddresses[name]) + delimiter
+ else:
+ print >>configfile, nodetype + "NODES=" + delimiter + delimiter
+ if gentesturl:
+ print >>configfile, nodetype + "TESTURLS=" + delimiter + " ".join([address for name in names for address in testaddresses[name]]) + delimiter
+ else:
+ print >>configfile, nodetype + "TESTURLS=" + delimiter + delimiter
+
+def multivaldict(dictlist):
+ d = {}
+ for (key, value) in dictlist:
+ d.setdefault(key, []).append(value)
+ return d
+
+def gen_testmakefile(config, testmakefile, shellvars=False):
configfile = open(testmakefile, "w")
print >>configfile, "#", testmakefile, "generated by", sys.argv[0], datetime.now()
@@ -442,27 +462,26 @@ def gen_testmakefile(config, testmakefile, machines, shellvars=False):
mergenodenames = set([node["name"] for node in config["mergenodes"]])
mergesecondarynodenames = set([node["name"] for node in config["mergenodes"] if node["name"] != config["primarymergenode"]])
- frontendnodeaddresses = [node["publicaddress"] for node in config["frontendnodes"]]
- storagenodeaddresses = [node["address"] for node in config["storagenodes"]]
- signingnodeaddresses = [node["address"] for node in config["signingnodes"]]
- mergesecondarynodeaddresses = [node["address"] for node in config["mergenodes"] if node["name"] != config["primarymergenode"]]
+ frontendnodenames_except_last = sorted(frontendnodenames)[:-1]
+ frontendnodenames_except_first = sorted(frontendnodenames)[1:]
+
+ allnodes = config["frontendnodes"] + config["storagenodes"] + config["signingnodes"] + config["mergenodes"]
+ testaddresses = multivaldict([(node["name"], node["address"]) for node in allnodes])
+
delimiter = '"' if shellvars else ''
+
+ print_nodevar(configfile, delimiter, "FRONTEND", "catlfish", frontendnodenames, testaddresses)
+ print_nodevar(configfile, delimiter, "FRONTENDEXCEPTLAST", "catlfish", frontendnodenames_except_last, testaddresses)
+ print_nodevar(configfile, delimiter, "FRONTENDEXCEPTFIRST", "catlfish", frontendnodenames_except_first, testaddresses)
+ print_nodevar(configfile, delimiter, "STORAGE", "catlfish", storagenodenames, testaddresses, gennodes=False)
+ print_nodevar(configfile, delimiter, "SIGNING", "catlfish", signingnodenames, testaddresses)
+ print_nodevar(configfile, delimiter, "MERGESECONDARY", "catlfish", mergesecondarynodenames, testaddresses)
+ print_nodevar(configfile, delimiter, "MERGEPRIMARY", "merge", [config["primarymergenode"]], testaddresses, gentesturl=False)
- print >>configfile, "NODES=" + delimiter + " ".join(frontendnodenames|storagenodenames|signingnodenames|mergenodenames) + delimiter
-
- print >>configfile, "FRONTENDNODES=" + delimiter + " ".join(['%s:%s' % (name, 'catlfish') for name in frontendnodenames]) + delimiter
- print >>configfile, "STORAGENODES=" + delimiter + " ".join(['%s:%s' % (name, 'catlfish') for name in storagenodenames if name not in frontendnodenames]) + delimiter
- print >>configfile, "SIGNINGNODES=" + delimiter + " ".join(['%s:%s' % (name, 'catlfish') for name in signingnodenames]) + delimiter
- print >>configfile, "MERGESECONDARYNODES=" + delimiter + " ".join(['%s:%s' % (name, 'catlfish') for name in mergesecondarynodenames]) + delimiter
- print >>configfile, "MERGEPRIMARYNODES=" + delimiter + '%s:%s' % (config["primarymergenode"], 'merge') + delimiter
-
- print >>configfile, "MACHINES=" + delimiter + " ".join([str(e) for e in range(1, machines+1)]) + delimiter
- print >>configfile, "FRONTENDTESTURLS=" + delimiter + " ".join(frontendnodeaddresses) + delimiter
- print >>configfile, "STORAGETESTURLS=" + delimiter + " ".join(storagenodeaddresses) + delimiter
- print >>configfile, "SIGNINGTESTURLS=" + delimiter + " ".join(signingnodeaddresses) + delimiter
- print >>configfile, "MERGESECONDARYTESTURLS=" + delimiter + " ".join(mergesecondarynodeaddresses) + delimiter
- print >>configfile, "MERGEPRIMARYTESTURLS=" + delimiter + " ".join([]) + delimiter
+ print >>configfile, "NODES=" + delimiter + " ".join(set([node["name"] for node in allnodes])) + delimiter
+
+ print >>configfile, "MACHINES=" + delimiter + " ".join([str(e) for e in frontendnodenames]) + delimiter
print >>configfile, "BASEURL=" + delimiter + config["baseurl"] + delimiter
configfile.close()
@@ -482,15 +501,14 @@ def main():
parser.add_argument("--testmakefile", metavar="file", help="Generate makefile variables for test")
parser.add_argument("--testshellvars", metavar="file", help="Generate shell variable file for test")
parser.add_argument("--getnodenames", action='store_true', help="Get list of node names")
- parser.add_argument("--machines", type=int, metavar="n", help="Number of machines")
args = parser.parse_args()
- if args.testmakefile and args.machines:
+ if args.testmakefile:
config = readconfig.read_config(args.config)
- gen_testmakefile(config, args.testmakefile, args.machines)
- elif args.testshellvars and args.machines:
+ gen_testmakefile(config, args.testmakefile)
+ elif args.testshellvars:
config = readconfig.read_config(args.config)
- gen_testmakefile(config, args.testshellvars, args.machines, shellvars=True)
+ gen_testmakefile(config, args.testshellvars, shellvars=True)
elif args.getnodenames:
config = readconfig.read_config(args.config)
printnodenames(config)