* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2006-12-18 4:44 jparsons
0 siblings, 0 replies; 14+ messages in thread
From: jparsons @ 2006-12-18 4:44 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: jparsons at sourceware.org 2006-12-18 04:44:52
Modified files:
luci/site/luci/Extensions: FenceHandler.py cluster_adapters.py
conga_constants.py
Log message:
addresses 212021
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.184&r2=1.185
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.28&r2=1.29
--- conga/luci/site/luci/Extensions/FenceHandler.py 2006/11/09 16:45:02 1.5
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2006/12/18 04:44:52 1.6
@@ -2,9 +2,12 @@
from ValidationError import ValidationError
import MessageLibrary
import ModelBuilder
+from conga_constants import *
INSTALLDIR="/usr/share/system-config-cluster"
+FD_NEW_SUCCESS = "New %s successfully added to cluster"
+FD_NEW_FAIL = "No agent type %s in shared device list"
FD_PROVIDE_NAME = "A unique name must be provided for each Fence Device"
FD_PROVIDE_PATH = "An xCAT path must be provided for each xCAT Fence Device"
@@ -52,6 +55,8 @@
"fence_egenera":"Egenera SAN Controller",
"fence_bullpap":"Bull PAP",
"fence_drac":"DRAC",
+ "fence_xvm":"Virtual Machine Fencing",
+ "fence_scsi":"SCSI Reservation",
"fence_ipmilan":"IPMI Lan",
"fence_manual":"Manual Fencing" }
@@ -1025,4 +1030,262 @@
gtkentry.set_text(name)
# select text
raise ValidationError('FATAL', ILLEGAL_CHARS_REPLACED)
-
+
+ def validateNewFenceDevice(self, form, model):
+ try:
+ agent_type = form['agent']
+ 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['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)
+
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/14 23:14:54 1.184
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/18 04:44:52 1.185
@@ -1101,9 +1101,146 @@
response.redirect(request['URL'] + "?pagetype=" + CLUSTER_CONFIG + "&clustername=" + clustername + '&busyfirst=true')
def validateFenceAdd(self, request):
- return (True, {})
+ errors = list()
+ messages = list()
+ rc = None
+
+ 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']})
+
+ fencehandler = FenceHandler()
+ error_code,error_string = fencehandler.validateNewFenceDevice(form, model)
+ if error_code == FD_VAL_SUCCESS:
+ message.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 validateFenceEdit(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']})
+
+ #This is a fence edit situation, so the model should already have an
+ #entry for this fence device.
+ #
+ #pass form and model to validation method, then save changes if it passes.
+
+ ##########End of orig method
return (True, {})
def validateDaemonProperties(self, request):
@@ -1213,7 +1350,7 @@
luci_log.debug_verbose('VP1: no handler for page type %d' % pagetype)
return None
else:
- return formValidators[pagetype](self, request)
+ return formValidators[pagetype](self, model, request)
def createCluChooser(self, request, systems):
--- conga/luci/site/luci/Extensions/conga_constants.py 2006/12/06 18:38:55 1.28
+++ conga/luci/site/luci/Extensions/conga_constants.py 2006/12/18 04:44:52 1.29
@@ -92,6 +92,9 @@
NODE_INACTIVE_STR="Not a Cluster Member"
NODE_UNKNOWN_STR="Unknown State"
+FD_VAL_FAIL=1
+FD_VAL_SUCCESS=0
+
#cluster/node create batch task index
INSTALL_TASK = 1
DISABLE_SVC_TASK = 2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2006-12-18 15:18 jparsons
0 siblings, 0 replies; 14+ messages in thread
From: jparsons @ 2006-12-18 15:18 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: jparsons at sourceware.org 2006-12-18 15:18:37
Modified files:
luci/site/luci/Extensions: FenceHandler.py cluster_adapters.py
Log message:
remove dingdang tabs and fix indent error
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.185&r2=1.186
--- conga/luci/site/luci/Extensions/FenceHandler.py 2006/12/18 04:44:52 1.6
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2006/12/18 15:18:37 1.7
@@ -1050,7 +1050,7 @@
fencedevs = model.getFenceDevices()
for fd in fencedevs:
- if fd.getName().strip() == fencedev_name
+ if fd.getName().strip() == fencedev_name:
return (FD_VAL_FAIL, FD_PROVIDE_NAME)
if agent_type == "fence_apc":
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/18 04:44:52 1.185
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/18 15:18:37 1.186
@@ -992,113 +992,112 @@
}
def validateConfigCluster(self, request):
- errors = list()
- messages = list()
- rc = None
+ errors = list()
+ messages = list()
+ rc = None
- 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('VCC0a: no model, no cluster name')
- return (False, {'errors': ['No cluster model was found.']})
+ 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('VCC0a: no model, no cluster name')
+ return (False, {'errors': ['No cluster model was found.']})
- try:
- model = getModelForCluster(self, cluname)
- except:
- model = None
+ try:
+ model = getModelForCluster(self, cluname)
+ except:
+ model = None
- if model is None:
- luci_log.debug_verbose('VCC0: unable to get model from session')
- return (False, {'errors': ['No cluster model was found.']})
- try:
- if not 'configtype' in request.form:
- luci_log.debug_verbose('VCC2: no configtype')
- raise Exception, 'no config type'
- except Exception, e:
- luci_log.debug_verbose('VCC2a: %s' % str(e))
- return (False, {'errors': ['No configuration type was submitted.']})
+ if model is None:
+ luci_log.debug_verbose('VCC0: unable to get model from session')
+ return (False, {'errors': ['No cluster model was found.']})
+ try:
+ if not 'configtype' in request.form:
+ luci_log.debug_verbose('VCC2: no configtype')
+ raise Exception, 'no config type'
+ except Exception, e:
+ luci_log.debug_verbose('VCC2a: %s' % str(e))
+ return (False, {'errors': ['No configuration type was submitted.']})
- if not request.form['configtype'] in configFormValidators:
- luci_log.debug_verbose('VCC3: invalid config type: %s' % request.form['configtype'])
- return (False, {'errors': ['An invalid configuration type was submitted.']})
+ if not request.form['configtype'] in configFormValidators:
+ luci_log.debug_verbose('VCC3: invalid config type: %s' % request.form['configtype'])
+ return (False, {'errors': ['An invalid configuration type was submitted.']})
- try:
- cp = model.getClusterPtr()
- except:
- luci_log.debug_verbose('VCC3a: getClusterPtr failed')
- return (False, {'errors': ['No cluster model was found.']})
+ try:
+ cp = model.getClusterPtr()
+ except:
+ luci_log.debug_verbose('VCC3a: getClusterPtr failed')
+ return (False, {'errors': ['No cluster model was found.']})
- config_validator = configFormValidators[request.form['configtype']]
- ret = config_validator(model, request.form)
+ config_validator = configFormValidators[request.form['configtype']]
+ ret = config_validator(model, request.form)
- retcode = ret[0]
- if 'errors' in ret[1]:
- errors.extend(ret[1]['errors'])
-
- if 'messages' in ret[1]:
- messages.extend(ret[1]['messages'])
-
- if retcode == True:
- try:
- config_ver = int(cp.getConfigVersion()) + 1
- # always increment the configuration version
- cp.setConfigVersion(str(config_ver))
- model.setModified(True)
- conf_str = model.exportModelAsString()
- if not conf_str:
- raise Exception, 'conf_str is none'
- except Exception, e:
- luci_log.debug_verbose('VCC4: export model as string failed: %s' \
- % str(e))
- errors.append('Unable to store the new cluster configuration')
+ retcode = ret[0]
+ if 'errors' in ret[1]:
+ errors.extend(ret[1]['errors'])
- try:
- clustername = model.getClusterName()
- if not clustername:
- raise Exception, 'cluster name from modelb.getClusterName() is blank'
- except Exception, e:
- luci_log.debug_verbose('VCC5: error: getClusterName: %s' % str(e))
- errors.append('Unable to determine cluster name from model')
+ if 'messages' in ret[1]:
+ messages.extend(ret[1]['messages'])
- if len(errors) > 0:
- return (retcode, {'errors': errors, 'messages': messages})
+ if retcode == True:
+ try:
+ config_ver = int(cp.getConfigVersion()) + 1
+ # always increment the configuration version
+ cp.setConfigVersion(str(config_ver))
+ model.setModified(True)
+ conf_str = model.exportModelAsString()
+ if not conf_str:
+ raise Exception, 'conf_str is none'
+ except Exception, e:
+ luci_log.debug_verbose('VCC4: export model as string failed: %s' \
+ % str(e))
+ errors.append('Unable to store the new cluster configuration')
- if not rc:
- rc = getRicciAgent(self, clustername)
- if not rc:
- luci_log.debug_verbose('VCC6: 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('VCC7: 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
+ try:
+ clustername = model.getClusterName()
+ if not clustername:
+ raise Exception, 'cluster name from modelb.getClusterName() is blank'
+ except Exception, e:
+ luci_log.debug_verbose('VCC5: error: getClusterName: %s' % str(e))
+ errors.append('Unable to determine cluster name from model')
- if len(errors) < 1:
- messages.append('The cluster properties have been updated.')
- else:
- return (retcode, {'errors': errors, 'messages': messages})
+ if len(errors) > 0:
+ return (retcode, {'errors': errors, 'messages': messages})
- response = request.RESPONSE
- response.redirect(request['URL'] + "?pagetype=" + CLUSTER_CONFIG + "&clustername=" + clustername + '&busyfirst=true')
+ if not rc:
+ rc = getRicciAgent(self, clustername)
+ if not rc:
+ luci_log.debug_verbose('VCC6: 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('VCC7: 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
+
+ if len(errors) < 1:
+ messages.append('The cluster properties have been updated.')
+ else:
+ return (retcode, {'errors': errors, 'messages': messages})
+
+ response = request.RESPONSE
+ response.redirect(request['URL'] + "?pagetype=" + CLUSTER_CONFIG + "&clustername=" + clustername + '&busyfirst=true')
def validateFenceAdd(self, request):
errors = list()
@@ -1129,68 +1128,68 @@
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
+ 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']})
+ if form is None:
+ 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)
if error_code == FD_VAL_SUCCESS:
message.append(error_string)
- try:
+ 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
+ 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})
+ 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):
@@ -1221,19 +1220,19 @@
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
+ 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']})
+ if form is None:
+ luci_log.debug_verbose('VFE: no form was submitted')
+ return (False, {'errors': ['No form was submitted']})
#This is a fence edit situation, so the model should already have an
#entry for this fence device.
@@ -1241,7 +1240,7 @@
#pass form and model to validation method, then save changes if it passes.
##########End of orig method
- return (True, {})
+ return (True, {})
def validateDaemonProperties(self, request):
errors = list()
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2006-12-18 22:16 jparsons
0 siblings, 0 replies; 14+ messages in thread
From: jparsons @ 2006-12-18 22:16 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: jparsons at 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'
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2006-12-20 20:24 jparsons
0 siblings, 0 replies; 14+ messages in thread
From: jparsons @ 2006-12-20 20:24 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: jparsons at 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()
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2006-12-20 22:06 jparsons
0 siblings, 0 replies; 14+ messages in thread
From: jparsons @ 2006-12-20 22:06 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: jparsons at sourceware.org 2006-12-20 22:06:51
Modified files:
luci/site/luci/Extensions: FenceHandler.py cluster_adapters.py
Log message:
minor nits
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.189&r2=1.190
--- conga/luci/site/luci/Extensions/FenceHandler.py 2006/12/20 20:24:27 1.9
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2006/12/20 22:06:49 1.10
@@ -2,7 +2,7 @@
from ValidationError import ValidationError
import MessageLibrary
import ModelBuilder
-from FenceDevice import FenceDevice
+#from FenceDevice import FenceDevice
from conga_constants import *
INSTALLDIR="/usr/share/system-config-cluster"
@@ -1034,6 +1034,7 @@
raise ValidationError('FATAL', ILLEGAL_CHARS_REPLACED)
def validateNewFenceDevice(form, model):
+ from FenceDevice import FenceDevice
try:
agent_type = form['fence_type']
except KeyError, e:
@@ -1292,6 +1293,7 @@
return (FD_VAL_FAIL, FD_NEW_FAIL % agent_type)
def validateFenceDevice(form, model):
+ from FenceDevice import FenceDevice
namechange = False
try:
agent_type = form['fence_type']
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/20 20:40:31 1.189
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/12/20 22:06:49 1.190
@@ -1186,6 +1186,7 @@
except:
pass
+ response.redirect(request['URL'] + "?pagetype=" + FENCEDEV + "&clustername=" + clustername + "&fencename=" + form['name'] + '&busyfirst=true')
return (True, {'errors': errors, 'messages': messages})
else:
errors.append(error_string)
@@ -1195,6 +1196,7 @@
def validateFenceEdit(self, request):
errors = list()
messages = list()
+ rc = None
try:
model = request.SESSION.get('model')
@@ -1271,7 +1273,7 @@
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')
+ luci_log.debug_verbose('VFA: setClusterConf: batchid or result is None')
errors.append('Unable to propagate the new cluster configuration for %s' \
% clustername)
else:
@@ -1281,6 +1283,7 @@
except:
pass
+ response.redirect(request['URL'] + "?pagetype=" + FENCEDEV + "&clustername=" + clustername + "&fencename=" + request['fencename'] + '&busyfirst=true')
return (True, {'errors': errors, 'messages': messages})
else:
errors.append(error_string)
@@ -1290,6 +1293,7 @@
def deleteFenceDevice(self, request):
errors = list()
messages = list()
+ rc = None
try:
model = request.SESSION.get('model')
@@ -1336,7 +1340,7 @@
except KeyError, e:
return (False, {'errors':['No device name in form submission']})
- fdev_to_delete = None:
+ fdev_to_delete = None
#iterate thru list of current fencedevs and find one to be deleted
fdevs = model.getFenceDevices()
for fdev in fdevs:
@@ -1345,7 +1349,7 @@
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'])
+ return (False, {'errors':['Could not find fence device name in model']})
#get fencedev ptr
fdev_ptr = model.getFenceDevicePtr()
@@ -1361,7 +1365,7 @@
try:
model.removeFenceInstancesForFenceDevice(orig_name)
except:
- luci_log.debug_verbose('VFD: Could not remove fence instances for %s' % origname)
+ luci_log.debug_verbose('VFD: Could not remove fence instances for')
if error_code == FD_VAL_SUCCESS:
@@ -1406,6 +1410,7 @@
except:
pass
+ response.redirect(request['URL'] + "?pagetype=" + FENCEDEVS + "&clustername=" + clustername + '&busyfirst=true')
return (True, {'errors': errors, 'messages': messages})
else:
errors.append(error_string)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2007-01-11 22:49 rmccabe
0 siblings, 0 replies; 14+ messages in thread
From: rmccabe @ 2007-01-11 22:49 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-01-11 22:49:42
Modified files:
luci/site/luci/Extensions: FenceHandler.py cluster_adapters.py
conga_constants.py
Log message:
fix fence add and fence edit
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.202&r2=1.203
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.33&r2=1.34
--- conga/luci/site/luci/Extensions/FenceHandler.py 2006/12/21 03:41:43 1.11
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2007/01/11 22:49:42 1.12
@@ -1058,7 +1058,7 @@
if agent_type == "fence_apc":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1066,7 +1066,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1082,11 +1082,11 @@
elif agent_type == "fence_wti":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1101,7 +1101,7 @@
elif agent_type == "fence_brocade":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1109,7 +1109,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1125,11 +1125,11 @@
elif agent_type == "fence_vixel":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1145,7 +1145,7 @@
elif agent_type == "fence_mcdata":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1153,7 +1153,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1199,7 +1199,7 @@
elif agent_type == "fence_sanbox2":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1207,7 +1207,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1223,7 +1223,7 @@
elif agent_type == "fence_bladecenter":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1231,7 +1231,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1247,7 +1247,7 @@
elif agent_type == "fence_bullpap":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1255,7 +1255,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1295,6 +1295,7 @@
def validateFenceDevice(form, model):
from FenceDevice import FenceDevice
namechange = False
+
try:
agent_type = form['fence_type']
except KeyError, e:
@@ -1309,7 +1310,7 @@
return (FD_VAL_FAIL, "No device name in form submission")
if fencedev_name == "":
- return (1, "A unique name is required for every fence device")
+ return (1, "No device name in form submission")
try:
orig_name = form['orig_name']
@@ -1319,10 +1320,12 @@
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)
+ fencedevs = model.getFenceDevices()
+ for fd in fencedevs:
+ if fd.getName().strip() == fencedev_name:
+ return (FD_VAL_FAIL, FD_PROVIDE_NAME)
+ else:
+ fencedevs = model.getFenceDevices()
#Now we know name is unique...find device now
fencedev = None
@@ -1336,7 +1339,7 @@
if agent_type == "fence_apc":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1344,7 +1347,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1359,11 +1362,11 @@
elif agent_type == "fence_wti":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1377,7 +1380,7 @@
elif agent_type == "fence_brocade":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1385,7 +1388,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1400,11 +1403,11 @@
elif agent_type == "fence_vixel":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1419,7 +1422,7 @@
elif agent_type == "fence_mcdata":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1427,7 +1430,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1470,7 +1473,7 @@
elif agent_type == "fence_sanbox2":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1478,7 +1481,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1493,7 +1496,7 @@
elif agent_type == "fence_bladecenter":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1501,7 +1504,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
@@ -1516,7 +1519,7 @@
elif agent_type == "fence_bullpap":
try:
- ip = form['ip_addr']
+ ip = form['ipaddr']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_IP)
try:
@@ -1524,7 +1527,7 @@
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_LOGIN)
try:
- pwd = form['password']
+ pwd = form['passwd']
except KeyError, e:
return (FD_VAL_FAIL, FD_PROVIDE_PASSWD)
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/11 19:11:04 1.202
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/11 22:49:42 1.203
@@ -1979,7 +1979,7 @@
31: validateResourceAdd,
33: validateResourceAdd,
51: validateFenceAdd,
- 50: validateFenceEdit,
+ 54: validateFenceEdit,
55: validateDaemonProperties,
57: deleteFenceDevice,
58: validateNodeFenceConfig
--- conga/luci/site/luci/Extensions/conga_constants.py 2007/01/05 23:44:11 1.33
+++ conga/luci/site/luci/Extensions/conga_constants.py 2007/01/11 22:49:42 1.34
@@ -130,7 +130,7 @@
POSSIBLE_REBOOT_MESSAGE = "This node is not currently responding and is probably rebooting as planned. This state should persist for 5 minutes or so..."
-REDIRECT_MSG = " You will be redirected in 5 seconds. Please fasten your safety restraints."
+REDIRECT_MSG = " You will be redirected in 5 seconds."
# Homebase-specific constants
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2007-01-19 19:41 rmccabe
0 siblings, 0 replies; 14+ messages in thread
From: rmccabe @ 2007-01-19 19:41 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-01-19 19:41:27
Modified files:
luci/site/luci/Extensions: FenceHandler.py cluster_adapters.py
Log message:
new, more generic and clean fence validation code
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.205&r2=1.206
--- conga/luci/site/luci/Extensions/FenceHandler.py 2007/01/11 22:49:42 1.12
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2007/01/19 19:41:26 1.13
@@ -1,1562 +1,846 @@
-import os
-from ValidationError import ValidationError
-import MessageLibrary
-import ModelBuilder
-#from FenceDevice import FenceDevice
+import re
+from Device import Device
+from FenceDevice import FenceDevice
from conga_constants import FD_VAL_SUCCESS, FD_VAL_FAIL
-INSTALLDIR="/usr/share/system-config-cluster"
+FD_NEW_SUCCESS = 'New %s successfully added to cluster'
+FD_UPDATE_SUCCESS = 'Fence device %s successfully updated'
+FD_NEW_FAIL = 'No agent type %s in shared device list'
+
+FI_NEW_FAIL = 'No instance type %s in fence instance list'
+
+FD_PROVIDE_AGENT = 'A valid agent type must be provided for each Fence Device'
+FD_PROVIDE_NAME = 'A unique name must be provided for each Fence Device'
+FD_PROVIDE_PATH = 'An xCAT path must be provided for each xCAT Fence Device'
+FD_PROVIDE_SERVER = 'A server address must be provided for this Fence Device'
+FD_PROVIDE_CSERVER = 'A cserver address must be provided for this Egenera Fence Device'
+FD_PROVIDE_IP = 'An IP address must be provided for this Fence Device'
+FD_PROVIDE_HOSTNAME = 'A host name must be provided for this Fence Device'
+FD_PROVIDE_LOGIN = 'A login name must be provided for this Fence Device'
+FD_PROVIDE_PASSWD = 'A password must be provided for this Fence Device'
+FD_PROVIDE_DEVICE = 'A device must be provided for this Fence Device'
+FD_PROVIDE_PORT = 'A port must be provided for this Fence Device'
+FD_PROVIDE_IPMILAN_AUTH = 'Authentication type must be "none" (or blank), "md5", or "password"'
+
+FI_PROVIDE_PARENT = 'A Fence Device name must be provided for this Fence'
+FI_PROVIDE_SWITCH = 'A switch address must be provided for this Fence'
+FI_PROVIDE_PORT = 'A port value must be provided for this Fence'
+FI_PROVIDE_BLADE = 'A Blade must be specified for this Fence'
+FI_PROVIDE_DOMAIN = 'A Domain must be specified for this Fence'
+FI_PROVIDE_IPADDRESS = 'An IP address must be provided for this Fence'
+FI_PROVIDE_ELPAN = 'A LPAN value must be provided for this Egenera Fence'
+FI_PROVIDE_EPSERVER = 'A PServer value must be provided for this Egenera Fence'
+FI_PROVIDE_NODENAME = 'A Node Name value must be provided for this SCSI Fence'
+
+ILLEGAL_CHARS_REPLACED = 'Illegal characters were replaced by underscores. Feel free to set a new value.'
+
+# For every new fence added, there will be a fence instance and fence device
+# form needed. There will also be a populate and a validate method for each
+# form. The methods will need to be added to this file, and the four hash
+# tables (self.fi_populate, self.fi_validate, self.fd_populate,
+# self.fd_validate) must be updated. The methods will use fields in the
+# forms to set_text and to check.
+
+FENCE_OPTS = {
+ 'fence_apc': 'APC Power Device',
+ 'fence_wti': 'WTI Power Device',
+ 'fence_brocade': 'Brocade Switch',
+ 'fence_vixel': 'Vixel SAN Switch',
+ 'fence_gnbd': 'Global Network Block Device',
+ 'fence_sanbox2': 'QLogic SANBox2',
+ 'fence_bladecenter': 'IBM Blade Center',
+ 'fence_mcdata': 'McDATA SAN Switch',
+ 'fence_egenera': 'Egenera SAN Controller',
+ 'fence_bullpap': 'Bull PAP',
+ 'fence_xvm': 'Virtual Machine Fencing',
+ 'fence_scsi': 'SCSI Reservation',
+ 'fence_ilo': 'HP ILO Device',
+ 'fence_ipmilan': 'IPMI Lan',
+ 'fence_drac': 'Dell DRAC',
+ 'fence_rsa': 'IBM RSA II Device',
+ 'fence_rps10': 'RPS10 Serial Switch',
+ 'fence_manual': 'Manual Fencing'
+}
+
+FENCE_SHARED = {
+ 'fence_apc': True,
+ 'fence_wti': True,
+ 'fence_brocade': True,
+ 'fence_vixel': True,
+ 'fence_gnbd': True,
+ 'fence_sanbox2': True,
+ 'fence_bladecenter': True,
+ 'fence_mcdata': True,
+ 'fence_egenera': True,
+ 'fence_bullpap': True,
+ 'fence_xvm': True,
+ 'fence_scsi': True,
+ 'fence_ilo': False,
+ 'fence_ipmilan': False,
+ 'fence_drac': False,
+ 'fence_rsa': False,
+ 'fence_rps10': False,
+ 'fence_manual': False
+}
+
+PRETTY_NAME_ATTRS = {
+ 'port': 'Port',
+ 'blade': 'Blade',
+ 'switch': 'Switch',
+ 'ipaddr': 'IP Address',
+ 'ipaddress': 'IP Address',
+ 'nodename': 'Node Name',
+ 'lpan': 'LPAN',
+ 'lanplus': 'Lanplus',
+ 'pserver': 'PServer',
+ 'login': 'Login',
+ 'passwd': 'Password',
+ 'name': 'Name',
+ 'server': 'Server',
+ 'domain': 'Domain',
+ 'hostname': 'Hostname',
+ 'path': 'Path',
+ 'cserver': 'CServer'
+}
+
+FI_VALIDATE = {
+ 'fence_apc': val_apc_fi,
+ 'fence_wti': val_wti_fi,
+ 'fence_brocade': val_brocade_fi,
+ 'fence_vixel': val_vixel_fi,
+ 'fence_gnbd': val_gnbd_fi,
+ 'fence_sanbox2': val_sanbox2_fi,
+ 'fence_bladecenter': val_bladecenter_fi,
+ 'fence_mcdata': val_mcdata_fi,
+ 'fence_egenera': val_egenera_fi,
+ 'fence_bullpap': val_bullpap_fi,
+ 'fence_xvm': val_xvm_fi,
+ 'fence_scsi': val_scsi_fi,
+ 'fence_ilo': val_noop_fi,
+ 'fence_ipmilan': val_noop_fi,
+ 'fence_drac': val_noop_fi,
+ 'fence_rsa': val_noop_fi,
+ 'fence_rps10': val_noop_fi,
+ 'fence_manual': val_noop_fi
+}
+
+FD_VALIDATE = {
+ 'fence_apc': val_apc_fd,
+ 'fence_wti': val_wti_fd,
+ 'fence_brocade': val_brocade_fd,
+ 'fence_vixel': val_vixel_fd,
+ 'fence_gnbd': val_gnbd_fd,
+ 'fence_sanbox2': val_sanbox2_fd,
+ 'fence_bladecenter': val_bladecenter_fd,
+ 'fence_mcdata': val_mcdata_fd,
+ 'fence_egenera': val_egenera_fd,
+ 'fence_bullpap': val_bullpap_fd,
+ 'fence_xvm': val_noop_fd,
+ 'fence_scsi': val_noop_fd,
+ 'fence_ilo': val_ilo_fd,
+ 'fence_ipmilan': val_ipmilan_fd,
+ 'fence_drac': val_drac_fd,
+ 'fence_rsa': val_rsa_fd,
+ 'fence_rps10': val_rps10_fd,
+ 'fence_manual': val_noop_fd
+}
+
+FENCE_FI_ATTRS = {
+ 'fence_apc': ['port', 'switch'],
+ 'fence_wti': ['port'],
+ 'fence_brocade': ['port'],
+ 'fence_vixel': ['port'],
+ 'fence_gnbd': ['ipaddress'],
+ 'fence_sanbox2': ['port'],
+ 'fence_bladecenter': ['blade'],
+ 'fence_mcdata': ['port'],
+ 'fence_egenera': ['lpan', 'pserver'],
+ 'fence_bullpap': ['domain'],
+ 'fence_xvm': ['domain'],
+ 'fence_scsi': ['nodename'],
+ 'fence_ilo': [],
+ 'fence_ipmilan': [],
+ 'fence_drac': [],
+ 'fence_rsa': [],
+ 'fence_rps10': [],
+ 'fence_manual': []
+}
+
+FENCE_FD_ATTRS = {
+ 'fence_apc': ['name', 'ipaddr', 'login', 'passwd'],
+ 'fence_wti': ['name', 'ipaddr', 'passwd'],
+ 'fence_brocade': ['name', 'ipaddr', 'login', 'passwd'],
+ 'fence_vixel': ['name', 'ipaddr', 'passwd'],
+ 'fence_gnbd': ['name', 'server'],
+ 'fence_sanbox2': ['name', 'ipaddr', 'login', 'passwd'],
+ 'fence_bladecenter': ['name', 'ipaddr', 'login', 'passwd'],
+ 'fence_mcdata': ['name', 'ipaddr', 'login', 'passwd'],
+ 'fence_egenera': ['name', 'cserver'],
+ 'fence_bullpap': ['name', 'ipaddr', 'login', 'passwd'],
+ 'fence_xvm': ['name'],
+ 'fence_scsi': ['name'],
+ 'fence_ilo': ['name', 'hostname', 'login', 'passwd'],
+ 'fence_ipmilan': ['name', 'ipaddr', 'login', 'passwd', 'lanplus', 'auth'],
+ 'fence_drac': ['name', 'ipaddr', 'login', 'passwd'],
+ 'fence_rsa': ['name', 'hostname', 'login', 'passwd'],
+ 'fence_rps10': ['name', 'device', 'port'],
+ 'fence_manual': ['name']
+}
+
+ILLEGAL_CHARS = re.compile(':| ')
+
+def makeNCName(name):
+ ### name must conform to relaxNG ID type ##
+ return re.sub('_', name)
+
+def check_unique_fd_name(model, name):
+ fds = model.getFenceDevices()
+ for fd in fds:
+ if fd.getName() == name:
+ return False
+ return True
+
+def validateNewFenceDevice(form, model):
+ fencedev = FenceDevice()
+
+ try:
+ ret = validate_fencedevice(form, model, fencedev)
+ if ret is None:
+ fencedevptr = model.getFenceDevicePtr()
+ fencedevptr.addChild(fencedev)
+ model.setModified(True)
+ return (FD_VAL_SUCCESS, FD_NEW_SUCCESS % FENCE_OPTS[fencedev.getAttribute('agent')])
+ except Exception, e:
+ ret = FD_PROVIDE_AGENT
-FD_NEW_SUCCESS = "New %s successfully added to cluster"
-FD_UPDATE_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"
-
-FD_PROVIDE_PATH = "An xCAT path must be provided for each xCAT Fence Device"
-FD_PROVIDE_SERVER = "A server address must be provided for this Fence Device"
-FD_PROVIDE_CSERVER = "A cserver address must be provided for this Egenera Fence Device"
-FD_PROVIDE_IP = "An IP address must be provided for this Fence Device"
-FD_PROVIDE_HOSTNAME = "A host name must be provided for this Fence Device"
-FD_PROVIDE_LOGIN = "A login name must be provided for this Fence Device"
-FD_PROVIDE_PASSWD = "A password must be provided for this Fence Device"
-FI_PROVIDE_XCATNODENAME = "An xCAT Nodename must be provided for this Fence"
-FI_PROVIDE_SWITCH = "A switch address must be provided for this Fence"
-FI_PROVIDE_PORT = "A port value must be provided for this Fence"
-FI_PROVIDE_BLADE = "A Blade must be specified for this Fence"
-FI_PROVIDE_DOMAIN = "A Domain must be specified for this Fence"
-FI_PROVIDE_IPADDRESS = "An IP address must be provided for this Fence"
-FI_PROVIDE_ELPAN = "A LPAN value must be provided for this Egenera Fence"
-FI_PROVIDE_EPSERVER = "A PServer value must be provided for this Egenera Fence"
-
-ILLEGAL_CHARS_REPLACED = "Illegal characters were replaced by underscores. Feel free to set a new value."
-ILLEGAL_CHARS = [':', ' ']
-
-#ADDING A NEW FENCE: fence instance form should be named the same as its agent
-#in gladefile. Then add agent name to this list.
-#
-#In Glade File, fence device form should be added to 'fence_device_container'
-#and fence instance form to fence_instance_container
-#
-#For every new fence added, there will be a fence instance and fence device
-#form needed. There will also be a populate and a validate method for each
-#form. The methods will need to be added to this file, and the four hash
-#tables (self.fi_populate, self.fi_validate, self.fd_populate,
-#self.fd_validate) must be updated. The methods will use fields in the
-#forms to set_text and to check.
-
-FENCE_OPTS = {"fence_apc":"APC Power Device",
- "fence_wti":"WTI Power Device",
- "fence_brocade":"Brocade Switch",
- "fence_vixel":"Vixel SAN Switch",
- "fence_gnbd":"Global Network Block Device",
- "fence_ilo":"HP ILO Device",
- "fence_rsa":"IBM RSA II Device",
- "fence_sanbox2":"QLogic SANBox2",
- "fence_bladecenter":"IBM Blade Center",
- "fence_mcdata":"McDATA SAN Switch",
- "fence_egenera":"Egenera SAN Controller",
- "fence_bullpap":"Bull PAP",
- "fence_drac":"DRAC",
- "fence_xvm":"Virtual Machine Fencing",
- "fence_scsi":"SCSI Reservation",
- "fence_ipmilan":"IPMI Lan",
- "fence_manual":"Manual Fencing" }
-
-FENCE_SHARED = {"fence_apc":True,
- "fence_wti":True,
- "fence_brocade":True,
- "fence_vixel":True,
- "fence_gnbd":True,
- "fence_ilo":False,
- "fence_rsa":False,
- "fence_sanbox2":True,
- "fence_bladecenter":True,
- "fence_mcdata":True,
- "fence_egenera":True,
- "fence_bullpap":True,
- "fence_drac":False,
- "fence_xvm":True,
- "fence_scsi":True,
- "fence_ipmilan":False,
- "fence_manual":False }
-
-FENCE_FD_ATTRS = {"fence_apc":["name","ipaddr","login","passwd"],
- "fence_wti":["name","ipaddr","passwd"],
- "fence_brocade":["name","ipaddr","login","passwd"],
- "fence_vixel":["name","ipaddr","passwd"],
- "fence_gnbd":["name","server"],
- "fence_ilo":["name","hostname","login","passwd"],
- "fence_sanbox2":["name","ipaddr","login","passwd"],
- "fence_bladecenter":["name","ipaddr","login","passwd"],
- "fence_mcdata":["name","ipaddr","login","passwd"],
- "fence_egenera":["name","cserver"],
- "fence_ipmilan":["name","ipaddr","login","passwd"],
- "fence_bullpap":["name","ipaddr","login","passwd"],
- "fence_manual":["name"] }
-
-FENCE_FI_ATTRS = {"fence_apc":["port","switch"],
- "fence_wti":["port"],
- "fence_brocade":["port"],
- "fence_vixel":["port"],
- "fence_gnbd":["ipaddress"],
- "fence_ilo":[],
- "fence_sanbox2":["port"],
- "fence_bladecenter":["blade"],
- "fence_mcdata":["port"],
- "fence_egenera":["lpan","pserver"],
- "fence_ipmilan":[],
- "fence_bullpap":["domain"],
- "fence_manual":[] }
-
-PRETTY_NAME_ATTRS = {"port":"Port",
- "blade":"Blade",
- "switch":"Switch",
- "ipaddr":"IP Address",
- "nodename":"Nodename",
- "lpan":"LPAN",
- "pserver":"PServer",
- "login":"Login",
- "passwd":"Password",
- "name":"Name",
- "server":"Server",
- "domain":"Domain",
- "hostname":"Hostname",
- "path":"Path",
- "cserver":"CServer" }
-
-class FenceHandler:
- def __init__(self, fi_proxy_widget, fd_proxy_widget, model_builder):
- self.fi_proxy_widget = fi_proxy_widget
- self.fd_proxy_widget = fd_proxy_widget
- self.model_builder = model_builder
- gladepath = "fence.glade"
- if not os.path.exists(gladepath):
- gladepath = "%s/%s" % (INSTALLDIR,gladepath)
-
- #gtk.glade.bindtextdomain(PROGNAME)
- self.fence_xml = gtk.glade.XML (gladepath, domain="NULL")
-
- #Generate hash table for agent --> fence instance form
- self.fi_hash = { }
- fence_opt_keys = FENCE_OPTS.keys()
- for fence in fence_opt_keys:
- self.fi_hash[fence] = self.fence_xml.get_widget(fence)
-
- #Generate hash table for agent --> fence device form
- self.fd_hash = { }
- fence_opt_keys = FENCE_OPTS.keys()
- for fence in fence_opt_keys:
- self.fd_hash[fence] = self.fence_xml.get_widget(fence + "_d")
-
- self.pretty_agentname_hash = FENCE_OPTS
-
- self.fi_container = self.fence_xml.get_widget('fence_instance_container')
- children = self.fi_container.get_children()
- for child in children:
- child.reparent(self.fi_proxy_widget)
-
- self.fi_container2 = self.fence_xml.get_widget('fence_instance_container2')
- children2 = self.fi_container2.get_children()
- for child in children2:
- child.reparent(self.fi_proxy_widget)
-
- self.fd_container = self.fence_xml.get_widget('fence_device_container')
- children = self.fd_container.get_children()
- for child in children:
- child.reparent(self.fd_proxy_widget)
-
- self.fd_container2 = self.fence_xml.get_widget('fence_device_container2')
- children2 = self.fd_container2.get_children()
- for child in children2:
- child.reparent(self.fd_proxy_widget)
-
- #For testing...
- #self.fence_xml.get_widget('fi_wti').show()
-
- self.fi_populate = {"fence_apc":self.pop_apc,
- "fence_wti":self.pop_wti,
- "fence_brocade":self.pop_brocade,
- "fence_vixel":self.pop_vixel,
- "fence_gnbd":self.pop_gnbd,
- "fence_ilo":self.pop_ilo,
- "fence_sanbox2":self.pop_sanbox2,
- "fence_bladecenter":self.pop_bladecenter,
- "fence_mcdata":self.pop_mcdata,
- "fence_egenera":self.pop_egenera,
- "fence_ipmilan":self.pop_ipmilan,
- "fence_bullpap":self.pop_bullpap,
- "fence_manual":self.pop_manual }
-
- self.fd_populate = {"fence_apc":self.pop_apc_fd,
- "fence_wti":self.pop_wti_fd,
- "fence_brocade":self.pop_brocade_fd,
- "fence_vixel":self.pop_vixel_fd,
- "fence_gnbd":self.pop_gnbd_fd,
- "fence_ilo":self.pop_ilo_fd,
- "fence_sanbox2":self.pop_sanbox2_fd,
- "fence_bladecenter":self.pop_bladecenter_fd,
- "fence_mcdata":self.pop_mcdata_fd,
- "fence_egenera":self.pop_egenera_fd,
- "fence_ipmilan":self.pop_ipmilan_fd,
- "fence_bullpap":self.pop_bullpap_fd,
- "fence_manual":self.pop_manual_fd }
-
- self.fi_validate = {"fence_apc":self.val_apc,
- "fence_wti":self.val_wti,
- "fence_brocade":self.val_brocade,
- "fence_vixel":self.val_vixel,
- "fence_gnbd":self.val_gnbd,
- "fence_ilo":self.val_ilo,
- "fence_sanbox2":self.val_sanbox2,
- "fence_bladecenter":self.val_bladecenter,
- "fence_mcdata":self.val_mcdata,
- "fence_egenera":self.val_egenera,
- "fence_ipmilan":self.val_ipmilan,
- "fence_bullpap":self.val_bullpap,
- "fence_manual":self.val_manual }
-
- self.fd_validate = {"fence_apc":self.val_apc_fd,
- "fence_wti":self.val_wti_fd,
- "fence_brocade":self.val_brocade_fd,
- "fence_vixel":self.val_vixel_fd,
- "fence_gnbd":self.val_gnbd_fd,
- "fence_ilo":self.val_ilo_fd,
- "fence_sanbox2":self.val_sanbox2_fd,
- "fence_bladecenter":self.val_bladecenter_fd,
- "fence_mcdata":self.val_mcdata_fd,
- "fence_egenera":self.val_egenera_fd,
- "fence_ipmilan":self.val_ipmilan_fd,
- "fence_bullpap":self.val_bullpap_fd,
- "fence_manual":self.val_manual_fd }
-
- self.process_widgets()
-
- def get_fence_instance_hash(self):
- return self.fi_hash
-
- def get_fence_device_hash(self):
- return self.fd_hash
-
- def populate_fi_form(self, agent_type, *attrs):
- apply(self.fi_populate[agent_type], attrs)
-
- def populate_fd_form(self, agent_type, *attrs):
- apply(self.fd_populate[agent_type], attrs)
-
- def pop_apc(self, attrs):
- self.apc_port.set_text(attrs["port"])
- self.apc_switch.set_text(attrs["switch"])
-
- def pop_wti(self, attrs):
- self.wti_port.set_text(attrs["port"])
-
- def pop_brocade(self, attrs):
- self.brocade_port.set_text(attrs["port"])
-
- def pop_ilo(self, attrs):
- pass
-
- def pop_vixel(self, attrs):
- self.vixel_port.set_text(attrs["port"])
-
- def pop_mcdata(self, attrs):
- self.mcdata_port.set_text(attrs["port"])
-
- def pop_manual(self, attrs):
- pass
-
- def pop_gnbd(self, attrs):
- self.gnbd_ip.set_text(attrs["ipaddress"])
-
- def pop_egenera(self, attrs):
- self.egenera_lpan.set_text(attrs["lpan"])
- self.egenera_pserver.set_text(attrs["pserver"])
-
- def pop_sanbox2(self, attrs):
- self.sanbox2_port.set_text(attrs["port"])
-
- def pop_bladecenter(self, attrs):
- self.bladecenter_blade.set_text(attrs["blade"])
-
- def pop_bullpap(self, attrs):
- self.bullpap_domain.set_text(attrs["domain"])
-
- def pop_ipmilan(self, attrs):
- pass
-
- def clear_fi_forms(self):
- self.apc_port.set_text("")
- self.apc_switch.set_text("")
- self.wti_port.set_text("")
- self.brocade_port.set_text("")
- self.vixel_port.set_text("")
- self.gnbd_ip.set_text("")
- self.sanbox2_port.set_text("")
- self.bladecenter_blade.set_text("")
- self.mcdata_port.set_text("")
- self.egenera_lpan.set_text("")
- self.egenera_pserver.set_text("")
- self.bullpap_domain.set_text("")
-
-
- def clear_fd_forms(self):
- self.apc_fd_name.set_text("")
- self.apc_fd_ip.set_text("")
- self.apc_fd_login.set_text("")
- self.apc_fd_passwd.set_text("")
- self.wti_fd_ip.set_text("")
- self.wti_fd_name.set_text("")
- self.wti_fd_passwd.set_text("")
- self.brocade_fd_name.set_text("")
- self.brocade_fd_ip.set_text("")
- self.brocade_fd_login.set_text("")
- self.brocade_fd_passwd.set_text("")
- self.ilo_fd_name.set_text("")
- self.ilo_fd_login.set_text("")
- self.ilo_fd_passwd.set_text("")
- self.ilo_fd_hostname.set_text("")
- self.vixel_fd_name.set_text("")
- self.vixel_fd_ip.set_text("")
- self.vixel_fd_passwd.set_text("")
- self.manual_fd_name.set_text("")
- self.mcdata_fd_name.set_text("")
- self.mcdata_fd_ip.set_text("")
- self.mcdata_fd_login.set_text("")
- self.mcdata_fd_passwd.set_text("")
- self.gnbd_fd_name.set_text("")
- self.gnbd_fd_server.set_text("")
- self.egenera_fd_name.set_text("")
- self.egenera_fd_cserver.set_text("")
- self.sanbox2_fd_name.set_text("")
- self.sanbox2_fd_ip.set_text("")
- self.sanbox2_fd_login.set_text("")
- self.sanbox2_fd_passwd.set_text("")
- self.bladecenter_fd_name.set_text("")
- self.bladecenter_fd_ip.set_text("")
- self.bladecenter_fd_login.set_text("")
- self.bladecenter_fd_passwd.set_text("")
- self.ipmilan_fd_name.set_text("")
- self.ipmilan_fd_login.set_text("")
- self.ipmilan_fd_passwd.set_text("")
- self.ipmilan_fd_ip.set_text("")
- self.bullpap_fd_name.set_text("")
- self.bullpap_fd_login.set_text("")
- self.bullpap_fd_passwd.set_text("")
- self.bullpap_fd_ip.set_text("")
-
- #Populate form methods for Fence Devices
- def pop_apc_fd(self, attrs):
- self.apc_fd_name.set_text(attrs["name"])
- self.apc_fd_ip.set_text(attrs["ipaddr"])
- self.apc_fd_login.set_text(attrs["login"])
- self.apc_fd_passwd.set_text(attrs["passwd"])
-
-
- def pop_wti_fd(self, attrs):
- self.wti_fd_ip.set_text(attrs["ipaddr"])
- self.wti_fd_name.set_text(attrs["name"])
- self.wti_fd_passwd.set_text(attrs["passwd"])
-
- def pop_brocade_fd(self, attrs):
- self.brocade_fd_name.set_text(attrs["name"])
- self.brocade_fd_ip.set_text(attrs["ipaddr"])
- self.brocade_fd_login.set_text(attrs["login"])
- self.brocade_fd_passwd.set_text(attrs["passwd"])
+ return (FD_VAL_FAIL, ret)
-
- def pop_ilo_fd(self, attrs):
- self.ilo_fd_name.set_text(attrs["name"])
- self.ilo_fd_login.set_text(attrs["login"])
- self.ilo_fd_passwd.set_text(attrs["passwd"])
- self.ilo_fd_hostname.set_text(attrs["hostname"])
-
-
- def pop_vixel_fd(self, attrs):
- self.vixel_fd_name.set_text(attrs["name"])
- self.vixel_fd_ip.set_text(attrs["ipaddr"])
- self.vixel_fd_passwd.set_text(attrs["passwd"])
-
-
- def pop_mcdata_fd(self, attrs):
- self.mcdata_fd_name.set_text(attrs["name"])
- self.mcdata_fd_ip.set_text(attrs["ipaddr"])
- self.mcdata_fd_login.set_text(attrs["login"])
- self.mcdata_fd_passwd.set_text(attrs["passwd"])
-
-
- def pop_manual_fd(self, attrs):
- self.manual_fd_name.set_text(attrs["name"])
-
- def pop_gnbd_fd(self, attrs):
- self.gnbd_fd_name.set_text(attrs["name"])
- self.gnbd_fd_server.set_text(attrs["server"])
-
-
- def pop_egenera_fd(self, attrs):
- self.egenera_fd_name.set_text(attrs["name"])
- self.egenera_fd_cserver.set_text(attrs["cserver"])
-
-
- def pop_sanbox2_fd(self, attrs):
- self.sanbox2_fd_name.set_text(attrs["name"])
- self.sanbox2_fd_ip.set_text(attrs["ipaddr"])
- self.sanbox2_fd_login.set_text(attrs["login"])
- self.sanbox2_fd_passwd.set_text(attrs["passwd"])
-
- def pop_bladecenter_fd(self, attrs):
- self.bladecenter_fd_name.set_text(attrs["name"])
- self.bladecenter_fd_ip.set_text(attrs["ipaddr"])
- self.bladecenter_fd_login.set_text(attrs["login"])
- self.bladecenter_fd_passwd.set_text(attrs["passwd"])
-
- def pop_ipmilan_fd(self, attrs):
- self.ipmilan_fd_name.set_text(attrs["name"])
- self.ipmilan_fd_login.set_text(attrs["login"])
- self.ipmilan_fd_passwd.set_text(attrs["passwd"])
- self.ipmilan_fd_ip.set_text(attrs["ipaddr"])
-
- def pop_bullpap_fd(self, attrs):
- self.bullpap_fd_name.set_text(attrs["name"])
- self.bullpap_fd_login.set_text(attrs["login"])
- self.bullpap_fd_passwd.set_text(attrs["passwd"])
- self.bullpap_fd_ip.set_text(attrs["ipaddr"])
-
-
- def process_widgets(self):
- ##Fence Instance Form Fields
- self.apc_port = self.fence_xml.get_widget('entry1')
- self.apc_switch = self.fence_xml.get_widget('entry2')
- self.wti_port = self.fence_xml.get_widget('entry3')
- self.brocade_port = self.fence_xml.get_widget('entry4')
- self.vixel_port = self.fence_xml.get_widget('entry5')
- self.gnbd_ip = self.fence_xml.get_widget('entry6')
- self.ilo_port = self.fence_xml.get_widget('entry7')
- self.sanbox2_port = self.fence_xml.get_widget('entry8')
- self.bladecenter_blade = self.fence_xml.get_widget('entry41')
- self.mcdata_port = self.fence_xml.get_widget('entry9')
- self.egenera_lpan = self.fence_xml.get_widget('entry10')
- self.egenera_pserver = self.fence_xml.get_widget('entry11')
- self.bullpap_domain = self.fence_xml.get_widget('entry51')
-
- ##Fence Device Forms
- self.apc_fd_name = self.fence_xml.get_widget('entry12')
- self.apc_fd_ip = self.fence_xml.get_widget('entry13')
- self.apc_fd_login = self.fence_xml.get_widget('entry14')
- self.apc_fd_passwd = self.fence_xml.get_widget('entry15')
-
- self.wti_fd_ip = self.fence_xml.get_widget('entry17')
- self.wti_fd_name = self.fence_xml.get_widget('entry16')
- self.wti_fd_passwd = self.fence_xml.get_widget('entry18')
-
- self.brocade_fd_name = self.fence_xml.get_widget('entry19')
- self.brocade_fd_ip = self.fence_xml.get_widget('entry20')
- self.brocade_fd_login = self.fence_xml.get_widget('entry21')
- self.brocade_fd_passwd = self.fence_xml.get_widget('entry22')
-
- self.vixel_fd_name = self.fence_xml.get_widget('entry23')
- self.vixel_fd_ip = self.fence_xml.get_widget('entry24')
- self.vixel_fd_passwd = self.fence_xml.get_widget('entry25')
-
- self.gnbd_fd_name = self.fence_xml.get_widget('entry26')
- self.gnbd_fd_server = self.fence_xml.get_widget('entry27')
-
- self.ilo_fd_name = self.fence_xml.get_widget('entry28')
- self.ilo_fd_login = self.fence_xml.get_widget('entry29')
- self.ilo_fd_passwd = self.fence_xml.get_widget('entry30')
- self.ilo_fd_hostname = self.fence_xml.get_widget('entry31')
-
- self.sanbox2_fd_name = self.fence_xml.get_widget('entry32')
- self.sanbox2_fd_ip = self.fence_xml.get_widget('entry33')
- self.sanbox2_fd_login = self.fence_xml.get_widget('entry46')
- self.sanbox2_fd_passwd = self.fence_xml.get_widget('entry47')
-
- self.bladecenter_fd_name = self.fence_xml.get_widget('entry42')
- self.bladecenter_fd_ip = self.fence_xml.get_widget('entry43')
- self.bladecenter_fd_login = self.fence_xml.get_widget('entry44')
- self.bladecenter_fd_passwd = self.fence_xml.get_widget('entry45')
-
- self.mcdata_fd_name = self.fence_xml.get_widget('entry34')
- self.mcdata_fd_ip = self.fence_xml.get_widget('entry35')
- self.mcdata_fd_login = self.fence_xml.get_widget('entry36')
- self.mcdata_fd_passwd = self.fence_xml.get_widget('entry37')
-
- self.egenera_fd_name = self.fence_xml.get_widget('entry38')
- self.egenera_fd_cserver = self.fence_xml.get_widget('entry39')
-
- self.manual_fd_name = self.fence_xml.get_widget('entry40')
-
- self.ipmilan_fd_name = self.fence_xml.get_widget('entry55')
- self.ipmilan_fd_ip = self.fence_xml.get_widget('entry48')
- self.ipmilan_fd_login = self.fence_xml.get_widget('entry49')
- self.ipmilan_fd_passwd = self.fence_xml.get_widget('entry50')
-
- self.bullpap_fd_name = self.fence_xml.get_widget('entry56')
- self.bullpap_fd_ip = self.fence_xml.get_widget('entry52')
- self.bullpap_fd_login = self.fence_xml.get_widget('entry53')
- self.bullpap_fd_passwd = self.fence_xml.get_widget('entry54')
-
- ##### Validation Methods
- def validate_fencedevice(self, agent_type, name=None):
- try:
- args = list()
- args.append(name)
- returnlist = apply(self.fd_validate[agent_type], args)
- except ValidationError, e:
- MessageLibrary.errorMessage(e.getMessage())
- return None
-
- return returnlist
-
-
- def val_apc_fd(self, name):
- rectify_fence_name = False
- if self.apc_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.apc_fd_name)
- if name != self.apc_fd_name.get_text():
- res = self.check_unique_fd_name(self.apc_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.apc_fd_ip.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_IP)
- if self.apc_fd_login.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_LOGIN)
- if self.apc_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.apc_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.apc_fd_name.get_text()
- fields["ipaddr"] = self.apc_fd_ip.get_text()
- fields["login"] = self.apc_fd_login.get_text()
- fields["passwd"] = self.apc_fd_passwd.get_text()
-
- return fields
-
-
- def val_wti_fd(self, name):
- rectify_fence_name = False
- if self.wti_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.wti_fd_name)
- if name != self.wti_fd_name.get_text():
- res = self.check_unique_fd_name(self.wti_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.wti_fd_ip.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_IP)
- if self.wti_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.wti_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.wti_fd_name.get_text()
- fields["ipaddr"] = self.wti_fd_ip.get_text()
- fields["passwd"] = self.wti_fd_passwd.get_text()
-
- return fields
-
-
- def val_brocade_fd(self, name):
- rectify_fence_name = False
- if self.brocade_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.brocade_fd_name)
- if name != self.brocade_fd_name.get_text():
- res = self.check_unique_fd_name(self.brocade_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.brocade_fd_ip.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_IP)
- if self.brocade_fd_login.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_LOGIN)
- if self.brocade_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.brocade_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.brocade_fd_name.get_text()
- fields["ipaddr"] = self.brocade_fd_ip.get_text()
- fields["login"] = self.brocade_fd_login.get_text()
- fields["passwd"] = self.brocade_fd_passwd.get_text()
-
- return fields
-
-
- def val_ilo_fd(self, name):
- rectify_fence_name = False
- if self.ilo_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.ilo_fd_name)
- if name != self.ilo_fd_name.get_text():
- res = self.check_unique_fd_name(self.ilo_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.ilo_fd_login.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_LOGIN)
- if self.ilo_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
- if self.ilo_fd_hostname.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_HOSTNAME)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.ilo_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.ilo_fd_name.get_text()
- fields["hostname"] = self.ilo_fd_hostname.get_text()
- fields["login"] = self.ilo_fd_login.get_text()
- fields["passwd"] = self.ilo_fd_passwd.get_text()
-
- return fields
-
-
- def val_vixel_fd(self, name):
- rectify_fence_name = False
- if self.vixel_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.vixel_fd_name)
- if name != self.vixel_fd_name.get_text():
- res = self.check_unique_fd_name(self.vixel_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.vixel_fd_ip.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_IP)
- if self.vixel_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.vixel_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.vixel_fd_name.get_text()
- fields["ipaddr"] = self.vixel_fd_ip.get_text()
- fields["passwd"] = self.vixel_fd_passwd.get_text()
-
- return fields
-
-
- def val_mcdata_fd(self, name):
- rectify_fence_name = False
- if self.mcdata_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.mcdata_fd_name)
- if name != self.mcdata_fd_name.get_text():
- res = self.check_unique_fd_name(self.mcdata_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.mcdata_fd_ip.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_IP)
- if self.mcdata_fd_login.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_LOGIN)
- if self.mcdata_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.mcdata_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.mcdata_fd_name.get_text()
- fields["ipaddr"] = self.mcdata_fd_ip.get_text()
- fields["login"] = self.mcdata_fd_login.get_text()
- fields["passwd"] = self.mcdata_fd_passwd.get_text()
-
- return fields
-
- def val_manual_fd(self, name):
- rectify_fence_name = False
- if self.manual_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.manual_fd_name)
- if name != self.manual_fd_name.get_text():
- res = self.check_unique_fd_name(self.manual_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.manual_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.manual_fd_name.get_text()
-
- return fields
-
- def val_gnbd_fd(self, name):
- rectify_fence_name = False
- if self.gnbd_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.gnbd_fd_name)
- if name != self.gnbd_fd_name.get_text():
- res = self.check_unique_fd_name(self.gnbd_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.gnbd_fd_server.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_SERVER)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.gnbd_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.gnbd_fd_name.get_text()
- fields["server"] = self.gnbd_fd_server.get_text()
-
- return fields
-
- def val_egenera_fd(self, name):
- rectify_fence_name = False
- if self.egenera_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.egenera_fd_name)
- if name != self.egenera_fd_name.get_text():
- res = self.check_unique_fd_name(self.egenera_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.egenera_fd_cserver.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_CSERVER)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.egenera_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.egenera_fd_name.get_text()
- fields["cserver"] = self.egenera_fd_cserver.get_text()
-
- return fields
-
-
- def val_sanbox2_fd(self, name):
- rectify_fence_name = False
- if self.sanbox2_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.sanbox2_fd_name)
- if name != self.sanbox2_fd_name.get_text():
- res = self.check_unique_fd_name(self.sanbox2_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.sanbox2_fd_ip.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_IP)
-
- if self.sanbox2_fd_login.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_LOGIN)
-
- if self.sanbox2_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.sanbox2_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.sanbox2_fd_name.get_text()
- fields["ipaddr"] = self.sanbox2_fd_ip.get_text()
- fields["login"] = self.sanbox2_fd_login.get_text()
- fields["passwd"] = self.sanbox2_fd_passwd.get_text()
-
- return fields
-
- def val_bladecenter_fd(self, name):
- rectify_fence_name = False
- if self.bladecenter_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.bladecenter_fd_name)
- if name != self.bladecenter_fd_name.get_text():
- res = self.check_unique_fd_name(self.bladecenter_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.bladecenter_fd_ip.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_IP)
-
- if self.bladecenter_fd_login.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_LOGIN)
-
- if self.bladecenter_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.bladecenter_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.bladecenter_fd_name.get_text()
- fields["ipaddr"] = self.bladecenter_fd_ip.get_text()
- fields["login"] = self.bladecenter_fd_login.get_text()
- fields["passwd"] = self.bladecenter_fd_passwd.get_text()
-
- return fields
-
- def val_ipmilan_fd(self, name):
- rectify_fence_name = False
- if self.ipmilan_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.ipmilan_fd_name)
- if name != self.ipmilan_fd_name.get_text():
- res = self.check_unique_fd_name(self.ipmilan_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.ipmilan_fd_login.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_LOGIN)
- if self.ipmilan_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
- if self.ipmilan_fd_ip.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_IP)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.ipmilan_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.ipmilan_fd_name.get_text()
- fields["ipaddr"] = self.ipmilan_fd_ip.get_text()
- fields["login"] = self.ipmilan_fd_login.get_text()
- fields["passwd"] = self.ipmilan_fd_passwd.get_text()
-
- return fields
-
-
- def val_bullpap_fd(self, name):
- rectify_fence_name = False
- if self.bullpap_fd_name.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- self.validateNCName(self.bullpap_fd_name)
- if name != self.bullpap_fd_name.get_text():
- res = self.check_unique_fd_name(self.bullpap_fd_name.get_text())
- if res == False: #name is already used
- raise ValidationError('FATAL', FD_PROVIDE_NAME)
- rectify_fence_name = True
-
- if self.bullpap_fd_login.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_LOGIN)
- if self.bullpap_fd_passwd.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_PASSWD)
- if self.bullpap_fd_ip.get_text() == "":
- raise ValidationError('FATAL', FD_PROVIDE_IP)
-
- if rectify_fence_name == True:
- self.model_builder.rectifyNewFencedevicenameWithFences(name,self.bullpap_fd_name.get_text())
-
- fields = {}
- fields["name"] = self.bullpap_fd_name.get_text()
- fields["ipaddr"] = self.bullpap_fd_ip.get_text()
- fields["login"] = self.bullpap_fd_login.get_text()
- fields["passwd"] = self.bullpap_fd_passwd.get_text()
-
- return fields
-
-
- #Validation Methods for Fence Instances
- def validate_fenceinstance(self, agent_type):
- try:
- returnlist = apply(self.fi_validate[agent_type])
- except ValidationError, e:
- MessageLibrary.errorMessage(e.getMessage())
- return None
-
- return returnlist
-
- def val_apc(self):
- if self.apc_port.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_PORT)
- if self.apc_switch.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_SWITCH)
-
- fields = {}
- fields["port"] = self.apc_port.get_text()
- fields["switch"] = self.apc_switch.get_text()
-
- return fields
-
- def val_wti(self):
- if self.wti_port.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_PORT)
-
- fields = {}
- fields["port"] = self.wti_port.get_text()
-
- return fields
-
- def val_brocade(self):
- if self.brocade_port.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_PORT)
-
- fields = {}
- fields["port"] = self.brocade_port.get_text()
-
- return fields
-
- def val_vixel(self):
- if self.vixel_port.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_PORT)
-
- fields = {}
- fields["port"] = self.vixel_port.get_text()
-
- return fields
-
- def val_gnbd(self):
- if self.gnbd_ip.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_IPADDRESS)
-
- fields = {}
- fields["ipaddress"] = self.gnbd_ip.get_text()
-
- return fields
-
- def val_ilo(self):
-
- fields = {}
-
- return fields
-
- def val_sanbox2(self):
- if self.sanbox2_port.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_PORT)
-
- fields = {}
- fields["port"] = self.sanbox2_port.get_text()
-
- return fields
-
- def val_bladecenter(self):
- if self.bladecenter_blade.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_BLADE)
-
- fields = {}
- fields["blade"] = self.bladecenter_blade.get_text()
-
- return fields
-
- def val_mcdata(self):
- if self.mcdata_port.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_PORT)
-
- fields = {}
- fields["port"] = self.mcdata_port.get_text()
-
- return fields
-
- def val_egenera(self):
- if self.egenera_lpan.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_ELPAN)
- if self.egenera_pserver.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_EPSERVER)
-
- fields = {}
- fields["lpan"] = self.egenera_lpan.get_text()
- fields["pserver"] = self.egenera_pserver.get_text()
-
- return fields
-
- def val_manual(self):
-
- fields = {}
- return fields
-
- def val_ipmilan(self):
-
- fields = {}
-
- return fields
-
- def val_bullpap(self):
- if self.bullpap_domain.get_text() == "":
- raise ValidationError('FATAL', FI_PROVIDE_DOMAIN)
-
- fields = {}
- fields["domain"] = self.bullpap_domain.get_text()
-
- return fields
-
- def check_unique_fd_name(self, name):
- fds = self.model_builder.getFenceDevices()
- for fd in fds:
- if fd.getName() == name:
- return False
-
- return True
-
- def getFENCE_OPTS(self):
- return FENCE_OPTS
-
- def set_model(self, model_builder):
- self.model_builder = model_builder
-
-
-
- ### name must conform to relaxNG ID type ##
- def isNCName(self, name):
- for ch in ILLEGAL_CHARS:
- if ch in name:
- return False
- return True
-
- def makeNCName(self, name):
- new_name = ''
- for ch in name:
- if ch in ILLEGAL_CHARS:
- new_name = new_name + '_'
- else:
- new_name = new_name + ch
- return new_name
-
- def validateNCName(self, gtkentry):
- name = gtkentry.get_text().strip()
- gtkentry.set_text(name)
- if not self.isNCName(name):
- name = self.makeNCName(name)
- gtkentry.set_text(name)
- # select text
- raise ValidationError('FATAL', ILLEGAL_CHARS_REPLACED)
-
-def validateNewFenceDevice(form, model):
- from FenceDevice import FenceDevice
- 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['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)
-
def validateFenceDevice(form, model):
- from FenceDevice import FenceDevice
- namechange = False
+ try:
+ old_fence_name = form['orig_name'].strip()
+ if not old_fence_name:
+ raise Exception, 'blank'
+ except Exception, e:
+ return (FD_VAL_FAIL, FD_PROVIDE_NAME)
+
+ fencedev = None
+ try:
+ fencedevs = model.getFenceDevices()
+ for fd in fencedevs:
+ if fd.getName().strip() == old_fence_name:
+ fencedev = fd
+ break
+ if fencedev is None:
+ raise Exception, 'fencedev is None'
+ except Exception, e:
+ return (FD_VAL_FAIL, FD_PROVIDE_NAME)
+
+ try:
+ ret = validate_fencedevice(form, model, fencedev, fence_edit=True)
+ if ret is None:
+ model.setModified(True)
+ return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % FENCE_OPTS[fencedev.getAttribute('name')])
+ except Exception, e:
+ ret = FD_PROVIDE_NAME
+
+ return (FD_VAL_FAIL, ret)
+
+def validate_fencedevice(form, model, fencedev, fence_edit=False):
+ try:
+ fence_name = form['name'].strip()
+ if not fence_name:
+ raise Exception, 'blank'
+ fence_name = makeNCName(fence_name)
+ except Exception, e:
+ return FD_PROVIDE_NAME
+
+ name_change = False
+ if fence_edit is True:
+ try:
+ old_fence_name = form['orig_name'].strip()
+ if not old_fence_name:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_NAME
+ if old_fence_name != fence_name:
+ if check_unique_fd_name(model, fence_name) is False:
+ return FD_PROVIDE_NAME
+ name_change = True
+ else:
+ if check_unique_fd_name(model, fence_name) is False:
+ return FD_PROVIDE_NAME
+
+ try:
+ fence_agent = form['agent'].strip()
+ if not fence_agent:
+ raise Exception, 'blank agent'
+ except Exception, e:
+ return FD_PROVIDE_AGENT
+
+ fencedev.addAttribute('name', fence_name)
+ fencedev.addAttribute('agent', fence_agent)
+
+ try:
+ ret = FD_VALIDATE[fence_agent](form, fencedev)
+ if ret is None and name_change is True:
+ try:
+ model.rectifyNewFencedevicenameWithFences(old_fence_name, fence_name)
+ except:
+ return FD_NEW_FAIL % fence_agent
+ return ret
+ except:
+ return FD_NEW_FAIL % fence_agent
+
+def val_apc_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_wti_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_brocade_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_vixel_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_mcdata_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_gnbd_fd(form, fencedev):
+ try:
+ server = form['server'].strip()
+ if not server:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_SERVER
+
+ fencedev.addAttribute('server', server)
+ return None
+
+def val_egenera_fd(form, fencedev):
+ try:
+ cserver = form['cserver'].strip()
+ if not cserver:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_CSERVER
+
+ fencedev.addAttribute('cserver', cserver)
+ return None
+
+def val_sanbox2_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_bladecenter_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_bullpap_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_noop_fd(dummy, dummy):
+ return None
+
+# non-shared devices
+
+def val_rsa_fd(form, fencedev):
+ try:
+ hostname = form['hostname'].strip()
+ if not hostname:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_HOSTNAME
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('hostname', hostname)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_drac_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_rps10_fd(form, fencedev):
+ try:
+ device = form['device'].strip()
+ if not device:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_DEVICE
+
+ try:
+ port = form['port'].strip()
+ if not port:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PORT
+
+ fencedev.addAttribute('device', device)
+ fencedev.addAttribute('port', port)
+ return None
+
+def val_ipmilan_fd(form, fencedev):
+ try:
+ ip = form['ipaddr'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_IP
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ if not pwd:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ try:
+ auth_type = form['auth_type'].strip().lower()
+ if not auth_type or auth_type == 'none':
+ fencedev.removeAttribute('auth_type')
+ elif auth_type == 'password' or auth_type == 'md5':
+ fencedev.setAttribute('auth_type', auth_type)
+ else:
+ return FD_PROVIDE_IPMILAN_AUTH
+ except KeyError, e:
+ fencedev.removeAttribute('auth_type')
+ except Exception, e:
+ return FD_PROVIDE_IPMILAN_AUTH
+
+ try:
+ lanplus = form['lanplus'].strip().lower()
+ if not lanplus or lanplus == '0' or lanplus == 'false' or lanplus == 'off':
+ fencedev.removeAttribute('lanplus')
+ else:
+ fencedev.setAttribute('lanplus', '1')
+ except Exception, e:
+ fencedev.removeAttribute('lanplus')
+
+ fencedev.addAttribute('ipaddr', ip)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+def val_ilo_fd(form, fencedev):
+ try:
+ hostname = form['hostname'].strip()
+ if not hostname:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_HOSTNAME
+
+ try:
+ log = form['login'].strip()
+ if not log:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FD_PROVIDE_LOGIN
+
+ try:
+ pwd = form['passwd'].strip()
+ except Exception, e:
+ return FD_PROVIDE_PASSWD
+
+ fencedev.addAttribute('hostname', hostname)
+ fencedev.addAttribute('login', log)
+ fencedev.addAttribute('passwd', pwd)
+ return None
+
+# Validation Methods for Fence Instances
+
+def validate_fenceinstance(form, parent_name):
+ try:
+ fence_agent = form['fence_type'].strip()
+ if not fence_agent:
+ raise Exception, 'blank'
+ except:
+ return FD_PROVIDE_AGENT
+
+ try:
+ if not parent_name.strip():
+ return FI_PROVIDE_PARENT
+ except:
+ return FI_PROVIDE_PARENT
+
+ fenceinst = Device()
+ fenceinst.addAttribute('name', parent_name)
+
+ try:
+ ret = FI_VALIDATE[fence_agent](form, fenceinst)
+ if ret is not None:
+ return (FD_VAL_FAIL, ret)
+ except Exception, e:
+ return (FD_VAL_FAIL, FI_NEW_FAIL % fence_agent)
+
+ return (FD_VAL_SUCCESS, fenceinst)
+
+def val_apc_fi(form, fenceinst):
+ try:
+ port = form['port'].strip()
+ if not port:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_PORT
+
+ try:
+ switch = form['switch'].strip()
+ if not switch:
+ raise KeyError, 'blank'
+ fenceinst.addAttribute('switch', switch)
+ except KeyError, e:
+ # switch is optional
+ fenceinst.removeAttribute('switch')
+
+ fenceinst.addAttribute('port', port)
+ return None
+
+def val_wti_fi(form, fenceinst):
+ try:
+ port = form['port'].strip()
+ if not port:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_PORT
+
+ fenceinst.addAttribute('port', port)
+ return None
+
+def val_brocade_fi(form, fenceinst):
+ try:
+ port = form['port'].strip()
+ if not port:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_PORT
+
+ fenceinst.addAttribute('port', port)
+ return None
+
+def val_vixel_fi(form, fenceinst):
+ try:
+ port = form['port'].strip()
+ if not port:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_PORT
+
+ fenceinst.addAttribute('port', port)
+ return None
+
+def val_gnbd_fi(form, fenceinst):
+ try:
+ ip = form['ipaddress'].strip()
+ if not ip:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_IPADDRESS
+
+ fenceinst.addAttribute('ipaddress', ip)
+ return None
+
+def val_sanbox2_fi(form, fenceinst):
+ try:
+ port = form['port'].strip()
+ if not port:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_PORT
+
+ fenceinst.addAttribute('port', port)
+ return None
+
+def val_bladecenter_fi(form, fenceinst):
+ try:
+ blade = form['blade'].strip()
+ if not blade:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_BLADE
+
+ fenceinst.addAttribute('blade', blade)
+ return None
+
+def val_mcdata_fi(form, fenceinst):
+ try:
+ port = form['port'].strip()
+ if not port:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_PORT
+
+ fenceinst.addAttribute('port', port)
+ return None
+
+def val_egenera_fi(form, fenceinst):
+ try:
+ lpan = form['lpan'].strip()
+ if not lpan:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_ELPAN
+
+ try:
+ pserver = form['pserver'].strip()
+ if not pserver:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_ELPAN
+
+ fenceinst.addAttribute('lpan', lpan)
+ fenceinst.addAttribute('pserver', pserver)
+ return None
+
+def val_bullpap_fi(form, fenceinst):
+ try:
+ domain = form['domain'].strip()
+ if not domain:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_DOMAIN
+
+ fenceinst.addAttribute('domain', domain)
+ return None
+
+def val_xvm_fi(form, fenceinst):
+ try:
+ domain = form['domain'].strip()
+ if not domain:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_DOMAIN
+
+ fenceinst.addAttribute('domain', domain)
+ return None
+
+def val_scsi_fi(form, fenceinst):
+ try:
+ nodename = form['nodename'].strip()
+ if not nodename:
+ raise Exception, 'blank'
+ except Exception, e:
+ return FI_PROVIDE_NODENAME
+
+ fenceinst.addAttribute('nodename', nodename)
+ return None
- 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, "No device name in form submission")
-
- 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)
- else:
- fencedevs = model.getFenceDevices()
-
- #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['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.addAttribute("agent",agent_type)
- fencedev.addAttribute("name",fencedev_name)
- 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":
- 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.addAttribute("agent",agent_type)
- 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":
- 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.addAttribute("agent",agent_type)
- fencedev.addAttribute("name",fencedev_name)
- 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":
- 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.addAttribute("agent",agent_type)
- 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_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.addAttribute("agent",agent_type)
- fencedev.addAttribute("name",fencedev_name)
- 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_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)
- if namechange:
- model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
- 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)
- if namechange:
- model.rectifyNewFencedevicenameWithFences(orig_name,fencedev_name)
- return (FD_VAL_SUCCESS, FD_UPDATE_SUCCESS % orig_name)
-
-
- 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.addAttribute("agent",agent_type)
- fencedev.addAttribute("name",fencedev_name)
- 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":
- 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.addAttribute("agent",agent_type)
- fencedev.addAttribute("name",fencedev_name)
- 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":
- 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.addAttribute("agent",agent_type)
- fencedev.addAttribute("name",fencedev_name)
- 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_xvm":
-
- 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
- else:
- return (FD_VAL_FAIL, FD_NEW_FAIL % agent_type)
+def val_noop_fi(dummy, dummy):
+ return None
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/18 02:48:37 1.205
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/19 19:41:26 1.206
@@ -6829,7 +6829,7 @@
clusterfolder = self.restrictedTraverse(path)
objs = clusterfolder.objectItems('Folder')
except Exception, e:
- luci_log.info('RNN0: error for %s/%s: %s' \
+ luci_log.debug_verbose('RNN0: error for %s/%s: %s' \
% (nodename, clustername, str(e)))
return nodename
@@ -6840,7 +6840,7 @@
except:
continue
- luci_log.info('RNN1: failed for %s/%s: nothing found' \
+ luci_log.debug_verbose('RNN1: failed for %s/%s: nothing found' \
% (nodename, clustername))
return nodename
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2007-01-19 21:48 rmccabe
0 siblings, 0 replies; 14+ messages in thread
From: rmccabe @ 2007-01-19 21:48 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-01-19 21:48:23
Modified files:
luci/site/luci/Extensions: FenceHandler.py cluster_adapters.py
Log message:
use the new fence validation code to validate fence add/edit and node fence operations
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.206&r2=1.207
--- conga/luci/site/luci/Extensions/FenceHandler.py 2007/01/19 20:57:38 1.14
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2007/01/19 21:48:23 1.15
@@ -37,7 +37,7 @@
# For every new fence added, there will be a fence instance and fence device
# form needed. There will also be a populate and a validate method for each
# form. The methods will need to be added to this file, and the four hash
-# tables (self.fi_populate, self.fi_validate, self.fd_populate,
+# tables (self.fi_populate, self.fi_validate, self.fd_populate,
# self.fd_validate) must be updated. The methods will use fields in the
# forms to set_text and to check.
@@ -183,7 +183,7 @@
'fence_ipmilan': ['name', 'ipaddr', 'login', 'passwd', 'lanplus', 'auth'],
'fence_drac': ['name', 'ipaddr', 'login', 'passwd'],
'fence_rsa': ['name', 'hostname', 'login', 'passwd'],
- 'fence_rps10': ['name', 'device', 'port'],
+ 'fence_rps10': ['name', 'device', 'port'],
'fence_manual': ['name']
}
@@ -205,23 +205,23 @@
try:
ret = validate_fencedevice(form, model, fencedev)
- if ret is None:
+ if len(ret) < 1:
fencedevptr = model.getFenceDevicePtr()
fencedevptr.addChild(fencedev)
model.setModified(True)
return (FD_VAL_SUCCESS, fencedev.getAttribute('name'))
except Exception, e:
- ret = FD_PROVIDE_AGENT
+ ret = [ FD_PROVIDE_AGENT ]
return (FD_VAL_FAIL, ret)
-def validateFenceDevice(form, model):
+def validateFenceDevice(form, model):
try:
old_fence_name = form['orig_name'].strip()
if not old_fence_name:
raise Exception, 'blank'
except Exception, e:
- return (FD_VAL_FAIL, FD_PROVIDE_NAME)
+ return (FD_VAL_FAIL, [ FD_PROVIDE_NAME ])
fencedev = None
try:
@@ -233,15 +233,15 @@
if fencedev is None:
raise Exception, 'fencedev is None'
except Exception, e:
- return (FD_VAL_FAIL, FD_PROVIDE_NAME)
+ return (FD_VAL_FAIL, [ FD_PROVIDE_NAME ])
try:
ret = validate_fencedevice(form, model, fencedev, fence_edit=True)
- if ret is None:
+ if len(ret) < 1:
model.setModified(True)
return (FD_VAL_SUCCESS, fencedev.getAttribute('name'))
except Exception, e:
- ret = FD_PROVIDE_NAME
+ ret = [ FD_PROVIDE_NAME ]
return (FD_VAL_FAIL, ret)
@@ -252,7 +252,7 @@
raise Exception, 'blank'
fence_name = makeNCName(fence_name)
except Exception, e:
- return FD_PROVIDE_NAME
+ return [ FD_PROVIDE_NAME ]
name_change = False
if fence_edit is True:
@@ -261,357 +261,385 @@
if not old_fence_name:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_NAME
+ return [ FD_PROVIDE_NAME ]
if old_fence_name != fence_name:
if check_unique_fd_name(model, fence_name) is False:
- return FD_PROVIDE_NAME
+ return [ FD_PROVIDE_NAME ]
name_change = True
else:
if check_unique_fd_name(model, fence_name) is False:
- return FD_PROVIDE_NAME
+ return [ FD_PROVIDE_NAME ]
try:
fence_agent = form['agent'].strip()
if not fence_agent:
raise Exception, 'blank agent'
except Exception, e:
- return FD_PROVIDE_AGENT
+ return [ FD_PROVIDE_AGENT ]
fencedev.addAttribute('name', fence_name)
fencedev.addAttribute('agent', fence_agent)
try:
ret = FD_VALIDATE[fence_agent](form, fencedev)
- if ret is None and name_change is True:
+ if len(ret) < 1 and name_change is True:
try:
model.rectifyNewFencedevicenameWithFences(old_fence_name, fence_name)
except:
- return FD_NEW_FAIL % fence_agent
+ return [ FD_NEW_FAIL % fence_agent ]
return ret
except:
- return FD_NEW_FAIL % fence_agent
+ return [ FD_NEW_FAIL % fence_agent ]
def val_apc_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
+ return errors
def val_wti_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('passwd', pwd)
- return None
-
+ return errors
+
def val_brocade_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
-
+ return errors
+
def val_vixel_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('passwd', pwd)
- return None
-
+ return errors
+
def val_mcdata_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
-
+ return errors
+
def val_gnbd_fd(form, fencedev):
+ errors = list()
+
try:
server = form['server'].strip()
if not server:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_SERVER
+ errors.append(FD_PROVIDE_SERVER)
fencedev.addAttribute('server', server)
- return None
-
+ return errors
+
def val_egenera_fd(form, fencedev):
+ errors = list()
+
try:
cserver = form['cserver'].strip()
if not cserver:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_CSERVER
+ errors.append(FD_PROVIDE_CSERVER)
fencedev.addAttribute('cserver', cserver)
- return None
-
+ return errors
+
def val_sanbox2_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
+ return errors
def val_bladecenter_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
+ return errors
def val_bullpap_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
+ return errors
def val_noop_fd(dummy, dummy):
- return None
+ return []
# non-shared devices
def val_rsa_fd(form, fencedev):
+ errors = list()
+
try:
hostname = form['hostname'].strip()
if not hostname:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_HOSTNAME
+ errors.append(FD_PROVIDE_HOSTNAME)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('hostname', hostname)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
+ return errors
def val_drac_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
+ return errors
def val_rps10_fd(form, fencedev):
+ errors = list()
+
try:
device = form['device'].strip()
if not device:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_DEVICE
+ errors.append(FD_PROVIDE_DEVICE)
try:
port = form['port'].strip()
if not port:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PORT
+ errors.append(FD_PROVIDE_PORT)
fencedev.addAttribute('device', device)
fencedev.addAttribute('port', port)
- return None
+ return errors
def val_ipmilan_fd(form, fencedev):
+ errors = list()
+
try:
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_IP
+ errors.append(FD_PROVIDE_IP)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
if not pwd:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
try:
auth_type = form['auth_type'].strip().lower()
@@ -620,11 +648,11 @@
elif auth_type == 'password' or auth_type == 'md5':
fencedev.setAttribute('auth_type', auth_type)
else:
- return FD_PROVIDE_IPMILAN_AUTH
+ errors.append(FD_PROVIDE_IPMILAN_AUTH)
except KeyError, e:
fencedev.removeAttribute('auth_type')
except Exception, e:
- return FD_PROVIDE_IPMILAN_AUTH
+ errors.append(FD_PROVIDE_IPMILAN_AUTH)
try:
lanplus = form['lanplus'].strip().lower()
@@ -638,34 +666,36 @@
fencedev.addAttribute('ipaddr', ip)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
+ return errors
def val_ilo_fd(form, fencedev):
+ errors = list()
+
try:
hostname = form['hostname'].strip()
if not hostname:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_HOSTNAME
+ errors.append(FD_PROVIDE_HOSTNAME)
try:
log = form['login'].strip()
if not log:
raise Exception, 'blank'
except Exception, e:
- return FD_PROVIDE_LOGIN
+ errors.append(FD_PROVIDE_LOGIN)
try:
pwd = form['passwd'].strip()
except Exception, e:
- return FD_PROVIDE_PASSWD
+ errors.append(FD_PROVIDE_PASSWD)
fencedev.addAttribute('hostname', hostname)
fencedev.addAttribute('login', log)
fencedev.addAttribute('passwd', pwd)
- return None
+ return errors
-# Validation Methods for Fence Instances
+# Validation Methods for Fence Instances
def validate_fenceinstance(form, parent_name):
try:
@@ -673,33 +703,35 @@
if not fence_agent:
raise Exception, 'blank'
except:
- return FD_PROVIDE_AGENT
+ return [ FD_PROVIDE_AGENT ]
try:
if not parent_name.strip():
- return FI_PROVIDE_PARENT
+ return [ FI_PROVIDE_PARENT ]
except:
- return FI_PROVIDE_PARENT
+ return [ FI_PROVIDE_PARENT ]
fenceinst = Device()
fenceinst.addAttribute('name', parent_name)
try:
ret = FI_VALIDATE[fence_agent](form, fenceinst)
- if ret is not None:
+ if len(ret) > 0:
return (FD_VAL_FAIL, ret)
except Exception, e:
- return (FD_VAL_FAIL, FI_NEW_FAIL % fence_agent)
+ return (FD_VAL_FAIL, [ FI_NEW_FAIL % fence_agent ])
return (FD_VAL_SUCCESS, fenceinst)
def val_apc_fi(form, fenceinst):
+ errors = list()
+
try:
port = form['port'].strip()
if not port:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_PORT
+ errors.append(FI_PROVIDE_PORT)
try:
switch = form['switch'].strip()
@@ -709,138 +741,162 @@
except KeyError, e:
# switch is optional
fenceinst.removeAttribute('switch')
+ except Exception, e:
+ errors.append(FI_PROVIDE_SWITCH)
fenceinst.addAttribute('port', port)
- return None
+ return errors
def val_wti_fi(form, fenceinst):
+ errors = list()
+
try:
port = form['port'].strip()
if not port:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_PORT
+ errors.append(FI_PROVIDE_PORT)
fenceinst.addAttribute('port', port)
- return None
+ return errors
def val_brocade_fi(form, fenceinst):
+ errors = list()
+
try:
port = form['port'].strip()
if not port:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_PORT
+ errors.append(FI_PROVIDE_PORT)
fenceinst.addAttribute('port', port)
- return None
+ return errors
def val_vixel_fi(form, fenceinst):
+ errors = list()
+
try:
port = form['port'].strip()
if not port:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_PORT
+ errors.append(FI_PROVIDE_PORT)
fenceinst.addAttribute('port', port)
- return None
+ return errors
def val_gnbd_fi(form, fenceinst):
+ errors = list()
+
try:
ip = form['ipaddress'].strip()
if not ip:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_IPADDRESS
+ errors.append(FI_PROVIDE_IPADDRESS)
fenceinst.addAttribute('ipaddress', ip)
- return None
+ return errors
def val_sanbox2_fi(form, fenceinst):
+ errors = list()
+
try:
port = form['port'].strip()
if not port:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_PORT
+ errors.append(FI_PROVIDE_PORT)
fenceinst.addAttribute('port', port)
- return None
+ return errors
def val_bladecenter_fi(form, fenceinst):
+ errors = list()
+
try:
blade = form['blade'].strip()
if not blade:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_BLADE
+ errors.append(FI_PROVIDE_BLADE)
fenceinst.addAttribute('blade', blade)
- return None
+ return errors
def val_mcdata_fi(form, fenceinst):
+ errors = list()
+
try:
port = form['port'].strip()
if not port:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_PORT
+ errors.append(FI_PROVIDE_PORT)
fenceinst.addAttribute('port', port)
- return None
+ return errors
def val_egenera_fi(form, fenceinst):
+ errors = list()
+
try:
lpan = form['lpan'].strip()
if not lpan:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_ELPAN
+ errors.append(FI_PROVIDE_ELPAN)
try:
pserver = form['pserver'].strip()
if not pserver:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_ELPAN
+ errors.append(FI_PROVIDE_ELPAN)
fenceinst.addAttribute('lpan', lpan)
fenceinst.addAttribute('pserver', pserver)
- return None
+ return errors
def val_bullpap_fi(form, fenceinst):
+ errors = list()
+
try:
domain = form['domain'].strip()
if not domain:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_DOMAIN
+ errors.append(FI_PROVIDE_DOMAIN)
fenceinst.addAttribute('domain', domain)
- return None
+ return errors
def val_xvm_fi(form, fenceinst):
+ errors = list()
+
try:
domain = form['domain'].strip()
if not domain:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_DOMAIN
+ errors.append(FI_PROVIDE_DOMAIN)
fenceinst.addAttribute('domain', domain)
- return None
+ return errors
def val_scsi_fi(form, fenceinst):
+ errors = list()
+
try:
nodename = form['nodename'].strip()
if not nodename:
raise Exception, 'blank'
except Exception, e:
- return FI_PROVIDE_NODENAME
+ errors.append(FI_PROVIDE_NODENAME)
fenceinst.addAttribute('nodename', nodename)
- return None
+ return errors
def val_noop_fi(dummy, dummy):
- return None
+ return []
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/19 19:41:26 1.206
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/01/19 21:48:23 1.207
@@ -32,7 +32,7 @@
from Method import Method
from FenceDevice import FenceDevice
from Device import Device
-from FenceHandler import validateNewFenceDevice, FENCE_OPTS, validateFenceDevice
+from FenceHandler import validateNewFenceDevice, FENCE_OPTS, validateFenceDevice, validate_fenceinstance
from GeneralError import GeneralError
from homebase_adapters import manageCluster, createClusterSystems, havePermCreateCluster, setNodeFlag, delNodeFlag, userAuthenticated, getStorageNode, getClusterNode, delCluster, parseHostForm
from LuciSyslog import LuciSyslog
@@ -1296,13 +1296,9 @@
return (False, {'errors': ['No form was submitted']})
#fencehandler = FenceHandler()
- error_code, error_string = validateNewFenceDevice(form, model)
+ error_code, retobj = validateNewFenceDevice(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'
@@ -1335,14 +1331,13 @@
else:
try:
set_node_flag(self, clustername, rc.hostname(), batch_id,
- CLUSTER_CONFIG, 'Updating cluster configuration')
+ CLUSTER_CONFIG, 'Adding new fence device \"%s\"' % retobj)
except:
pass
- response.redirect(request['URL'] + "?pagetype=" + FENCEDEV + "&clustername=" + clustername + "&fencename=" + form['name'] + '&busyfirst=true')
- return (True, {'errors': errors, 'messages': messages})
+ response.redirect(request['URL'] + "?pagetype=" + FENCEDEV + "&clustername=" + clustername + "&fencename=" + retobj + '&busyfirst=true')
else:
- errors.append(error_string)
+ errors.extend(retobj)
return (False, {'errors': errors, 'messages': messages})
@@ -1393,19 +1388,15 @@
#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)
+ error_code, retobj = 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))
+ % str(e))
errors.append('Unable to store the new cluster configuration')
try:
@@ -1421,28 +1412,29 @@
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)
+ % 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: setClusterConf: batchid or result is None')
errors.append('Unable to propagate the new cluster configuration for %s' \
- % clustername)
+ % clustername)
else:
try:
set_node_flag(self, clustername, rc.hostname(), batch_id,
- CLUSTER_CONFIG, 'Updating cluster configuration')
+ CLUSTER_CONFIG, 'Updating fence device \"%s\"' % retobj)
except:
pass
- response.redirect(request['URL'] + "?pagetype=" + FENCEDEV + "&clustername=" + clustername + "&fencename=" + request['fencename'] + '&busyfirst=true')
- return (True, {'errors': errors, 'messages': messages})
+ response.redirect(request['URL'] + "?pagetype=" + FENCEDEV + "&clustername=" + clustername + "&fencename=" + retobj + '&busyfirst=true')
else:
- errors.append(error_string)
+ errors.extend(retobj)
return (False, {'errors': errors, 'messages': messages})
def validateNodeFenceConfig(self, request):
+ errors = list()
+
try:
form_xml = request['fence_xml']
if not form_xml:
@@ -1581,7 +1573,6 @@
for i in fh_keys:
fencedev_name = None
fencedev_unknown = False
- fencedev_obj = None
try:
fence_form, instance_list = form_hash[i]
@@ -1593,140 +1584,70 @@
fence_type = fence_form['fence_type']
if not fence_type:
raise Exception, 'fence type is blank'
- fence_form['agent'] = fence_type
except Exception, e:
luci_log.debug_verbose('vNFC12: %s %s' % (i, str(e)))
fence_type = None
- try:
- del fence_form['fence_type']
- except:
- pass
-
if 'existing_device' in fence_form:
- del fence_form['existing_device']
-
try:
fencedev_name = fence_form['name']
if not fencedev_name.strip():
raise Exception, 'no fence name'
except Exception, e:
- return (False, {'errors': [ 'You must provide a unique name for all fence devices.' ]})
+ errors.append('You must provide a unique name for all fence devices.')
+ continue
if fence_type is None:
- # An unknown device. Pull the data out of
+ # An unknown fence device agent. Pull the data out of
# the model and persist it and all instances.
# All we care about is its name.
fencedev_unknown = True
else:
- if 'sharable' in fence_form:
+ if not 'sharable' in fence_form:
# If it's a shared fence device that already exists, the
# user could not have edited it (without playing dirty
# games), so it's safe to pull the existing entry from
- # the model. All we need is the device name.
- del fence_form['sharable']
- else:
- # An existing non-shared device; build up the device
- # from scratch since the user could have edited it.
- try:
- old_name = fence_form['old_name']
- if not old_name:
- raise Exception, 'old name is blank'
- del fence_form['old_name']
- except Exception, e:
- luci_log.debug_verbose('vNFC12: no old name for %s %s' \
- % (fence_form['name'], str(e)))
- return (False, {'errors': [ 'Unable to determine the original name for the device now named %s' % fencedev_name ]})
-
- fencedev_obj = None
- fence_dev_list = model.getFenceDevices()
- for fd in fence_dev_list:
- if fd.getAttribute('name') == old_name:
- fencedev_obj = fd
- break
-
- if fencedev_obj is None:
- luci_log.debug_verbose('vNFC14: no fence device named %s was found' % old_name)
- return (False, {'errors': ['No fence device named %s was found' % old_name ] })
+ # the model. All we need is the device name, and nothing
+ # else needs to be done here.
+ #
+ # For an existing non-shared device update the device
+ # in the model, since the user could have edited it.
+ retcode, retmsg = validateFenceDevice(fence_form, model)
+ if retcode != FD_VAL_SUCCESS:
+ errors.extend(retmsg)
+ continue
else:
- try:
- model.fencedevices_ptr.removeChild(fd)
- except Exception, e:
- luci_log.debug_verbose('VNFC8a: %s: %s' \
- % (old_name, str(e)))
- return (False, {'errors': [ 'Unable to remove old fence device %s' % old_name ]})
-
- for k in fence_form.keys():
- if fence_form[k]:
- fencedev_obj.addAttribute(k, str(fence_form[k]))
+ fencedev_name = retmsg
# Add back the tags under the method block
# for the fence instance
instance_list.append({'name': fencedev_name })
else:
# The user created a new fence device.
- try:
- fencedev_name = fence_form['name']
- if not fencedev_name.strip():
- raise Exception, 'no fence name'
- except Exception, e:
- return (False, {'errors': [ 'You must provide a unique name for all fence devices.' ]})
-
- fencedev_obj = FenceDevice()
- for k in fence_form.keys():
- if fence_form[k]:
- fencedev_obj.addAttribute(k, str(fence_form[k]))
+ retcode, retmsg = validateNewFenceDevice(fence_form, model)
+ if retcode != FD_VAL_SUCCESS:
+ errors.extend(retmsg)
+ continue
+ else:
+ fencedev_name = retmsg
# If it's not shared, we need to create an instance form
# so the appropriate XML goes into the <method> block inside
# <node><fence>. All we need for that is the device name.
if not 'sharable' in fence_form:
instance_list.append({'name': fencedev_name })
- else:
- del fence_form['sharable']
-
- if fencedev_obj is not None:
- # If a device with this name exists in the model
- # already, replace it with the current object. If
- # this block is not executed, we don't need to make
- # any changes to the fencedevices block for this
- # device
- fence_dev_list = model.getFenceDevices()
- for fd in fence_dev_list:
- if fencedev_name == fd.getAttribute('name'):
- luci_log.debug_verbose('vNFC15: fence ident %s already in use' % fencedev_name)
- return (False, {'errors': ['There is already a fence device named %s' % fencedev_name ] })
- model.fencedevices_ptr.addChild(fencedev_obj)
if fencedev_unknown is True:
# Save any instances for this fence device.
+ # XXX FIX ME - instances must be saved.
pass
for inst in instance_list:
- try:
- del inst['parent_fencedev']
- except:
- pass
- try:
- del inst['new_instance']
- except:
- pass
- try:
- del inst['name']
- except:
- pass
- try:
- del inst['existing_instance']
- except:
- pass
-
- device_obj = Device()
- device_obj.setAgentType(fence_type)
- device_obj.addAttribute('name', fencedev_name)
- for k in inst.keys():
- if inst[k]:
- device_obj.addAttribute(k, str(inst[k]))
- fence_method.addChild(device_obj)
+ retcode, retobj = validate_fenceinstance(inst, fencedev_name)
+ if retcode != FD_VAL_SUCCESS:
+ errors.extend(retobj)
+ continue
+ fence_method.addChild(retobj)
if len(node.getChildren()) > 0:
# There's already a <fence> block
@@ -1746,9 +1667,10 @@
fence_node.addChild(fence_method)
node.addChild(fence_node)
+ if len(errors) > 0:
+ return (False, {'errors': errors })
+
try:
- cp = model.getClusterPtr()
- cp.incrementConfigVersion()
model.setModified(True)
conf = str(model.exportModelAsString())
if not conf:
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2007-05-15 21:42 rmccabe
0 siblings, 0 replies; 14+ messages in thread
From: rmccabe @ 2007-05-15 21:42 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Branch: EXPERIMENTAL
Changes by: rmccabe at sourceware.org 2007-05-15 21:42:21
Modified files:
luci/site/luci/Extensions: FenceHandler.py HelperFunctions.py
LuciClusterActions.py
LuciClusterInfo.py LuciDB.py
LuciSyslog.py LuciZope.py
PropsObject.py ResourceHandler.py
RicciQueries.py StorageReport.py
Variable.py cluster_adapters.py
conga_constants.py conga_ssl.py
conga_storage_constants.py
homebase_adapters.py
ricci_communicator.py
ricci_defines.py storage_adapters.py
system_adapters.py
luci/site/luci/Extensions/ClusterModel: BaseResource.py
Cluster.py
ClusterNode.py
FailoverDomainNode.py
FailoverDomains.py
FenceDevice.py
ModelBuilder.py
TagObject.py
Added files:
luci/site/luci/Extensions: LuciZopePerm.py
Log message:
More cleanup and refactor.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopePerm.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.18.2.1&r2=1.18.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/HelperFunctions.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.6.4.2&r2=1.6.4.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterActions.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciDB.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.5&r2=1.1.2.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciSyslog.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.11.4.1&r2=1.11.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZope.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.3&r2=1.1.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2.8.2&r2=1.2.8.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ResourceHandler.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/RicciQueries.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.23.2.2&r2=1.23.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/Variable.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.4.8.2&r2=1.4.8.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.255.2.4&r2=1.255.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.39.2.3&r2=1.39.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_ssl.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2.4.1&r2=1.2.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_storage_constants.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.8.8.1&r2=1.8.8.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.50.2.3&r2=1.50.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.25.2.3&r2=1.25.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_defines.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.8.1&r2=1.1.8.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/storage_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.9.4.2&r2=1.9.4.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/system_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2.2.2&r2=1.2.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/BaseResource.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/Cluster.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ClusterNode.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FailoverDomainNode.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FailoverDomains.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FenceDevice.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.3&r2=1.1.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/TagObject.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
--- conga/luci/site/luci/Extensions/FenceHandler.py 2007/05/03 20:16:38 1.18.2.1
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2007/05/15 21:42:21 1.18.2.2
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ClusterModel.Device import Device
FD_VAL_FAIL = 1
--- conga/luci/site/luci/Extensions/HelperFunctions.py 2007/05/04 19:10:24 1.6.4.2
+++ conga/luci/site/luci/Extensions/HelperFunctions.py 2007/05/15 21:42:21 1.6.4.3
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ricci_communicator import RicciCommunicator
import threading
@@ -67,7 +74,7 @@
trusted = False
ricci = ss[hostname]
- if ricci != None:
+ if ricci is not None:
OS = ricci.os()
cluname = ricci.cluster_info()[0]
cluali = ricci.cluster_info()[1]
@@ -81,9 +88,9 @@
'hostname' : hostname,
'OS' : OS,
'cluname' : cluname,
- 'key_fp' : key_fp,
- 'clualias' : cluali,
- 'available' : ricci != None,
+ 'key_fp' : key_fp,
+ 'clualias' : cluali,
+ 'available' : ricci is not None,
'trusted' : trusted,
'authed' : authed
}
--- conga/luci/site/luci/Extensions/Attic/LuciClusterActions.py 2007/05/14 18:00:14 1.1.2.2
+++ conga/luci/site/luci/Extensions/Attic/LuciClusterActions.py 2007/05/15 21:42:21 1.1.2.3
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
import RicciQueries as rq
from LuciDB import set_node_flag, getRicciAgent
from LuciSyslog import get_logger
--- conga/luci/site/luci/Extensions/Attic/LuciClusterInfo.py 2007/05/14 18:00:14 1.1.2.2
+++ conga/luci/site/luci/Extensions/Attic/LuciClusterInfo.py 2007/05/15 21:42:21 1.1.2.3
@@ -1,8 +1,16 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ClusterModel.GeneralError import GeneralError
import RicciQueries as rq
from ricci_communicator import RicciCommunicator
from FenceHandler import FENCE_OPTS
from LuciSyslog import get_logger
+from LuciDB import resolve_nodename
from conga_constants import CLUNAME, CLUSTER_CONFIG, CLUSTER_DELETE, \
CLUSTER_PROCESS, CLUSTER_RESTART, CLUSTER_START, CLUSTER_STOP, \
@@ -13,7 +21,7 @@
PROP_FENCE_TAB, PROP_GENERAL_TAB, PROP_GULM_TAB, PROP_MCAST_TAB, \
PROP_QDISK_TAB, RESOURCE, RESOURCE_CONFIG, RESOURCE_REMOVE, \
SERVICE, SERVICE_DELETE, SERVICE_MIGRATE, SERVICE_RESTART, \
- SERVICE_START, SERVICE_STOP, VM_CONFIG
+ SERVICE_START, SERVICE_STOP, VM_CONFIG, LUCI_DEBUG_MODE
luci_log = get_logger()
@@ -226,7 +234,7 @@
rc_map['name'] = child.getName()
#Note: Final version needs all resource attrs
- if child.isRefObject() == True:
+ if child.isRefObject() is True:
rc_map['ref_object'] = True
rc_map['tag_name'] = child.getObj().TAG_NAME
rc_map['type'] = child.getObj().getResourceType()
@@ -369,7 +377,7 @@
try:
if int(svc.getAttribute('exclusive')):
- hmap['exclusive'] = 'true'
+ hmap['exclusive'] = 'true'
else:
hmap['exclusive'] = 'false'
except:
@@ -757,7 +765,7 @@
if (item['type'] == "node") and (item['name'] == nodename):
found = True
break
- if found == False:
+ if found is False:
luci_log.debug_verbose('getNodeInfo1: Unable to resolve node name in cluster status')
return {}
@@ -1018,7 +1026,7 @@
for item in nodes_used:
if item['nodename'] == node.getName().strip():
found_duplicate = True
- if found_duplicate == True:
+ if found_duplicate is True:
continue
baseurl = request['URL']
clustername = model.getClusterName()
@@ -1117,7 +1125,7 @@
continue
if fd is not None:
- if fd.isShared() == False: #Not a shared dev...build struct and add
+ if fd.isShared() is False: #Not a shared dev...build struct and add
fencedev = {}
try:
fencedev['prettyname'] = FENCE_OPTS[fd.getAgentType()]
@@ -1192,13 +1200,13 @@
#level1 list is complete now, but it is still necessary to build shared1
for fd in fds:
isUnique = True
- if fd.isShared() == False:
+ if fd.isShared() is False:
continue
for fdev in level1:
if fd.getName().strip() == fdev['name']:
isUnique = False
break
- if isUnique == True:
+ if isUnique is True:
shared_struct = {}
shared_struct['name'] = fd.getName().strip()
agentname = fd.getAgentType()
@@ -1225,7 +1233,7 @@
fd = None #Set to None in case last time thru loop
continue
if fd is not None:
- if fd.isShared() == False: #Not a shared dev...build struct and add
+ if fd.isShared() is False: #Not a shared dev...build struct and add
fencedev = {}
try:
fencedev['prettyname'] = FENCE_OPTS[fd.getAgentType()]
@@ -1300,13 +1308,13 @@
#level2 list is complete but like above, we need to build shared2
for fd in fds:
isUnique = True
- if fd.isShared() == False:
+ if fd.isShared() is False:
continue
for fdev in level2:
if fd.getName().strip() == fdev['name']:
isUnique = False
break
- if isUnique == True:
+ if isUnique is True:
shared_struct = {}
shared_struct['name'] = fd.getName().strip()
agentname = fd.getAgentType()
@@ -1324,7 +1332,8 @@
def getFencesInfo(self, model, request):
fences_map = {}
if not model:
- luci_log.debug_verbose('getFencesInfo0: model is None')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getFencesInfo0: model is None')
fences_map['fencedevs'] = list()
return fences_map
@@ -1339,7 +1348,7 @@
#create fencedev hashmap
nodes_used = list()
- if fd.isShared() == True:
+ if fd.isShared() is True:
fencedev = {}
attr_hash = fd.getAttributes()
kees = attr_hash.keys()
@@ -1369,7 +1378,7 @@
for item in nodes_used:
if item['nodename'] == node.getName().strip():
found_duplicate = True
- if found_duplicate == True:
+ if found_duplicate is True:
continue
node_hash = {}
cur_nodename = node.getName().strip()
@@ -1410,8 +1419,9 @@
try:
vm = model.retrieveVMsByName(vmname)
except:
- luci_log.debug('An error occurred while attempting to get VM %s' \
- % vmname)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug('An error occurred while attempting to get VM %s' \
+ % vmname)
return vm_map
attrs = vm.getAttributes()
@@ -1431,14 +1441,16 @@
try:
cluname = request.form['clustername']
except:
- luci_log.debug_verbose('getResourcesInfo missing cluster name')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getResourcesInfo missing cluster name')
return resList
#CALL LUCICLUSTERINFO
return resList
def getResourceInfo(model, request):
if not model:
- luci_log.debug_verbose('GRI0: no model object in session')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GRI0: no model object in session')
return {}
name = None
@@ -1459,7 +1471,8 @@
pass
if name is None:
- luci_log.debug_verbose('getResourceInfo missing res name')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GRI1: missing res name')
return {}
try:
@@ -1468,13 +1481,15 @@
try:
cluname = request.form['clustername']
except:
- luci_log.debug_verbose('getResourceInfo missing cluster name')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GRI2: missing cluster name')
return {}
try:
baseurl = request['URL']
except:
- luci_log.debug_verbose('getResourceInfo missing URL')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GRI3: missing URL')
return {}
#CALL
@@ -1485,6 +1500,8 @@
def getClusterAlias(self, model):
if not model:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GCA0: no model')
return ''
alias = model.getClusterAlias()
if not alias:
--- conga/luci/site/luci/Extensions/Attic/LuciDB.py 2007/05/14 18:00:14 1.1.2.5
+++ conga/luci/site/luci/Extensions/Attic/LuciDB.py 2007/05/15 21:42:21 1.1.2.6
@@ -1,7 +1,14 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from AccessControl import getSecurityManager
import RicciQuery as rq
from ricci_communicator import RicciCommunicator
-from LuciZope import isAdmin
+from LuciZopePerm import isAdmin
from LuciSyslog import get_logger
from conga_constants import CLUSTER_FOLDER_PATH, BATCH_ID, TASKTYPE, \
@@ -92,7 +99,7 @@
luci_log.debug_verbose(errmsg)
raise Exception, errmsg
-def noNodeStatussPresent(self, nodefolder, flagname, hostname):
+def noNodeStatusPresent(self, nodefolder, flagname, hostname):
try:
items = nodefolder.objectItems('ManagedSystem')
except Exception, e:
@@ -125,7 +132,7 @@
batch_ret = rq.checkBatch(rc, item[1].getProperty(BATCH_ID))
finished = batch_ret[0]
- if finished == True or finished == -1:
+ if finished is True or finished == -1:
if finished == -1:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('NNFP2: batch error: %s' \
@@ -585,32 +592,6 @@
luci_log.debug_verbose('delCluSystems2: %s' % err)
return ''.join(error_list)
-# In case we want to give access to non-admin users in the future
-
-def havePermCreateCluster(self):
- return isAdmin(self)
-
-def havePermAddStorage(self):
- return isAdmin(self)
-
-def havePermAddCluster(self):
- return isAdmin(self)
-
-def havePermAddUser(self):
- return isAdmin(self)
-
-def havePermDelUser(self):
- return isAdmin(self)
-
-def havePermRemStorage(self):
- return isAdmin(self)
-
-def havePermRemCluster(self):
- return isAdmin(self)
-
-def havePermEditPerms(self):
- return isAdmin(self)
-
def getSystems(self):
storage = getStorage(self)
clusters = getClusters(self)
@@ -620,7 +601,7 @@
need_auth_hash = {}
for i in storage:
storageList.append(i[0])
- if testNodeStatus(i[1], CLUSTER_NODE_NEED_AUTH) != False:
+ if testNodeStatus(i[1], CLUSTER_NODE_NEED_AUTH) is not False:
need_auth_hash[i[0]] = i[1]
chash = {}
@@ -628,7 +609,7 @@
csystems = getClusterSystems(self, i[0])
cslist = list()
for c in csystems:
- if testNodeStatus(c[1], CLUSTER_NODE_NEED_AUTH) != False:
+ if testNodeStatus(c[1], CLUSTER_NODE_NEED_AUTH) is not False:
need_auth_hash[c[0]] = c[1]
cslist.append(c[0])
chash[i[0]] = cslist
@@ -658,7 +639,7 @@
return None
if cluster_permission_check(self, cluster):
- return cluster_nodes
+ return cluster_nodes
return None
def getClusters(self):
@@ -669,8 +650,6 @@
luci_log.debug_verbose('GC0: %r' % e)
return None
- if isAdmin(self):
- return clusters
return check_clusters(self, clusters)
def getStorage(self):
--- conga/luci/site/luci/Extensions/LuciSyslog.py 2007/05/14 18:00:14 1.11.4.1
+++ conga/luci/site/luci/Extensions/LuciSyslog.py 2007/05/15 21:42:21 1.11.4.2
@@ -1,8 +1,16 @@
-from conga_constants import LUCI_DEBUG_MODE, LUCI_DEBUG_VERBOSITY
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from syslog import openlog, closelog, syslog, \
LOG_DAEMON, LOG_PID, LOG_NDELAY, LOG_INFO, \
LOG_WARNING, LOG_AUTH, LOG_DEBUG
+from conga_constants import LUCI_DEBUG_MODE, LUCI_DEBUG_VERBOSITY
+
# Exception class for the LuciSyslog facility
class LuciSyslogError(Exception):
def __init__(self, msg):
--- conga/luci/site/luci/Extensions/Attic/LuciZope.py 2007/05/14 18:00:14 1.1.2.3
+++ conga/luci/site/luci/Extensions/Attic/LuciZope.py 2007/05/15 21:42:21 1.1.2.4
@@ -1,11 +1,17 @@
-from AccessControl import getSecurityManager
-from ricci_communicator import CERTS_DIR_PATH
-from conga_constants import PLONE_ROOT
-from LuciDB import allowed_systems
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+from LuciZopePerm import userAuthenticated
+from LuciDB import allowed_systems
def siteIsSetup(self):
import os
+ from ricci_communicator import CERTS_DIR_PATH
+
try:
return os.path.isfile('%sprivkey.pem' % CERTS_DIR_PATH) and os.path.isfile('%scacert.pem' % CERTS_DIR_PATH)
except:
@@ -16,28 +22,6 @@
import re
return re.sub(regex, replaceChar, arg)
-def userAuthenticated(self):
- try:
- if (isAdmin(self) or getSecurityManager().getUser().has_role('Authenticated', self.restrictedTraverse(PLONE_ROOT))):
- return True
- except Exception, e:
- pass
- return False
-
-def isAdmin(self):
- try:
- return getSecurityManager().getUser().has_role('Owner', self.restrictedTraverse(PLONE_ROOT))
- except Exception, e:
- pass
- return False
-
-def userIsAdmin(self, userId):
- try:
- return self.portal_membership.getMemberById(userId).has_role('Owner', self.restrictedTraverse(PLONE_ROOT))
- except Exception, e:
- pass
- return False
-
# removes systems that user is not authorized access to
def get_systems_statuses(self, systems, from_cache=False):
from HelperFunctions import get_system_info
@@ -46,7 +30,7 @@
session = self.REQUEST.SESSION
if session.has_key(CACHED_INDEX):
res = session[CACHED_INDEX]
- if res != None:
+ if res is not None:
session.set(CACHED_INDEX, None)
if from_cache:
return res
@@ -73,12 +57,13 @@
value = request.cookies[cookie_prefix + var_name]
session.set(var_name, value)
- response.setCookie(cookie_prefix + var_name, value,
+ response.setCookie(cookie_prefix + var_name, value,
expires='Tue, 30 Jun 2060 12:00:00 GMT')
return value
# returns (str(float), units) that fits best,
# takes prefered units into account
+
def bytes_to_value_prefunits(self, bytes):
from HelperFunctions import bytes_to_value_units, convert_bytes, get_units_multiplier
--- conga/luci/site/luci/Extensions/PropsObject.py 2007/05/14 18:00:14 1.2.8.2
+++ conga/luci/site/luci/Extensions/PropsObject.py 2007/05/15 21:42:21 1.2.8.3
@@ -1,14 +1,20 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from Variable import parse_variable
from ricci_defines import PROPS_TAG
import xml
import xml.dom
-
class PropsObject:
-
+
def __init__(self):
self.__vars = {}
-
+
def add_prop(self, variable):
self.__vars[variable.get_name()] = variable
def get_prop(self, name):
@@ -16,24 +22,24 @@
return self.__vars[name].get_value()
else:
return None
-
+
def get_props(self):
return self.__vars
-
+
def export_xml(self, doc, parent_node):
props = doc.createElement(str(PROPS_TAG))
parent_node.appendChild(props)
for var in self.__vars:
props.appendChild(self.__vars[var].export_xml(doc))
return props
-
+
def import_xml(self, parent_node):
props = None
for node in parent_node.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == str(PROPS_TAG):
props = node
- if props == None:
+ if props is None:
return self
for node in props.childNodes:
try:
@@ -42,4 +48,4 @@
except:
continue
return self
-
+
--- conga/luci/site/luci/Extensions/Attic/ResourceHandler.py 2007/05/14 18:00:14 1.1.2.2
+++ conga/luci/site/luci/Extensions/Attic/ResourceHandler.py 2007/05/15 21:42:21 1.1.2.3
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ClusterModel.Ip import Ip
from ClusterModel.Fs import Fs
from ClusterModel.Clusterfs import Clusterfs
@@ -687,7 +694,7 @@
if form.has_key('edit'):
if not form.has_key('oldname'):
raise Exception, [ 'Cannot find this resource\'s original name.' ]
-
+
oldname = form['oldname'].strip()
if not oldname:
raise Exception, [ 'Cannot find this resource\'s original name.' ]
--- conga/luci/site/luci/Extensions/Attic/RicciQueries.py 2007/05/14 18:00:14 1.1.2.2
+++ conga/luci/site/luci/Extensions/Attic/RicciQueries.py 2007/05/15 21:42:21 1.1.2.3
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from xml.dom import minidom
from xml.dom.Node import ELEMENT_NODE
from ricci_communicator import RicciCommunicator, extract_module_status
@@ -54,7 +61,7 @@
upgrade_rpms,
gulm):
batch = list()
-
+
batch.append('<?xml version="1.0" ?>')
batch.append('<batch>')
batch.append('<module name="rpm">')
@@ -80,7 +87,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="service">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="disable">')
@@ -100,7 +107,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
need_reboot = install_base or install_services or install_shared_storage or install_LVS
if need_reboot:
batch.append('<module name="reboot">')
@@ -114,7 +121,7 @@
batch.append('<function_call name="install"/>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="cluster">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="set_cluster.conf">')
@@ -131,7 +138,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
if install_shared_storage:
batch.append('<module name="storage">')
batch.append('<request API_version="1.0">')
@@ -144,7 +151,7 @@
batch.append('<function_call name="install"/>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="cluster">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="start_node"/>')
@@ -168,7 +175,7 @@
batch = list()
batch.append('<?xml version="1.0" ?>')
batch.append('<batch>')
-
+
batch.append('<module name="rpm">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="install">')
@@ -195,7 +202,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="service">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="disable">')
@@ -215,7 +222,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
need_reboot = install_base or install_services or install_shared_storage or install_LVS
if need_reboot:
batch.append('<module name="reboot">')
@@ -229,7 +236,7 @@
batch.append('<function_call name="install"/>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="cluster">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="set_cluster.conf">')
@@ -264,7 +271,7 @@
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
-
+
if install_shared_storage:
batch.append('<module name="storage">')
batch.append('<request API_version="1.0">')
@@ -277,7 +284,7 @@
batch.append('<function_call name="install"/>')
batch.append('</request>')
batch.append('</module>')
-
+
batch.append('<module name="cluster">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="start_node">')
@@ -433,11 +440,11 @@
def nodeLeaveCluster(rc, cluster_shutdown=False, purge=False):
cshutdown = 'false'
- if cluster_shutdown == True:
+ if cluster_shutdown is True:
cshutdown = 'true'
purge_conf = 'true'
- if purge == False:
+ if purge is False:
purge_conf = 'false'
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="stop_node"><var mutable="false" name="cluster_shutdown" type="boolean" value="%s"/><var mutable="false" name="purge_conf" type="boolean" value="%s"/></function_call></request></module>' % (cshutdown, purge_conf)
@@ -453,7 +460,7 @@
def nodeJoinCluster(rc, cluster_startup=False):
cstartup = 'false'
- if cluster_startup == True:
+ if cluster_startup is True:
cstartup = 'true'
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="start_node"><var mutable="false" name="cluster_startup" type="boolean" value="%s"/></function_call></request></module>' % cstartup
@@ -462,7 +469,7 @@
return batchAttemptResult(ricci_xml)
def startService(rc, servicename, preferrednode=None):
- if preferrednode != None:
+ if preferrednode is not None:
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="start_service"><var mutable="false" name="servicename" type="string" value="%s"/><var mutable="false" name="nodename" type="string" value="%s"/></function_call></request></module>' % (servicename, preferrednode)
else:
batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="start_service"><var mutable="false" name="servicename" type="string" value="%s"/></function_call></request></module>' % servicename
@@ -543,7 +550,7 @@
return doc
batch_str = '<module name="service"><request API_version="1.0"><function_call name="%s"><var mutable="false" name="services" type="list_xml"><service name="%s"/></var></function_call></request></module>' % (svc_func, servicename)
-
+
ricci_xml = rc.batch_run(batch_str, async=False)
if not ricci_xml or not ricci_xml.firstChild:
elem.setAttribute('message', 'operation failed')
--- conga/luci/site/luci/Extensions/StorageReport.py 2007/05/04 19:10:24 1.23.2.2
+++ conga/luci/site/luci/Extensions/StorageReport.py 2007/05/15 21:42:21 1.23.2.3
@@ -1,18 +1,30 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
import xml
import xml.dom
from xml.dom import minidom
-
from Variable import parse_variable, Variable, VariableList
+
from ricci_defines import *
-from conga_storage_constants import *
-from HelperFunctions import *
-from LuciZope import bytes_to_value_prefunits, get_systems_statuses
+from conga_storage_constants import ADD_SOURCES, get_fs_icon, \
+ get_mapper_icons, get_pretty_fs_name, get_pretty_mapper_info, \
+ get_pretty_prop_name, PAGETYPE, PT_MAPPER_ID, PT_MAPPER_TYPE, \
+ PT_PATH, STONAME, STORAGE, VIEW_BD, VIEW_MAPPER
-from ricci_communicator import get_ricci_communicator, batch_status, extract_module_status
+from HelperFunctions import convert_bytes, \
+ get_units_multiplier, bytes_to_value_units
+from LuciZope import bytes_to_value_prefunits, get_systems_statuses
+
+from ricci_communicator import get_ricci_communicator, \
+ batch_status, extract_module_status
SESSION_STORAGE_XML_REPORT = 'storage_xml_report_dir'
@@ -20,11 +32,11 @@
class StorageReport:
-
+
def __init__(self, storage_xml_report):
#self.__report = minidom.parseString(storage_xml_report).firstChild
self.__report = storage_xml_report.cloneNode(True)
-
+
self.__mappers = None
self.__m_temps = None
for node in self.__report.childNodes:
@@ -36,16 +48,16 @@
self.__m_temps = var.get_value()
except:
pass
- if self.__mappers == None or self.__m_temps == None:
+ if self.__mappers is None or self.__m_temps is None:
raise Exception, 'invalid storage_xml_report'
-
+
self.__mapp_dir = {} # holds mapper lists by mapper_type
for mapp_node in self.__mappers:
m_type = mapp_node.getAttribute('mapper_type')
if not (m_type in self.__mapp_dir):
self.__mapp_dir[m_type] = []
self.__mapp_dir[m_type].append(mapp_node.cloneNode(True))
-
+
self.__m_temps_dir = {} # holds mapper_template lists by mapper_type
for temp_node in self.__m_temps:
m_type = temp_node.getAttribute('mapper_type')
@@ -53,15 +65,15 @@
self.__m_temps_dir[m_type] = []
self.__m_temps_dir[m_type].append(temp_node.cloneNode(True))
#
-
-
-
-
-
+
+
+
+
+
def get_xml_report(self):
return self.__report.cloneNode(True)
-
-
+
+
def get_mappers(self, type=''):
l = []
if type == '':
@@ -72,8 +84,8 @@
for s in l:
r.append(s.cloneNode(True))
return r
-
-
+
+
def get_mappers_dir(self):
r = {}
for type in self.__mapp_dir:
@@ -82,8 +94,8 @@
l.append(m.cloneNode(True))
r[type] = l
return r
-
-
+
+
def get_mapper(self, id):
if id == '':
raise Exception, 'empty mapper_id!!!'
@@ -91,8 +103,8 @@
if m.getAttribute('mapper_id') == id:
return m.cloneNode(True)
return None
-
-
+
+
def get_mapper_temps_dir(self):
r = {}
for type in self.__m_temps_dir:
@@ -101,8 +113,8 @@
l.append(m.cloneNode(True))
r[type] = l
return r
-
-
+
+
def get_mapper_temps(self, type=''):
l = []
if type == '':
@@ -113,12 +125,12 @@
for s in l:
r.append(s.cloneNode(True))
return r
-
-
+
+
def get_targets(self, mapper):
- if mapper == None:
+ if mapper is None:
return []
-
+
targets_list = []
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -129,12 +141,12 @@
if node.nodeName == BD_TYPE:
targets_list.append(node.cloneNode(True))
return targets_list
-
-
+
+
def get_new_targets(self, mapper):
- if mapper == None:
+ if mapper is None:
return []
-
+
targets_list = []
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -145,12 +157,12 @@
if node.nodeName == BD_TEMPLATE:
targets_list.append(node.cloneNode(True))
return targets_list
-
-
+
+
def get_sources(self, mapper):
- if mapper == None:
+ if mapper is None:
return []
-
+
targets_list = []
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -161,12 +173,12 @@
if node.nodeName == BD_TYPE:
targets_list.append(node.cloneNode(True))
return targets_list
-
-
+
+
def get_new_sources(self, mapper):
- if mapper == None:
+ if mapper is None:
return []
-
+
targets_list = []
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -177,39 +189,38 @@
if node.nodeName == BD_TYPE:
targets_list.append(node.cloneNode(True))
return targets_list
-
-
+
+
def get_mapper_props(self, mapper):
- if mapper == None:
+ if mapper is None:
return None
-
+
props = None
for node in mapper.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == PROPS_TAG:
props = node.cloneNode(True)
- if props == None:
+ if props is None:
raise Exception, 'mapper missing properties tag'
return props
-
-
+
+
def get_target(self, mapper_id, path):
mapper = self.get_mapper(mapper_id)
- if mapper == None:
+ if mapper is None:
return None
-
+
targets = self.get_targets(mapper)
for t_xml in targets:
if t_xml.getAttribute('path') == path:
return t_xml.cloneNode(True)
return None
-
-
+
def is_storage_report_cached(session, storagename):
if session.has_key(SESSION_STORAGE_XML_REPORT):
reports_dir = session[SESSION_STORAGE_XML_REPORT]
if reports_dir.has_key(storagename):
- if reports_dir[storagename] != None:
+ if reports_dir[storagename] is not None:
return True
return False
@@ -221,12 +232,10 @@
session.set(SESSION_STORAGE_XML_REPORT, reports_dir)
return
-
-def cache_storage_report(ricci_comm,
- session):
+def cache_storage_report(ricci_comm, session):
try:
rep = get_storage_report(ricci_comm, session)
- if rep == None:
+ if rep is None:
raise Exception, 'Unable to communicate with host (either system down or ricci not running on it)'
else:
return True
@@ -240,32 +249,32 @@
session):
#print 'get_storage_report()'
#print ricci_comm, session
-
- if ricci_comm == None:
+
+ if ricci_comm is None:
return None
-
+
storagename = ricci_comm.hostname()
-
+
# setup cache, if not already set up
if not session.has_key(SESSION_STORAGE_XML_REPORT):
session.set(SESSION_STORAGE_XML_REPORT, {})
# return cached report if existing
if session[SESSION_STORAGE_XML_REPORT].has_key(storagename):
tmp_report = session[SESSION_STORAGE_XML_REPORT][storagename]
- if tmp_report != None:
+ if tmp_report is not None:
print 'using cached storage_xml_report'
return StorageReport(tmp_report)
-
-
+
+
# retrieve storage report using ricci
print 'retrieving new storage_xml_report'
-
+
#print ricci_comm.authenticated()
#print ricci_comm.cluster_info()
print ricci_comm.hostname()
print ricci_comm.os()
-
-
+
+
# request
doc = minidom.Document()
batch = doc.createElement('batch')
@@ -278,7 +287,7 @@
batch.appendChild(module)
module.appendChild(request)
request.appendChild(function)
-
+
# get report
batch_r = ricci_comm.process_batch(batch)
if batch_r.getAttribute('status') != '0':
@@ -290,7 +299,7 @@
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'module':
module_r = node
- if module_r == None:
+ if module_r is None:
raise Exception, 'malformed response: missing <module/> in <batch/>'
module_r_status = module_r.getAttribute('status')
if module_r_status != '0':
@@ -302,14 +311,14 @@
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'response':
resp_r = node
- if resp_r == None:
+ if resp_r is None:
raise Exception, 'malformed response: missing <response/> in <module/>'
fr_r = None
for node in resp_r.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'function_response':
fr_r = node
- if fr_r == None:
+ if fr_r is None:
raise Exception, 'malformed response: missing <function_response/> in <response/>'
succ_v = None
err_code_v = None
@@ -325,23 +334,23 @@
err_desc_v = var
except:
pass
- if succ_v == None:
+ if succ_v is None:
raise Exception, 'malformed response: missing "success" variable in <function_response/>'
- if succ_v.get_value() != True:
+ if succ_v.get_value() is not True:
# error
if err_code_v.get_value() == -1:
raise Exception, 'Generic error on host:\n\n%s' % err_desc_v.get_value()
else:
raise Exception, 'Host responded: %s' % err_desc_v.get_value()
-
+
#xml_report = fr_r.toxml()
xml_report = fr_r
-
+
# cache xml_report
reports_dir = session[SESSION_STORAGE_XML_REPORT]
reports_dir[storagename] = xml_report
session.set(SESSION_STORAGE_XML_REPORT, reports_dir)
-
+
return StorageReport(xml_report)
@@ -357,13 +366,13 @@
def get_bd_data(self, storage_report, mapper_id, path):
- if storage_report == None or mapper_id == None:
+ if storage_report is None or mapper_id is None:
return None
-
+
mapper = get_mapper_data(self, storage_report, mapper_id)
- if mapper == None:
+ if mapper is None:
return None
-
+
for t in mapper['targets']:
if t['path'] == path:
return t
@@ -394,7 +403,7 @@
ret_dir[mapp_type] = {}
ret_dir[mapp_type]['mappers'] = []
ret_dir[mapp_type]['mapper_template'] = get_mapper_template_data(self, storage_report, mapp_type)
-
+
# pretty stuff
for mapp_type in ret_dir:
info = ret_dir[mapp_type]
@@ -408,23 +417,23 @@
info['pretty_targets_name'] = info_source['pretty_targets_name']
info['pretty_source_name'] = info_source['pretty_source_name']
info['pretty_sources_name'] = info_source['pretty_sources_name']
-
+
return ret_dir
def get_mapper_data(self, storage_report, mapper_id):
- if self == None or storage_report == None or mapper_id == None:
+ if self is None or storage_report is None or mapper_id is None:
return None
-
+
session = self.REQUEST.SESSION
-
+
mapper = storage_report.get_mapper(mapper_id)
- if mapper == None:
+ if mapper is None:
return None
-
+
removable, props = get_props_data_internal(session, mapper)
-
+
new_targets = []
for t_xml in storage_report.get_new_targets(mapper):
new_targets.append(get_bd_data_internal(session, t_xml, mapper))
@@ -437,7 +446,7 @@
sources = []
for s_xml in storage_report.get_sources(mapper):
sources.append(get_bd_data_internal(session, s_xml, mapper))
-
+
type = mapper.getAttribute('mapper_type')
pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(type)
pretty_name = mapper_id.replace('%s:' % type, '').replace('/dev/', '')
@@ -445,7 +454,7 @@
pretty_sources_name = '%ss' % pretty_source_name
icon_name, dummy1, dummy2 = get_mapper_icons(type)
color = 'black'
-
+
mapper_ret = {}
mapper_ret['pretty_type'] = pretty_type
mapper_ret['pretty_name'] = pretty_name
@@ -464,9 +473,9 @@
mapper_ret['icon'] = icon_name
mapper_ret['color'] = color
mapper_ret['xml'] = mapper.cloneNode(True)
-
+
assemble_all_targets(mapper_ret)
-
+
actions = []
if removable:
action = {'name' : 'Remove',
@@ -474,7 +483,7 @@
'link' : ''}
actions.append(action)
if type == MAPPER_VG_TYPE or type == MAPPER_MDRAID_TYPE or type == MAPPER_ATARAID_TYPE or type == MAPPER_MULTIPATH_TYPE:
- action = {'name' : 'Add %s' % mapper_ret['pretty_sources_name'],
+ action = {'name' : 'Add %s' % mapper_ret['pretty_sources_name'],
'msg' : '',
'link' : './?%s=%s&%s=%s&%s=%s' % (PAGETYPE, ADD_SOURCES, PT_MAPPER_ID, mapper_ret['mapper_id'], PT_MAPPER_TYPE, mapper_ret['mapper_type'])}
actions.append(action)
@@ -482,7 +491,7 @@
for nt in mapper_ret['new_targets']:
if nt['props']['snapshot']['value'] == 'false':
if nt['new']:
- action = {'name' : 'New %s' % mapper_ret['pretty_target_name'],
+ action = {'name' : 'New %s' % mapper_ret['pretty_target_name'],
'msg' : '',
'link' : './?%s=%s&%s=%s&%s=%s&%s=%s' \
% (PAGETYPE, VIEW_BD,
@@ -492,10 +501,10 @@
actions.append(action)
break
mapper_ret['actions'] = actions
-
+
if type == MAPPER_VG_TYPE:
link_snapshots(mapper_ret)
-
+
# cylinders work properly for VGs only, for now
mapper_ret['graphical_view'] = type != MAPPER_PT_TYPE
if mapper_ret['graphical_view']:
@@ -504,9 +513,9 @@
else:
mapper_ret['mappings-view_css_classnames'] = {'graphical_view' : 'invisible',
'textual_view' : 'visible'}
-
+
mapper_ret['need_apply_button'] = mutable_props(mapper_ret['props'])
-
+
return mapper_ret
@@ -517,7 +526,7 @@
orig_name = snap['props']['snapshot_origin']['value']
snap['description'] = '%s, %s\'s Snapshot' \
% (snap['description'], orig_name)
-
+
# find origin
for t in mapper['targets']:
if t['pretty_name'] == orig_name:
@@ -532,7 +541,7 @@
def assemble_all_targets(mapper_data):
mdata = mapper_data
targets_all = []
-
+
if mdata['mapper_type'] == MAPPER_VG_TYPE:
for t in mdata['targets']:
targets_all.append(t)
@@ -563,9 +572,9 @@
for t in mdata['new_targets']:
if t['props']['partition_type']['value'] != 'extended':
targets_all.append(t)
-
+
# TODO: place logical into extended
-
+
# sort partitions
sorted = []
while len(targets_all) != 0:
@@ -588,26 +597,26 @@
targets_all.append(t)
for t in mdata['new_targets']:
targets_all.append(t)
-
+
mdata['targets_all'] = targets_all
-
+
def get_mapper_template_data(self, storage_report, mapper_type):
- if self == None or storage_report == None or mapper_type == None:
+ if self is None or storage_report is None or mapper_type is None:
return None
-
+
session = self.REQUEST.SESSION
-
+
mapper_id = ''
-
+
templ_xml_list = storage_report.get_mapper_temps(mapper_type)
mapper = None
if len(templ_xml_list) != 0:
mapper = templ_xml_list[0]
- if mapper == None:
+ if mapper is None:
return None
-
+
removable, props = get_props_data_internal(session, mapper)
-
+
new_targets = []
for t_xml in storage_report.get_new_targets(mapper):
new_targets.append(get_bd_data_internal(session, t_xml, mapper))
@@ -620,7 +629,7 @@
sources = []
for s_xml in storage_report.get_sources(mapper):
sources.append(get_bd_data_internal(session, s_xml, mapper))
-
+
type = mapper.getAttribute('mapper_type')
pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(type)
pretty_name = mapper_id.replace('%s:' % type, '').replace('/dev/', '')
@@ -628,7 +637,7 @@
pretty_sources_name = '%ss' % pretty_source_name
icon_name, dummy1, dummy2 = get_mapper_icons(type)
color = 'black'
-
+
min_sources = '0'
max_sources = '0'
new_props = {}
@@ -640,7 +649,7 @@
else:
new_props[name] = props[name]
props = new_props
-
+
mapper_ret = {}
mapper_ret['pretty_type'] = pretty_type
mapper_ret['pretty_name'] = pretty_name
@@ -662,9 +671,9 @@
mapper_ret['icon'] = icon_name
mapper_ret['color'] = color
mapper_ret['xml'] = mapper.cloneNode(True)
-
+
mapper_ret['actions'] = []
-
+
mapper_ret['need_apply_button'] = True
return mapper_ret
@@ -680,13 +689,13 @@
#return 'size has to be within limits'
#return request
#return 'OK'
-
+
object_type = request['object_type']
mapper_id = request['mapper_id']
-
+
props = None
content_props = None
-
+
if object_type == 'bd' or object_type == 'bd_template':
path = request[PT_PATH]
bd_data = get_bd_data(self, storage_report, mapper_id, path)
@@ -721,22 +730,22 @@
if sources_num == 0 or sources_num > len(data['new_sources']):
return 'BAD: Invalid number of %s selected' % data['pretty_sources_name']
- if props != None:
+ if props is not None:
res = check_props(self, props, request)
- if res[0] == False:
+ if res[0] is False:
return '%s %s' % (res[1], res[2])
-
- if content_props != None:
+
+ if content_props is not None:
res = check_props(self, content_props, request)
- if res[0] == False:
+ if res[0] is False:
return '%s %s' % (res[1], res[2])
-
+
return 'OK'
def check_props(self, props, request):
valid = True
var_name = ''
msg = 'no message - BUG :('
-
+
for prop_name in props:
if prop_name in request:
prop = props[prop_name]
@@ -806,7 +815,7 @@
var_name = prop_name
valid = False
break
-
+
return [valid, var_name, msg]
@@ -814,11 +823,11 @@
def apply(self, ricci, storage_report, request):
if validate(self, storage_report, request) != 'OK':
raise Exception, 'Internal error: input not validated!!!'
-
+
session = request.SESSION
-
+
storagename = request['storagename']
-
+
object_type = request['object_type']
mapper_id = request[PT_MAPPER_ID]
mapper_type = request[PT_MAPPER_TYPE]
@@ -826,14 +835,14 @@
path = ''
if request.has_key(PT_PATH):
path = request[PT_PATH]
-
-
+
+
batch_id = ''
-
+
if object_type == 'bd':
bd_data = get_bd_data(self, storage_report, mapper_id, path)
bd_xml = bd_data['xml'].cloneNode(True)
-
+
if action_type == 'Remove':
doc = minidom.Document()
batch = doc.createElement("batch")
@@ -845,15 +854,15 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'remove_bd')
f_call.appendChild(Variable('bd', bd_xml.cloneNode(True)).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
elif action_type == 'Apply':
# BD props
props_xml = None
@@ -888,7 +897,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[var_name])
-
+
# content
content_data_list = get_content_data_internal(session, bd_xml)
current_content_id = content_data_list[0]['id']
@@ -899,7 +908,7 @@
if c_data['id'] == selected_content_id:
selected_content_data = c_data
selected_content = c_data['xml'].cloneNode(True)
-
+
# update selected_content props
props_xml = None
for node in selected_content.childNodes:
@@ -934,7 +943,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[req_name])
-
+
if current_content_id == selected_content_id:
# no change of content
# replace content_xml
@@ -966,21 +975,21 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'modify_bd')
f_call.appendChild(Variable('bd', bd_xml).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
elif object_type == 'bd_template':
path = request[PT_PATH]
bd_data = get_bd_data(self, storage_report, mapper_id, path)
bd_xml = bd_data['xml'].cloneNode(True)
#return bd_xml.toprettyxml()
-
+
if action_type == 'Apply': # Create
# BD props
props_xml = None
@@ -1015,7 +1024,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[var_name])
-
+
if path != 'new_snapshot':
# content
content_data_list = get_content_data_internal(session, bd_xml)
@@ -1027,7 +1036,7 @@
if c_data['id'] == selected_content_id:
selected_content_data = c_data
selected_content = c_data['xml'].cloneNode(True)
-
+
# update selected_content props
props_xml = None
for node in selected_content.childNodes:
@@ -1062,7 +1071,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[req_name])
-
+
if current_content_id == selected_content_id:
# no change of content
# replace content_xml
@@ -1094,21 +1103,21 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'create_bd')
f_call.appendChild(Variable('bd', bd_xml).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
-
+
+
+
elif object_type == 'mapper':
mapper_data = get_mapper_data(self, storage_report, mapper_id)
mapper_xml = mapper_data['xml'].cloneNode(True)
#return mapper_xml.toprettyxml()
-
+
if action_type == 'Remove':
doc = minidom.Document()
batch = doc.createElement("batch")
@@ -1120,15 +1129,15 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'remove_mapper')
f_call.appendChild(Variable('mapper', mapper_xml).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
elif action_type == 'Apply':
# props
props_xml = None
@@ -1174,21 +1183,21 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'modify_mapper')
f_call.appendChild(Variable('mapper', mapper_xml).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
elif object_type == 'mapper_template':
mapper_data = get_mapper_template_data(self, storage_report, mapper_type)
mapper_xml = mapper_data['xml'].cloneNode(True)
#return mapper_xml.toprettyxml()
-
+
if action_type == 'Apply':
# props
props_xml = None
@@ -1223,7 +1232,7 @@
node.setAttribute('value', str(val))
else:
node.setAttribute('value', request[var_name])
-
+
# find sources
for v in request.keys():
if v.find('source_bd_') == 0:
@@ -1246,23 +1255,23 @@
f_call = doc.createElement("function_call")
f_call.setAttribute('name', 'create_mapper')
f_call.appendChild(Variable('mapper', mapper_xml.cloneNode(True)).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
-
-
+
+
+
+
elif object_type == 'add_sources':
mapper_data = get_mapper_data(self, storage_report, mapper_id)
mapper_xml = mapper_data['xml'].cloneNode(True)
new_sources = []
#return mapper_xml.toprettyxml()
-
+
if action_type == 'Apply':
# find sources
for v in request.keys():
@@ -1286,15 +1295,15 @@
f_call.appendChild(Variable('mapper_id', mapper_id).export_xml(doc))
f_call.appendChild(Variable('mapper_state_ind', mapper_xml.getAttribute('state_ind')).export_xml(doc))
f_call.appendChild(VariableList('bds', new_sources, [], VARIABLE_TYPE_LIST_XML).export_xml(doc))
-
+
req.appendChild(f_call)
module.appendChild(req)
batch.appendChild(module)
-
+
res = ricci.process_batch(batch, True)
batch_id = res.getAttribute('batch_id')
-
-
+
+
if batch_id == '':
raise Exception, 'unsupported function'
else:
@@ -1302,17 +1311,17 @@
return batch_id
-def get_storage_batch_result(self,
- storagename,
- ricci,
- index_html_URL,
+def get_storage_batch_result(self,
+ storagename,
+ ricci,
+ index_html_URL,
batch_id):
error = True # ricci reported failure or no ricci
completed = False # no batch, or batch done (defined if no error)
url = index_html_URL # redirect URL
msg = 'Unknown error occured'
-
- if ricci == None:
+
+ if ricci is None:
# ricci down
error = True
url = url
@@ -1327,7 +1336,7 @@
error = True
url = url
msg = 'Ricci on %s responded with error. No detailed info available.' % storagename
- elif batch == None:
+ elif batch is None:
# no such batch
error = False
completed = True
@@ -1431,7 +1440,7 @@
url = '%s?%s=%s&%s=%s' \
% (index_html_URL, STONAME, storagename, PAGETYPE, STORAGE)
msg = err_msg
-
+
return {'error' : error,
'completed' : completed,
'redirect_url' : url,
@@ -1445,29 +1454,29 @@
-def get_commit_redirect(main_url,
- storagename,
+def get_commit_redirect(main_url,
+ storagename,
batch_xml):
module_r = None
for node in batch_xml.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'module':
module_r = node
- if module_r == None:
+ if module_r is None:
raise Exception, 'missing <module/> in <batch/>'
resp_r = None
for node in module_r.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == RESPONSE_TAG:
resp_r = node
- if resp_r == None:
+ if resp_r is None:
raise Exception, 'missing <response/> in <module/>'
fr_r = None
for node in resp_r.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == FUNC_RESP_TAG:
fr_r = node
- if fr_r == None:
+ if fr_r is None:
raise Exception, 'missing <function_response/> in <response/>'
vars = {}
for node in fr_r.childNodes:
@@ -1476,8 +1485,8 @@
vars[var.get_name()] = var
except:
pass
-
-
+
+
mapper_id = ''
mapper_type = ''
bd_path = ''
@@ -1499,7 +1508,7 @@
url_list.append('&%s=%s' % (PT_MAPPER_ID, mapper_id))
if bd_path != '':
url_list.append('&%s=%s' % (PT_PATH, bd_path))
-
+
if mapper_type == '':
url_list.append('&%s=%s' % (PAGETYPE, STORAGE))
elif bd_path != '':
@@ -1512,19 +1521,19 @@
def get_bd_data_internal(session, bd_xml, mapper_xml):
data = {}
-
+
removable, props = get_props_data_internal(session, bd_xml)
-
+
path = bd_xml.getAttribute('path')
mapper_type = bd_xml.getAttribute('mapper_type')
mapper_id = bd_xml.getAttribute('mapper_id')
contents = get_content_data_internal(session, bd_xml)
-
+
pretty_mapper_type, pretty_type, dummy2 = get_pretty_mapper_info(mapper_type)
pretty_name = path.replace('/dev/','')
dummy1, icon_name, dummy2 = get_mapper_icons(mapper_type)
color = 'black'
-
+
size_in_units, units = bytes_to_value_units(props['size']['value'])
description = None
@@ -1542,7 +1551,7 @@
if description is None:
description = '%s %s' % (size_in_units, units)
-
+
if bd_xml.nodeName == BD_TEMPLATE:
if mapper_type == MAPPER_PT_TYPE:
path = 'unused_segment_%s_%s' \
@@ -1560,7 +1569,7 @@
contents = []
path = 'new_snapshot'
pretty_name = ''
-
+
data['pretty_mapper_type'] = pretty_mapper_type
data['pretty_type'] = pretty_type
data['pretty_name'] = pretty_name
@@ -1574,7 +1583,7 @@
data['icon'] = icon_name
data['color'] = color
data['xml'] = bd_xml.cloneNode(True)
-
+
actions = []
if removable:
action = {'name' : 'Remove',
@@ -1593,12 +1602,12 @@
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == BD_TEMPLATE:
snap_lv = get_bd_data_internal(session, node, mapper_xml)
- if snap_lv != None:
+ if snap_lv is not None:
if snap_lv['props']['snapshot']['value'] == 'true':
origs = snap_lv['props']['snapshot_origin']['value']
if pretty_name in origs:
action = {'name' : 'Take Snapshot',
- 'msg' : '',
+ 'msg' : '',
'link' : './?%s=%s&%s=%s&%s=%s&%s=%s' \
% (PAGETYPE, VIEW_BD, \
PT_MAPPER_ID, data['mapper_id'], \
@@ -1606,9 +1615,9 @@
PT_PATH, snap_lv['path'])}
actions.append(action)
data['actions'] = actions
-
+
need_apply_butt = mutable_props(data['props'])
- if need_apply_butt == False:
+ if need_apply_butt is False:
if len(data['contents']) > 1:
need_apply_butt = True
elif len(data['contents']) == 1:
@@ -1616,15 +1625,15 @@
else:
need_apply_butt = False
data['need_apply_button'] = need_apply_butt
-
+
return data
def get_props_data_internal(session, xml_tag):
data = {}
removable = False
-
-
+
+
props_xml = None
for node in xml_tag.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -1641,13 +1650,13 @@
mutable = var.getAttribute('mutable') == 'true'
type = var.getAttribute('type')
value = var.getAttribute('value')
-
+
d_units = ''
if name in ['size', 'extent_size', 'block_size', 'size_free', 'partition_begin']:
d_units = 'bytes'
if 'percent' in name:
d_units = '%'
-
+
validation_data = {}
if type == VARIABLE_TYPE_INT:
d_type = 'int'
@@ -1699,15 +1708,15 @@
else:
d_type = 'label'
d_value = value
-
+
if not mutable and d_type != 'label' and d_type != 'hidden':
d_type = 'label'
d_value = str(value)
-
+
hidden = False
if type == 'hidden' or name in ['partition_begin', 'snapshot']:
hidden = True
-
+
if name == 'removable':
removable = value == 'true'
elif name == 'path':
@@ -1720,7 +1729,7 @@
'units' : d_units,
'validation' : validation_data,
'hidden' : hidden}
-
+
return (removable, data)
@@ -1749,7 +1758,7 @@
uuids.append(prop)
else:
rest.append(prop)
-
+
ordered = []
for prop in names:
ordered.append(prop)
@@ -1783,9 +1792,9 @@
if node.nodeName == CONTENT_TYPE:
c_xml = node
break
- if c_xml == None:
+ if c_xml is None:
return {}
-
+
a_xmls = []
for node in c_xml.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -1796,7 +1805,7 @@
if node.nodeName == "content_template":
a_xmls.append(node)
break
-
+
current = {}
removable, props = get_props_data_internal(session, c_xml)
current['props'] = props
@@ -1804,7 +1813,7 @@
current['name'] = name
current['id'] = id
current['xml'] = c_xml.cloneNode(True)
-
+
data = [current]
for a_xml in a_xmls:
available = {}
@@ -1814,9 +1823,9 @@
available['name'] = name
available['id'] = id
available['xml'] = a_xml.cloneNode(True)
-
+
data.append(available)
-
+
for d in data:
old_props = d['props']
new_props = {}
@@ -1827,7 +1836,7 @@
d['props'] = new_props
d['props_ordered'] = get_ordered_props(new_props)
d['is_source'] = False
-
+
# content's color and icon
color = 'black'
icon_name = ''
@@ -1849,10 +1858,10 @@
pass
elif type == 'hidden':
pass
-
+
d['color'] = color
d['icon'] = icon_name
-
+
return data
@@ -1892,7 +1901,7 @@
name = 'Extended Partition'
else:
name = "Unknown type"
-
+
return name, id
@@ -1916,12 +1925,12 @@
nonclu_list = clusters[cluname]
else:
cl = {'name' : cluname,
- 'alias' : clusters[cluname][0]['clualias'],
+ 'alias' : clusters[cluname][0]['clualias'],
'nodes' : clusters[cluname]}
clu_list.append(cl)
-
+
ret = [nonclu_list, clu_list, bad_list]
-
+
return ret
@@ -1932,18 +1941,18 @@
length):
# highlights
high_list = {}
-
+
# upper cyl
upper_cyl = {'offset' : 0,
'cyls' : [],
'highs' : [],
'js' : [],
- 'color' : 'blue',
- 'color_css' : '#0192db',
+ 'color' : 'blue',
+ 'color_css' : '#0192db',
'description': mapper_data['pretty_targets_name']}
if mapper_data['mapper_type'] == MAPPER_PT_TYPE:
upper_cyl['description'] = 'Physical %s' % upper_cyl['description']
-
+
offset = 0
for t in mapper_data['targets_all']:
if t['mapper_type'] == MAPPER_PT_TYPE:
@@ -1964,34 +1973,34 @@
data['color_css'] = 'black'
upper_cyl['cyls'].append(data)
offset = end
-
+
# scale ranges
for d in upper_cyl['cyls']:
d['beg'] = d['beg'] * length / offset
d['end'] = d['end'] * length / offset - 1
-
+
# build highlights
for d in upper_cyl['cyls']:
h_id = '%s_selected' % d['id']
beg = d['beg']
end = d['end']
- upper_cyl['highs'].append({'beg' : beg,
- 'end' : end,
+ upper_cyl['highs'].append({'beg' : beg,
+ 'end' : end,
'id' : h_id,
'type' : 'select'})
upper_cyl['js'].append([d['id'],
[beg, end],
d['bd']['pretty_name']])
high_list[d['id']] = [h_id]
-
+
# snapshots
bd = d['bd']
if bd['mapper_type'] == MAPPER_VG_TYPE and not bd['new']:
if 'origin' in bd:
# snapshot
snap_id = '%s_snapshot' % bd['path']
- upper_cyl['highs'].append({'beg' : beg,
- 'end' : end,
+ upper_cyl['highs'].append({'beg' : beg,
+ 'end' : end,
'id' : snap_id,
'type' : 'snapshot'})
orig = bd['origin']
@@ -1999,26 +2008,26 @@
high_list[d['id']].append(snap_id)
if 'snapshots' in bd:
# origin
- upper_cyl['highs'].append({'beg' : beg,
- 'end' : end,
+ upper_cyl['highs'].append({'beg' : beg,
+ 'end' : end,
'id' : '%s_origin' % bd['path'],
'type' : 'snapshot-origin'})
for snap in bd['snapshots']:
high_list[d['id']].append('%s_snapshot', snap['path'])
-
-
-
+
+
+
upper_cyl['js'] = str(upper_cyl['js']).replace('L,', ',').replace('L]', ']').replace('u\'', '\'').replace('L]', ']')
-
+
# lower cylinder
lower_cyl = {'offset' : 0,
'cyls' : [],
'highs' : [],
'js' : [],
- 'color' : 'red',
- 'color_css' : '#a43737',
+ 'color' : 'red',
+ 'color_css' : '#a43737',
'description': mapper_data['pretty_sources_name']}
-
+
offset = 0
for t in mapper_data['sources']:
data = {}
@@ -2032,14 +2041,14 @@
data['color_css'] = '#a43737'
lower_cyl['cyls'].append(data)
offset = end
-
+
if mapper_data['mapper_type'] == MAPPER_PT_TYPE:
lower_cyl['description'] = 'Logical %s' % mapper_data['pretty_targets_name']
lower_cyl['cyls'] = []
lower_cyl['color'] = 'blue'
lower_cyl['color_css'] = '#0192db'
lower_cyl['offset'] = 9999999999999999999999999
-
+
offset = 0
for t in mapper_data['targets_all']:
if t['props']['partition_type']['value'] != 'logical':
@@ -2058,8 +2067,8 @@
data['color_css'] = '#0192db'
lower_cyl['cyls'].append(data)
offset = end
-
-
+
+
# scale ranges
length_in_bytes = 0
for t in mapper_data['sources']:
@@ -2069,16 +2078,16 @@
for d in lower_cyl['cyls']:
d['beg'] = int(d['beg'] * ppb)
d['end'] = int(d['end'] * ppb - 1)
-
-
-
+
+
+
# build highlights
for d in lower_cyl['cyls']:
h_id = '%s_selected' % d['id']
beg = d['beg']
end = d['end']
- lower_cyl['highs'].append({'beg' : beg,
- 'end' : end,
+ lower_cyl['highs'].append({'beg' : beg,
+ 'end' : end,
'id' : h_id,
'type' : 'select'})
lower_cyl['js'].append([d['id'],
@@ -2086,20 +2095,20 @@
d['bd']['pretty_name']])
high_list[d['id']] = [h_id]
lower_cyl['js'] = str(lower_cyl['js']).replace('L,', ',').replace('L]', ']').replace('u\'', '\'').replace('L]', ']')
-
+
# transform list of highlights
high_list_js = [[mapper_data['mapper_id'], []]]
for id in high_list:
high_list_js.append([id, high_list[id]])
high_list_js = str(high_list_js).replace('L,', ',').replace('L]', ']').replace('u\'', '\'').replace('L]', ']')
-
+
# put everything together
ret = {}
ret['mapper'] = mapper_data
ret['upper_cyl'] = upper_cyl
ret['lower_cyl'] = lower_cyl
ret['js'] = high_list_js
-
+
return ret
--- conga/luci/site/luci/Extensions/Variable.py 2007/05/04 19:10:24 1.4.8.2
+++ conga/luci/site/luci/Extensions/Variable.py 2007/05/15 21:42:21 1.4.8.3
@@ -1,13 +1,24 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
import xml.dom
-from ricci_defines import VARIABLE_TAG, VARIABLE_TYPE_BOOL, VARIABLE_TYPE_FLOAT, VARIABLE_TYPE_INT, VARIABLE_TYPE_INT_SEL, VARIABLE_TYPE_LISTENTRY, VARIABLE_TYPE_LIST_INT, VARIABLE_TYPE_LIST_STR, VARIABLE_TYPE_LIST_XML, VARIABLE_TYPE_STRING, VARIABLE_TYPE_STRING_SEL, VARIABLE_TYPE_XML
+from ricci_defines import VARIABLE_TAG, VARIABLE_TYPE_BOOL, \
+ VARIABLE_TYPE_FLOAT, VARIABLE_TYPE_INT, VARIABLE_TYPE_INT_SEL, \
+ VARIABLE_TYPE_LISTENTRY, VARIABLE_TYPE_LIST_INT, \
+ VARIABLE_TYPE_LIST_STR, VARIABLE_TYPE_LIST_XML, VARIABLE_TYPE_STRING, \
+ VARIABLE_TYPE_STRING_SEL, VARIABLE_TYPE_XML
def parse_variable(node):
if node.nodeType != xml.dom.Node.ELEMENT_NODE:
raise Exception, 'not a variable'
if node.nodeName != str(VARIABLE_TAG):
raise Exception, 'not a variable'
-
+
attrs_dir = {}
attrs = node.attributes
for attrName in attrs.keys():
@@ -18,12 +29,12 @@
raise Exception, 'incomplete variable'
if (attrs_dir['type'] != VARIABLE_TYPE_LIST_INT and attrs_dir['type'] != VARIABLE_TYPE_LIST_STR and attrs_dir['type'] != VARIABLE_TYPE_LIST_XML and attrs_dir['type'] != VARIABLE_TYPE_XML) and ('value' not in attrs_dir):
raise Exception, 'incomplete variable'
-
+
mods = {}
for mod in attrs_dir:
if mod not in ['name', 'value', 'type']:
mods[mod] = attrs_dir[mod]
-
+
value = ''
if attrs_dir['type'] == VARIABLE_TYPE_LIST_STR:
value = []
@@ -38,7 +49,7 @@
v = attrValue
else:
continue
- if v == None:
+ if v is None:
raise Exception, 'invalid listentry'
value.append(v)
return VariableList(attrs_dir['name'], value, mods, VARIABLE_TYPE_LIST_STR)
@@ -71,7 +82,7 @@
value = (attrs_dir['value'] == 'true')
else:
raise Exception, 'invalid variable'
-
+
return Variable(attrs_dir['name'], value, mods)
@@ -84,7 +95,7 @@
def get_name(self):
return self.__name
-
+
def get_value(self):
return self.__value
@@ -92,15 +103,15 @@
if self.__is_bool(value):
self.__type = VARIABLE_TYPE_BOOL
self.__value = value
-
+
elif self.__is_int(value):
self.__type = VARIABLE_TYPE_INT
self.__value = int(value)
-
+
elif self.__is_float(value):
self.__type = VARIABLE_TYPE_FLOAT
self.__value = float(value)
-
+
elif self.__is_list(value):
raise Exception, "lists not implemented"
if self.__is_int(value[0]):
@@ -114,11 +125,11 @@
elif self.__is_xml(value):
self.__type = VARIABLE_TYPE_XML
self.__value = value
-
+
else:
self.__value = str(value)
self.__type = VARIABLE_TYPE_STRING
-
+
def type(self):
if 'valid_values' in self.__mods:
if self.__type == VARIABLE_TYPE_INT:
@@ -126,13 +137,13 @@
elif self.__type == VARIABLE_TYPE_STRING:
return VARIABLE_TYPE_STRING_SEL
return self.__type
-
+
def get_modifiers(self):
return self.__mods
def set_modifier(self, mod_name, mod_value):
self.__mods[mod_name] = mod_value
return
-
+
def export_xml(self, doc):
elem = doc.createElement(VARIABLE_TAG)
elem.setAttribute('name', self.__name)
@@ -178,10 +189,10 @@
return VARIABLE_TYPE_XML
else:
return VARIABLE_TYPE_STRING
-
-
-
-
+
+
+
+
def __is_xml(self, value):
try:
value.toxml()
@@ -220,8 +231,8 @@
except:
pass
return False
-
-
+
+
class VariableList(Variable):
def __init__(self, name, value, mods, list_type):
Variable.__init__(name, value, mods=mods)
@@ -233,29 +244,29 @@
self.__mods = mods
self.__type = list_type
self.__value = value
-
+
def get_name(self):
return self.__name
-
+
def get_value(self):
return self.__value
def set_value(self, value):
raise Exception, 'VariableList.set_value() not implemented'
-
+
def type(self):
return self.__type
-
+
def get_modifiers(self):
return self.__mods
def set_modifier(self, mod_name, mod_value):
self.__mods[mod_name] = mod_value
return
-
+
def export_xml(self, doc):
elem = doc.createElement(VARIABLE_TAG)
elem.setAttribute('name', self.__name)
elem.setAttribute('type', self.type())
-
+
l = self.get_value()
for x in l:
if self.type() == VARIABLE_TYPE_LIST_XML:
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/05/14 18:00:14 1.255.2.4
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/05/15 21:42:21 1.255.2.5
@@ -1,5 +1,11 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from xml.dom import minidom
-import AccessControl
from ClusterModel.ModelBuilder import ModelBuilder
from ClusterModel.FailoverDomain import FailoverDomain
@@ -22,12 +28,11 @@
from ResourceHandler import create_resource
from system_adapters import validate_svc_update
from homebase_adapters import parseHostForm
-from LuciZope import userAuthenticated
from LuciClusterInfo import getClusterInfo
from conga_constants import *
-from FenceHandler import validateNewFenceDevice, FENCE_OPTS, \
+from FenceHandler import validateNewFenceDevice, \
validateFenceDevice, validate_fenceinstance, \
FD_VAL_FAIL, FD_VAL_SUCCESS
@@ -35,10 +40,11 @@
batch_status, extract_module_status
from LuciDB import manageCluster, createClusterSystems, \
- havePermCreateCluster, setNodeStatus, getStorageNode, \
+ setNodeStatus, getStorageNode, noNodeStatusPresent, \
getClusterNode, delCluster, buildClusterCreateFlags, \
- noNodeStatussPresent, resolve_nodename, set_node_flag, \
- getRicciAgent
+ resolve_nodename, set_node_flag, getRicciAgent
+
+from LuciZopePerm import havePermCreateCluster
luci_log = get_logger()
@@ -577,12 +583,12 @@
while True:
batch_ret = rq.checkBatch(cluster_ricci, batch_number)
code = batch_ret[0]
- if code == True:
+ if code is True:
break
if code == -1:
errors.append(batch_ret[1])
raise Exception, str(batch_ret[1])
- if code == False:
+ if code is False:
time.sleep(0.5)
except Exception, e:
incomplete = True
@@ -888,7 +894,7 @@
except Exception, e:
luci_log.debug_verbose('VRA1: no model: %s' % str(e))
return None
-
+
errors = list()
try:
res = create_resource(res_type, request.form, model)
@@ -935,7 +941,7 @@
errors.append('An invalid multicast selection was made')
return (False, {'errors': errors})
- if mcast_manual == True:
+ if mcast_manual is True:
try:
addr_str = form['mcast_address'].strip()
socket.inet_pton(socket.AF_INET, addr_str)
@@ -951,7 +957,7 @@
else:
addr_str = None
- if (addr_str is None and mcast_manual != True) or (mcast_manual == True and addr_str == model.getMcastAddr()):
+ if (addr_str is None and mcast_manual is not True) or (mcast_manual is True and addr_str == model.getMcastAddr()):
errors.append('No multicast configuration changes were made')
return (False, {'errors': errors})
@@ -1930,7 +1936,7 @@
if fdev.getName().strip() == fencedev_name:
fdev_to_delete = fdev
break
- if fdev_to_delete == None:
+ if fdev_to_delete is 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']})
@@ -2647,7 +2653,7 @@
else:
svadd['currentItem'] = False
- if model.getIsVirtualized() == True:
+ if model.getIsVirtualized() is True:
vmadd = {}
vmadd['Title'] = "Add a Virtual Service"
vmadd['cfg_type'] = "vmadd"
@@ -2724,7 +2730,7 @@
kids = list()
kids.append(svadd)
- if model.getIsVirtualized() == True:
+ if model.getIsVirtualized() is True:
kids.append(vmadd)
kids.append(svcfg)
sv['children'] = kids
@@ -3161,7 +3167,7 @@
if nodename is None:
luci_log.debug_verbose('serviceMigrate1: no target node name')
return None
-
+
cluname = None
try:
cluname = req['clustername']
@@ -3335,14 +3341,14 @@
return None
objname = '%s____flag' % nodename_resolved
- fnpresent = noNodeStatussPresent(self, nodefolder, objname, nodename_resolved)
+ fnpresent = noNodeStatusPresent(self, nodefolder, objname, nodename_resolved)
if fnpresent is None:
luci_log.debug('NL1: An error occurred while checking flags for %s' \
% nodename_resolved)
return None
- if fnpresent == False:
+ if fnpresent is False:
luci_log.debug('NL2: flags are still present for %s -- bailing out' \
% nodename_resolved)
return None
@@ -4004,7 +4010,7 @@
if batch_xml is None:
# The job is done and gone from queue
- if redirect_message == False:
+ if redirect_message is False:
# We have not displayed this message yet
node_report['desc'] = REDIRECT_MSG
node_report['iserror'] = True
@@ -4139,7 +4145,7 @@
finished = batch_res[0]
err_msg = batch_res[1]
- if finished == True or finished == -1:
+ if finished is True or finished == -1:
if finished == -1:
flag_msg = err_msg
else:
@@ -4173,7 +4179,7 @@
part2 = tmpstr
###FIXME - The above assumes that the 'busyfirst' query var is at the
###end of the URL...
- busy_map['refreshurl'] = '5; url=%s?%s' % (part1, part2)
+ busy_map['refreshurl'] = '5; url=%s?%s' % (part1, part2)
req['specialpagetype'] = '1'
else:
try:
@@ -4482,7 +4488,7 @@
cc_xml = minidom.parseString(cc)
except:
pass
- if cc_xml == None:
+ if cc_xml is None:
msg_list.append('FAILED\n')
msg_list.append('Fix the error and try again:\n')
else:
@@ -4523,4 +4529,4 @@
model = req.SESSION.get('model')
cc = model.exportModelAsString()
- return {'msg': ''.join(msg_list), 'cluster_conf': cc}
+ return { 'msg': ''.join(msg_list), 'cluster_conf': cc }
--- conga/luci/site/luci/Extensions/conga_constants.py 2007/05/14 16:02:11 1.39.2.3
+++ conga/luci/site/luci/Extensions/conga_constants.py 2007/05/15 21:42:21 1.39.2.4
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
# Cluster area page types
CLUSTERLIST = '3'
CLUSTERS = '4'
@@ -131,7 +138,7 @@
PRE_CFG = 'Reboot stage successful, but configuration for the cluster is not yet distributed.'
PRE_JOIN = 'Packages are installed and configuration has been distributed, but the node has not yet joined the cluster.'
-POSSIBLE_REBOOT_MESSAGE = 'This node is not currently responding and is probably rebooting as planned. This state should persist for 5 minutes or so...'
+POSSIBLE_REBOOT_MESSAGE = 'This node is not currently responding and is probably rebooting as planned. This state could persist for 5 minutes or so...'
REDIRECT_MSG = ' -- You will be redirected in 5 seconds.'
--- conga/luci/site/luci/Extensions/conga_ssl.py 2007/05/04 19:10:24 1.2.4.1
+++ conga/luci/site/luci/Extensions/conga_ssl.py 2007/05/15 21:42:21 1.2.4.2
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
import sys
sys.path.append('/usr/lib/luci/ssl')
sys.path.append('/usr/lib64/luci/ssl')
@@ -9,7 +16,7 @@
# timeouts are in seconds (int)
class SSLSocket:
-
+
def __init__(self,
hostname,
port,
@@ -25,10 +32,10 @@
if self.__id != -1:
conga_ssl_lib.disconnect(self.__id)
self.__id = -1
-
+
def peer_fingerprint(self):
return conga_ssl_lib.peer_fingerprint(self.__id)
-
+
def trusted(self):
return conga_ssl_lib.trusted(self.__id) == 1
def trust(self):
@@ -37,7 +44,7 @@
return conga_ssl_lib.trust(self.__id, self.__hostname) == 1
def untrust(self):
return conga_ssl_lib.untrust(self.__id) == 1
-
+
def send(self, msg, timeout):
conga_ssl_lib.send(self.__id, msg, timeout)
def recv(self, timeout):
--- conga/luci/site/luci/Extensions/conga_storage_constants.py 2007/05/03 20:16:38 1.8.8.1
+++ conga/luci/site/luci/Extensions/conga_storage_constants.py 2007/05/15 21:42:21 1.8.8.2
@@ -1,4 +1,13 @@
-from ricci_defines import MAPPER_ATARAID_TYPE, MAPPER_CRYPTO_TYPE, MAPPER_iSCSI_TYPE, MAPPER_MDRAID_TYPE, MAPPER_MULTIPATH_TYPE, MAPPER_PT_TYPE, MAPPER_SYS_TYPE, MAPPER_VG_TYPE
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
+from ricci_defines import MAPPER_ATARAID_TYPE, MAPPER_CRYPTO_TYPE, \
+ MAPPER_iSCSI_TYPE, MAPPER_MDRAID_TYPE, MAPPER_MULTIPATH_TYPE, \
+ MAPPER_PT_TYPE, MAPPER_SYS_TYPE, MAPPER_VG_TYPE
## request vars ##
@@ -66,12 +75,12 @@
'extents_used' : "Used Extents",
'failed' : "Failed",
'format' : "Format",
- 'fstab' : "List in /etc/fstab",
- 'fstabpoint' : "/etc/fstab Mountpoint",
- 'gfs_fsname' : "Unique GFS Name",
+ 'fstab' : "List in /etc/fstab",
+ 'fstabpoint' : "/etc/fstab Mountpoint",
+ 'gfs_fsname' : "Unique GFS Name",
'has_journal' : "Journaling Enabled - ext3",
- 'journals_num' : "Number Of Journals",
- 'journal_size' : "Journal Size",
+ 'journals_num' : "Number Of Journals",
+ 'journal_size' : "Journal Size",
'label' : "Label",
'level' : "Level",
'locking_protocol' : "Locking Protocol",
@@ -84,7 +93,7 @@
'model' : "Model",
'mount' : "Mount",
'mountable' : "Mountable",
- 'mountpoint' : "Mountpoint",
+ 'mountpoint' : "Mountpoint",
'num_devices' : "Number of Devices",
'num_spares' : "Number of Spares",
'partition_begin' : "Partition Begin",
--- conga/luci/site/luci/Extensions/homebase_adapters.py 2007/05/14 18:00:14 1.50.2.3
+++ conga/luci/site/luci/Extensions/homebase_adapters.py 2007/05/15 21:42:21 1.50.2.4
@@ -1,15 +1,24 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from conga_constants import PLONE_ROOT, CLUSTER_NODE_NEED_AUTH, \
- STORAGE_FOLDER_PATH, CLUSTER_FOLDER_PATH
+ STORAGE_FOLDER_PATH, CLUSTER_FOLDER_PATH, LUCI_DEBUG_MODE
from RicciQueries import getClusterConf
from LuciSyslog import get_logger
from HelperFunctions import resolveOSType
-from LuciDB import delCluster, clearNodeStatus, delSystem, getClusterNode, \
- getClusters, getStorage, getStorageNode, \
- havePermAddCluster, havePermAddUser, havePermDelUser, \
- havePermEditPerms, havePermRemCluster, havePermRemStorage, \
- havePermAddStorage, manageCluster
+from LuciDB import delCluster, clearNodeStatus, delSystem, \
+ getClusterNode, getClusters, getStorage, getStorageNode, \
+ manageCluster
+
+from LuciZopePerm import havePermAddCluster, havePermRemCluster, \
+ havePermAddUser, havePermDelUser, havePermEditPerms, \
+ havePermRemStorage, havePermAddStorage
from ricci_communicator import RicciCommunicator
@@ -59,7 +68,7 @@
if not request.form.has_key('deluserId'):
return (False, { 'errors': [ 'No User ID given' ] })
-
+
userId = request.form['deluserId']
try:
@@ -67,27 +76,32 @@
if not user:
raise Exception, 'user %s does not exist' % userId
except Exception, e:
- luci_log.debug_verbose('VDU0: %s: %r' % (userId, e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VDU0: %s: %r' % (userId, e))
return (False, {'errors': [ 'No such user: "%s"' % userId ] })
for i in getClusters(self):
try:
i[1].manage_delLocalRoles([ userId ])
except Exception, e:
- luci_log.debug_verbose('VDU1: %s %s: %r' % (userId, i[0], e))
- errors.append('Error deleting roles from cluster "%s" for user "%s"' % (i[0], userId))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VDU1: %s %s: %r' % (userId, i[0], e))
+ errors.append('Error deleting roles from cluster "%s" for user "%s"' \
+ % (i[0], userId))
for i in getStorage(self):
try:
i[1].manage_delLocalRoles([ userId ])
except Exception, e:
- luci_log.debug_verbose('VDU2: %s: %r' % (userId, i[0], e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VDU2: %s: %r' % (userId, i[0], e))
errors.append('Error deleting roles from storage system "%s" for user "%s"' % (i[0], userId))
try:
self.acl_users.userFolderDelUsers([ userId ])
except Exception, e:
- luci_log.debug_verbose('VDU3: %s %r' % (userId, e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VDU3: %s %r' % (userId, e))
errors.append('Unable to delete user "%s"' % userId)
return (False, {'errors': errors })
@@ -118,7 +132,8 @@
try:
self.portal_registration.addMember(user, passwd, properties = { 'username': user, 'password': passwd, 'confirm': passwd, 'roles': [ 'Member' ], 'domains': [], 'email': '%s at conga.example.com' % user })
except Exception, e:
- luci_log.debug_verbose('VAU0: %s: %r' % (user, e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAU0: %s: %r' % (user, e))
return (False, { 'errors': [ 'Unable to add new user "%s"' % user ] })
if not self.portal_membership.getMemberById(user):
@@ -144,7 +159,8 @@
raise Exception, 'no node was given'
cur_host = sysData[0]
except Exception, e:
- luci_log.debug_verbose('vACI0: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI0: %r' % e)
return (False, { 'errors': [ 'You must provide the address of at least one node in the cluster you wish to add.' ]})
cur_entry = { 'host': cur_host }
@@ -154,7 +170,8 @@
cur_pass = sysData[1]
cur_entry['passwd'] = cur_pass
except:
- luci_log.debug_verbose('vACI1: %s no password given')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI1: %s no password given' % cur_host)
request.SESSION.set('add_cluster_initial', cur_entry)
return (False, { 'errors': [ 'No password was given for %s' % cur_host ] })
@@ -194,10 +211,10 @@
else:
cur_entry['fp'] = cur_fp[1]
except Exception, e:
- luci_log.debug_verbose('vACI2: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI2: %s: %r' % (cur_host, e))
request.SESSION.set('add_cluster_initial', cur_entry)
- return (False, { 'errors': [ 'Unable to establish a connection to the ricci agent on %s: %s' \
- % (cur_host, str(e)) ] })
+ return (False, { 'errors': [ 'Unable to establish a connection to the ricci agent on %s: %s' % (cur_host, str(e)) ] })
if not check_certs or cur_host_trusted:
try:
@@ -213,7 +230,8 @@
return (False, { 'errors': [ errmsg ] })
rc.trust()
except Exception, e:
- luci_log.debug_verbose('vACI3: %s %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI3: %s %r' % (cur_host, e))
request.SESSION.set('add_cluster_initial', cur_entry)
return (False, { 'errors': [ 'Unable to establish trust for host %s' % (cur_host, str(e)) ] })
elif check_certs:
@@ -241,7 +259,8 @@
raise Exception, 'rc is None'
cur_entry['trusted'] = rc.trusted()
except Exception, e:
- luci_log.debug_verbose('vACI4: %s %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI4: %s %r' % (cur_host, e))
request.SESSION.set('add_cluster_initial', cur_entry)
return (False, { 'errors': [ 'Unable to connect to the ricci agent on %s' % cur_host ] })
@@ -252,8 +271,8 @@
if not rc.authed():
raise Exception, 'authentication failed'
except Exception, e:
- errmsg = 'Unable to authenticate to the ricci agent on %s: %s' % (cur_host, str(e))
- luci_log.debug_verbose('vACI5: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI5: %s: %r' % (cur_host, e))
request.SESSION.set('add_cluster_initial', cur_entry)
return (False, { 'errors': [ 'Unable to authenticate to the ricci agent on "%s"' % cur_host ] })
@@ -280,8 +299,9 @@
cluster_name = cluster_info[0]
cluster_os = resolveOSType(rc.os())
- luci_log.debug_verbose('vACI5a: cluster os is %s (%s)' \
- % (cluster_os, rc.os()))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vACI5a: cluster os is %s (%s)' \
+ % (cluster_os, rc.os()))
try:
cluster_conf = getClusterConf(rc)
@@ -347,7 +367,8 @@
try:
num_storage = int(request.form['numStorage'].strip())
except Exception, e:
- luci_log.debug_verbose('PHF1: numStorage field missing: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('PHF1: numStorage field missing: %r' % e)
errors.append('The number of systems entered could not be determined.')
trust_shown = False
@@ -431,8 +452,8 @@
except:
pass
errors.append('Unable to retrieve the SSL fingerprint for node %s: %s' % (cur_host, str(e)))
- luci_log.debug_verbose('PHF2: %s: %s' \
- % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('PHF2: %s: %r' % (cur_host, e))
else:
try:
rc = RicciCommunicator(cur_host, enforce_trust=False)
@@ -456,9 +477,10 @@
del cur_system['trusted']
rc.untrust()
except:
- pass
+ pass
errors.append('Unable to add the key for node %s to the trusted keys list.' % cur_host)
- luci_log.debug_verbose('PHF3: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('PHF3: %s: %r' % (cur_host, e))
system_list[cur_host] = cur_system
i += 1
@@ -476,13 +498,15 @@
try:
cluster_name = request.form['clusterName'].strip()
except:
- luci_log.debug_verbose('VAC0: no cluster name')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC0: no cluster name')
errors.append('No cluster name was given.')
try:
cluster_os = request.form['cluster_os'].strip()
except:
- luci_log.debug_verbose('VAC1: no cluster os')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC1: no cluster os')
errors.append('Unable to determine the version of cluster %s.' % cluster_name)
check_certs = request.form.has_key('check_certs')
@@ -523,8 +547,8 @@
% (cur_host, str(e)))
incomplete = True
cur_system['errors'] = True
- luci_log.debug_verbose('VAC2: %s: %s' \
- % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC2: %s: %r' % (cur_host, e))
continue
try:
@@ -536,7 +560,8 @@
% (cur_host, str(e)))
incomplete = True
cur_system['errors'] = True
- luci_log.debug_verbose('VAC3: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC3: %s: %r' % (cur_host, e))
continue
cluster_info = rc.cluster_info()
@@ -559,16 +584,19 @@
try:
rc.unauth()
except Exception, e:
- luci_log.debug_verbose('VAC4: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC4: %s: %r' % (cur_host, e))
errors.append(err_msg)
- luci_log.debug_verbose('VAC5: %s' % err_msg)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC5: %s' % err_msg)
continue
cur_os = resolveOSType(rc.os())
if cur_os != cluster_os:
- luci_log.debug_verbose('VAC5a: "%s" / "%s" -> "%s"' \
- % (cluster_os, rc.os(), cur_os))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC5a: "%s" / "%s" -> "%s"' \
+ % (cluster_os, rc.os(), cur_os))
incomplete = True
cur_system['errors'] = True
@@ -576,13 +604,15 @@
try:
rc.unauth()
except Exception, e:
- luci_log.debug_verbose('VAC6: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC6: %s: %r' % (cur_host, e))
err_msg = 'Node %s reports its cluster version is %s and we expect %s' \
% (cur_host, cur_os, cluster_os)
errors.append(err_msg)
- luci_log.debug_verbose('VAC7: %s' % err_msg)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC7: %s' % err_msg)
continue
else:
incomplete = True
@@ -594,10 +624,9 @@
err_msg = manageCluster(self, cluster_name, system_list, cluster_os)
if err_msg:
incomplete = True
- errors.append('An error occurred while creating the database objects for cluster %s: %s' \
- % (cluster_name, err_msg))
- luci_log.debug_verbose('VAC7: error adding cluster DB objects for %s: %s' \
- % (cluster_name, err_msg))
+ errors.append('An error occurred while creating the database objects for cluster %s: %s' % (cluster_name, err_msg))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VAC7: error adding cluster DB objects for %s: %s' % (cluster_name, err_msg))
else:
messages.append('Cluster %s is now managed by Luci' % cluster_name)
incomplete = False
@@ -608,7 +637,7 @@
return_code = False
else:
return_code = True
-
+
return (return_code, {'errors': errors, 'messages': messages })
def validateAddSystem(self, request):
@@ -658,7 +687,8 @@
try:
request.SESSION.set('add_systems', add_systems)
except Exception, e:
- luci_log.debug_verbose('validateSA2: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('validateSA2: %r' % e)
return_code = False
else:
try:
@@ -687,7 +717,8 @@
raise Exception, 'no user'
user_id = user.getUserId()
except Exception, e:
- luci_log.debug_verbose('VP1: no user "%s": %r' % (username, e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VP1: no user "%s": %r' % (username, e))
errors.append('An invalid user "%s" was given' % username)
if len(errors) > 0:
@@ -707,7 +738,8 @@
i[1].manage_delLocalRoles([ user_id ])
messages.append('Removed permission for user "%s" for cluster "%s"' % (user_id, i[0]))
except Exception, e:
- luci_log.debug_verbose('VP2: %s %s: %r' % (user_id, i[0], e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VP2: %s %s: %r' % (user_id, i[0], e))
errors.append('Failed to remove permission for user "%s" for cluster "%s"' % (user_id, i[0]))
else:
for i in clusters:
@@ -719,7 +751,8 @@
i[1].manage_setLocalRoles(user_id, roles)
messages.append('Added permission for user "%s" for cluster "%s"' % (user_id, i[0]))
except Exception, e:
- luci_log.debug_verbose('VP3: %s %s %r' % (user_id, i[0], e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VP3: %s %s %r' % (user_id, i[0], e))
errors.append('Failed to add permission for user "%s" for cluster "%s"' % (user_id, i[0]))
else:
try:
@@ -734,7 +767,8 @@
messages.append('Removed permission for user "%s" for cluster "%s"' % (user_id, i[0]))
except Exception, e:
- luci_log.debug_verbose('VP4: %s %s %r' % (user_id, i[0], e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VP4: %s %s %r' % (user_id, i[0], e))
errors.append('Failed to remove permission for user "%s" for cluster "%s"' % (user_id, i[0]))
@@ -814,7 +848,8 @@
if not rc:
raise Exception, 'connection failed'
except Exception, e:
- luci_log.debug_verbose('validateAuth0: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('validateAuth0: %s: %r' % (cur_host, e))
errors.append('Unable to communicate with the ricci agent on %s: %s' \
% (cur_host, str(e)))
incomplete = True
@@ -842,7 +877,8 @@
pass
except Exception, e:
errors.append('Unable to authenticate to %s: %s' % (cur_host, str(e)))
- luci_log.debug_verbose('validateAuth1: %s: %s' % (cur_host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('validateAuth1: %s: %r' % (cur_host, e))
incomplete = True
cur_system['error'] = True
@@ -856,7 +892,8 @@
try:
request.SESSION.set('auth_systems', system_list)
except Exception, e:
- luci_log.debug_verbose('validateAuthenticate2: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('validateAuthenticate2: %r' % e)
else:
try:
request.SESSION.delete('auth_systems')
@@ -1086,7 +1123,8 @@
def createSystem(self, host, passwd):
try:
dummy = self.restrictedTraverse('%s%s' % (STORAGE_FOLDER_PATH, host)).objectItems()
- luci_log.debug_verbose('CS0: %s already exists' % host)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS0: %s already exists' % host)
return 'Storage system %s is already managed' % host
except:
pass
@@ -1096,28 +1134,32 @@
if rc is None:
raise Exception, 'rc is None'
except Exception, e:
- luci_log.debug_verbose('CS1: %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS1: %s: %s' % (host, e))
return 'Unable to establish a secure connection to the ricci agent on %s: %s' % (host, str(e))
try:
if not rc.authed():
rc.auth(passwd)
except Exception, e:
- luci_log.debug_verbose('CS2: %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS2: %s: %s' % (host, e))
return 'Unable to communicate with the ricci agent on %s for authentication' % host
try:
i = rc.authed()
except Exception, e:
- luci_log.debug_verbose('CS3 %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS3 %s: %r' % (host, e))
return 'Unable to authenticate to the ricci agent on %s' % host
- if i != True:
+ if i is not True:
return 'Authentication for storage system %s failed' % host
try:
dummy = self.restrictedTraverse('%s%s' % (STORAGE_FOLDER_PATH, host)).objectItems()
- luci_log.debug_verbose('CS4 %s already exists' % host)
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS4 %s already exists' % host)
return 'Storage system %s is already managed' % host
except:
pass
@@ -1125,21 +1167,24 @@
try:
ssystem = self.restrictedTraverse(STORAGE_FOLDER_PATH)
except Exception, e:
- luci_log.debug_verbose('CS5 %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS5 %s: %r' % (host, e))
return 'Unable to create storage system %s: %s' % host
try:
ssystem.manage_addFolder(host, '__luci__:system')
newSystem = self.restrictedTraverse('%s%s' % (STORAGE_FOLDER_PATH, host))
except Exception, e:
- luci_log.debug_verbose('CS6 %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS6 %s: %r' % (host, e))
return 'Unable to create DB entry for storage system %s' % host
try:
newSystem.manage_acquiredPermissions([])
newSystem.manage_role('View', ['Access contents information', 'View'])
except Exception, e:
- luci_log.debug_verbose('CS7 %s: %s' % (host, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('CS7 %s: %r' % (host, e))
return 'Unable to set permissions on storage system %s' % host
return None
@@ -1157,11 +1202,13 @@
members.sort()
user = members[0].getUserName()
except Exception, e:
- luci_log.debug_verbose('getDefaultUser0: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getDefaultUser0: %r' % e)
user = None
if not user:
- luci_log.debug_verbose('getDefaultUser1: user is none')
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getDefaultUser1: user is none')
return user
def getUserPerms(self):
@@ -1174,7 +1221,8 @@
raise Exception, 'no portal members exist'
members.sort()
except Exception, e:
- luci_log.debug_verbose('getUserPerms0: %s' % str(e))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getUserPerms0: %r' % e)
return {}
for i in members:
@@ -1188,22 +1236,25 @@
clusters = self.restrictedTraverse('%s/systems/cluster/objectItems' % PLONE_ROOT)('Folder')
storage = self.restrictedTraverse('%s/systems/storage/objectItems' % PLONE_ROOT)('Folder')
except Exception, e:
- luci_log.debug_verbose('getUserPerms1: user %s: %s' % (userName, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getUserPerms1: user %s: %r' % (userName, e))
continue
for c in clusters:
try:
perms[userName]['cluster'][c[0]] = i.has_role('View', c[1])
except Exception, e:
- luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %s' \
- % (userName, c[0], str(e)))
-
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %r' \
+ % (userName, c[0], e))
+
for s in storage:
try:
perms[userName]['storage'][s[0]] = i.has_role('View', s[1])
except Exception, e:
- luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %s' \
- % (userName, s[0], str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %r' \
+ % (userName, s[0], e))
return perms
def getClusterConfNodes(conf_dom):
--- conga/luci/site/luci/Extensions/ricci_communicator.py 2007/05/14 18:00:14 1.25.2.3
+++ conga/luci/site/luci/Extensions/ricci_communicator.py 2007/05/15 21:42:21 1.25.2.4
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
import xml
import xml.dom
from xml.dom import minidom
@@ -15,15 +22,15 @@
def __init__(self, hostname, enforce_trust=True, port=11111):
self.__hostname = hostname
self.__port = port
-
+
self.__timeout_init = 4
self.__timeout_auth = 4
self.__timeout_short = 6
self.__timeout_long = 600
-
+
self.__privkey_file = '%sprivkey.pem' % CERTS_DIR_PATH
self.__cert_file = '%scacert.pem' % CERTS_DIR_PATH
-
+
try:
self.ss = SSLSocket(self.__hostname,
self.__port,
@@ -37,7 +44,7 @@
except:
raise RicciError, 'Error setting up SSL for connection to %s' \
% self.__hostname
-
+
# receive ricci header
hello = self.__receive(self.__timeout_init)
try:
@@ -46,14 +53,14 @@
% (self.__hostname, hello.toxml()))
except:
pass
-
+
self.__authed = hello.firstChild.getAttribute('authenticated') == 'true'
self.__cluname = hello.firstChild.getAttribute('clustername')
self.__clualias = hello.firstChild.getAttribute('clusteralias')
self.__reported_hostname = hello.firstChild.getAttribute('hostname')
self.__os = hello.firstChild.getAttribute('os')
self.__dom0 = hello.firstChild.getAttribute('xen_host') == 'true'
-
+
def hostname(self):
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:hostname: [auth %d] hostname = %s' \
@@ -110,7 +117,7 @@
luci_log.debug_verbose('RC:auth0: already authenticated to %s' \
% self.__hostname)
return True
-
+
# send request
doc = minidom.Document()
ricci = doc.createElement("ricci")
@@ -119,7 +126,7 @@
ricci.setAttribute("password", password)
doc.appendChild(ricci)
self.__send(doc, self.__timeout_auth)
-
+
# receive response
resp = self.__receive(self.__timeout_auth)
self.__authed = resp.firstChild.getAttribute('authenticated') == 'true'
@@ -133,7 +140,7 @@
self.__dom0 = resp.firstChild.getAttribute('xen_host') == 'true'
except:
pass
-
+
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:auth1: auth call returning %d' \
% self.__authed)
@@ -183,7 +190,7 @@
if not self.authed():
raise RicciError, 'not authenticated to host %s' % self.__hostname
-
+
# construct request
doc = minidom.Document()
ricci = doc.createElement("ricci")
@@ -197,7 +204,7 @@
ricci.setAttribute("async", async_str)
doc.appendChild(ricci)
ricci.appendChild(batch_xml.cloneNode(True))
-
+
# send request
try:
self.__send(doc, self.__timeout_short)
@@ -208,7 +215,7 @@
% (self.__hostname, str(e))
except:
raise RicciError, 'Error sending XML to host %s' % self.__hostname
-
+
# receive response
doc = self.__receive(self.__timeout_long)
if LUCI_DEBUG_MODE is True:
@@ -217,26 +224,26 @@
% (self.__hostname, doc.toxml()))
except:
pass
-
+
if doc.firstChild.getAttribute('success') != '0':
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:PB3: batch command failed')
raise RicciError, 'The last ricci command to host %s failed' \
% self.__hostname
-
+
batch_node = None
for node in doc.firstChild.childNodes:
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'batch':
batch_node = node.cloneNode(True)
- if batch_node == None:
+ if batch_node is None:
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:PB4: batch node missing <batch/>')
raise RicciError, 'missing <batch/> in ricci response from "%s"' \
% self.__hostname
return batch_node
-
+
def batch_run(self, batch_str, async=True):
try:
batch_xml_str = '<?xml version="1.0" ?><batch>%s</batch>' \
@@ -271,7 +278,7 @@
if not self.authed():
raise RicciError, 'Not authenticated to host %s' % self.__hostname
-
+
# construct request
doc = minidom.Document()
ricci = doc.createElement("ricci")
@@ -279,11 +286,11 @@
ricci.setAttribute("function", "batch_report")
ricci.setAttribute("batch_id", str(batch_id))
doc.appendChild(ricci)
-
+
# send request
self.__send(doc, self.__timeout_short)
-
-
+
+
# receive response
doc = self.__receive(self.__timeout_short)
if doc.firstChild.getAttribute('success') == '12':
@@ -295,7 +302,7 @@
if node.nodeType == xml.dom.Node.ELEMENT_NODE:
if node.nodeName == 'batch':
batch_node = node.cloneNode(True)
- if batch_node == None:
+ if batch_node is None:
raise RicciError, 'Missing <batch/> in ricci\'s response from host %s' % self.__hostname
return batch_node
@@ -308,10 +315,10 @@
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:send0: Error sending XML "%s" to %s: %s' % (buff, self.__hostname, str(e)))
raise RicciError, 'write error while sending XML to host %s' \
- % self.__hostname
+ % self.__hostname
except:
raise RicciError, 'write error while sending XML to host %s' \
- % self.__hostname
+ % self.__hostname
if LUCI_DEBUG_MODE is True:
try:
luci_log.debug_verbose('RC:send1: Sent XML "%s" to host %s' \
@@ -319,7 +326,7 @@
except:
pass
return
-
+
def __receive(self, timeout):
doc = None
xml_in = ''
@@ -340,7 +347,7 @@
% (xml_in, self.__hostname))
try:
- if doc == None:
+ if doc is None:
doc = minidom.parseString(xml_in)
except Exception, e:
if LUCI_DEBUG_MODE is True:
@@ -351,8 +358,8 @@
if not doc or not doc.firstChild:
raise RicciError, 'Error an empty response was received from host %s' % self.__hostname
-
- try:
+
+ try:
if doc.firstChild.nodeName != 'ricci':
if LUCI_DEBUG_MODE is True:
luci_log.debug_verbose('RC:recv3: Expecting "ricci" got XML "%s" from %s' % (xml_in, self.__hostname))
@@ -361,11 +368,11 @@
raise RicciError, 'Invalid XML ricci response from host %s' \
% self.__hostname
return doc
-
+
def get_ricci_communicator(self, hostname, allowed_systems):
if not self.access_to_host_allowed(hostname, allowed_systems):
return None
-
+
try:
return RicciCommunicator(hostname)
except Exception, e:
@@ -395,13 +402,13 @@
# check the status of batch
# returns (int num, int total)
# * total:
-# total number of modules in batch
+# total number of modules in batch
# * num:
-# if num == total:
+# if num == total:
# all modules in the batch completed successfuly
-# if num > 0:
+# if num > 0:
# last seq. number of module that successfuly finished
-# if num < 0:
+# if num < 0:
# module (-num) failed (next module won't be processed)
def batch_status(batch_xml):
@@ -438,20 +445,20 @@
# extract error_code from module's response
# * module_num:
-# 1-based seq. number of module to process
+# 1-based seq. number of module to process
#
# returns (int error_code, string error_msg)
# * error_code: each module defines own error codes, which are >0
-# -101 - in progress
-# -102 - scheduled
-# -103 - removed from schedule
-# -104 - failed to execute module
-#
-# >-3 - module executed. Following codes are defined:
-# -2 - API error
-# -1 - undefined error occured (msg not necesarily very informative)
-# 0 - no error (msg is empty string)
-# >0 - predefined error has occured
+# -101 - in progress
+# -102 - scheduled
+# -103 - removed from schedule
+# -104 - failed to execute module
+#
+# >-3 - module executed. Following codes are defined:
+# -2 - API error
+# -1 - undefined error occured (msg not necesarily very informative)
+# 0 - no error (msg is empty string)
+# >0 - predefined error has occured
# (check respective API, msg will be fully descriptive)
# * error_msg: error message
@@ -481,7 +488,7 @@
if node_j.nodeType == xml.dom.Node.ELEMENT_NODE:
if node_j.nodeName == 'function_response':
code = -11111111
- msg = 'BUG'
+ msg = 'BUG'
for var in node_j.childNodes:
if var.nodeType == xml.dom.Node.ELEMENT_NODE:
if var.nodeName == 'var':
@@ -492,7 +499,7 @@
elif var.getAttribute('name') == 'error_description':
msg = var.getAttribute('value')
return code, msg
-
+
elif status == '1':
return -102, 'module scheduled for execution'
elif status == '2':
@@ -501,5 +508,5 @@
return -104, 'failed to locate/execute module'
elif status == '5':
return -103, 'module removed from schedule'
-
+
raise RicciError, 'no %dth module in the batch, or malformed response' % module_num
--- conga/luci/site/luci/Extensions/ricci_defines.py 2007/05/03 20:16:38 1.1.8.1
+++ conga/luci/site/luci/Extensions/ricci_defines.py 2007/05/15 21:42:21 1.1.8.2
@@ -1,3 +1,10 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
REQUEST_TAG = 'request'
RESPONSE_TAG = 'response'
--- conga/luci/site/luci/Extensions/storage_adapters.py 2007/05/04 19:10:24 1.9.4.2
+++ conga/luci/site/luci/Extensions/storage_adapters.py 2007/05/15 21:42:21 1.9.4.3
@@ -1,29 +1,22 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
+from conga_storage_constants import ADD_SOURCES, CLUNAME, CLUSTER_STORAGE, \
+ CREATE_MAPPER, get_pretty_mapper_info, PAGETYPE, PT_MAPPER_ID, \
+ PT_MAPPER_TYPE, PT_PATH, STONAME, STORAGE, STORAGESYS, \
+ VIEW_BD, VIEW_BDS, VIEW_MAPPER, VIEW_MAPPERS
-#from ZPublisher import HTTPRequest
-
-import xml
-import xml.dom
-from xml.dom import minidom
-
-from conga_storage_constants import *
-from ricci_defines import *
-from Variable import parse_variable
+from ricci_defines import MAPPER_SYS_TYPE, MAPPER_VG_TYPE, SYSTEM_PREFIX, VG_PREFIX
from LuciZope import get_systems_statuses
-
-
-#Policy for showing the cluster chooser menu:
-#1) If there are no clusters in the ManagedClusterSystems
-#folder, then only the admin user may see this menu, and
-#the configure option should not be displayed.
-#2)If there are clusters in the ManagedClusterSystems,
-#then only display chooser if the current user has
-#permissions on at least one. If the user is admin, show ALL clusters
-
def createStorageChooser(self, request, systems):
dummynode = {}
-
- #First, see if a storage system is chosen, then
+
+ #First, see if a storage system is chosen, then
#check that the current user can access that system
stoname = None
try:
@@ -40,7 +33,7 @@
pagetype = request[PAGETYPE]
except KeyError, e:
pagetype = "0"
-
+
sdata = {}
sdata['Title'] = "System List"
sdata['cfg_type'] = "storages"
@@ -54,8 +47,8 @@
sdata['show_children'] = True
else:
sdata['show_children'] = False
-
-
+
+
syslist = list()
if sdata['show_children']:
#display_clusters = True
@@ -78,7 +71,7 @@
data,
syslist)
sdata['children'] = syslist
-
+
mylist = list()
mylist.append(sdata)
#mylist.append(sadd)
@@ -114,14 +107,14 @@
kids)
ssys['children'] = kids
else:
- if system_data['authed'] == False:
+ if system_data['authed'] is False:
return
ssys['Title'] = system_data['hostname']
ssys['cfg_type'] = "storage"
ssys['absolute_url'] = '%s?%s=%s&%s=%s' \
% (url, PAGETYPE, STORAGE, STONAME, system_data['hostname'])
ssys['Description'] = "Configure storage on %s" % system_data['hostname']
-
+
if pagetype == STORAGE:
if stoname == system_data['hostname']:
ssys['currentItem'] = True
@@ -135,7 +128,7 @@
def create_mapper_subitem(storage_report, request, mapper_list, mapper_templ_list):
-
+
try:
pagetype_req = request[PAGETYPE]
except KeyError, e:
@@ -157,25 +150,25 @@
except KeyError, e:
url = "."
hostname = request[STONAME]
-
-
+
+
mapper_type = None
if len(mapper_list) != 0:
mapper_type = mapper_list[0].getAttribute('mapper_type')
if len(mapper_templ_list) != 0:
mapper_type = mapper_templ_list[0].getAttribute('mapper_type')
- if mapper_type == None:
+ if mapper_type is None:
return None
-
-
+
+
buff, dummy1, dummy2 = get_pretty_mapper_info(mapper_type)
pretty_names = '%ss' % buff
pretty_names_desc = 'Manage %ss' % buff
pretty_name_desc = 'Manage %s' % buff
pretty_new_name = 'New %s' % buff
pretty_new_name_desc = 'Create New %s' % buff
-
-
+
+
srs_p = {}
srs_p['Title'] = pretty_names
srs_p['cfg_type'] = "nodes"
@@ -190,9 +183,9 @@
srs_p['currentItem'] = True
else:
srs_p['currentItem'] = False
-
+
srs_list = []
-
+
# new mapper
if len(mapper_templ_list) != 0:
sr = {}
@@ -202,36 +195,36 @@
% (url, PAGETYPE, CREATE_MAPPER, STONAME, hostname, PT_MAPPER_TYPE, mapper_type)
sr['Description'] = pretty_new_name_desc
sr['show_children'] = False
-
+
if pagetype_req == CREATE_MAPPER and mapper_type_req == mapper_type:
sr['currentItem'] = True
else:
sr['currentItem'] = False
-
+
srs_list.append(sr)
-
+
# existing mappers
for sr_xml in mapper_list:
sr_id = sr_xml.getAttribute('mapper_id')
srname = sr_id.replace('%s:' % mapper_type, '').replace('/dev/', '')
-
+
if srname == '' and mapper_type == MAPPER_VG_TYPE and sr_id == VG_PREFIX:
#srname = 'Uninitialized PVs'
continue
-
+
sr = {}
sr['Title'] = srname
sr['cfg_type'] = "nodes"
sr['absolute_url'] = '%s?%s=%s&%s=%s&%s=%s&%s=%s' \
% (url, PAGETYPE, VIEW_MAPPER, STONAME, hostname, PT_MAPPER_TYPE, mapper_type, PT_MAPPER_ID, sr_id)
sr['Description'] = pretty_name_desc
-
+
if (pagetype_req == VIEW_MAPPER or pagetype_req == ADD_SOURCES or pagetype_req == VIEW_BD) and mapper_id_req == sr_id:
sr['currentItem'] = True
else:
sr['currentItem'] = False
sr['show_children'] = False
-
+
# targets
tgts_list = []
for tgt_xml in storage_report.get_targets(sr_xml):
@@ -246,16 +239,16 @@
% (url, PAGETYPE, VIEW_BD, STONAME, hostname, PT_MAPPER_TYPE, mapper_type, PT_MAPPER_ID, sr_id, PT_PATH, tg_path)
tg['Description'] = tgname
tg['show_children'] = False
-
+
if pagetype_req == VIEW_BD and path_req == tg_path:
tg['currentItem'] = True
else:
tg['currentItem'] = False
tgts_list.append(tg)
-
+
sr['children'] = tgts_list
srs_list.append(sr)
-
+
if len(srs_list) != 0:
srs_p['children'] = srs_list
return srs_p
@@ -266,9 +259,9 @@
def createStorageConfigTree(self, request, storage_report):
dummynode = {}
- if storage_report == None:
+ if storage_report is None:
return dummynode
-
+
try:
pagetype = request[PAGETYPE]
except KeyError, e:
@@ -290,12 +283,12 @@
except KeyError, e:
url = "."
hostname = request[STONAME]
-
-
+
+
### Hard Drives ###
-
+
hds_pretty_name, hd_pretty_name, dummy = get_pretty_mapper_info(MAPPER_SYS_TYPE)
-
+
hds_p = {}
hds_p['Title'] = hds_pretty_name
hds_p['cfg_type'] = "nodes"
@@ -310,14 +303,14 @@
hds_p['currentItem'] = True
else:
hds_p['currentItem'] = False
-
+
targets_list = storage_report.get_targets(storage_report.get_mapper(SYSTEM_PREFIX))
-
+
hds_list = []
for target in targets_list:
sys_id = target.getAttribute('mapper_id')
hd_path = target.getAttribute('path')
-
+
hd = {}
hd['Title'] = hd_path.replace('/dev/', '')
hd['cfg_type'] = "nodes"
@@ -325,22 +318,22 @@
% (url, PAGETYPE, VIEW_BD, STONAME, hostname, PT_MAPPER_TYPE, MAPPER_SYS_TYPE, PT_MAPPER_ID, sys_id, PT_PATH, hd_path)
hd['Description'] = 'Manage %s' % hd_pretty_name
hd['show_children'] = False
-
+
if pagetype == VIEW_BD and mapper_id == sys_id and path == hd_path:
hd['currentItem'] = True
else:
hd['currentItem'] = False
-
+
hds_list.append(hd)
-
+
hds_p['children'] = hds_list
-
-
-
+
+
+
## mappers ##
-
+
main_kids = [hds_p]
-
+
mappers_dir = storage_report.get_mappers_dir()
mapper_templs_dir = storage_report.get_mapper_temps_dir()
glo_dir = {}
@@ -351,12 +344,12 @@
glo_dir[cur_type] = [[], mapper_templs_dir[cur_type]]
else:
glo_dir[cur_type][1] = mapper_templs_dir[cur_type]
-
+
for cur_type in glo_dir:
if cur_type == MAPPER_SYS_TYPE:
continue
item = create_mapper_subitem(storage_report, request, glo_dir[cur_type][0], glo_dir[cur_type][1])
- if item == None:
+ if item is None:
continue
else:
main_kids.append(item)
@@ -372,4 +365,4 @@
baseurl = request['URL']
except KeyError, e:
baseurl = "."
- return '%s?%s=%s&%s=%s' % (baseurl, PAGETYPE, str(STORAGE), STONAME, hostname)
+ return '%s?%s=%s&%s=%s' % (baseurl, PAGETYPE, str(STORAGE), STONAME, hostname)
--- conga/luci/site/luci/Extensions/system_adapters.py 2007/05/14 18:00:14 1.2.2.2
+++ conga/luci/site/luci/Extensions/system_adapters.py 2007/05/15 21:42:21 1.2.2.3
@@ -1,6 +1,14 @@
+# Copyright (C) 2006-2007 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
from ricci_communicator import RicciCommunicator
from RicciQueries import list_services, updateServices, svc_manage
from LuciSyslog import get_logger
+from conga_constants import LUCI_DEBUG_MODE
from xml.dom import minidom
luci_log = get_logger()
@@ -11,7 +19,8 @@
if not rc:
raise Exception, 'None'
except Exception, e:
- luci_log.debug_verbose('GSSL0: %s: %s' % (hostname, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('GSSL0: %s: %r' % (hostname, e))
return []
service_list = list_services(rc)
@@ -74,7 +83,8 @@
if not rc:
raise Exception, 'unknown error'
except Exception, e:
- luci_log.debug_verbose('VSU0: %s: %s' % (hostname, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VSU0: %s: %r' % (hostname, e))
return (False, {'errors': [ 'Unable to connect to the ricci agent on %s: %s' % (hostname, str(e)) ]})
sys_svc_list = list()
@@ -86,7 +96,8 @@
sys_svc_hash[svc_name] = i
sys_svc_list.append(svc_name)
except Exception, e:
- luci_log.debug_verbose('VSU1: %s: %s' % (hostname, str(e)))
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VSU1: %s: %r' % (hostname, e))
return (False, {'errors': [ 'Unable to retrieve the list of services from %s' % hostname ]})
try:
@@ -136,6 +147,8 @@
raise Exception, 'none'
ret = svc_manage(rc, hostname, servicename, op)
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VMS0: %r' % e)
result.setAttribute('message', str(e))
ret.appendChild(result)
else:
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/BaseResource.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/BaseResource.py 2007/05/15 21:42:21 1.1.2.3
@@ -21,4 +21,3 @@
def isDenyAll(self):
return self.deny_all_children
-
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/Cluster.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/Cluster.py 2007/05/15 21:42:21 1.1.2.3
@@ -39,7 +39,7 @@
for kid in kids:
if kid.getTagName().strip() == "quorumd":
return True
-
+
return False
def getQuorumdPtr(self):
@@ -47,11 +47,11 @@
for kid in kids:
if kid.getTagName().strip() == "quorumd":
return kid
-
+
return None
def generateXML(self, doc, parent=None):
- if self.is_cfg_version_dirty == False:
+ if self.is_cfg_version_dirty is False:
self.incrementConfigVersion()
else:
self.is_cfg_version_dirty = False
@@ -59,11 +59,11 @@
def getNameAlias(self):
return self.getAlias()
-
+
def getAlias(self):
# returns None if no alias set
alias = self.getAttribute("alias")
- if alias == None:
+ if alias is None:
alias = self.getName()
self.addAttribute('alias', alias)
return alias
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/ClusterNode.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/ClusterNode.py 2007/05/15 21:42:21 1.1.2.3
@@ -35,14 +35,14 @@
def getInterface(self):
nd = self.getMulticastNode()
- if nd == None:
+ if nd is None:
return None
else:
return nd.getAttribute("interface")
def setInterface(self, ifc):
nd = self.getMulticastNode()
- if nd == None:
+ if nd is None:
return
else:
nd.addAttribute("interface", ifc)
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/FailoverDomainNode.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/FailoverDomainNode.py 2007/05/15 21:42:21 1.1.2.3
@@ -20,16 +20,16 @@
if self.priority_level > 1:
self.priority_level = self.priority_level - 1
self.addAttribute("priority", str(self.priority_level))
-
+
def lowerPriorityLevel(self):
self.priority_level = self.priority_level + 1
self.addAttribute("priority", str(self.priority_level))
def getPriorityLevel(self):
return self.priority_level
-
+
def setPriorityLevel(self, level):
- self.priority_level = level
+ self.priority_level = level
self.addAttribute("priority", str(self.priority_level))
def addAttribute(self, name, value):
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/FailoverDomains.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/FailoverDomains.py 2007/05/15 21:42:21 1.1.2.3
@@ -8,7 +8,7 @@
from TagObject import TagObject
TAG_NAME = "failoverdomains"
-
+
class FailoverDomains(TagObject):
def __init__(self):
TagObject.__init__(self)
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/FenceDevice.py 2007/05/15 18:58:55 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/FenceDevice.py 2007/05/15 21:42:21 1.1.2.3
@@ -34,7 +34,7 @@
agent = self.getAgentType()
if agent == "fence_drac": #2 variants of drac...
mname = self.getAttribute("modulename")
- if mname == None or mname == "":
+ if not mname:
return False
else:
return True
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/ModelBuilder.py 2007/05/15 18:58:55 1.1.2.3
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/ModelBuilder.py 2007/05/15 21:42:21 1.1.2.4
@@ -88,7 +88,7 @@
'quorumd': QuorumD,
'heuristic': Heuristic,
'script': Script,
- 'nfsexport': NFSExport,
+ 'nfsexport': NFSExport,
'nfsclient': NFSClient,
'SAPInstance': SAPInstance,
'SABDatabase': SAPDatabase,
@@ -138,12 +138,12 @@
self.fence_xvmd_ptr = None
self.unusual_items = list()
self.isVirtualized = False
- if mcast_addr == None:
+ if mcast_addr is None:
self.usesMulticast = False
else:
self.usesMulticast = True
- if domm != None:
+ if domm is not None:
self.parent = domm
self.object_tree = self.buildModel(None)
self.check_empty_ptrs()
@@ -154,7 +154,7 @@
self.check_for_multicast()
self.check_for_nodeids()
else:
- if filename == None:
+ if filename is None:
if lock_type == DLM_TYPE:
self.lock_type = DLM_TYPE
self.object_tree = self.buildDLMModelTemplate()
@@ -178,7 +178,7 @@
def buildModel(self, parent_node, parent_object=None):
- if parent_node == None:
+ if parent_node is None:
parent_node = self.parent
new_object = None
@@ -204,7 +204,7 @@
self.unusual_items.append((parent_object, new_object))
for item in parent_node.childNodes:
result_object = self.buildModel(item, new_object)
- if result_object != None:
+ if result_object is not None:
new_object.addChild(result_object)
return None
@@ -245,7 +245,7 @@
for item in parent_node.childNodes:
result_object = self.buildModel(item, new_object)
- if result_object != None:
+ if result_object is not None:
new_object.addChild(result_object)
return (new_object)
@@ -267,7 +267,7 @@
self.CMAN_ptr = cman
obj_tree.addChild(cman)
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
mcast = Multicast()
mcast.addAttribute("addr", self.mcast_address)
cman.addChild(mcast)
@@ -291,7 +291,7 @@
self.isModified = False
return obj_tree
-
+
def buildGULMModelTemplate(self):
obj_tree = Cluster()
self.cluster_ptr = obj_tree
@@ -326,7 +326,7 @@
self.isModified = False
return obj_tree
-
+
##Because fence devices are declared in a separate XML section
##in conf file, agent types for fence instances must be done in
@@ -337,7 +337,7 @@
agent_hash = {}
for fd in fds:
agent = fd.getAttribute("agent")
- if agent != None:
+ if agent is not None:
agent_hash[fd.getName()] = agent
nodes = self.getNodes()
@@ -349,33 +349,33 @@
child.setAgentType(agent_hash[child.getName()])
##This method builds RefObject containers for appropriate
- ##entities after the object tree is built.
+ ##entities after the object tree is built.
def resolve_references(self):
reset_list_sentinel = True
- while(reset_list_sentinel == True):
+ while(reset_list_sentinel is True):
reset_list_sentinel = False
resource_children = self.resourcemanager_ptr.getChildren()
for r_child in resource_children:
if r_child.getTagName() == SERVICE:
reset_list_sentinel = self.find_references(r_child)
- if reset_list_sentinel == True:
+ if reset_list_sentinel is True:
break
-
+
def find_references(self, entity, parent=None):
result = False
- if (entity.getAttribute("ref") != None) and (entity.isRefObject() == False):
+ if (entity.getAttribute("ref") is not None) and (entity.isRefObject() is False):
result = self.transform_reference(entity, parent)
return result
-
+
children = entity.getChildren()
if len(children) > 0:
for child in children:
result = self.find_references(child, entity)
- if result == True:
+ if result is True:
return result
-
+
return result
-
+
def transform_reference(self, entity, parent):
result = False
#This entity has a "ref" attr...need to walk through resources list
@@ -399,11 +399,11 @@
rf.addChild(kid)
result = True
break
-
- if result == False:
+
+ if result is False:
return result
-
- if parent == None: #Must be a service
+
+ if parent is None: #Must be a service
self.resourcemanager_ptr.addChild(rf)
self.resourcemanager_ptr.removeChild(entity)
return True
@@ -413,9 +413,9 @@
return True
def exportModelAsString(self):
- if self.perform_final_check() == False: # failed
+ if self.perform_final_check() is False: # failed
return None
-
+
#check for dual power fences
self.dual_power_fence_check()
self.restore_unusual_items()
@@ -437,7 +437,7 @@
self.resolve_fence_instance_types()
self.purgePCDuplicates()
self.resolve_references()
- self.check_for_multicast()
+ self.check_for_multicast()
finally:
pass
@@ -457,15 +457,15 @@
if kid == item[1]:
duplicate = True
break
- if duplicate == True:
+ if duplicate is True:
continue
else:
- item[0].addChild(item[1])
+ item[0].addChild(item[1])
def check_for_nodeids(self):
nodes = self.getNodes()
for node in nodes:
- if node.getAttribute('nodeid') == None:
+ if node.getAttribute('nodeid') is None:
new_id = self.getUniqueNodeID()
node.addAttribute('nodeid', new_id)
@@ -475,39 +475,39 @@
dex_list = list()
for nd_idx in range (1, (total_nodes + 3)):
dex_list.append(str(nd_idx))
-
+
for dex in dex_list:
found = False
for node in nodes:
ndid = node.getAttribute('nodeid')
- if ndid != None:
+ if ndid is not None:
if ndid == dex:
found = True
break
else:
continue
-
- if found == True:
+
+ if found is True:
continue
else:
return dex
-
+
def setIsVirtualized(self, isVirtualized):
- if isVirtualized == None:
+ if isVirtualized is None:
self.isVirtualized = False
else:
self.isVirtualized = isVirtualized
def getIsVirtualized(self):
return self.isVirtualized
-
+
def getNodes(self):
- #Find the clusternodes obj and return get_children
+ #Find the clusternodes obj and return get_children
return self.clusternodes_ptr.getChildren()
def addNode(self, clusternode):
self.clusternodes_ptr.addChild(clusternode)
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
mcast = Multicast()
mcast.addAttribute("addr", self.mcast_address)
mcast.addAttribute("interface", "eth0") #eth0 is the default
@@ -525,7 +525,7 @@
found_one = True
- while found_one == True:
+ while found_one is True:
found_one = False
fdoms = self.getFailoverDomains()
for fdom in fdoms:
@@ -538,7 +538,7 @@
lock_type = self.getLockType()
if lock_type == GULM_TYPE:
- if self.isNodeLockserver(clusternode.getName()) == True:
+ if self.isNodeLockserver(clusternode.getName()) is True:
self.removeLockserver(clusternode)
self.isModified = True
@@ -595,7 +595,7 @@
self.fence_xvmd_ptr = None
def getFenceDevices(self):
- if self.fencedevices_ptr == None:
+ if self.fencedevices_ptr is None:
return list()
else:
return self.fencedevices_ptr.getChildren()
@@ -604,7 +604,7 @@
return self.fencedevices_ptr
def getFailoverDomains(self):
- if self.failoverdomains_ptr == None:
+ if self.failoverdomains_ptr is None:
return list()
else:
return self.failoverdomains_ptr.getChildren()
@@ -639,7 +639,7 @@
newnode = FailoverDomainNode()
if len(kids) != 0: #Use an existing node as a baseline...
attrs = kids[0].getAttributes()
- kees = attrs.keys()
+ kees = attrs.keys()
for k in kees:
newnode.addAttribute(k, attrs[k])
newnode.addAttribute("name", node)
@@ -656,9 +656,9 @@
if fdom.getName().encode('ascii', 'ignore') == fd:
kids = fdom.getChildren()
for kid in kids:
- if kid.getName().encode('ascii', 'ignore') == node:
+ if kid.getName().encode('ascii', 'ignore') == node:
fdom.removeChild(kid)
- return
+ return
return
@@ -666,13 +666,13 @@
return self.usesMulticast
def check_for_multicast(self):
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
#set mcast address
children = self.CMAN_ptr.getChildren()
for child in children:
if child.getTagName() == MCAST_STR:
addr = child.getAttribute("addr")
- if addr != None:
+ if addr is not None:
self.mcast_address = addr
return
else: #What a mess! a multicast tag, but no addr attribute
@@ -689,34 +689,34 @@
return self.quorumd_ptr
def check_empty_ptrs(self):
- if self.resourcemanager_ptr == None:
+ if self.resourcemanager_ptr is None:
rm = Rm()
self.cluster_ptr.addChild(rm)
self.resourcemanager_ptr = rm
- if self.failoverdomains_ptr == None:
+ if self.failoverdomains_ptr is None:
fdoms = FailoverDomains()
self.resourcemanager_ptr.addChild(fdoms)
self.failoverdomains_ptr = fdoms
- if self.fencedevices_ptr == None:
+ if self.fencedevices_ptr is None:
fds = FenceDevices()
self.cluster_ptr.addChild(fds)
self.fencedevices_ptr = fds
-
- if self.resources_ptr == None:
+
+ if self.resources_ptr is None:
rcs = Resources()
self.resourcemanager_ptr.addChild(rcs)
self.resources_ptr = rcs
-
+
if self.GULM_ptr is None and self.fence_daemon_ptr is None:
fdp = FenceDaemon()
self.cluster_ptr.addChild(fdp)
self.fence_daemon_ptr = fdp
-
+
def getServices(self):
rg_list = list()
- if self.resourcemanager_ptr != None:
+ if self.resourcemanager_ptr is not None:
kids = self.resourcemanager_ptr.getChildren()
for kid in kids:
if kid.getTagName() == SERVICE:
@@ -731,34 +731,34 @@
return service
return None
-
+
def getVMs(self):
rg_list = list()
- if self.resourcemanager_ptr != None:
+ if self.resourcemanager_ptr is not None:
kids = self.resourcemanager_ptr.getChildren()
for kid in kids:
if kid.getTagName() == VM:
rg_list.append(kid)
return rg_list
-
+
def deleteService(self, service):
- if self.resourcemanager_ptr != None:
+ if self.resourcemanager_ptr is not None:
kids = self.resourcemanager_ptr.getChildren()
for kid in kids:
if kid.getName() == service:
self.resourcemanager_ptr.removeChild(kid)
break
-
+
def getResources(self):
- if self.resources_ptr != None:
+ if self.resources_ptr is not None:
return self.resources_ptr.getChildren()
else:
return list()
def getResourcesPtr(self):
return self.resources_ptr
-
+
def getResourceManagerPtr(self):
return self.resourcemanager_ptr
@@ -773,7 +773,7 @@
def getClusterNodesPtr(self):
return self.clusternodes_ptr
-
+
def getClusterPtr(self):
return self.cluster_ptr
@@ -811,7 +811,7 @@
def isNodeLockserver(self, name):
gptr = self.getGULMPtr()
- if gptr == None: #Obviously not GULM
+ if gptr is None: #Obviously not GULM
return False
children = gptr.getChildren()
for child in children:
@@ -822,7 +822,7 @@
def removeLockserver(self, clusternode):
gptr = self.getGULMPtr()
- if gptr == None: #Obviously not GULM
+ if gptr is None: #Obviously not GULM
return
children = gptr.getChildren()
for child in children:
@@ -851,9 +851,9 @@
#remove votes attr from each node
nodes = self.getNodes()
for node in nodes:
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
mnode = node.getMulticastNode()
- if mnode != None:
+ if mnode is not None:
node.removeChild(mnode)
node.removeAttribute('votes')
@@ -870,7 +870,7 @@
ls.addAttribute('name', node.getName())
self.GULM_ptr.addChild(ls)
break
-
+
#set modified
self.isModified = True
@@ -903,9 +903,9 @@
self.isModified = True
def swap_multicast_state(self, address=None):
- if self.usesMulticast == True:
+ if self.usesMulticast is True:
#First, eliminate <multicast> tag
- if self.CMAN_ptr != None:
+ if self.CMAN_ptr is not None:
children = self.CMAN_ptr.getChildren()
if len(children) > 0:
for child in children:
@@ -913,7 +913,7 @@
self.CMAN_ptr.removeChild(child)
break
found_one = True
- while found_one == True:
+ while found_one is True:
found_one = False
nodes = self.clusternodes_ptr.getChildren()
for node in nodes:
@@ -923,16 +923,16 @@
node.removeChild(node_child)
found_one = True
break
- if found_one == True:
+ if found_one is True:
break
- self.usesMulticast = False
+ self.usesMulticast = False
self.mcast_address = None
self.isModified = True
-
+
else:
- if self.CMAN_ptr != None:
+ if self.CMAN_ptr is not None:
mcast = Multicast()
mcast.addAttribute("addr", address)
self.CMAN_ptr.addChild(mcast)
@@ -946,7 +946,7 @@
if node_child.getTagName() == MCAST_STR:
has_one = True
break
- if has_one == False:
+ if has_one is False:
mcast = Multicast()
mcast.addAttribute("addr", address)
mcast.addAttribute("interface", "eth0")
@@ -955,8 +955,8 @@
self.mcast_address = address
self.usesMulticast = True
self.isModified = True
-
-
+
+
def check_fence_daemon(self):
if self.GULM_ptr is None and self.fence_daemon_ptr is None:
@@ -970,7 +970,7 @@
return self.isModified
def setModified(self, modified=None):
- if modified == None:
+ if modified is None:
self.isModified = True
else:
self.isModified = modified
@@ -1008,7 +1008,7 @@
if fence.getName() == name:
kill_list.append(fence)
for victim in kill_list:
- level.removeChild(victim)
+ level.removeChild(victim)
def removeReferences(self, tagobj):
self.__removeReferences(tagobj, self.cluster_ptr)
@@ -1019,7 +1019,7 @@
level.removeChild(t)
continue
self.__removeReferences(tagobj, t)
-
+
def updateReferences(self):
self.__updateReferences(self.cluster_ptr)
def __updateReferences(self, level):
@@ -1027,14 +1027,14 @@
if t.isRefObject():
t.setRef(t.getObj().getName())
self.__updateReferences(t)
-
+
def perform_final_check(self):
- if self.check_gulm_count() == False:
+ if self.check_gulm_count() is False:
return False
self.check_two_node()
#add more checks
-
+
return True
def check_gulm_count(self):
@@ -1045,11 +1045,11 @@
return True
def check_two_node(self):
- if self.getLockType() == DLM_TYPE and self.quorumd_ptr == None:
+ if self.getLockType() == DLM_TYPE and self.quorumd_ptr is None:
clusternodes_count = len(self.clusternodes_ptr.getChildren())
#Make certain that there is a cman tag in the file
#If missing, it will not hurt to add it here
- if self.CMAN_ptr == None:
+ if self.CMAN_ptr is None:
cman = Cman()
self.cluster_ptr.addChild(cman)
self.CMAN_ptr = cman
@@ -1059,7 +1059,7 @@
else:
if self.CMAN_ptr.getAttribute('expected_votes') in ('0', '1'):
self.CMAN_ptr.removeAttribute('expected_votes')
- self.CMAN_ptr.removeAttribute('two_node')
+ self.CMAN_ptr.removeAttribute('two_node')
def dual_power_fence_check(self):
#if 2 or more power controllers reside in the same fence level,
@@ -1078,7 +1078,7 @@
kids = level.getChildren()
l = list()
for kid in kids:
- if kid.isPowerController() == True:
+ if kid.isPowerController() is True:
l.append(kid)
if len(l) > 1: #Means we found multiple PCs in the same level
for fence in l:
@@ -1093,10 +1093,10 @@
d.addAttribute(k, attrs[k])
d.addAttribute("option", "on")
level.addChild(d)
-
+
def purgePCDuplicates(self):
found_one = True
- while found_one == True:
+ while found_one is True:
found_one = False
nodes = self.getNodes()
for node in nodes:
@@ -1105,20 +1105,18 @@
kids = level.getChildren()
for kid in kids: #kids are actual fence instance objects
res = kid.getAttribute("option")
- if res != None:
+ if res is not None:
if res == "off":
kid.removeAttribute("option")
else:
level.removeChild(kid)
found_one = True
break
- if found_one == True:
+ if found_one is True:
break
-
+
def searchObjectTree(self, tagtype):
objlist = list()
self.object_tree.searchTree(objlist, tagtype)
return objlist
-
-
--- conga/luci/site/luci/Extensions/ClusterModel/Attic/TagObject.py 2007/05/15 18:58:56 1.1.2.2
+++ conga/luci/site/luci/Extensions/ClusterModel/Attic/TagObject.py 2007/05/15 21:42:21 1.1.2.3
@@ -11,7 +11,7 @@
def __init__(self, tagname=None):
self.attr_hash = {}
self.children = list()
- if tagname == None:
+ if tagname is None:
self.TAG_NAME = TAG_NAME
else:
self.TAG_NAME = tagname
@@ -39,7 +39,7 @@
#print "TAGNAME is %s" % TAG_NAME
#print "self.TAGNAME is %s" % self.TAG_NAME
tag = doc.createElement(self.TAG_NAME)
- if parent != None:
+ if parent is not None:
parent.appendChild(tag)
else:
doc.appendChild(tag)
@@ -48,7 +48,7 @@
#parent.appendChild(tag)
if len(self.children) > 0:
for child in self.children:
- if child == None:
+ if child is None:
continue
child.generateXML(doc, tag)
@@ -86,6 +86,6 @@
objlist.append(self)
if len(self.children) > 0:
for child in self.children:
- if child == None:
+ if child is None:
continue
child.searchTree(objlist, tagtype)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2007-07-26 4:36 rmccabe
0 siblings, 0 replies; 14+ messages in thread
From: rmccabe @ 2007-07-26 4:36 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Branch: RHEL5
Changes by: rmccabe at sourceware.org 2007-07-26 04:36:34
Modified files:
luci/site/luci/Extensions: FenceHandler.py cluster_adapters.py
Log message:
Part of the fix for bz249066
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.7&r2=1.4.2.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.120.2.32&r2=1.120.2.33
--- conga/luci/site/luci/Extensions/FenceHandler.py 2007/07/24 15:00:30 1.4.2.7
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2007/07/26 04:36:34 1.4.2.8
@@ -6,6 +6,8 @@
# Free Software Foundation.
from ClusterModel.Device import Device
+from conga_constants import LUCI_DEBUG_MODE
+from LuciSyslog import get_logger
FD_VAL_FAIL = 1
FD_VAL_SUCCESS = 0
@@ -152,6 +154,7 @@
'fence_manual': ['name']
}
+luci_log = get_logger()
def makeNCName(name):
### name must conform to relaxNG ID type ##
@@ -178,6 +181,8 @@
model.setModified(True)
return (FD_VAL_SUCCESS, fencedev.getAttribute('name'))
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VNFD0: %r %s' % (e, str(e)))
ret = [ FD_PROVIDE_AGENT ]
return (FD_VAL_FAIL, ret)
@@ -188,6 +193,8 @@
if not old_fence_name:
raise Exception, 'blank'
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VFD0: %r %s' % (e, str(e)))
return (FD_VAL_FAIL, [ FD_PROVIDE_NAME ])
fencedev = None
@@ -200,6 +207,8 @@
if fencedev is None:
raise Exception, 'fencedev is None'
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VFD1: %r %s' % (e, str(e)))
return (FD_VAL_FAIL, [ FD_PROVIDE_NAME ])
try:
@@ -208,6 +217,8 @@
model.setModified(True)
return (FD_VAL_SUCCESS, fencedev.getAttribute('name'))
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('VFD2: %r %s' % (e, str(e)))
ret = [ FD_PROVIDE_NAME ]
return (FD_VAL_FAIL, ret)
@@ -219,6 +230,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -226,6 +238,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -257,8 +270,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_wti_fd(form, fencedev):
@@ -268,6 +279,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -299,7 +311,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
return errors
def val_brocade_fd(form, fencedev):
@@ -309,6 +320,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -316,6 +328,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -347,8 +360,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_vixel_fd(form, fencedev):
@@ -358,6 +369,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -389,7 +401,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
return errors
def val_mcdata_fd(form, fencedev):
@@ -399,6 +410,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -406,6 +418,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -437,8 +450,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_gnbd_fd(form, fencedev):
@@ -448,10 +459,10 @@
server = form['servers'].strip()
if not server:
raise Exception, 'blank'
+ fencedev.addAttribute('servers', server)
except Exception, e:
errors.append(FD_PROVIDE_SERVER)
- fencedev.addAttribute('servers', server)
return errors
def val_egenera_fd(form, fencedev):
@@ -461,10 +472,10 @@
cserver = form['cserver'].strip()
if not cserver:
raise Exception, 'blank'
+ fencedev.addAttribute('cserver', cserver)
except Exception, e:
errors.append(FD_PROVIDE_CSERVER)
- fencedev.addAttribute('cserver', cserver)
return errors
def val_sanbox2_fd(form, fencedev):
@@ -474,6 +485,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -481,6 +493,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -512,8 +525,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_bladecenter_fd(form, fencedev):
@@ -523,6 +534,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -530,6 +542,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -561,8 +574,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_bullpap_fd(form, fencedev):
@@ -572,6 +583,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -579,6 +591,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -610,8 +623,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_noop_fd(dummy, _dummy):
@@ -626,6 +637,7 @@
hostname = form['hostname'].strip()
if not hostname:
raise Exception, 'blank'
+ fencedev.addAttribute('hostname', hostname)
except Exception, e:
errors.append(FD_PROVIDE_HOSTNAME)
@@ -633,6 +645,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -664,8 +677,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('hostname', hostname)
- fencedev.addAttribute('login', log)
return errors
def val_drac_fd(form, fencedev):
@@ -675,6 +686,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -682,6 +694,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -713,8 +726,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_rps10_fd(form, fencedev):
@@ -724,6 +735,7 @@
device = form['device'].strip()
if not device:
raise Exception, 'blank'
+ fencedev.addAttribute('device', device)
except Exception, e:
errors.append(FD_PROVIDE_DEVICE)
@@ -731,11 +743,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fencedev.addAttribute('port', port)
except Exception, e:
errors.append(FD_PROVIDE_PORT)
- fencedev.addAttribute('device', device)
- fencedev.addAttribute('port', port)
return errors
def val_ipmilan_fd(form, fencedev):
@@ -745,6 +756,7 @@
ip = form['ipaddr'].strip()
if not ip:
raise Exception, 'blank'
+ fencedev.addAttribute('ipaddr', ip)
except Exception, e:
errors.append(FD_PROVIDE_IP)
@@ -752,6 +764,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -764,6 +777,7 @@
fencedev.addAttribute('passwd', form['passwd'])
else:
raise Exception, 'blank'
+
fencedev.addAttribute('passwd', pwd)
has_passwd = True
except Exception, e:
@@ -809,8 +823,6 @@
except Exception, e:
fencedev.removeAttribute('lanplus')
- fencedev.addAttribute('ipaddr', ip)
- fencedev.addAttribute('login', log)
return errors
def val_ilo_fd(form, fencedev):
@@ -820,6 +832,7 @@
hostname = form['hostname'].strip()
if not hostname:
raise Exception, 'blank'
+ fencedev.addAttribute('hostname', hostname)
except Exception, e:
errors.append(FD_PROVIDE_HOSTNAME)
@@ -827,6 +840,7 @@
log = form['login'].strip()
if not log:
raise Exception, 'blank'
+ fencedev.addAttribute('login', log)
except Exception, e:
errors.append(FD_PROVIDE_LOGIN)
@@ -858,8 +872,6 @@
if not has_passwd:
errors.append(FD_PROVIDE_PASSWD)
- fencedev.addAttribute('hostname', hostname)
- fencedev.addAttribute('login', log)
return errors
FD_VALIDATE = {
@@ -923,10 +935,15 @@
if len(ret) < 1 and name_change is True:
try:
model.rectifyNewFencedevicenameWithFences(old_fence_name, fence_name)
- except:
+ except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vfd0: %s %r %s' \
+ % (fence_agent, e, str(e)))
return [ FD_NEW_FAIL % fence_agent ]
return ret
- except:
+ except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vfd1: %s %r %s' % (fence_agent, e, str(e)))
return [ FD_NEW_FAIL % fence_agent ]
# Validation Methods for Fence Instances
@@ -938,6 +955,7 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
@@ -952,7 +970,6 @@
except Exception, e:
errors.append(FI_PROVIDE_SWITCH)
- fenceinst.addAttribute('port', port)
return errors
def val_wti_fi(form, fenceinst):
@@ -962,10 +979,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_brocade_fi(form, fenceinst):
@@ -975,10 +992,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_vixel_fi(form, fenceinst):
@@ -988,10 +1005,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_gnbd_fi(form, fenceinst):
@@ -1001,10 +1018,10 @@
ip = form['ipaddress'].strip()
if not ip:
raise Exception, 'blank'
+ fenceinst.addAttribute('ipaddress', ip)
except Exception, e:
errors.append(FI_PROVIDE_IPADDRESS)
- fenceinst.addAttribute('ipaddress', ip)
return errors
def val_sanbox2_fi(form, fenceinst):
@@ -1014,10 +1031,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_bladecenter_fi(form, fenceinst):
@@ -1027,10 +1044,10 @@
blade = form['blade'].strip()
if not blade:
raise Exception, 'blank'
+ fenceinst.addAttribute('blade', blade)
except Exception, e:
errors.append(FI_PROVIDE_BLADE)
- fenceinst.addAttribute('blade', blade)
return errors
def val_mcdata_fi(form, fenceinst):
@@ -1040,10 +1057,10 @@
port = form['port'].strip()
if not port:
raise Exception, 'blank'
+ fenceinst.addAttribute('port', port)
except Exception, e:
errors.append(FI_PROVIDE_PORT)
- fenceinst.addAttribute('port', port)
return errors
def val_egenera_fi(form, fenceinst):
@@ -1053,6 +1070,7 @@
lpan = form['lpan'].strip()
if not lpan:
raise Exception, 'blank'
+ fenceinst.addAttribute('lpan', lpan)
except Exception, e:
errors.append(FI_PROVIDE_ELPAN)
@@ -1060,11 +1078,10 @@
pserver = form['pserver'].strip()
if not pserver:
raise Exception, 'blank'
+ fenceinst.addAttribute('pserver', pserver)
except Exception, e:
errors.append(FI_PROVIDE_ELPAN)
- fenceinst.addAttribute('lpan', lpan)
- fenceinst.addAttribute('pserver', pserver)
return errors
def val_bullpap_fi(form, fenceinst):
@@ -1074,10 +1091,10 @@
domain = form['domain'].strip()
if not domain:
raise Exception, 'blank'
+ fenceinst.addAttribute('domain', domain)
except Exception, e:
errors.append(FI_PROVIDE_DOMAIN)
- fenceinst.addAttribute('domain', domain)
return errors
def val_xvm_fi(form, fenceinst):
@@ -1087,10 +1104,10 @@
domain = form['domain'].strip()
if not domain:
raise Exception, 'blank'
+ fenceinst.addAttribute('domain', domain)
except Exception, e:
errors.append(FI_PROVIDE_DOMAIN)
- fenceinst.addAttribute('domain', domain)
return errors
def val_scsi_fi(form, fenceinst):
@@ -1100,10 +1117,10 @@
nodename = form['nodename'].strip()
if not nodename:
raise Exception, 'blank'
+ fenceinst.addAttribute('nodename', nodename)
except Exception, e:
errors.append(FI_PROVIDE_NODENAME)
- fenceinst.addAttribute('nodename', nodename)
return errors
def val_noop_fi(dummy, _dummy):
@@ -1150,6 +1167,8 @@
if len(ret) > 0:
return (FD_VAL_FAIL, ret)
except Exception, e:
+ if LUCI_DEBUG_MODE is True:
+ luci_log.debug_verbose('vfi0: %s: %r %s' % (fence_agent, e, str(e)))
return (FD_VAL_FAIL, [ FI_NEW_FAIL % fence_agent ])
return (FD_VAL_SUCCESS, fenceinst)
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/06/27 06:19:22 1.120.2.32
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/07/26 04:36:34 1.120.2.33
@@ -832,7 +832,7 @@
recovery = None
else:
if recovery != 'restart' and recovery != 'relocate' and recovery != 'disable':
- errors.append('You entered an invalid recovery option: "%s" Valid options are "restart" "relocate" and "disable."')
+ errors.append('You entered an invalid recovery option: "%s" Valid options are "restart" "relocate" and "disable"')
except:
recovery = None
@@ -2591,7 +2591,8 @@
54: validateFenceEdit,
55: validateDaemonProperties,
57: deleteFenceDevice,
- 58: validateNodeFenceConfig
+ 58: validateNodeFenceConfig,
+ 80: process_cluster_conf_editor
}
def validatePost(self, request):
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2007-09-21 3:02 rmccabe
0 siblings, 0 replies; 14+ messages in thread
From: rmccabe @ 2007-09-21 3:02 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-09-21 03:02:47
Modified files:
luci/site/luci/Extensions: FenceHandler.py cluster_adapters.py
luci/site/luci/Extensions/ClusterModel: ModelBuilder.py
Log message:
Factor fence addition and deletion out of the luci code and stuff it into the cluster model code.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.271&r2=1.272
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&r1=1.10&r2=1.11
--- conga/luci/site/luci/Extensions/FenceHandler.py 2007/09/20 22:37:32 1.23
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2007/09/21 03:02:46 1.24
@@ -51,13 +51,6 @@
ILLEGAL_CHARS = re.compile(':| ')
return ILLEGAL_CHARS.sub('_', name)
-def check_unique_fd_name(model, name):
- fds = model.getFenceDevices()
- for fd in fds:
- if fd.getName() == name:
- return False
- return True
-
def validateNewFenceDevice(form, model):
from ClusterModel.FenceDevice import FenceDevice
fencedev = FenceDevice()
@@ -65,8 +58,7 @@
try:
ret = validate_fencedevice(form, model, fencedev)
if len(ret) < 1:
- fencedevptr = model.getFenceDevicePtr()
- fencedevptr.addChild(fencedev)
+ model.addFenceDevice(fencedev)
model.setModified(True)
return (FD_VAL_SUCCESS, fencedev.getAttribute('name'))
except Exception, e:
@@ -88,11 +80,7 @@
fencedev = None
try:
- fencedevs = model.getFenceDevices()
- for fd in fencedevs:
- if fd.getName().strip() == old_fence_name:
- fencedev = fd
- break
+ fencedev = model.getFenceDeviceByName(old_fence_name)
if fencedev is None:
raise Exception, 'fencedev is None'
except Exception, e:
@@ -805,12 +793,13 @@
raise Exception, 'blank'
except Exception, e:
return [ FD_PROVIDE_NAME ]
+
if old_fence_name != fence_name:
- if check_unique_fd_name(model, fence_name) is False:
+ if model.getFenceDeviceByName(fence_name) is not None:
return [ FD_PROVIDE_NAME ]
name_change = True
else:
- if check_unique_fd_name(model, fence_name) is False:
+ if model.getFenceDeviceByName(fence_name) is not None:
return [ FD_PROVIDE_NAME ]
try:
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/09/20 22:37:32 1.271
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/09/21 03:02:47 1.272
@@ -1794,34 +1794,23 @@
fencedev_name = fvar['orig_name']
if fencedev_name is None:
- return (False, {'errors': ['No device name in form submission']})
+ return (False, {'errors': ['No fence device name in form submission']})
- # XXX - FIXME: use new model calls to do this.
- fdev_to_delete = None
- fdevs = model.getFenceDevices()
- for fdev in fdevs:
- if fdev.getName().strip() == fencedev_name:
- fdev_to_delete = fdev
- break
-
- if fdev_to_delete is None:
- if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('DFD3: Could not find fence device "%s" in model' % fencedev_name)
- return (False, {'errors': ['Could not find fence device "%s" in model' % fencedev_name ]})
-
- fdev_ptr = model.getFenceDevicePtr()
try:
- fdev_ptr.removeChild(fdev_to_delete)
- except:
- errors.append('Fence device "%s" could not be removed from configuration' % fencedev_name)
- return (False, { 'errors': errors })
-
- try:
- model.removeFenceInstancesForFenceDevice(fencedev_name)
+ fdev = model.getFenceDeviceByName(fencedev_name)
+ if fdev:
+ if model.deleteFenceDevice(fdev) is not True:
+ raise Exception, 'failed to remove %s' % fdev.getName()
+ model.removeFenceInstancesForFenceDevice(fencedev_name)
+ else:
+ raise Exception, 'no fence device named "%s" was found' \
+ % fencedev_name
except Exception, e:
if LUCI_DEBUG_MODE is True:
- luci_log.debug_verbose('DFD4: error removing %s: %r %s' \
+ luci_log.debug_verbose('DFD3: %s: %r %s' \
% (fencedev_name, e, str(e)))
+ return (False, { 'errors': [ 'Error removing fence device %s: %s' \
+ % (fencedev_name, str(e)) ]})
ret = propagateClusterConfAsync(self, model, None, CLUSTER_CONFIG,
'Removing fence device "%s"' % fencedev_name)
--- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 2007/09/20 22:37:32 1.10
+++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 2007/09/21 03:02:47 1.11
@@ -335,9 +335,10 @@
def getFenceDeviceByName(self, name):
device = filter(lambda x: x.getName() == name, self.getFenceDevices())
- if len(device) > 1:
- raise Exception, '%d fence devices named %s exist' % (len(device), name)
- if len(device) < 1:
+ num_fdevs = len(device)
+ if num_fdevs > 1:
+ raise Exception, '%d fence devices named %s exist' % (num_fdevs, name)
+ if num_fdevs < 1:
return None
return device[0]
@@ -621,6 +622,9 @@
self.cluster_ptr.removeChild(self.fence_xvmd_ptr)
self.fence_xvmd_ptr = None
+ def addFenceDevice(self, device):
+ self.fencedevices_ptr.addChild(device)
+
def deleteFenceDevice(self, device):
if self.fencedevices_ptr is None or device is None:
return False
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2007-10-03 19:40 rmccabe
0 siblings, 0 replies; 14+ messages in thread
From: rmccabe @ 2007-10-03 19:40 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-10-03 19:40:37
Modified files:
luci/site/luci/Extensions: FenceHandler.py
luci/site/luci/Extensions/ClusterModel: Device.py FenceDevice.py
FenceDeviceAttr.py
ModelBuilder.py
Log message:
Fix a bug that caused the check for dual power fencing to fail when adding new fence instances for the first time.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/Device.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FenceDevice.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FenceDeviceAttr.py.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&r1=1.11&r2=1.12
--- conga/luci/site/luci/Extensions/FenceHandler.py 2007/10/03 02:11:58 1.26
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2007/10/03 19:40:37 1.27
@@ -1077,6 +1077,7 @@
fenceinst = Device()
fenceinst.addAttribute('name', parent_name)
+ fenceinst.setAgentType(fence_agent)
if form.has_key('option'):
option = form['option'].strip()
--- conga/luci/site/luci/Extensions/ClusterModel/Device.py 2007/09/20 22:37:32 1.5
+++ conga/luci/site/luci/Extensions/ClusterModel/Device.py 2007/10/03 19:40:37 1.6
@@ -31,11 +31,7 @@
return self.has_native_option_set
def isPowerController(self):
- for item in FenceDeviceAttr.FENCE_POWER_CONTROLLERS:
- if self.agent_type == item:
- return True
-
- return False
+ return self.agent_type in FenceDeviceAttr.FENCE_POWER_CONTROLLERS
def addAttribute(self, name, value):
if name == OPTION:
--- conga/luci/site/luci/Extensions/ClusterModel/FenceDevice.py 2007/09/20 22:37:32 1.3
+++ conga/luci/site/luci/Extensions/ClusterModel/FenceDevice.py 2007/10/03 19:40:37 1.4
@@ -29,7 +29,11 @@
return agent
def getPrettyName(self):
- return self.pretty_fence_names[self.attr_hash['name']]
+ agent_type = self.getAgentType()
+ pname = self.pretty_fence_names.get(agent_type)
+ if pname is None:
+ pname = agent_type
+ return pname
def isShared(self):
agent = self.getAgentType()
@@ -39,8 +43,4 @@
return False
else:
return True
-
- try:
- return self.shared_fences[agent]
- except KeyError, e:
- return False
+ return self.shared_fences.has_key(agent)
--- conga/luci/site/luci/Extensions/ClusterModel/FenceDeviceAttr.py 2007/09/21 16:06:52 1.2
+++ conga/luci/site/luci/Extensions/ClusterModel/FenceDeviceAttr.py 2007/10/03 19:40:37 1.3
@@ -5,7 +5,11 @@
# GNU General Public License as published by the
# Free Software Foundation.
-FENCE_POWER_CONTROLLERS = [ 'fence_wti', 'fence_apc', 'fence_apc_snmp' ]
+FENCE_POWER_CONTROLLERS = (
+ 'fence_wti',
+ 'fence_apc',
+ 'fence_apc_snmp'
+)
FENCE_OPTS = {
'fence_apc': 'APC Power Device',
@@ -70,61 +74,61 @@
}
FENCE_FI_ATTRS = {
- 'fence_apc': [ 'port', 'switch' ],
- 'fence_wti': [ 'port' ],
- 'fence_brocade': [ 'port' ],
- 'fence_vixel': [ 'port' ],
- 'fence_gnbd': [ 'ipaddress' ],
- 'fence_sanbox2': [ 'port' ],
- 'fence_bladecenter': [ 'blade' ],
- 'fence_mcdata': [ 'port' ],
- 'fence_egenera': [ 'lpan', 'pserver' ],
- 'fence_bullpap': [ 'domain' ],
- 'fence_xvm': [ 'domain' ],
- 'fence_scsi': [ 'node' ],
- 'fence_ilo': [ ],
- 'fence_ipmilan': [ ],
- 'fence_drac': [ ],
- 'fence_rsa': [ ],
- 'fence_rps10': [ ],
- 'fence_manual': [ ]
+ 'fence_apc': ( 'port', 'switch' ),
+ 'fence_wti': ( 'port' ),
+ 'fence_brocade': ( 'port' ),
+ 'fence_vixel': ( 'port' ),
+ 'fence_gnbd': ( 'ipaddress' ),
+ 'fence_sanbox2': ( 'port' ),
+ 'fence_bladecenter': ( 'blade' ),
+ 'fence_mcdata': ( 'port' ),
+ 'fence_egenera': ( 'lpan', 'pserver' ),
+ 'fence_bullpap': ( 'domain' ),
+ 'fence_xvm': ( 'domain' ),
+ 'fence_scsi': ( 'node' ),
+ 'fence_ilo': ( ),
+ 'fence_ipmilan': ( ),
+ 'fence_drac': ( ),
+ 'fence_rsa': ( ),
+ 'fence_rps10': ( ),
+ 'fence_manual': ( )
}
FENCE_FD_ATTRS = {
'fence_apc':
- [ 'name', 'ipaddr', 'login', 'passwd' ],
+ ( 'name', 'ipaddr', 'login', 'passwd' ),
'fence_wti':
- [ 'name', 'ipaddr', 'passwd' ],
+ ( 'name', 'ipaddr', 'passwd' ),
'fence_brocade':
- [ 'name', 'ipaddr', 'login', 'passwd' ],
+ ( 'name', 'ipaddr', 'login', 'passwd' ),
'fence_vixel':
- [ 'name', 'ipaddr', 'passwd' ],
+ ( 'name', 'ipaddr', 'passwd' ),
'fence_gnbd':
- [ 'name', 'servers' ],
+ ( 'name', 'servers' ),
'fence_sanbox2':
- [ 'name', 'ipaddr', 'login', 'passwd' ],
+ ( 'name', 'ipaddr', 'login', 'passwd' ),
'fence_bladecenter':
- [ 'name', 'ipaddr', 'login', 'passwd' ],
+ ( 'name', 'ipaddr', 'login', 'passwd' ),
'fence_mcdata':
- [ 'name', 'ipaddr', 'login', 'passwd' ],
+ ( 'name', 'ipaddr', 'login', 'passwd' ),
'fence_egenera':
- [ 'name', 'cserver' ],
+ ( 'name', 'cserver' ),
'fence_bullpap':
- [ 'name', 'ipaddr', 'login', 'passwd' ],
+ ( 'name', 'ipaddr', 'login', 'passwd' ),
'fence_xvm':
- [ 'name' ],
+ ( 'name' ),
'fence_scsi':
- [ 'name' ],
+ ( 'name' ),
'fence_ilo':
- [ 'name', 'hostname', 'login', 'passwd' ],
+ ( 'name', 'hostname', 'login', 'passwd' ),
'fence_ipmilan':
- [ 'name', 'ipaddr', 'login', 'passwd', 'lanplus', 'auth' ],
+ ( 'name', 'ipaddr', 'login', 'passwd', 'lanplus', 'auth' ),
'fence_drac':
- [ 'name', 'ipaddr', 'login', 'passwd' ],
+ ( 'name', 'ipaddr', 'login', 'passwd' ),
'fence_rsa':
- [ 'name', 'hostname', 'login', 'passwd' ],
+ ( 'name', 'hostname', 'login', 'passwd' ),
'fence_rps10':
- [ 'name', 'device', 'port' ],
+ ( 'name', 'device', 'port' ),
'fence_manual':
- [ 'name' ]
+ ( 'name' )
}
--- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 2007/09/21 03:02:47 1.11
+++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 2007/10/03 19:40:37 1.12
@@ -347,21 +347,17 @@
##a separate pass, after the DOM is completely built. This method
##sets the agent type for each fence instance.
def resolve_fence_instance_types(self):
- fds = self.getFenceDevices()
agent_hash = {}
- for fd in fds:
- agent = fd.getAttribute("agent")
+ for fd in self.getFenceDevices():
+ agent = fd.getAgentType()
if agent is not None:
agent_hash[fd.getName()] = agent
- nodes = self.getNodes()
- for node in nodes:
- levels = node.getFenceLevels()
- for level in levels:
- children = level.getChildren()
- for child in children:
+ for node in self.getNodes():
+ for level in node.getFenceLevels():
+ for child in level.getChildren():
child.setAgentType(agent_hash[child.getName()])
-
+
##This method builds RefObject containers for appropriate
##entities after the object tree is built.
def resolve_references(self):
@@ -1137,40 +1133,36 @@
self.CMAN_ptr.removeAttribute('two_node')
def dual_power_fence_check(self):
- #if 2 or more power controllers reside in the same fence level,
- #duplicate entries must be made for every controller with an
- #attribute for option set first for off, then for on.
-
- #for every node:
- #for every fence level:
- #examine every fence
- #If fence is of power type, add to 'found' list for that level
- #If 'found' list is longer than 1, write out extra objs
- nodes = self.getNodes()
- for node in nodes:
- levels = node.getFenceLevels()
- for level in levels:
- kids = level.getChildren()
- l = list()
- for kid in kids:
- if kid.hasNativeOptionSet() == True:
+ # if 2 or more power controllers reside in the same fence level,
+ # duplicate entries must be made for every controller with an
+ # attribute for option set first for off, then for on.
+
+ # for every node:
+ # for every fence level:
+ # examine every fence
+ # If fence is of power type, add to 'found' list for that level
+ # If 'found' list is longer than 1, write out extra objs
+ for node in self.getNodes():
+ for level in node.getFenceLevels():
+ pc_list = list()
+ for kid in level.getChildren():
+ if kid.hasNativeOptionSet() is True:
continue
if kid.isPowerController() is True:
- l.append(kid)
- if len(l) > 1: #Means we found multiple PCs in the same level
- for fence in l:
- fence.addAttribute("option", "off")
- for fence in l:
- if fence.getAttribute("option") == "off":
- d = Device()
- d.setAgentType(fence.getAgentType())
- attrs = fence.getAttributes()
- kees = attrs.keys()
- for k in kees:
- d.addAttribute(k, attrs[k])
- d.addAttribute("option", "on")
- level.addChild(d)
+ pc_list.append(kid)
+ if len(pc_list) > 1:
+ # Means we found multiple PCs in the same level
+ for fence in pc_list:
+ fence.addAttribute("option", "off")
+ d = Device()
+ d.setAgentType(fence.getAgentType())
+ attrs = fence.getAttributes()
+ for (k, v) in attrs.iteritems():
+ d.addAttribute(k, v)
+ d.addAttribute("option", "on")
+ level.addChild(d)
+
def purgePCDuplicates(self):
found_one = True
while found_one is True:
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2008-01-02 21:00 rmccabe
0 siblings, 0 replies; 14+ messages in thread
From: rmccabe @ 2008-01-02 21:00 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2008-01-02 21:00:32
Modified files:
luci/site/luci/Extensions: FenceHandler.py HelperFunctions.py
LuciClusterInfo.py LuciSyslog.py
LuciValidation.py LuciZope.py
LuciZopeAsync.py
LuciZopeClusterPortal.py
LuciZopeExternal.py LuciZopePerm.py
PropsObject.py ResourceHandler.py
Variable.py cluster_adapters.py
conga_constants.py conga_ssl.py
conga_storage_constants.py
homebase_adapters.py
ricci_communicator.py
ricci_defines.py system_adapters.py
Log message:
Update date ranges in copyright notices
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/HelperFunctions.py.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciSyslog.py.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciValidation.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZope.py.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeAsync.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeClusterPortal.py.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeExternal.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopePerm.py.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ResourceHandler.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/Variable.py.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.276&r2=1.277
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_ssl.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_storage_constants.py.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_defines.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/system_adapters.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
--- conga/luci/site/luci/Extensions/FenceHandler.py 2007/12/11 15:54:16 1.28
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2008/01/02 21:00:31 1.29
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/HelperFunctions.py 2007/12/12 15:48:29 1.11
+++ conga/luci/site/luci/Extensions/HelperFunctions.py 2008/01/02 21:00:31 1.12
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/LuciClusterInfo.py 2007/11/06 23:05:07 1.17
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py 2008/01/02 21:00:31 1.18
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/LuciSyslog.py 2007/06/25 16:03:38 1.12
+++ conga/luci/site/luci/Extensions/LuciSyslog.py 2008/01/02 21:00:31 1.13
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/LuciValidation.py 2007/12/12 15:43:15 1.1
+++ conga/luci/site/luci/Extensions/LuciValidation.py 2008/01/02 21:00:31 1.2
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 Red Hat, Inc.
+# Copyright (C) 2007-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/LuciZope.py 2007/12/12 15:48:29 1.6
+++ conga/luci/site/luci/Extensions/LuciZope.py 2008/01/02 21:00:31 1.7
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/LuciZopeAsync.py 2007/12/12 15:48:30 1.4
+++ conga/luci/site/luci/Extensions/LuciZopeAsync.py 2008/01/02 21:00:31 1.5
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 Red Hat, Inc.
+# Copyright (C) 2007-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/LuciZopeClusterPortal.py 2007/06/25 16:03:38 1.2
+++ conga/luci/site/luci/Extensions/LuciZopeClusterPortal.py 2008/01/02 21:00:31 1.3
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/LuciZopeExternal.py 2007/12/12 15:48:30 1.4
+++ conga/luci/site/luci/Extensions/LuciZopeExternal.py 2008/01/02 21:00:31 1.5
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 Red Hat, Inc.
+# Copyright (C) 2007-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/LuciZopePerm.py 2007/06/25 16:03:38 1.2
+++ conga/luci/site/luci/Extensions/LuciZopePerm.py 2008/01/02 21:00:31 1.3
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/PropsObject.py 2007/09/24 21:19:42 1.8
+++ conga/luci/site/luci/Extensions/PropsObject.py 2008/01/02 21:00:31 1.9
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/ResourceHandler.py 2007/09/24 21:19:42 1.4
+++ conga/luci/site/luci/Extensions/ResourceHandler.py 2008/01/02 21:00:31 1.5
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/Variable.py 2007/09/24 21:19:42 1.6
+++ conga/luci/site/luci/Extensions/Variable.py 2008/01/02 21:00:31 1.7
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/12/12 15:45:27 1.276
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2008/01/02 21:00:32 1.277
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/conga_constants.py 2007/11/02 20:49:55 1.46
+++ conga/luci/site/luci/Extensions/conga_constants.py 2008/01/02 21:00:32 1.47
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/conga_ssl.py 2007/09/24 21:19:42 1.4
+++ conga/luci/site/luci/Extensions/conga_ssl.py 2008/01/02 21:00:32 1.5
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/conga_storage_constants.py 2007/10/09 20:20:02 1.11
+++ conga/luci/site/luci/Extensions/conga_storage_constants.py 2008/01/02 21:00:32 1.12
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/homebase_adapters.py 2007/08/08 21:00:07 1.53
+++ conga/luci/site/luci/Extensions/homebase_adapters.py 2008/01/02 21:00:32 1.54
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/ricci_communicator.py 2007/10/09 20:20:02 1.31
+++ conga/luci/site/luci/Extensions/ricci_communicator.py 2008/01/02 21:00:32 1.32
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/ricci_defines.py 2007/09/24 21:19:42 1.3
+++ conga/luci/site/luci/Extensions/ricci_defines.py 2008/01/02 21:00:32 1.4
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
--- conga/luci/site/luci/Extensions/system_adapters.py 2007/06/25 16:03:39 1.3
+++ conga/luci/site/luci/Extensions/system_adapters.py 2008/01/02 21:00:32 1.4
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
@ 2010-08-06 20:17 rmccabe
0 siblings, 0 replies; 14+ messages in thread
From: rmccabe @ 2010-08-06 20:17 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: conga
Branch: RHEL5
Changes by: rmccabe at sourceware.org 2010-08-06 20:17:22
Modified files:
luci/site/luci/Extensions: FenceHandler.py RicciQueries.py
cluster_adapters.py
Log message:
Fix rhbz#612300 - conga will fail to start a new node that is added via luci
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.20&r2=1.4.2.21
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/RicciQueries.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.4.11&r2=1.1.4.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.120.2.48&r2=1.120.2.49
--- conga/luci/site/luci/Extensions/FenceHandler.py 2010/08/05 19:06:35 1.4.2.20
+++ conga/luci/site/luci/Extensions/FenceHandler.py 2010/08/06 20:17:20 1.4.2.21
@@ -650,45 +650,34 @@
fencedev.removeAttribute('secure')
try:
- vmlogin = form['vmlogin'].strip()
- if not vmlogin:
+ vmware_type = form['vmware_type'].strip()
+ if not vmware_type in ('esx', 'server1', 'server2'):
+ vmware_type = None
raise Exception, 'blank'
- fencedev.addAttribute('vmlogin', vmlogin)
- except Exception, e:
- errors.append(FD_PROVIDE_VMLOGIN)
-
- has_vmpasswd = False
- try:
- vmpwd = form['vmpasswd'].strip()
- if not vmpwd:
- # Allow passwords that consist of only spaces.
- if not form.has_key('vmpasswd') or form['vmpasswd'] == '':
- raise Exception, 'blank'
- else:
- vmpwd = form['vmpasswd']
- fencedev.addAttribute('vmpasswd', vmpwd)
- has_vmpasswd = True
+ fencedev.addAttribute('vmware_type', vmware_type)
except Exception, e:
try:
- fencedev.removeAttribute('vmpasswd')
+ fencedev.removeAttribute('vmware_type')
except:
pass
- try:
- vmpwd_script = form['vmpasswd_script'].strip()
- if not vmpwd_script:
- raise Exception, 'blank'
- fencedev.addAttribute('vmpasswd_script', vmpwd_script)
- has_vmpasswd = True
- except Exception, e:
+ if not vmware_type in ('server1', 'server2'):
try:
- fencedev.removeAttribute('vmpasswd_script')
+ vmware_dc = form['vmware_datacenter'].strip()
+ if not vmware_dc:
+ raise Exception, 'blank'
+ fencedev.addAttribute('vmware_datacenter', vmware_dc)
+ except Exception, e:
+ try:
+ fencedev.removeAttribute('vmware_datacenter')
+ except:
+ pass
+ else:
+ try:
+ fencedev.removeAttribute('vmware_datacenter')
except:
pass
- if not has_vmpasswd:
- errors.append(FD_PROVIDE_VMPASSWD)
-
return errors
def val_noop_fd(dummy, _dummy):
--- conga/luci/site/luci/Extensions/RicciQueries.py 2008/09/17 06:29:54 1.1.4.11
+++ conga/luci/site/luci/Extensions/RicciQueries.py 2010/08/06 20:17:20 1.1.4.12
@@ -13,6 +13,7 @@
luci_log = get_logger()
def addClusterNodeBatch(cluster_name,
+ conf_str,
install_base,
install_services,
install_shared_storage,
@@ -22,6 +23,11 @@
reboot_nodes=False):
batch = list()
+ conf = str(conf_str).replace('<?xml version="1.0"?>', '')
+ conf = conf.replace('<?xml version="1.0" ?>', '')
+ conf = conf.replace('<? xml version="1.0"?>', '')
+ conf = conf.replace('<? xml version="1.0" ?>', '')
+
batch.append('<module name="rpm">')
batch.append('<request API_version="1.0">')
batch.append('<function_call name="install">')
@@ -84,15 +90,7 @@
batch.append('<request API_version="1.0">')
batch.append('<function_call name="set_cluster.conf">')
batch.append('<var mutable="false" name="propagate" type="boolean" value="false"/>')
- batch.append('<var mutable="false" name="cluster.conf" type="xml">')
- batch.append('<cluster config_version="1" name="%s">' % cluster_name)
- batch.append('<fence_daemon post_fail_delay="0" post_join_delay="3"/>')
- batch.append('<clusternodes/>')
- batch.append('<cman/>')
- batch.append('<fencedevices/>')
- batch.append('<rm/>')
- batch.append('</cluster>')
- batch.append('</var>')
+ batch.append('<var mutable="false" name="cluster.conf" type="xml">%s</var>' % conf)
batch.append('</function_call>')
batch.append('</request>')
batch.append('</module>')
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2009/01/26 17:01:22 1.120.2.48
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2010/08/06 20:17:21 1.120.2.49
@@ -545,7 +545,26 @@
try:
skeys = system_list.keys()
skeys.sort()
+
+ for x in skeys:
+ i = system_list[x]
+ next_node_id += 1
+ new_node = ClusterNode()
+ new_node.attr_hash['name'] = str(i['host'])
+ new_node.attr_hash['votes'] = str(1)
+ while next_node_id in used_ids:
+ next_node_id += 1
+ new_node.attr_hash['nodeid'] = str(next_node_id)
+ nodesptr.addChild(new_node)
+
+ model.setModified(True)
+ conf_str = str(model.exportModelAsString())
+ if not conf_str:
+ raise Exception, 'Unable to save the new cluster model'
+
+ # Propagate the new cluster.conf to the existing nodes
batch_node = rq.addClusterNodeBatch(clustername,
+ conf_str,
True,
True,
shared_storage,
@@ -559,27 +578,12 @@
raise Exception, 'batch is blank'
for x in skeys:
- i = system_list[x]
system_list[x]['batch'] = batch_node_xml
- next_node_id += 1
- new_node = ClusterNode()
- new_node.attr_hash['name'] = str(i['host'])
- new_node.attr_hash['votes'] = str(1)
- while next_node_id in used_ids:
- next_node_id += 1
- new_node.attr_hash['nodeid'] = str(next_node_id)
- nodesptr.addChild(new_node)
if incomplete or len(errors) > 0:
request.SESSION.set('add_node', add_cluster)
return (False, { 'errors': errors, 'messages': messages })
- model.setModified(True)
- conf_str = str(model.exportModelAsString())
- if not conf_str:
- raise Exception, 'Unable to save the new cluster model'
-
- # Propagate the new cluster.conf to the existing nodes
# before having any of the new nodes join. If this fails,
# abort the whole process.
result = rq.setClusterConfSync(cluster_ricci, conf_str)
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2010-08-06 20:17 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-06 20:17 [Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p rmccabe
-- strict thread matches above, loose matches on Subject: below --
2008-01-02 21:00 rmccabe
2007-10-03 19:40 rmccabe
2007-09-21 3:02 rmccabe
2007-07-26 4:36 rmccabe
2007-05-15 21:42 rmccabe
2007-01-19 21:48 rmccabe
2007-01-19 19:41 rmccabe
2007-01-11 22:49 rmccabe
2006-12-20 22:06 jparsons
2006-12-20 20:24 jparsons
2006-12-18 22:16 jparsons
2006-12-18 15:18 jparsons
2006-12-18 4:44 jparsons
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).