summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/hbnotes.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-09-23 18:39:57 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-09-23 18:39:57 (GMT)
commitb2a8f5b6cf0bd826151b23beaade6cc024c96d24 (patch)
tree74e3ad329f23fd1717635efe500cf439c79a427f /abs/core/xymon/hbnotes.py
parentbe519352aab83e48d3bfaeb2f076f373c1e8e9e4 (diff)
downloadlinhes_pkgbuild-b2a8f5b6cf0bd826151b23beaade6cc024c96d24.zip
linhes_pkgbuild-b2a8f5b6cf0bd826151b23beaade6cc024c96d24.tar.gz
linhes_pkgbuild-b2a8f5b6cf0bd826151b23beaade6cc024c96d24.tar.bz2
supplemental-web/xymon: When restoring the database from the webui, prompt to make sure it's really what the user wants.
Also limit db dropdown to 30 entries
Diffstat (limited to 'abs/core/xymon/hbnotes.py')
-rw-r--r--abs/core/xymon/hbnotes.py142
1 files changed, 97 insertions, 45 deletions
diff --git a/abs/core/xymon/hbnotes.py b/abs/core/xymon/hbnotes.py
index 6751865..78145f2 100644
--- a/abs/core/xymon/hbnotes.py
+++ b/abs/core/xymon/hbnotes.py
@@ -24,17 +24,26 @@ def createdropdown(currenthostype):
dropdown=" "
dropdown='''
<input name="param2" type="radio" value="Restore" />Restore database </>
- <select name="param1">
- '''
+ <select name="param1">\n'''
+ os.chdir(dir)
if os.path.exists(dir):
files = os.listdir(dir)
- for file in os.listdir(dir):
+ files.sort(key=lambda x: os.path.getmtime(x) , reverse=True)
+ #for file in os.listdir(dir):
+ if len(files) > 20:
+ del files[20:]
+
+
+ for file in files:
if (file.endswith(".tgz")):
- dropdown+='<option value="' + file + '">' + file + '</option> '
- dropdown+='</select> <br><input name="param2" type="radio" value="Backup" checked="checked" />Backup database<br /> '
- dropdown+='<input name="param2" type="radio" value="Optimize" />Optimize database<br /> '
+ dropdown+=' <option value="' + file + '">' + file + '</option> \n'
+ dropdown+=''' </select>
+ <br>
+ <input name="param2" type="radio" value="Backup" checked="checked" />Backup database<br />
+ <input name="param2" type="radio" value="Optimize" />Optimize database<br />
+ '''
if currenthostype == "Master_backend":
- dropdown+='<input name="param2" type="radio" value="ShutdownAll" />Shutdown All Systems (expect MBE)<br /> '
+ dropdown+='<input name="param2" type="radio" value="ShutdownAll" />Shutdown All Systems (expect MBE)<br /> \n'
#dropdown+='''<input name="param2" type="radio" value="UpdateAll" />Update All Systems </> <select name="param5">
#<option value="Myth_only">Myth only</option>
#<option value="All"> Full System</option>
@@ -43,7 +52,7 @@ def createdropdown(currenthostype):
#</br>
#</br>'''
- dropdown+=''' </br></br>'''
+ dropdown+=''' </br></br>\n'''
return dropdown
def main(argv):
@@ -266,14 +275,55 @@ def main(argv):
file = open(filename,'w')
string='''
- <html>
- <head>
- <style type="text/css">@import "/frame.css";</style>
- </head>
- '''
+<html>
+<head> <style type="text/css">@import "/frame.css";</style>
+<SCRIPT>
+
+function do_submission()
+{
+ document.form.submit();
+}
+
+
+function Do_it ()
+{
+ chosen = ""
+ len = document.form.param2.length
+ for (i = 0; i <len; i++)
+ {
+ if (document.form.param2[i].checked)
+ {
+ chosen = document.form.param2[i].value
+ }
+ }
+
+
+ if (chosen == "Restore")
+ {
+ if (confirm('Continue with database restore?'))
+ {
+ do_submission();
+ }
+ else
+ {
+ alert(" database was not restored");
+ }
+
+
+ }
+ else
+ {
+ //alert("not restore")
+ do_submission();
+ }
+}
+
+</SCRIPT>
+</head>
+
+'''
file.write(string)
-
for i in range( 0 , len(hostvalues)):
value=hostvalues[i][0]
data=hostvalues[i][1]
@@ -284,7 +334,6 @@ def main(argv):
found_uuid="true"
uuid=data
if value == "HostSystemType" :
-
currenthostname= str(row[0]).strip()
currenthostype=str(data).strip()
header="<h1>" + currenthostname + " (" + currenthostype + ") </h1>"
@@ -292,7 +341,7 @@ def main(argv):
if found_uuid == "true" :
- string=str("http://smolt.mythvantage.com/client/show?uuid=")
+ string=str("http://smolt.mythtv.org/client/show?uuid=")
string+=str(uuid)
file.write("<A href=\"" )
file.write(string)
@@ -303,42 +352,45 @@ def main(argv):
buttonform_top='''
- <div class="content" style="solid #aaa; width:500px; height:350px; overflow:auto; color:#FFF;text-align:left;">
- <form action="/process.py" method="get">
+ <div class="content" style="solid #aaa; width:500px; height:350px; overflow:auto; color:#FFF;text-align:left;">
+ <form name="form" action="/process.py" method="get">
'''
buttonform_bottom='''
- <input name="param2" type="radio" value="Update" />Update System </>
- <select name="param3">
- <option value="Myth_only">Myth only</option>
- <option value="All"> Full System</option>
- </select>
- </br>
- <input name="param2" type="radio" value="Kill" />Restart interface: </>
- <select name="param6">
- <option value="killX">Full UI</option>
- <option value="killmyth">MythFrontend</option>
- </select>
- </br>
- <input name="param2" type="radio" value="Shutdown" />Shutdown System<br />
- <input name="param2" type="radio" value="Reboot" />Reboot System<br />
- <input name="param2" type="radio" value="WOL" />Wake on Lan<br />
- <input name="hiddenparam" type="hidden" value="
- '''
- oldurlform='''
- "/>
- <input name="param4" type="hidden" value="
- '''
+ <input name="param2" type="radio" value="Update" />Update System </>
+ <select name="param3">
+ <option value="Myth_only">Myth only</option>
+ <option value="All"> Full System</option>
+ </select>
+ </br>
+
+ <input name="param2" type="radio" value="Kill" />Restart interface: </>
+ <select name="param6">
+ <option value="killX">Full UI</option>
+ <option value="killmyth">MythFrontend</option>
+ </select>
+ </br>
+
+ <input name="param2" type="radio" value="Shutdown" />Shutdown System<br />
+ <input name="param2" type="radio" value="Reboot" />Reboot System<br />
+ <input name="param2" type="radio" value="WOL" />Wake on Lan<br />
+ <input name="hiddenparam" type="hidden" value=" '''
+
+ oldurlform=''' "/>
+ <input name="param4" type="hidden" value="
+ '''
closetag='''
"/>
- </br>
- <input id="submitbutton" type="submit" />
- </form>
- </div>
- '''
+ </br>
+ <!--<input id="submitbutton" type="submit" />-->
+ <a href="Javascript:Do_it();">
+ <img src="/go.png"></a>
+ </form>
+ </div>
+'''
if currenthostype == "Master_backend" or currenthostype == "Standalone":
mbeoptions=createdropdown(currenthostype)
@@ -356,7 +408,7 @@ def main(argv):
file.write(returnurl)
file.write(closetag)
- string=(' </html>')
+ string=('</html>')
file.write(string)
if __name__ == "__main__":