From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 24 Aug 2007 22:01:47 -0000 Subject: [Cluster-devel] conga/luci cluster/form-macros cluster/validat ... Message-ID: <20070824220147.28677.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2007-08-24 22:01:45 Modified files: luci/cluster : form-macros validate_config_multicast.js validate_config_qdisk.js luci/site/luci/Extensions: LuciClusterInfo.py cluster_adapters.py luci/site/luci/Extensions/ClusterModel: ModelBuilder.py Log message: qdisk and multicast configuration fixes from the RHEL4 branch Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.209&r2=1.210 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_multicast.js.diff?cvsroot=cluster&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_qdisk.js.diff?cvsroot=cluster&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.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.268&r2=1.269 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&r1=1.6&r2=1.7 --- conga/luci/cluster/form-macros 2007/08/24 18:42:06 1.209 +++ conga/luci/cluster/form-macros 2007/08/24 22:01:41 1.210 @@ -1082,7 +1082,7 @@ @@ -1097,7 +1097,7 @@ @@ -1122,6 +1122,18 @@ value clusterinfo/mcast_addr |nothing" /> + + + Multicast network interface (optional) + + + + + --- conga/luci/cluster/validate_config_multicast.js 2007/08/24 18:42:06 1.5 +++ conga/luci/cluster/validate_config_multicast.js 2007/08/24 22:01:41 1.6 @@ -8,24 +8,36 @@ */ var prev_mcast_str = ''; +var prev_mcast_if = ''; -function disable_mcast(addrId) { - addrObj = document.getElementById(addrId); - if (!addrObj) { - return; - } - addrObj.disabled = true; - prev_mcast_str = addrObj.value; - addrObj.value = ''; +function disable_mcast(addrId, ifId) { + var addrObj = document.getElementById(addrId); + if (addrObj) { + prev_mcast_str = addrObj.value; + addrObj.disabled = true; + addrObj.value = ''; + } + + var ifObj = document.getElementById(ifId); + if (ifObj) { + prev_mcast_if = ifObj.value; + ifObj.disabled = true; + ifObj.value = ''; + } } -function enable_mcast(addrId) { - addrObj = document.getElementById(addrId); - if (!addrObj) { - return; +function enable_mcast(addrId, ifId) { + var addrObj = document.getElementById(addrId); + if (addrObj) { + addrObj.disabled = false; + addrObj.value = prev_mcast_str; + } + + var ifObj = document.getElementById(ifId); + if (ifObj) { + ifObj.disabled = false; + ifObj.value = prev_mcast_if; } - addrObj.disabled = false; - addrObj.value = prev_mcast_str; } function validate_form(form) { @@ -54,6 +66,7 @@ clr_form_err(form.mcast[0]); clr_form_err(form.mcast[1]); clr_form_err(form.mcast_address); + clr_form_err(form.mcast_interface); } if (mcast == 1) { @@ -68,6 +81,15 @@ } clr_form_err(form.mcast_address); } + + if (form.cluster_version && form.cluster_version.value == 'rhel4') { + if (!form.mcast_interface || str_is_blank(form.mcast_interface.value)) { + set_form_err(form.mcast_interface); + errors.push('No multicast interface was given.'); + } else { + clr_form_err(form.mcast_interface); + } + } } if (error_dialog(errors)) --- conga/luci/cluster/validate_config_qdisk.js 2007/08/08 21:00:06 1.8 +++ conga/luci/cluster/validate_config_qdisk.js 2007/08/24 22:01:41 1.9 @@ -180,17 +180,6 @@ clr_form_err(form.interval); } - if (!form.votes || str_is_blank(form.votes.value)) { - errors.push('No votes setting was given.'); - set_form_err(form.votes); - } else { - if (!is_valid_int(form.votes.value, 1, null)) { - errors.push('Votes values must be greater than 0.'); - set_form_err(form.votes); - } else - clr_form_err(form.votes); - } - if (!form.tko || str_is_blank(form.tko.value)) { errors.push('No TKO setting was given.'); set_form_err(form.tko); @@ -202,15 +191,15 @@ clr_form_err(form.tko); } - 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); + if (!form.votes || str_is_blank(form.votes.value)) { + errors.push('No votes setting was given.'); + set_form_err(form.votes); } 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); + if (!is_valid_int(form.votes.value, 1, null)) { + errors.push('Votes values must be greater than 0.'); + set_form_err(form.votes); } else - clr_form_err(form.min_score); + clr_form_err(form.votes); } var no_dev = !form.device || str_is_blank(form.device.value); @@ -226,6 +215,23 @@ 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); } } --- conga/luci/site/luci/Extensions/LuciClusterInfo.py 2007/08/24 18:42:06 1.11 +++ conga/luci/site/luci/Extensions/LuciClusterInfo.py 2007/08/24 22:01:42 1.12 @@ -618,9 +618,11 @@ is_mcast = model.isMulticast() if is_mcast: clumap['mcast_addr'] = model.getMcastAddr() + clumap['mcast_interface'] = model.getMcastInterface() clumap['is_mcast'] = 'True' else: clumap['mcast_addr'] = None + clumap['mcast_interface'] = None clumap['is_mcast'] = 'False' clumap['gulm'] = False else: --- conga/luci/site/luci/Extensions/cluster_adapters.py 2007/08/24 18:42:06 1.268 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2007/08/24 22:01:42 1.269 @@ -974,6 +974,14 @@ errors.append('An invalid multicast selection was made') return (False, {'errors': errors}) + mcast_interface = None + if form.has_key('mcast_interface'): + mcast_interface = form['mcast_interface'].strip() + + if mcast_manual is True and form.has_key('cluster_version') and form['cluster_version'].strip() == 'rhel4' and not mcast_interface: + errors.append('No multicast interface was specified') + return (False, {'errors': errors}) + if mcast_manual is True: import socket try: @@ -992,20 +1000,13 @@ addr_str = None try: - old_mcast_addr = model.getMcastAddr() - except Exception, e: - luci_log.debug_verbose('VMCC0: %r %s' % (e, str(e))) - old_mcast_addr = None - - if (addr_str is None and mcast_manual is not True and not old_mcast_addr) or (mcast_manual is True and addr_str == old_mcast_addr): - errors.append('No multicast configuration changes were made') - return (False, {'errors': errors}) - - try: - if model.getMcastAddr() is not None and not addr_str: + if not addr_str: + if mcast_interface: + errors.append('A multicast interface was specified, but no multicast address was given') + return (False, {'errors': errors}) model.del_cluster_multicast() else: - model.set_cluster_multicast(addr_str) + model.set_cluster_multicast(addr_str, mcast_if=mcast_interface) except Exception, e: if LUCI_DEBUG_MODE is True: luci_log.debug('Error updating mcast properties: %r %s' \ @@ -1108,7 +1109,7 @@ for i in xrange(num_heuristics): try: h = form['heuristic%d' % i] - if not h or len(h) != 3: + if not h or len(h) != 3 or not (h[0].strip() and h[1].strip() and h[2].strip()): continue except: continue @@ -1118,26 +1119,26 @@ if not hprog: raise Exception, 'no hprog' except Exception, e: - errors.append('No program was given for heuristic %d' % i + 1) + 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' except KeyError, e: - errors.append('No interval was given for heuristic %d' % i + 1) + errors.append('No interval was given for heuristic %d' % (i + 1)) except ValueError, e: errors.append('An invalid interval was given for heuristic %d: %s' \ - % (i + 1, str(e))) + % ((i + 1), str(e))) try: 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) + errors.append('No score was given for heuristic %d' % (i + 1)) except ValueError, e: errors.append('An invalid score was given for heuristic %d: %s' \ - % (i + 1, str(e))) + % ((i + 1), str(e))) heuristics.append([ hprog, hint, hscore ]) --- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 2007/08/24 18:42:06 1.6 +++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py 2007/08/24 22:01:42 1.7 @@ -682,17 +682,23 @@ children = self.CMAN_ptr.getChildren() for child in children: if child.getTagName() == MCAST_STR: + self.mcast_ptr = child addr = child.getAttribute("addr") if addr is not None: self.mcast_address = addr - return else: #What a mess! a multicast tag, but no addr attribute self.mcast_address = "" - return + mcastif = child.getAttribute("interface") + if mcastif is not None: + self.mcast_interface = mcastif + return def getMcastAddr(self): return self.mcast_address + def getMcastInterface(self): + return self.mcast_interface + def isQuorumd(self): return self.usesQuorumd @@ -877,6 +883,8 @@ self.usesMulticast = None self.mcast_address = None + self.mcast_interface = None + self.mcast_ptr = None #reset self.lock_type self.lock_type = GULM_TYPE @@ -985,7 +993,7 @@ for child in iter(self.CMAN_ptr.getChildren()): if child.getTagName() == MCAST_STR: self.CMAN_ptr.removeChild(child) - break + self.mcast_ptr = None self.usesMulticast = False self.mcast_address = None