conga/luci/site/luci/Extensions cluster_adapte ...
CVSROOT: /cvs/cluster
Module name: conga
Changes by: jparsons at sourceware.org 2006-07-28 14:02:45
Modified files:
luci/site/luci/Extensions: cluster_adapters.py
conga_constants.py
Log message:
Refactored how DB flags are created for service changes, and also added DB Flags for cluster creation.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
luci/site/luci/Extensions/cluster_adapters.py +43 -11
@@ -131,20 +131,38 @@ cluster_properties['isComplete'] = False errors.append(error) return (False, {'errors': errors, 'requestResults':cluster_properties }) - + batch_id_map = {} for i in nodeList: try: rc = RicciCommunicator(i['ricci_host']) resultNode = rc.process_batch(batchNode, async=True) + batch_id_map[i['ricci_host']] = resultNode.getAttribute('batch_id') except: nodeUnauth(nodeList) cluster_properties['isComplete'] = False errors.append('An error occurred while attempting to add cluster node \"' + i['ricci_host'] + '\"') return (False, {'errors': errors, 'requestResults':cluster_properties }) + buildClusterCreateFlags(batch_id_map, clusterName) + messages.append('Creation of cluster \"' + clusterName + '\" has begun') return (True, {'errors': errors, 'messages': messages }) +def buildClusterCreateFlags(self, batch_map, clusterName): + path = CLUSTER_FOLDER_PATH + clusterName + clusterfolder = self.restrictedTraverse(path) + for key in batch_map.keys(): + id = batch_map[key] + batch_id = str(id) + clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(key) + #now designate this new object properly + objpath = path + "/" + key + flag = self.restrictedTraverse(objpath) + flag[BATCH_ID] = batch_id + flag[TASKTYPE] = CLUSTER_ADD + flag[FLAG_DESC] = "Creating node " + key + " for cluster " + clusterName + + def validateAddClusterNode(self, request): if 'clusterName' in request.form: clusterName = request.form['clusterName']
@@ -888,7 +906,13 @@ path = CLUSTER_FOLDER_PATH + cluname clusterfolder = self.restrictedTraverse(path) batch_id = str(batch_number) - clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(ricci_agent + "___" + batch_id) + clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(ricci_agent) + #Now we need to annotate the new DB object + objpath = path + "/" + ricci_agent + flag = self.restrictedTraverse(objpath) + flag[BATCH_ID] = batch_id + flag[TASKTYPE] = SERVICE_START + flag[FLAG_DESC] = "Starting service " + svcname response = req.RESPONSE response.redirect(req['HTTP_REFERER'] + "&busyfirst=true")
@@ -905,7 +929,13 @@ path = CLUSTER_FOLDER_PATH + cluname clusterfolder = self.restrictedTraverse(path) batch_id = str(batch_number) - clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(ricci_agent + "___" + batch_id) + clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(ricci_agent) + #Now we need to annotate the new DB object + objpath = path + "/" + ricci_agent + flag = self.restrictedTraverse(objpath) + flag[BATCH_ID] = batch_id + flag[TASKTYPE] = SERVICE_RESTART + flag[FLAG_DESC] = "Restarting service " + svcname response = req.RESPONSE response.redirect(req['HTTP_REFERER'] + "&busyfirst=true")
@@ -921,11 +951,14 @@ path = CLUSTER_FOLDER_PATH + cluname clusterfolder = self.restrictedTraverse(path) batch_id = str(batch_number) - clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(ricci_agent + "___" + batch_id) - #newobjpath = path + "/" + batch_id - #newobj = self.restrictedTraverse(newobjpath) - #newobj.manage_addProperty('title', ricci_agent, 'string') - #newobj.manage_addProperty('Description', "Please be Patient - Stopping Service", 'string') + clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(ricci_agent) + #Now we need to annotate the new DB object + objpath = path + "/" + ricci_agent + flag = self.restrictedTraverse(objpath) + flag[BATCH_ID] = batch_id + flag[TASKTYPE] = SERVICE_STOP + flag[FLAG_DESC] = "Stopping service " + svcname + time.sleep(2) response = req.RESPONSE
@@ -1276,9 +1309,8 @@ ##3) The ricci agent has no recollection of the task, so handle like 1 above for item in items: #Check here for more than 1 entry (an error) - datastrings = item[0].split('___') - rb = ricci_bridge(datastrings[0]) - finished = rb.checkBatch(datastrings[1]) + rb = ricci_bridge(item[0]) + finished = rb.checkBatch(item[1][BATCH_ID]) if finished == True: clusterfolder.manage_delObjects(item[0]) return map
luci/site/luci/Extensions/conga_constants.py +3 -0
@@ -52,7 +52,10 @@ PAGETYPE="pagetype" ACTIONTYPE="actiontype" +TASKTYPE="tasktype" CLUNAME="clustername" +BATCH_ID="batch_id" +FLAG_DESC="flag_desc" PATH_TO_PRIVKEY="/var/lib/luci/var/certs/privkey.pem" PATH_TO_CACERT="/var/lib/luci/var/certs/cacert.pem"