From c2e98d262d9e6003dfe7aadee5713028fb4d27cb Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Fri, 4 Jan 2013 20:41:23 -0600
Subject: xymon: hbnotes, for MBE systems generate a notes file that allows the
 download/upload of backup files.

refs #893
---
 abs/core/xymon/PKGBUILD   |   4 +-
 abs/core/xymon/hbnotes.py | 127 +++++++++++++++++++++++++++++++++-------------
 2 files changed, 94 insertions(+), 37 deletions(-)

diff --git a/abs/core/xymon/PKGBUILD b/abs/core/xymon/PKGBUILD
index 91fdb49..8441779 100755
--- a/abs/core/xymon/PKGBUILD
+++ b/abs/core/xymon/PKGBUILD
@@ -1,7 +1,7 @@
 pkgbase=xymon
 pkgname=(xymonserver xymonclient)
 pkgver=4.3.5
-pkgrel=43
+pkgrel=44
 pkgdesc="Hobbit is a system for monitoring servers and networks. "
 license="GPL"
 arch=('i686' 'x86_64')
@@ -125,7 +125,7 @@ md5sums=('31923ec126fe1c264fceb459d2175161'
          '2d88e59ab17114030da514ba3f0a5b64'
          'ee608dcafc050d790e28647a670f6b60'
          'b2f98ac0df013332deedc1efae0a270d'
-         '8ad9dded90acc96e9186ba846a91bbb9'
+         'fc24435b97254f0954233319ba09689b'
          '0f70e76a164f648f0a4a01110137cb20'
          'f6921f0413215ae174e81306be80d37f'
          '80d9cfac86c6d96836e6f406e35e7cf5'
diff --git a/abs/core/xymon/hbnotes.py b/abs/core/xymon/hbnotes.py
index 8d73dbf..be34dc6 100644
--- a/abs/core/xymon/hbnotes.py
+++ b/abs/core/xymon/hbnotes.py
@@ -173,8 +173,8 @@ def create_dot_file():
 
 def createdropdown(currenthostype):
     dir = "/data/storage/disk0/backup/system_backups"
-    dropdown=" "
     dropdown='''
+    </br>
      <input name="param2" type="radio"  value="Restore" />Restore database </>
      <select name="param1">\n'''
     os.chdir(dir)
@@ -185,13 +185,37 @@ def createdropdown(currenthostype):
         if len(files) > 20:
             del files[20:]
 
-
         for file in files:
             if (file.endswith(".tgz")):
                 dropdown+='        <option value="' + file + '">' + file + '</option> \n'
-    dropdown+='''     </select>
+    dropdown+='''
+    </select>
+    </br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp
+    <input type="checkbox" name="param8" >Partial Restore<br>
+
     <br>
+    <input name="param2" type="radio" value="Upload"  />Upload file to restore  </>
+    <input name="uFile"  type="file" size="40">
+
+    <br><br>
     <input name="param2" type="radio" value="Backup" checked="checked" />Backup database<br />
+    '''
+
+    #This is for the d/l backup option
+    dropdown+='''
+
+
+    <input name="param2" type="radio"  value="Dbackup" />Download backup </>
+    <select name="param7">\n\n </br>'''
+
+    for file in files:
+        if (file.endswith(".tgz")):
+            dropdown+='        <option value="' + file + '">' + file + '</option> \n'
+
+    dropdown+='''
+    </select>
+
+    <br>
     <input name="param2" type="radio" value="Optimize"  />Optimize database<br />
     '''
     if currenthostype == "Master_backend":
@@ -215,7 +239,8 @@ def create_notes():
     cursor.execute("SELECT DISTINCT(hostname) from settings")
     result = cursor.fetchall()
     for row in result:
-       cursor.execute("select value,data  from settings where hostname=%s and value in ('HostSystemType','HostHwuuid');",(row))
+       #cursor.execute("select value,data  from settings where hostname=%s and value in ('HostSystemType','HostHwuuid');",(row))
+       cursor.execute("select value,data  from settings where hostname=%s and value in ('HostSystemType','HardwareProfilePublicUUID');",(row))
        hostvalues=cursor.fetchall()
        #This is here to ignore non LinHES hosts, or those that don't have a HostSystemType
        if len(hostvalues) == 0:
@@ -261,6 +286,38 @@ function Do_it ()
             alert(" database was not restored");
         }
     }
+    else if (chosen == "Backup")
+    {
+        if (confirm('Continue with database backup?'))
+        {
+            do_submission();
+        }
+        else
+        {
+            alert(" backup cancelled");
+        }
+    }
+    else if (chosen == "Upload")
+    {
+        if (confirm('About to upload the backup file to server'))
+        {
+            alert("Uploading file to server");
+            do_submission();
+        }
+    }
+    else if (chosen == "Optimize")
+    {
+        if (confirm('Continue with database maintenance?'))
+        {
+            do_submission();
+        }
+        else
+        {
+            alert("Optimization cancelled");
+        }
+    }
+
+
 
     else if (chosen == "Shutdown")
     {
@@ -318,7 +375,8 @@ function Do_it ()
             data=hostvalues[i][1]
             currenthostype=''
             currenthostname=''
-            if  value == "HostHwuuid" :
+            #if  value == "HostHwuuid" :
+            if  value == "HardwareProfilePublicUUID" :
                 if data != "blank" :
                     found_uuid="true"
                     uuid=data
@@ -337,46 +395,45 @@ function Do_it ()
             file.write("\" >" +  str(uuid)   + "</A>")
        else:
             file.write( "uuid  not found, please submit a hardware profile" )
-
-
-
        buttonform_top='''
-    <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">
-         '''
+    <div id="resultbox" >
+        <form name="form" action="/process.py"  enctype="multipart/form-data" method="POST" >
+    '''
 
 
        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=" '''
+        <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="param4" type="hidden" value="
     '''
-
-
        closetag='''
            "/>
+        </br>
+    </div>
     </br>
-    <!--<input id="submitbutton" type="submit" />-->
-    <a href="Javascript:Do_it();">
-    <img src="/go.png"></a>
+    <div id="center_button" >
+        <!--<input id="submitbutton" type="submit" />-->
+        <a href="Javascript:Do_it();">
+        <img src="/go.png"></a>
     </form>
     </div>
 '''
-- 
cgit v0.12

