[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	jparsons sourceware org	2006-08-12 18:53:10

Modified files:
	luci/site/luci/Extensions: cluster_adapters.py 

Log message:
	Support for node actions

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.40&r2=1.41

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/08/11 00:29:11	1.40
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/08/12 17:53:09	1.41
@@ -1315,6 +1315,169 @@
 
   return map
 
+def nodeTaskProcess(self, model, request):
+  clustername = request['clustername']
+  nodename = request['nodename']
+  task = request['task']
+
+  if task == NODE_LEAVE_CLUSTER:
+    rb = ricci_bridge(nodename)
+    batch_number, result = rb.nodeLeaveCluster()
+
+    path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename
+    nodefolder = self.restrictedTraverse(path)
+    batch_id = str(batch_number)
+    objname = nodename + "____flag"
+    nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
+    #Now we need to annotate the new DB object
+    objpath = path + "/" + objname
+    flag = self.restrictedTraverse(objpath)
+    flag.manage_addProperty(BATCH_ID,batch_id, "string")
+    flag.manage_addProperty(TASKTYPE,NODE_LEAVE_CLUSTER, "string")
+    flag.manage_addProperty(FLAG_DESC,"Node \'" + nodename + "\' leaving cluster", "string")
+                                                                                
+    response = req.RESPONSE
+    #Is this correct? Should we re-direct to the cluster page?
+    response.redirect(req['URL'] + "?pagetype=" + CLUSTER_CONFIG)
+
+  elif task == NODE_JOIN_CLUSTER:
+    rb = ricci_bridge(nodename)
+    batch_number, result = rb.nodeJoinCluster()
+
+    path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename
+    nodefolder = self.restrictedTraverse(path)
+    batch_id = str(batch_number)
+    objname = nodename + "____flag"
+    nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
+    #Now we need to annotate the new DB object
+    objpath = path + "/" + objname
+    flag = self.restrictedTraverse(objpath)
+    flag.manage_addProperty(BATCH_ID,batch_id, "string")
+    flag.manage_addProperty(TASKTYPE,NODE_JOIN_CLUSTER, "string")
+    flag.manage_addProperty(FLAG_DESC,"Node \'" + nodename + "\' joining cluster", "string")
+                                                                                
+    response = req.RESPONSE
+    #Once again, is this correct? Should we re-direct to the cluster page?
+    response.redirect(req['URL'] + "?pagetype=" + CLUSTER_CONFIG)
+
+
+  elif task == NODE_REBOOT:
+    rb = ricci_bridge(nodename)
+    batch_number, result = rb.nodeReboot()
+
+    path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename
+    nodefolder = self.restrictedTraverse(path)
+    batch_id = str(batch_number)
+    objname = nodename + "____flag"
+    nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
+    #Now we need to annotate the new DB object
+    objpath = path + "/" + objname
+    flag = self.restrictedTraverse(objpath)
+    flag.manage_addProperty(BATCH_ID,batch_id, "string")
+    flag.manage_addProperty(TASKTYPE,NODE_REBOOT, "string")
+    flag.manage_addProperty(FLAG_DESC,"Node \'" + nodename + "\' is being rebooted", "string")
+                                                                                
+    response = req.RESPONSE
+    #Once again, is this correct? Should we re-direct to the cluster page?
+    response.redirect(req['URL'] + "?pagetype=" + CLUSTER_CONFIG)
+
+
+  elif task == NODE_FENCE:
+    #here, we DON'T want to open connection to node to be fenced.
+    path = CLUSTER_FOLDER_PATH + clustername
+    clusterfolder = self.restrictedTraverse(path)
+    if clusterfolder != None:
+      nodes = clusterfolder.objectItems('Folder')
+      found_one = False
+      for node in nodes:
+        if node[1].getID() == nodename:
+          continue
+        rb = ricci_bridge(node[1].getId())
+        if rb.getRicciResponse() == True:
+          found_one = True
+          break
+      if found_one == False:
+        return None
+    else:
+      return None
+
+    batch_number, result = rb.nodeFence(nodename)
+
+    path = path + "/" + nodename
+    nodefolder = self.restrictedTraverse(path)
+    batch_id = str(batch_number)
+    objname = nodename + "____flag"
+    nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
+    #Now we need to annotate the new DB object
+    objpath = path + "/" + objname
+    flag = self.restrictedTraverse(objpath)
+    flag.manage_addProperty(BATCH_ID,batch_id, "string")
+    flag.manage_addProperty(TASKTYPE,NODE_FENCE, "string")
+    flag.manage_addProperty(FLAG_DESC,"Node \'" + nodename + "\' is being fenced", "string")
+                                                                                
+    response = req.RESPONSE
+    #Once again, is this correct? Should we re-direct to the cluster page?
+    response.redirect(req['URL'] + "?pagetype=" + CLUSTER_CONFIG)
+
+
+  elif task == NODE_DELETE:
+    #We need to get a node name other than the node
+    #to be deleted, then delete the node from the cluster.conf
+    #and propogate it. We will need two ricci agents for this task.
+    
+    #First, delete cluster.conf from node to be deleted.
+
+    #next, have node leave cluster.
+    rb = ricci_bridge(nodename)
+    batch_number, result = rb.nodeLeaveCluster()
+
+    #It is not worth flagging this node in DB, as we are going
+    #to delete it anyway. Now, we need to delete node from model
+    #and send out new cluster.conf
+
+    model.deleteNode(nodename)
+    str_buf = ""
+    model.exportModelAsString(str_buf)
+
+    #here, we DON'T want to open connection to node to be fenced.
+    path = CLUSTER_FOLDER_PATH + clustername
+    clusterfolder = self.restrictedTraverse(path)
+    if clusterfolder != None:
+      nodes = clusterfolder.objectItems('Folder')
+      found_one = False
+      for node in nodes:
+        if node[1].getID() == nodename:
+          continue
+        rbridge = ricci_bridge(node[1].getId())
+        if rbridge.getRicciResponse() == True:
+          found_one = True
+          break
+      if found_one == False:
+        return None
+    else:
+      return None
+
+    batch_number, result = rbridge.setClusterConf(str(str_buf))
+
+    #Now we need to delete the node from the DB
+    path = CLUSTER_FOLDER_PATH + clustername
+    del_path = path + "/" + nodename
+    delnode = self.restrictedTraverse(del_path)
+    clusterfolder = self.restrictedTraverse(path)
+    clusterfolder.manage_delObjects(delnode[0])
+
+    batch_id = str(batch_number)
+    objname = ragent + "____flag"
+    clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
+    #Now we need to annotate the new DB object
+    objpath = path + "/" + objname
+    flag = self.restrictedTraverse(objpath)
+    flag.manage_addProperty(BATCH_ID,batch_id, "string")
+    flag.manage_addProperty(TASKTYPE,NODE_DELETE, "string")
+    flag.manage_addProperty(FLAG_DESC,"Deleting node \'" + nodename + "\'", "string")
+    response = request.RESPONSE
+    response.redirect(request['HTTP_REFERER'] + "&busyfirst=true")
+  
 
 def getNodeInfo(self, model, status, request):
   infohash = {}
@@ -1344,16 +1507,16 @@
                                                                                 
   #set up drop down links
   if nodestate == NODE_ACTIVE:
-    infohash['jl_url'] = baseurl + "?pagetype=" + NODE_LEAVE_CLUSTER + "&nodename=" + nodename + "&clustername=" + clustername
-    infohash['reboot_url'] = baseurl + "?pagetype=" + NODE_REBOOT + "&nodename=" + nodename + "&clustername=" + clustername
-    infohash['fence_url'] = baseurl + "?pagetype=" + NODE_FENCE + "&nodename=" + nodename + "&clustername=" + clustername
-    infohash['delete_url'] = baseurl + "?pagetype=" + NODE_DELETE + "&nodename=" + nodename + "&clustername=" + clustername
+    infohash['jl_url'] = baseurl + "?pagetype=" + NODE_PROCESS + "&task=" + NODE_LEAVE_CLUSTER + "&nodename=" + nodename + "&clustername=" + clustername
+    infohash['reboot_url'] = baseurl + "?pagetype=" +NODE_PROCESS + "&task=" + NODE_REBOOT + "&nodename=" + nodename + "&clustername=" + clustername
+    infohash['fence_url'] = baseurl + "?pagetype=" + NODE_PROCESS + "&task=" + NODE_FENCE + "&nodename=" + nodename + "&clustername=" + clustername
+    infohash['delete_url'] = baseurl + "?pagetype=" + NODE_PROCESS + "&task=" + NODE_DELETE + "&nodename=" + nodename + "&clustername=" + clustername
                                                                                 
   if nodestate == NODE_INACTIVE:
-    infohash['jl_url'] = baseurl + "?pagetype=" + NODE_JOIN_CLUSTER + "&nodename=" + nodename + "&clustername=" + clustername
-    infohash['reboot_url'] = baseurl + "?pagetype=" + NODE_REBOOT + "&nodename=" + nodename + "&clustername=" + clustername
-    infohash['fence_url'] = baseurl + "?pagetype=" + NODE_FENCE + "&nodename=" + nodename + "&clustername=" + clustername
-    infohash['delete_url'] = baseurl + "?pagetype=" + NODE_DELETE + "&nodename=" + nodename + "&clustername=" + clustername
+    infohash['jl_url'] = baseurl + "?pagetype=" + NODE_PROCESS + "&task=" + NODE_JOIN_CLUSTER + "&nodename=" + nodename + "&clustername=" + clustername
+    infohash['reboot_url'] = baseurl + "?pagetype=" + NODE_PROCESS + "&task=" + NODE_REBOOT + "&nodename=" + nodename + "&clustername=" + clustername
+    infohash['fence_url'] = baseurl + "?pagetype=" + NODE_PROCESS + "&task=" + NODE_FENCE + "&nodename=" + nodename + "&clustername=" + clustername
+    infohash['delete_url'] = baseurl + "?pagetype=" + NODE_PROCESS + "&task=" + NODE_DELETE + "&nodename=" + nodename + "&clustername=" + clustername
                                                                                 
   #return infohash
   if nodestate == NODE_ACTIVE or nodestate == NODE_INACTIVE:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]