summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2015-09-25 16:26:42 +0200
committerLinus Nordberg <linus@nordu.net>2015-09-25 16:26:42 +0200
commit300149c520921523f107537be5a3bb20fed829f0 (patch)
tree119126f4a6bc11690a4ca262201cc57c33412500
parent02ab9ba3b43d7d42323db2effd787a0dce64e378 (diff)
merge_backup.py and merge_dist.py take nodes on command line.
If no nodes are given on the command line, all appropriate nodes are used.
-rwxr-xr-xtools/merge_backup.py13
-rwxr-xr-xtools/merge_dist.py11
-rw-r--r--tools/mergetools.py1
3 files changed, 19 insertions, 6 deletions
diff --git a/tools/merge_backup.py b/tools/merge_backup.py
index 48197fc..37b2757 100755
--- a/tools/merge_backup.py
+++ b/tools/merge_backup.py
@@ -15,12 +15,11 @@ from mergetools import chunks, backup_sendlog, get_logorder, \
hexencode, setverifiedsize, sendentry_merge, verifyroot, \
get_nfetched, parse_args
-def merge_backup(args, config, localconfig):
+def merge_backup(args, config, localconfig, secondaries):
paths = localconfig["paths"]
own_key = (localconfig["nodename"],
"%s/%s-private.pem" % (paths["privatekeys"],
localconfig["nodename"]))
- secondaries = config.get("mergenodes", [])
mergedb = paths["mergedb"]
chainsdir = mergedb + "/chains"
logorderfile = mergedb + "/logorder"
@@ -138,11 +137,19 @@ def main():
Sleep some and start over.
"""
args, config, localconfig = parse_args()
+ all_secondaries = \
+ [n for n in config.get('mergenodes', []) if \
+ n['name'] != config['primarymergenode']]
paths = localconfig["paths"]
create_ssl_context(cafile=paths["https_cacertfile"])
+ if len(args.node) == 0:
+ nodes = all_secondaries
+ else:
+ nodes = [n for n in all_secondaries if n["name"] in args.node]
+
while True:
- merge_backup(args, config, localconfig)
+ merge_backup(args, config, localconfig, nodes)
if args.interval is None:
break
print >>sys.stderr, "sleeping", args.interval, "seconds"
diff --git a/tools/merge_dist.py b/tools/merge_dist.py
index 0e85984..20b6a06 100755
--- a/tools/merge_dist.py
+++ b/tools/merge_dist.py
@@ -13,12 +13,11 @@ from certtools import timing_point, \
from mergetools import get_curpos, get_logorder, chunks, get_missingentries, \
sendsth, sendlog, sendentry, read_chain, parse_args
-def merge_dist(args, config, localconfig, timestamp):
+def merge_dist(args, localconfig, frontendnodes, timestamp):
paths = localconfig["paths"]
own_key = (localconfig["nodename"],
"%s/%s-private.pem" % (paths["privatekeys"],
localconfig["nodename"]))
- frontendnodes = config["frontendnodes"]
mergedb = paths["mergedb"]
chainsdir = mergedb + "/chains"
logorderfile = mergedb + "/logorder"
@@ -125,8 +124,14 @@ def main():
"""
args, config, localconfig = parse_args()
timestamp = 0
+
+ if len(args.node) == 0:
+ nodes = config["frontendnodes"]
+ else:
+ nodes = [n for n in config["frontendnodes"] if n["name"] in args.node]
+
while True:
- timestamp = merge_dist(args, config, localconfig, timestamp)
+ timestamp = merge_dist(args, localconfig, nodes, timestamp)
if args.interval is None:
break
print >>sys.stderr, "sleeping", args.interval, "seconds"
diff --git a/tools/mergetools.py b/tools/mergetools.py
index 86f9255..7b674de 100644
--- a/tools/mergetools.py
+++ b/tools/mergetools.py
@@ -391,6 +391,7 @@ def chunks(l, n):
def parse_args():
parser = argparse.ArgumentParser(description="")
+ parser.add_argument('node', nargs='*', help="Node to operate on")
parser.add_argument('--config', help="System configuration",
required=True)
parser.add_argument('--localconfig', help="Local configuration",