From c3eb0f03fc7582c60b4e85e0d5e5399014291ccc Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Tue, 3 May 2016 18:31:34 +0200 Subject: [PATCH] update All hosts --- hbd | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hbd b/hbd index 66af86d..9c7c6b8 100755 --- a/hbd +++ b/hbd @@ -622,16 +622,25 @@ class HttpHandler(BaseHTTPServer.BaseHTTPRequestHandler): log(uname, ll) elif qr.path == "/u": # update - uname=qa.get('h',[None])[0] + uname=urllib.unquote(qa.get('h',[None])[0]) ucode=qa.get('c', [None])[0] if not ucode or not uname: code, res=self.builderror(400, 'Argument error', "need h= and c= arguments") - elif not Host.hosts.has_key(uname): + elif uname != 'All' and not Host.hosts.has_key(uname): code, res=self.builderror(400, 'Data error', "h=%s not found" % uname) else: - err = updatecode(ucode, urllib.unquote(uname)) res=self.buildhead() - res.append("3 Done: %s" % err if err else "OK") + if uname != 'All': + names = [uname] + else: + names = [] + for n in Host.hosts: + if Host.hosts[n].cver >= 2: # earliest version that supports update + names.append(n) + for n in names: + err = updatecode(ucode, n) + res.append("update started for %s: %s
" % (n, err if err else "OK")) + res.append("Done") elif qr.path == "/api/0/hosts": # api access to host table headerdict = {"Content-Type": "application/json; charset=utf-8" }