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

[Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	jparsons sourceware org	2006-12-20 20:24:27

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

Log message:
	still adressing bz212021

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ModelBuilder.py.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.187&r2=1.188

--- conga/luci/site/luci/Extensions/FenceHandler.py	2006/12/18 22:16:18	1.8
+++ conga/luci/site/luci/Extensions/FenceHandler.py	2006/12/20 20:24:27	1.9
@@ -1351,6 +1351,8 @@
     fencedev.addAttribute("ipaddr",ip)
     fencedev.addAttribute("login",log)
     fencedev.addAttribute("passwd",pwd)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
   elif agent_type == "fence_wti":
@@ -1367,6 +1369,8 @@
     fencedev.addAttribute("name",fencedev_name)
     fencedev.addAttribute("ipaddr",ip)
     fencedev.addAttribute("passwd",pwd)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
   elif agent_type == "fence_brocade":
@@ -1388,6 +1392,8 @@
     fencedev.addAttribute("ipaddr",ip)
     fencedev.addAttribute("login",log)
     fencedev.addAttribute("passwd",pwd)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
   elif agent_type == "fence_vixel":
@@ -1404,6 +1410,8 @@
     fencedev.addAttribute("name",fencedev_name)
     fencedev.addAttribute("ipaddr",ip)
     fencedev.addAttribute("passwd",pwd)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
 
@@ -1426,6 +1434,8 @@
     fencedev.addAttribute("ipaddr",ip)
     fencedev.addAttribute("login",log)
     fencedev.addAttribute("passwd",pwd)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
 
@@ -1438,6 +1448,8 @@
     fencedev.addAttribute("agent",agent_type)
     fencedev.addAttribute("name",fencedev_name)
     fencedev.addAttribute("server",server)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
   elif agent_type == "fence_egenera":
@@ -1449,6 +1461,8 @@
     fencedev.addAttribute("agent",agent_type)
     fencedev.addAttribute("name",fencedev_name)
     fencedev.addAttribute("cserver",cserver)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
 
@@ -1471,6 +1485,8 @@
     fencedev.addAttribute("ipaddr",ip)
     fencedev.addAttribute("login",log)
     fencedev.addAttribute("passwd",pwd)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
   elif agent_type == "fence_bladecenter":
@@ -1492,6 +1508,8 @@
     fencedev.addAttribute("ipaddr",ip)
     fencedev.addAttribute("login",log)
     fencedev.addAttribute("passwd",pwd)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
   elif agent_type == "fence_bullpap":
@@ -1513,6 +1531,8 @@
     fencedev.addAttribute("ipaddr",ip)
     fencedev.addAttribute("login",log)
     fencedev.addAttribute("passwd",pwd)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
 
@@ -1520,12 +1540,16 @@
 
     fencedev.addAttribute("agent",agent_type)
     fencedev.addAttribute("name",fencedev_name)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
   elif agent_type == "fence_scsi":
 
     fencedev.addAttribute("agent",agent_type)
     fencedev.addAttribute("name",fencedev_name)
+    if namechange:
+      model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
     return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
 
   #Oh-oh...no agent match
--- conga/luci/site/luci/Extensions/ModelBuilder.py	2006/10/26 22:59:13	1.10
+++ conga/luci/site/luci/Extensions/ModelBuilder.py	2006/12/20 20:24:27	1.11
@@ -902,6 +902,21 @@
           if fence.getName() == oldname:
             fence.addAttribute("name",newname)
 
+  ###Method for removing fence instances if a fence device
+  ###has been deleted from the configuration
+  def removeFenceInstancesForFenceDevice(self, name):
+    nodes = self.getNodes()
+    for node in nodes:
+      levels = node.getFenceLevels()
+      for level in levels:
+        fences = level.getChildren()
+        kill_list = list()
+        for fence in fences:
+          if fence.getName() == name:
+            kill_list.append(fence)
+        for victim in kill_list:
+          level.removeChild(victim) 
+
   def removeReferences(self, tagobj):
     self.__removeReferences(tagobj, self.cluster_ptr)
   def __removeReferences(self, tagobj, level):
@@ -911,7 +926,7 @@
           level.removeChild(t)
           continue
       self.__removeReferences(tagobj, t)
-  
+ 
   def updateReferences(self):
     self.__updateReferences(self.cluster_ptr)
   def __updateReferences(self, level):
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/12/18 22:16:18	1.187
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/12/20 20:24:27	1.188
@@ -1329,7 +1329,87 @@
     luci_log.debug_verbose('VFE: no form was submitted')
     return (False, {'errors': ['No form was submitted']})
 
-  pass
+  #get name of fencedev
+  try:
+    fencedev_name = form['orig_name']
+    fencedev_name = fencedev_name.strip()
+  except KeyError, e:
+    return (False, {'errors':['No device name in form submission'])
+
+  fdev_to_delete = None:
+  #iterate thru list of current fencedevs and find one to be deleted
+  fdevs = model.getFenceDevices()
+  for fdev in fdevs:
+    if fdev.getName().strip() == fencedev_name:
+      fdev_to_delete = fdev
+      break
+  if fdev_to_delete == None:
+    luci_log.debug_verbose('VFD: Could not find fence device name in model')
+    return (False, {'errors':['Could not find fence device name in model'])
+
+  #get fencedev ptr
+  fdev_ptr = model.getFenceDevicePtr()
+  #remove child
+  try:
+    fdev_ptr.removeChild(fdev_to_delete)
+    error_code = FD_VAL_SUCCESS
+    error_string = "Fence device %s successfully removed from configuration" % fencedev_name
+  except:
+    error_code = FD_VAL_FAIL
+    error_string = "Fence device %s could not be removed from configuration" % fencedev_name
+ 
+  try:
+    model.removeFenceInstancesForFenceDevice(orig_name)
+  except:
+    luci_log.debug_verbose('VFD: Could not remove fence instances for %s' % origname)
+     
+
+  if error_code == FD_VAL_SUCCESS:
+    messages.append(error_string)
+    try:
+      cp = model.getClusterPtr()
+      cp.incrementConfigVersion()
+      model.setModified(True)
+      conf_str = model.exportModelAsString()
+      if not conf_str:
+        raise Exception, 'conf_str is none'
+    except Exception, e:
+      luci_log.debug_verbose('VFE: export model as string failed: %s' \
+      % str(e))
+      errors.append('Unable to store the new cluster configuration')
+
+    try:
+      clustername = model.getClusterName()
+      if not clustername:
+        raise Exception, 'cluster name from modelb.getClusterName() is blank'
+    except Exception, e:
+      luci_log.debug_verbose('VFA: error: getClusterName: %s' % str(e))
+      errors.append('Unable to determine cluster name from model') 
+
+    if not rc:
+      rc = getRicciAgent(self, clustername)
+      if not rc:
+        luci_log.debug_verbose('VFA: unable to find a ricci agent for the %s cluster' % clustername)
+        errors.append('Unable to contact a ricci agent for cluster %s' \
+        % clustername)
+
+    if rc:
+      batch_id, result = setClusterConf(rc, str(conf_str))
+      if batch_id is None or result is None:
+        luci_log.debug_verbose('VFA: setCluserConf: batchid or result is None')
+        errors.append('Unable to propagate the new cluster configuration for %s' \
+        % clustername)
+      else:
+        try:
+          set_node_flag(self, clustername, rc.hostname(), batch_id,
+          CLUSTER_CONFIG, 'Updating cluster configuration')
+        except:
+          pass
+
+    return (True, {'errors': errors, 'messages': messages})
+  else:
+    errors.append(error_string)
+    return (False, {'errors': errors, 'messages': messages})
 
 def validateDaemonProperties(self, request):
 	errors = list()


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