From mboxrd@z Thu Jan 1 00:00:00 1970 From: kupcevic@sourceware.org Date: 5 Oct 2006 23:21:40 -0000 Subject: [Cluster-devel] conga/luci site/luci/Extensions/HelperFunction ... Message-ID: <20061005232140.10920.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 in ' - if module_r.getAttribute('status') != '0': - raise 'error retrieving storage report' + raise Exception, 'malformed response: missing in ' + 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 in ' + raise Exception, 'malformed response: missing in ' 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 in ' + raise Exception, 'malformed response: missing in ' + 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 ' + 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 @@ - - + - - -OK - - -error - + global access_to_host_allowed python:here.access_to_host_allowed(storagename, allowed_systems)" + tal:replace="string:"/> + + + + --- 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; } }