[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-18 22:16:18

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

Log message:
	212021 work

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.186&r2=1.187
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.29&r2=1.30

--- conga/luci/site/luci/Extensions/FenceHandler.py	2006/12/18 15:18:37	1.7
+++ conga/luci/site/luci/Extensions/FenceHandler.py	2006/12/18 22:16:18	1.8
@@ -2,11 +2,13 @@
 from ValidationError import ValidationError
 import MessageLibrary
 import ModelBuilder
+from FenceDevice import FenceDevice
 from conga_constants import *
 
 INSTALLDIR="/usr/share/system-config-cluster"
 
 FD_NEW_SUCCESS = "New %s successfully added to cluster"
+FD_NEW_SUCCESS = "Fence device %s successfully updated"
 FD_NEW_FAIL = "No agent type %s in shared device list"
 FD_PROVIDE_NAME = "A unique name must be provided for each Fence Device"
 
@@ -1031,261 +1033,501 @@
       # select text
       raise ValidationError('FATAL', ILLEGAL_CHARS_REPLACED)
 
-  def validateNewFenceDevice(self, form, model): 
+def validateNewFenceDevice(form, model): 
+  try:
+    agent_type = form['fence_type']
+  except KeyError, e:
+    return (FD_VAL_FAIL, "No agent type in form submission")
+
+  ##Now that we have an agent type, we should check the fencedev name
+  ##before wasting any time checking other fields.
+  try:
+    fencedev_name = form['name']
+    fencedev_name = fencedev_name.strip()
+  except KeyError, e:
+    return (FD_VAL_FAIL, "No device name in form submission")
+
+  if fencedev_name == "":
+    return (1, "A unique name is required for every fence device")
+
+  fencedevs = model.getFenceDevices()
+  for fd in fencedevs:
+    if fd.getName().strip() == fencedev_name:
+      return (FD_VAL_FAIL, FD_PROVIDE_NAME)
+
+  if agent_type == "fence_apc":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+  elif agent_type == "fence_wti":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("passwd",pwd)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+  elif agent_type == "fence_brocade":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+  elif agent_type == "fence_vixel":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("passwd",pwd)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+
+  elif agent_type == "fence_mcdata":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+
+  elif agent_type == "fence_gnbd":
+    try:
+      server = form['server']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_SERVER)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("server",server)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+  elif agent_type == "fence_egenera":
+    try:
+      cserver = form['cserver']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_CSERVER)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("cserver",cserver)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+
+  elif agent_type == "fence_sanbox2":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+  elif agent_type == "fence_bladecenter":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+  elif agent_type == "fence_bullpap":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+
+  elif agent_type == "fence_xvm":
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+  elif agent_type == "fence_scsi":
+
+    fencedev = FenceDevice()
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedevptr = model.getFenceDevicePtr()
+    fencedevptr.addChild(fencedev)
+    return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
+
+  #Oh-oh...no agent match
+  else:
+    return (FD_VAL_FAIL, FD_NEW_FAIL % agent_type)
+  
+def validateFenceDevice(form, model): 
+  namechange = False
+  try:
+    agent_type = form['fence_type']
+  except KeyError, e:
+    return (FD_VAL_FAIL, "No agent type in form submission")
+
+  ##Now that we have an agent type, we should check the fencedev name
+  ##before wasting any time checking other fields.
+  try:
+    fencedev_name = form['name']
+    fencedev_name = fencedev_name.strip()
+  except KeyError, e:
+    return (FD_VAL_FAIL, "No device name in form submission")
+
+  if fencedev_name == "":
+    return (1, "A unique name is required for every fence device")
+
+  try:
+    orig_name = form['orig_name']
+  except KeyError, e:
+    return (FD_VAL_FAIL, "Cannot retrieve original fence device")
+
+  if orig_name != fencedev_name:
+    namechange = True
+
+  fencedevs = model.getFenceDevices()
+  for fd in fencedevs:
+    if fd.getName().strip() == fencedev_name:
+      return (FD_VAL_FAIL, FD_PROVIDE_NAME)
+
+  #Now we know name is unique...find device now
+  fencedev = None
+  for fd in fencedevs:
+    if fd.getName().strip() == orig_name:
+      fencedev = fd
+      break
+
+  if fencedev == None:
+    return (FD_VAL_FAIL, "Could not find fencedevice in current configuration")
+
+  if agent_type == "fence_apc":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
     try:
-      agent_type = form['agent']
+      pwd = form['password']
     except KeyError, e:
-      return (FD_VAL_FAIL, "No agent type in form submission")
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
 
-    ##Now that we have an agent type, we should check the fencedev name
-    ##before wasting any time checking other fields.
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+  elif agent_type == "fence_wti":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
     try:
-      fencedev_name = form['name']
-      fencedev_name = fencedev_name.strip()
-    except KeyError, e:
-      return (FD_VAL_FAIL, "No device name in form submission")
-
-    if fencedev_name == "":
-      return (1, "A unique name is required for every fence device")
-
-    fencedevs = model.getFenceDevices()
-    for fd in fencedevs:
-      if fd.getName().strip() == fencedev_name:
-        return (FD_VAL_FAIL, FD_PROVIDE_NAME)
-
-    if agent_type == "fence_apc":
-      try:
-        ip = form['ipaddr']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_IP)
-      try:
-        log = form['login']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
-      try:
-        pwd = form['passwd']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("ipaddr",ip)
-      fencedev.addAttribute("login",log)
-      fencedev.addAttribute("passwd",pwd)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-    elif agent_type == "fence_wti":
-      try:
-        ip = form['ipaddr']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_IP)
-      try:
-        pwd = form['passwd']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("ipaddr",ip)
-      fencedev.addAttribute("passwd",pwd)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-    elif agent_type == "fence_brocade":
-      try:
-        ip = form['ipaddr']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_IP)
-      try:
-        log = form['login']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
-      try:
-        pwd = form['passwd']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("ipaddr",ip)
-      fencedev.addAttribute("login",log)
-      fencedev.addAttribute("passwd",pwd)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-    elif agent_type == "fence_vixel":
-      try:
-        ip = form['ipaddr']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_IP)
-      try:
-        pwd = form['passwd']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("ipaddr",ip)
-      fencedev.addAttribute("passwd",pwd)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-
-    elif agent_type == "fence_mcdata":
-      try:
-        ip = form['ipaddr']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_IP)
-      try:
-        log = form['login']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
-      try:
-        pwd = form['passwd']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("ipaddr",ip)
-      fencedev.addAttribute("login",log)
-      fencedev.addAttribute("passwd",pwd)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-
-    elif agent_type == "fence_gnbd":
-      try:
-        server = form['server']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_SERVER)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("server",server)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-    elif agent_type == "fence_egenera":
-      try:
-        cserver = form['cserver']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_CSERVER)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("cserver",cserver)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-
-    elif agent_type == "fence_sanbox2":
-      try:
-        ip = form['ipaddr']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_IP)
-      try:
-        log = form['login']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
-      try:
-        pwd = form['passwd']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("ipaddr",ip)
-      fencedev.addAttribute("login",log)
-      fencedev.addAttribute("passwd",pwd)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-    elif agent_type == "fence_bladecenter":
-      try:
-        ip = form['ipaddr']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_IP)
-      try:
-        log = form['login']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
-      try:
-        pwd = form['passwd']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("ipaddr",ip)
-      fencedev.addAttribute("login",log)
-      fencedev.addAttribute("passwd",pwd)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-    elif agent_type == "fence_bullpap":
-      try:
-        ip = form['ipaddr']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_IP)
-      try:
-        log = form['login']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
-      try:
-        pwd = form['passwd']
-      except KeyError, e:
-        return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedev.addAttribute("ipaddr",ip)
-      fencedev.addAttribute("login",log)
-      fencedev.addAttribute("passwd",pwd)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-
-    elif agent_type == "fence_xvm":
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-    elif agent_type == "fence_scsi":
-
-      fencedev = FenceDevice()
-      fencedev.addAttribute("agent",agent_type)
-      fencedev.addAttribute("name",fencedev_name)
-      fencedevptr = model.getFenceDevicePtr()
-      fencedevptr.addChild(fencedev)
-      return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[agent_type])
-
-    #Oh-oh...no agent match
-    else:
-      return (FD_VAL_FAIL, FD_NEW_FAIL % agent_type)
-      
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("passwd",pwd)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+  elif agent_type == "fence_brocade":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+  elif agent_type == "fence_vixel":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("passwd",pwd)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+
+  elif agent_type == "fence_mcdata":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+
+  elif agent_type == "fence_gnbd":
+    try:
+      server = form['server']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_SERVER)
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("server",server)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+  elif agent_type == "fence_egenera":
+    try:
+      cserver = form['cserver']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_CSERVER)
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("cserver",cserver)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+
+  elif agent_type == "fence_sanbox2":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+  elif agent_type == "fence_bladecenter":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+  elif agent_type == "fence_bullpap":
+    try:
+      ip = form['ip_addr']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_IP)
+    try:
+      log = form['login']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
+    try:
+      pwd = form['password']
+    except KeyError, e:
+      return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("name",fencedev_name)
+    fencedev.addAttribute("ipaddr",ip)
+    fencedev.addAttribute("login",log)
+    fencedev.addAttribute("passwd",pwd)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+
+  elif agent_type == "fence_xvm":
+
+    fencedev.addAttribute("agent",agent_type)
+    fencedev.addAttribute("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)
+    return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
+
+  #Oh-oh...no agent match
+  else:
+    return (FD_VAL_FAIL, FD_NEW_FAIL % agent_type)
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/12/18 15:18:37	1.186
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/12/18 22:16:18	1.187
@@ -24,7 +24,7 @@
 from QuorumD import QuorumD
 from Heuristic import Heuristic
 from clusterOS import resolveOSType
-from FenceHandler import FenceHandler, FENCE_OPTS
+from FenceHandler import validateNewFenceDevice, FENCE_OPTS
 from GeneralError import GeneralError
 from homebase_adapters import nodeUnauth, nodeAuth, manageCluster, createClusterSystems, havePermCreateCluster, setNodeFlag, delNodeFlag, userAuthenticated, getStorageNode, getClusterNode, delCluster
 from LuciSyslog import LuciSyslog
@@ -1142,10 +1142,10 @@
     luci_log.debug_verbose('VFE: no form was submitted')
     return (False, {'errors': ['No form was submitted']})
 
-  fencehandler = FenceHandler()
-  error_code,error_string = fencehandler.validateNewFenceDevice(form, model)
+  #fencehandler = FenceHandler()
+  error_code,error_string = validateNewFenceDevice(form, model)
   if error_code == FD_VAL_SUCCESS:
-    message.append(error_string)
+    messages.append(error_string)
     try:
       cp = model.getClusterPtr()
       cp.incrementConfigVersion()
@@ -1186,10 +1186,10 @@
         except:
           pass
 
-    return (TRUE, {'errors': errors, 'messages': messages})
+    return (True, {'errors': errors, 'messages': messages})
   else:
     errors.append(error_string)
-    return (FALSE, {'errors': errors, 'messages': messages})
+    return (False, {'errors': errors, 'messages': messages})
 
 
 def validateFenceEdit(self, request):
@@ -1238,9 +1238,98 @@
   #entry for this fence device.
   #
   #pass form and model to validation method, then save changes if it passes.
+  error_code,error_string = validateFenceDevice(form, model)
+  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 deleteFenceDevice(self, request):
+  errors = list()
+  messages = list()
+                                                                                
+  try:
+    model = request.SESSION.get('model')
+    if not model:
+      raise Exception, 'model is none'
+  except Exception, e:
+    model = None
+    try:
+      cluname = request.form['clustername']
+    except:
+      try:
+        cluname = request['clustername']
+      except:
+        luci_log.debug_verbose('VFE: no model, no cluster name')
+        return (False, {'errors': ['No cluster model was found.']})
+                                                                                
+    try:
+      model = getModelForCluster(self, cluname)
+    except:
+      model = None
+                                                                                
+    if model is None:
+      luci_log.debug_verbose('VFE: unable to get model from session')
+      return (False, {'errors': ['No cluster model was found.']})
+
+  form = None
+  try:
+    response = request.response
+    form = request.form
+    if not form:
+      form = None
+      raise Exception, 'no form was submitted'
+  except:
+    pass
+
+  if form is None:
+    luci_log.debug_verbose('VFE: no form was submitted')
+    return (False, {'errors': ['No form was submitted']})
 
-  ##########End of orig method
-  return (True, {})
+  pass
 
 def validateDaemonProperties(self, request):
 	errors = list()
@@ -1335,7 +1424,8 @@
 	33: validateResourceAdd,
 	51: validateFenceAdd,
 	50: validateFenceEdit,
-	55: validateDaemonProperties
+	55: validateDaemonProperties,
+  57: deleteFenceDevice
 }
 
 def validatePost(self, request):
@@ -1349,7 +1439,7 @@
 		luci_log.debug_verbose('VP1: no handler for page type %d' % pagetype)
 		return None
 	else:
-		return formValidators[pagetype](self, model, request)
+		return formValidators[pagetype](self, request)
 
 
 def createCluChooser(self, request, systems):
--- conga/luci/site/luci/Extensions/conga_constants.py	2006/12/18 04:44:52	1.29
+++ conga/luci/site/luci/Extensions/conga_constants.py	2006/12/18 22:16:18	1.30
@@ -44,6 +44,7 @@
 FENCEDEV="54"
 CLUSTER_DAEMON="55"
 SERVICE_DELETE = '56'
+FENCEDEV_DELETE = "57"
 
 #Cluster tasks
 CLUSTER_STOP = '1000'


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