[Cluster-devel] conga/luci/site/luci/Extensions FenceHandler.p ...
jparsons at sourceware.org
jparsons at sourceware.org
Mon Dec 18 15:18:38 UTC 2006
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()
More information about the Cluster-devel
mailing list