aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen_conf.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gen_conf.py')
-rw-r--r--scripts/gen_conf.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/gen_conf.py b/scripts/gen_conf.py
index bc45540..2cfc54b 100644
--- a/scripts/gen_conf.py
+++ b/scripts/gen_conf.py
@@ -6,15 +6,16 @@ import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Generate configuration file for a batch of replicas')
parser.add_argument('--prefix', type=str, default='hotstuff.gen')
- parser.add_argument('--iplist', type=str, default=None)
+ parser.add_argument('--ips', type=str, default=None)
parser.add_argument('--iter', type=int, default=10)
parser.add_argument('--pport', type=int, default=10000)
parser.add_argument('--cport', type=int, default=20000)
parser.add_argument('--keygen', type=str, default='./hotstuff-keygen')
+ parser.add_argument('--nodes', type=str, default='nodes.txt')
args = parser.parse_args()
- if args.iplist is None:
+ if args.ips is None:
ips = ['127.0.0.1']
else:
ips = [l.strip() for l in open(args.iplist, 'r').readlines()]
@@ -22,9 +23,10 @@ if __name__ == "__main__":
iter = args.iter
base_pport = args.pport
base_cport = args.cport
- keygen_bin= args.keygen
+ keygen_bin = args.keygen
main_conf = open("{}.conf".format(prefix), 'w')
+ nodes = open(args.nodes, 'w')
replicas = ["{}:{};{}".format(ip, base_pport + i, base_cport + i)
for ip in ips
for i in range(iter)]
@@ -33,6 +35,8 @@ if __name__ == "__main__":
keys = [[t[4:] for t in l.decode('ascii').split()] for l in p.stdout]
for r in zip(replicas, keys, itertools.count(0)):
main_conf.write("replica = {}, {}\n".format(r[0], r[1][0]))
- r_conf = open("{}-sec{}.conf".format(prefix, r[2]), 'w')
+ r_conf_name = "{}-sec{}.conf".format(prefix, r[2])
+ nodes.write("{}:{}\t{}\n".format(r[2], r[0], r_conf_name))
+ r_conf = open(r_conf_name, 'w')
r_conf.write("privkey = {}\n".format(r[1][1]))
r_conf.write("idx = {}\n".format(r[2]))