From mboxrd@z Thu Jan 1 00:00:00 1970 From: jparsons@sourceware.org Date: 11 Oct 2006 16:25:00 -0000 Subject: [Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ... Message-ID: <20061011162500.31519.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: jparsons at sourceware.org 2006-10-11 16:24:59 Modified files: luci/site/luci/Extensions: cluster_adapters.py Log message: fixes for cluster and node creation busywait page Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.89&r2=1.90 --- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/10/11 16:18:58 1.89 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/10/11 16:24:59 1.90 @@ -2128,7 +2128,7 @@ level = levels[i] else: #No more levels... - return map + continue kids = level.getChildren() if len(kids) == 0: continue @@ -2189,6 +2189,9 @@ def isClusterBusy(self, req): items = None map = {} + isBusy = False + nodereports = list() + map['nodereports'] = nodereports cluname = req['clustername'] path = CLUSTER_FOLDER_PATH + cluname clusterfolder = self.restrictedTraverse(path) @@ -2200,32 +2203,97 @@ ##normal page ##2) The batch task is NOT done, so meta refresh in 5 secs and try again ##3) The ricci agent has no recollection of the task, so handle like 1 above + ### + ##Here is what we have to do: + ##the map should have two lists: + ##One list of non-cluster create tasks + ##and one of cluster create task structs + ##For each item in items, check if this is a cluster create tasktype + ##If so, call RC, and then call stan's batch report method + ##check for error...if error, report and then remove flag. + ##if no error, check if complete. If not complete, report status + ##If complete, report status and remove flag. for item in items: - #Check here for more than 1 entry (an error) - ricci = item[0].split("____") #This removes the 'flag' suffix - rb = ricci_bridge(ricci[0]) - finished = rb.checkBatch(item[1].getProperty(BATCH_ID)) - if finished == True: - clusterfolder.manage_delObjects(item[0]) - map['refreshurl'] = '5; url=\".\"' - map['desc'] = item[1].getProperty(FLAG_DESC) - return map + tasktype = item[1].getProperty(TASKTYPE) + if tasktype == CLUSTER_ADD or tasktype == NODE_ADD: + node_report = {} + node_report['isnodecreation'] = True + node_report['iserror'] = False #Default value + node_report['desc'] = item[1].getProperty(FLAG_DESC) + ricci = item[0].split("____") #This removes the 'flag' suffix + rc = RicciCommunicator(ricci[0]) + batch_xml = rc.batch_report(item[1].getProperty(BATCH_ID)) + (creation_status, total) = rc.batch_status(batch_xml) + if creation_status < 0: #an error was encountered + if creation_status == -(INSTALL_TASK): + node_report['iserror'] = True + (err_code, err_msg) = extract_module_status(batch_xml, INSTALL_TASK) + node_report['errormessage'] = CLUNODE_CREATE_ERRORS[INSTALL_TASK] + err_msg + elif creation_status == -(REBOOT_TASK): + node_report['iserror'] = True + (err_code, err_msg) = extract_module_status(batch_xml, REBOOT_TASK) + node_report['errormessage'] = CLUNODE_CREATE_ERRORS[REBOOT_TASK] + err_msg + elif creation_status == -(SEND_CONF): + node_report['iserror'] = True + (err_code, err_msg) = extract_module_status(batch_xml, SEND_CONF) + node_report['errormessage'] = CLUNODE_CREATE_ERRORS[SEND_CONF] + err_msg + elif creation_status == -(START_NODE): + node_report['iserror'] = True + (err_code, err_msg) = extract_module_status(batch_xml, START_NODE) + node_report['errormessage'] = CLUNODE_CREATE_ERRORS[START_NODE] + else: + node_report['iserror'] = True + node_report['errormessage'] = CLUNODE_CREATE_ERRORS[0] + clusterfolder.manage_delObjects(item[0]) + nodereports.append(node_report) + continue + else: #either batch completed successfully, or still running + if creation_status == total: #finished... + node_report['statusmessage'] = "Node created successfully" + node_report['statusindex'] = creation_status + nodereports.append(node_report) + clusterfolder.manage_delObjects(item[0]) + continue + else: + map['busy'] = "true" + isBusy = True + node_report['statusmessage'] = "Node still being created" + node_report['statusindex'] = creation_status + nodereports.append(node_report) + clusterfolder.manage_delObjects(item[0]) + continue + else: - map['busy'] = "true" - part1 = req['ACTUAL_URL'] - part2 = req['QUERY_STRING'] - dex = part2.find("&busyfirst") - if dex != (-1): - tmpstr = part2[:dex] #This strips off busyfirst var - part2 = tmpstr - ###FIXME - The above assumes that the 'busyfirst' query var is at the - ###end of the URL... - wholeurl = part1 + "?" + part2 - #map['url'] = "5, url=" + req['ACTUAL_URL'] + "?" + req['QUERY_STRING'] - map['refreshurl'] = "5; url=" + wholeurl - map['desc'] = item[1].getProperty(FLAG_DESC) - req['specialpagetype'] = "1" - return map + node_report = {} + node_report['isnodecreation'] = False + ricci = item[0].split("____") #This removes the 'flag' suffix + rb = ricci_bridge(ricci[0]) + finished = rb.checkBatch(item[1].getProperty(BATCH_ID)) + if finished == True: + node_report['desc'] = item[1].getProperty(FLAG_DESC) + nodereports.append(node_report) + clusterfolder.manage_delObjects(item[0]) + else: + node_report = {} + map['busy'] = "true" + isBusy = True + node_report['desc'] = item[1].getProperty(FLAG_DESC) + nodereports.append(node_report) + if isBusy: + part1 = req['ACTUAL_URL'] + part2 = req['QUERY_STRING'] + dex = part2.find("&busyfirst") + if dex != (-1): + tmpstr = part2[:dex] #This strips off busyfirst var + part2 = tmpstr + ###FIXME - The above assumes that the 'busyfirst' query var is@the + ###end of the URL... + wholeurl = part1 + "?" + part2 + #map['url'] = "5, url=" + req['ACTUAL_URL'] + "?" + req['QUERY_STRING'] + map['refreshurl'] = "5; url=" + wholeurl + req['specialpagetype'] = "1" + else: + map['refreshurl'] = '5; url=\".\"' return map def getClusterOS(self, ragent, request):