Index: luci/cluster/validate_config_qdisk.js =================================================================== RCS file: /cvs/cluster/conga/luci/cluster/validate_config_qdisk.js,v retrieving revision 1.4.2.7 diff -u -r1.4.2.7 validate_config_qdisk.js --- a/luci/cluster/validate_config_qdisk.js 14 Jul 2008 21:52:30 -0000 1.4.2.7 +++ b/luci/cluster/validate_config_qdisk.js 6 Aug 2010 23:52:09 -0000 @@ -104,8 +104,6 @@ var hint = document.getElementById(hstr + ':hinterval'); if (!hint || str_is_blank(hint.value)) { ++blank; - errors.push('No interval was given for heuristic ' + (hnum + 1)); - set_form_err(hint); } else { if (!is_valid_int(hint.value, 1, null)) { errors.push('Heuristic interval values must be greater than 0.'); @@ -117,8 +115,6 @@ var hscore = document.getElementById(hstr + ':hscore'); if (!hscore || str_is_blank(hscore.value)) { ++blank; - errors.push('No score was given for heuristic ' + (hnum + 1)); - set_form_err(hscore); } else { if (!is_valid_int(hscore.value, 0, null)) { errors.push('Heuristic score values must be 0 or greater.'); @@ -169,9 +165,8 @@ } if (qpart) { - if (!form.interval || str_is_blank(form.interval.value)) { - errors.push('No interval setting was given.'); - set_form_err(form.interval); + if (form.interval && str_is_blank(form.interval.value)) { + clr_form_err(form.interval); } else { if (!is_valid_int(form.interval.value, 1, null)) { errors.push('Interval values must be integers greater than 0.'); @@ -180,9 +175,8 @@ clr_form_err(form.interval); } - if (!form.tko || str_is_blank(form.tko.value)) { - errors.push('No TKO setting was given.'); - set_form_err(form.tko); + if (form.tko && str_is_blank(form.tko.value)) { + clr_form_err(form.tko); } else { if (!is_valid_int(form.tko.value, 1, null)) { errors.push('TKO values must be greater than 0.'); @@ -191,9 +185,8 @@ clr_form_err(form.tko); } - if (!form.votes || str_is_blank(form.votes.value)) { - errors.push('No votes setting was given.'); - set_form_err(form.votes); + if (form.votes && str_is_blank(form.votes.value)) { + clr_form_err(form.votes); } else { if (!is_valid_int(form.votes.value, 1, null)) { errors.push('Votes values must be greater than 0.'); @@ -202,6 +195,16 @@ clr_form_err(form.votes); } + if (form.min_score && str_is_blank(form.min_score.value)) { + clr_form_err(form.min_score); + } else { + if (!is_valid_int(form.min_score.value, 1, null)) { + errors.push('Minimum score values must be greater than 0.'); + set_form_err(form.min_score); + } else + clr_form_err(form.min_score); + } + var no_dev = !form.device || str_is_blank(form.device.value); var no_label = !form.label || str_is_blank(form.label.value); if (no_dev && no_label) @@ -218,21 +221,6 @@ if (err) errors = errors.concat(err); } - - if (hnum > 1) { - if (!form.min_score || str_is_blank(form.min_score.value)) { - errors.push('No minimum score setting was given.'); - set_form_err(form.min_score); - } else { - if (!is_valid_int(form.min_score.value, 1, null)) { - errors.push('Minimum score values must be greater than 0.'); - set_form_err(form.min_score); - } else - clr_form_err(form.min_score); - } - } else { - clr_form_err(form.min_score); - } } else { clr_form_err(form.min_score); } Index: luci/site/luci/Extensions/LuciValidation.py =================================================================== RCS file: /cvs/cluster/conga/luci/site/luci/Extensions/LuciValidation.py,v retrieving revision 1.6.2.15 diff -u -r1.6.2.15 LuciValidation.py --- a/luci/site/luci/Extensions/LuciValidation.py 6 Aug 2010 21:57:43 -0000 1.6.2.15 +++ b/luci/site/luci/Extensions/LuciValidation.py 6 Aug 2010 23:52:09 -0000 @@ -747,38 +747,46 @@ return (True, {}) try: - interval = int(form['interval']) - if interval < 0: - raise ValueError, 'Interval must be 0 or greater' + interval = form['interval'] + if interval: + interval = int(interval) + if interval < 0: + raise ValueError, 'Interval must be 0 or greater' except KeyError, e: errors.append('No Interval value was given') except ValueError, e: errors.append('An invalid Interval value was given: %s' % str(e)) try: - votes = int(form['votes']) - if votes < 1: - raise ValueError, 'Votes must be greater than 0' + votes = form['votes'] + if votes: + votes = int(votes) + if votes < 1: + raise ValueError, 'Votes must be greater than 0' except KeyError, e: - errors.append('No Votes value was given') + votes = None except ValueError, e: errors.append('An invalid Votes value was given: %s' % str(e)) try: - tko = int(form['tko']) - if tko < 0: - raise ValueError, 'TKO must be 0 or greater' + tko = form['tko'] + if tko: + tko = int(tko) + if tko < 0: + raise ValueError, 'TKO must be 0 or greater' except KeyError, e: - errors.append('No TKO value was given') + tko = None except ValueError, e: errors.append('An invalid TKO value was given: %s' % str(e)) try: - min_score = int(form['min_score']) - if min_score < 1: - raise ValueError('Minimum Score must be greater than 0') + min_score = form['min_score'] + if min_score: + min_score = int(min_score) + if min_score < 1: + raise ValueError('Minimum Score must be greater than 0') except KeyError, e: - errors.append('No Minimum Score value was given') + min_score = None except ValueError, e: errors.append('An invalid Minimum Score value was given: %s' % str(e)) @@ -826,21 +834,23 @@ except Exception, e: errors.append('No program was given for heuristic %d' % (i + 1)) try: - hint = int(h[1]) - if hint < 1: - raise ValueError, 'Heuristic interval values must be greater than 0' + if h[1]: + hint = int(h[1]) + if hint < 1: + raise ValueError, 'Heuristic interval values must be greater than 0' except KeyError, e: - errors.append('No interval was given for heuristic %d' % (i + 1)) + hint = None except ValueError, e: errors.append('An invalid interval was given for heuristic %d: %s' \ % ((i + 1), str(e))) try: - hscore = int(h[2]) - if hscore < 1: - raise ValueError, 'Heuristic scores must be greater than 0' + if h[2]: + hscore = int(h[2]) + if hscore < 1: + raise ValueError, 'Heuristic scores must be greater than 0' except KeyError, e: - errors.append('No score was given for heuristic %d' % (i + 1)) + hscore = None except ValueError, e: errors.append('An invalid score was given for heuristic %d: %s' \ % ((i + 1), str(e))) @@ -851,10 +861,14 @@ return (False, {'errors': errors }) qd = QuorumD() - qd.addAttribute('interval', str(interval)) - qd.addAttribute('votes', str(votes)) - qd.addAttribute('tko', str(tko)) - qd.addAttribute('min_score', str(min_score)) + if interval: + qd.addAttribute('interval', str(interval)) + if votes: + qd.addAttribute('votes', str(votes)) + if tko: + qd.addAttribute('tko', str(tko)) + if min_score: + qd.addAttribute('min_score', str(min_score)) if device: qd.addAttribute('device', str(device)) @@ -871,8 +885,10 @@ for h in heuristics: new_h = Heuristic() new_h.addAttribute('program', str(h[0])) - new_h.addAttribute('interval', str(h[1])) - new_h.addAttribute('score', str(h[2])) + if h[1]: + new_h.addAttribute('interval', str(h[1])) + if h[2]: + new_h.addAttribute('score', str(h[2])) qd.addChild(new_h) if len(errors) > 0: Index: luci/site/luci/Extensions/ClusterModel/ModelBuilder.py =================================================================== RCS file: /cvs/cluster/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py,v retrieving revision 1.1.4.14 diff -u -r1.1.4.14 ModelBuilder.py --- a/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 6 Aug 2010 21:57:43 -0000 1.1.4.14 +++ b/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 6 Aug 2010 23:52:09 -0000 @@ -1120,7 +1120,10 @@ cur_votes = 1 node_votes += cur_votes - return node_votes + qdisk_votes + if qdisk_votes != 0: + return node_votes + qdisk_votes + else: + return 2 * node_votes - 1 def updateReferences(self): self.__updateReferences(self.cluster_ptr)