update All hosts

This commit is contained in:
2016-05-03 18:31:34 +02:00
parent a585fdf54b
commit c3eb0f03fc
+13 -4
View File
@@ -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<br>" % (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" }