[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 21:31:18

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

Log message:
	resolve FQDNs

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

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/08/12 18:22:29	1.42
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/08/12 20:31:18	1.43
@@ -1319,15 +1319,18 @@
   clustername = request['clustername']
   nodename = request['nodename']
   task = request['task']
+  nodename_resolved = resolve_nodename(clustername, nodename)
+  if nodename_resolved == None:
+    return None
 
   if task == NODE_LEAVE_CLUSTER:
-    rb = ricci_bridge(nodename)
+    rb = ricci_bridge(nodename_resolved)
     batch_number, result = rb.nodeLeaveCluster()
 
-    path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename
+    path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename_resolved
     nodefolder = self.restrictedTraverse(path)
     batch_id = str(batch_number)
-    objname = nodename + "____flag"
+    objname = nodename_resolved + "____flag"
     nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
     #Now we need to annotate the new DB object
     objpath = path + "/" + objname
@@ -1341,13 +1344,13 @@
     response.redirect(req['URL'] + "?pagetype=" + CLUSTER_CONFIG)
 
   elif task == NODE_JOIN_CLUSTER:
-    rb = ricci_bridge(nodename)
+    rb = ricci_bridge(nodename_resolved)
     batch_number, result = rb.nodeJoinCluster()
 
-    path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename
+    path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename_resolved
     nodefolder = self.restrictedTraverse(path)
     batch_id = str(batch_number)
-    objname = nodename + "____flag"
+    objname = nodename_resolved + "____flag"
     nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
     #Now we need to annotate the new DB object
     objpath = path + "/" + objname
@@ -1362,13 +1365,13 @@
 
 
   elif task == NODE_REBOOT:
-    rb = ricci_bridge(nodename)
+    rb = ricci_bridge(nodename_resolved)
     batch_number, result = rb.nodeReboot()
 
-    path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename
+    path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename_resolved
     nodefolder = self.restrictedTraverse(path)
     batch_id = str(batch_number)
-    objname = nodename + "____flag"
+    objname = nodename_resolved + "____flag"
     nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
     #Now we need to annotate the new DB object
     objpath = path + "/" + objname
@@ -1390,7 +1393,7 @@
       nodes = clusterfolder.objectItems('Folder')
       found_one = False
       for node in nodes:
-        if node[1].getID() == nodename:
+        if node[1].getID().find(nodename) != (-1):
           continue
         rb = ricci_bridge(node[1].getId())
         if rb.getRicciResponse() == True:
@@ -1403,10 +1406,10 @@
 
     batch_number, result = rb.nodeFence(nodename)
 
-    path = path + "/" + nodename
+    path = path + "/" + nodename_resolved
     nodefolder = self.restrictedTraverse(path)
     batch_id = str(batch_number)
-    objname = nodename + "____flag"
+    objname = nodename_resolved + "____flag"
     nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
     #Now we need to annotate the new DB object
     objpath = path + "/" + objname
@@ -1428,7 +1431,7 @@
     #First, delete cluster.conf from node to be deleted.
 
     #next, have node leave cluster.
-    rb = ricci_bridge(nodename)
+    rb = ricci_bridge(nodename_resolved)
     batch_number, result = rb.nodeLeaveCluster()
 
     #It is not worth flagging this node in DB, as we are going
@@ -1446,8 +1449,9 @@
       nodes = clusterfolder.objectItems('Folder')
       found_one = False
       for node in nodes:
-        if node[1].getID() == nodename:
+        if node[1].getID().find(nodename) != (-1):
           continue
+        #here we make certain the node is up...
         rbridge = ricci_bridge(node[1].getId())
         if rbridge.getRicciResponse() == True:
           found_one = True
@@ -1461,13 +1465,13 @@
 
     #Now we need to delete the node from the DB
     path = CLUSTER_FOLDER_PATH + clustername
-    del_path = path + "/" + nodename
+    del_path = path + "/" + nodename_resolved
     delnode = self.restrictedTraverse(del_path)
     clusterfolder = self.restrictedTraverse(path)
     clusterfolder.manage_delObjects(delnode[0])
 
     batch_id = str(batch_number)
-    objname = ragent + "____flag"
+    objname = nodename_resolved + "____flag"
     clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
     #Now we need to annotate the new DB object
     objpath = path + "/" + objname
@@ -1906,4 +1910,12 @@
     pass
   return
 
+def resolve_nodename(self, clustername, nodename):
+  path = CLUSTER_FOLDER_PATH + clustername
+  clusterfolder = self.restrictedTraverse(path)
+  objs = clusterfolder.objectItems()
+  for obj in objs:
+    if obj[0].find(nodename) != (-1):
+      return obj[0]
 
+  return None


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