aboutsummaryrefslogtreecommitdiff
path: root/scripts/deploy/gen_inventory.py
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2020-08-30 00:15:08 -0400
committerDeterminant <tederminant@gmail.com>2020-08-30 00:15:08 -0400
commitd5bf357c8010bb1219d04ede14ce699b409e93c5 (patch)
tree042e6bc94994b899c9b31b7816648b557271a3f5 /scripts/deploy/gen_inventory.py
parentdc28778f9c10d8128abfcf4fea7339c69bd6074d (diff)
fix the connection issue with --notls flag on; WIP: deployment example
Diffstat (limited to 'scripts/deploy/gen_inventory.py')
-rw-r--r--scripts/deploy/gen_inventory.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/deploy/gen_inventory.py b/scripts/deploy/gen_inventory.py
new file mode 100644
index 0000000..23af205
--- /dev/null
+++ b/scripts/deploy/gen_inventory.py
@@ -0,0 +1,34 @@
+import argparse
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description='Generate configuration files for a run.')
+ parser.add_argument('--replicas', type=str, default='replicas.txt',
+ help='text file with all replicas IPs (each row is "<external_ip> <inter_replica_net_ip>", repeat a line if you would like to share the same machine)')
+ parser.add_argument('--clients', type=str, default='clients.txt',
+ help='text file with all clients IPs (each row is "<external_ip>")')
+ parser.add_argument('--prefix', type=str, default='hotstuff.gen')
+ args = parser.parse_args()
+
+ print("[nodes_setup]")
+ host_idx_count = {}
+ replicas = []
+ clients = []
+ with open(args.replicas, "r") as rfile:
+ for line in rfile:
+ (pub_ip, priv_ip) = line.split()
+ replicas.append((pub_ip.strip(), priv_ip.strip()))
+ with open(args.clients, "r") as cfile:
+ for line in cfile:
+ clients.append(line.strip())
+ machines = sorted(set([pub_ip for (pub_ip, _) in replicas] + clients))
+ print("\n".join(machines))
+ print("\n[nodes]")
+ for (i, (pub_ip, priv_ip)) in enumerate(replicas):
+ host_idx = host_idx_count.setdefault(pub_ip, 0)
+ host_idx_count[pub_ip] += 1
+ print("replica{} ansible_host={} host_idx={} extra_conf={}-sec{}.conf".format(
+ i, pub_ip, host_idx, args.prefix, i))
+
+ print("\n[clients]")
+ for (i, ip) in enumerate(clients):
+ print("client{} ansible_host={} cid={}".format(i, ip, i))