All of lore.kernel.org
 help / color / mirror / Atom feed
From: kupcevic@sourceware.org <kupcevic@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci site/luci/Extensions/HelperFunction ...
Date: 5 Oct 2006 23:21:40 -0000	[thread overview]
Message-ID: <20061005232140.10920.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-05 23:21:40

Modified files:
	luci/site/luci/Extensions: HelperFunctions.py StorageReport.py 
	luci/storage   : cache_report form-macros 

Log message:
	luci storage: error reporting during probes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/HelperFunctions.py.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/cache_report.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&r1=1.4&r2=1.5

--- conga/luci/site/luci/Extensions/HelperFunctions.py	2006/08/03 18:56:10	1.2
+++ conga/luci/site/luci/Extensions/HelperFunctions.py	2006/10/05 23:21:39	1.3
@@ -87,6 +87,6 @@
                 value)
     response.setCookie(cookie_prefix + var_name,
                        value, 
-                       expires='Tue, 30 Jun 2020 12:00:00 GMT')
+                       expires='Tue, 30 Jun 2060 12:00:00 GMT')
     
     return value
--- conga/luci/site/luci/Extensions/StorageReport.py	2006/10/05 16:11:37	1.8
+++ conga/luci/site/luci/Extensions/StorageReport.py	2006/10/05 23:21:39	1.9
@@ -218,8 +218,6 @@
                 return True
     return False
 
-
-
 def invalidate_storage_report(session, storagename):
     reports_dir = {}
     if session.has_key(SESSION_STORAGE_XML_REPORT):
@@ -229,6 +227,19 @@
     return
 
 
+def cache_storage_report(ricci_comm,
+                         session):
+    try:
+        rep = get_storage_report(ricci_comm, session)
+        if rep == None:
+            raise Exception, 'Unable to communicate to host'
+        else:
+            return True
+    except Exception, e:
+        return str(e)
+    except:
+        return 'Luci internal error. Please file bug report.'
+    return 'should never come here'
 
 def get_storage_report(ricci_comm,
                        session):
@@ -275,30 +286,57 @@
     # get report
     batch_r = ricci_comm.process_batch(batch)
     if batch_r.getAttribute('status') != '0':
-        raise 'error retrieving storage report'
+        #raise Exception, 'error retrieving storage report'
+        # dig deeper to find causing error
+        pass
     module_r = None
     for node in batch_r.childNodes:
         if node.nodeType == xml.dom.Node.ELEMENT_NODE:
             if node.nodeName == 'module':
                 module_r = node
     if module_r == None:
-        raise 'missing <module/> in <batch/>'
-    if module_r.getAttribute('status') != '0':
-        raise 'error retrieving storage report'
+        raise Exception, 'malformed response: missing <module/> in <batch/>'
+    module_r_status = module_r.getAttribute('status')
+    if module_r_status != '0':
+        #raise Exception, 'error retrieving storage report'
+        if module_r_status == '3':
+            raise Exception, 'Unable to find storage module: reinstall it'
     resp_r = None
     for node in module_r.childNodes:
         if node.nodeType == xml.dom.Node.ELEMENT_NODE:
             if node.nodeName == 'response':
                 resp_r = node
     if resp_r == None:
-        raise 'missing <response/> in <module/>'
+        raise Exception, 'malformed response: missing <response/> in <module/>'
     fr_r = None
     for node in resp_r.childNodes:
         if node.nodeType == xml.dom.Node.ELEMENT_NODE:
             if node.nodeName == 'function_response':
                 fr_r = node
     if fr_r == None:
-        raise 'missing <function_response/> in <response/>'
+        raise Exception, 'malformed response: missing <function_response/> in <response/>'
+    succ_v     = None
+    err_code_v = None
+    err_desc_v = None
+    for node in fr_r.childNodes:
+        try:
+            var = parse_variable(node)
+            if var.get_name() == 'success':
+                succ_v = var
+            elif var.get_name() == 'error_code':
+                err_code_v = var
+            elif var.get_name() == 'error_description':
+                err_desc_v = var
+        except:
+            pass
+    if succ_v == None:
+        raise Exception, 'malformed response: missing "success" variable in <function_response/>'
+    if succ_v.get_value() != True:
+        # error
+        if err_code_v.get_value() == -1:
+            raise Exception, 'Generic error:\n\n' + err_desc_v.get_value()
+        else:
+            raise Exception, err_desc_v.get_value()
     
     #xml_report = fr_r.toxml()
     xml_report = fr_r
@@ -307,7 +345,7 @@
     reports_dir = session[SESSION_STORAGE_XML_REPORT]
     reports_dir[storagename] = xml_report
     session.set(SESSION_STORAGE_XML_REPORT, reports_dir)
-        
+    
     return StorageReport(xml_report)
 
 
--- conga/luci/storage/cache_report	2006/06/30 17:00:02	1.1
+++ conga/luci/storage/cache_report	2006/10/05 23:21:40	1.2
@@ -1,17 +1,15 @@
-<span tal:omit-tag="" 
-      tal:define="global storagename request/storagename|nothing"/>
-<span tal:omit-tag="" 
-      tal:define="stosystemss context/systems/storage/objectItems;
+<span tal:define="global storagename request/storagename|nothing"
+      tal:replace="string:"/>
+<span tal:define="stosystemss context/systems/storage/objectItems;
                   global allowed_systems python:here.allowed_systems(user, stosystemss);
-                  global access_to_host_allowed python:here.access_to_host_allowed(storagename, allowed_systems)"/>
-<span tal:omit-tag="" 
-      tal:define="global ricci python:here.get_ricci_communicator(storagename, allowed_systems);
-                  global storage_report python:here.get_storage_report(ricci, request.SESSION)"/>
-<span tal:omit-tag=""
-      tal:condition="storage_report">
-OK
-</span>
-<span tal:omit-tag=""
-      tal:condition="not: storage_report">
-error
-</span>
+                  global access_to_host_allowed python:here.access_to_host_allowed(storagename, allowed_systems)"
+      tal:replace="string:"/>
+<span tal:define="global ricci python:here.get_ricci_communicator(storagename, allowed_systems);
+                  global cache_result python:here.cache_storage_report(ricci, request.SESSION)"
+      tal:replace="string:"/>
+<span tal:condition="python: cache_result == True" 
+      tal:replace="string:OK"/>
+<span tal:condition="python: cache_result != True and access_to_host_allowed"
+      tal:replace="structure cache_result"/>
+<span tal:condition="python: not access_to_host_allowed"
+      tal:replace="string: Insufficient Rights"/>
--- conga/luci/storage/form-macros	2006/08/03 18:56:09	1.4
+++ conga/luci/storage/form-macros	2006/10/05 23:21:40	1.5
@@ -141,11 +141,11 @@
         if (res.substr(0, 2) == "OK") {
            window.location.reload();
         } else {
-           alert('An error has occured while probing storage');
+           alert('An error has occured while probing storage:\n\n' + res);
            window.location = list_URL;
         }
     } else {
-        alert("Error retrieving data from server");
+        alert("Error retrieving data from Luci server");
         window.location = list_URL;
     }
   }



             reply	other threads:[~2006-10-05 23:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-05 23:21 kupcevic [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-10-06 22:08 [Cluster-devel] conga/luci site/luci/Extensions/HelperFunction kupcevic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061005232140.10920.qmail@sourceware.org \
    --to=kupcevic@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.