Skip to contentSkip to conversation

conga/luci cluster/form-macros cluster/resourc ...

Cluster-devel [email protected] 1 participant 1 message Feb 8, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-02-08 05:05:22

Modified files:
luci/cluster : form-macros resource_form_handlers.js
luci/homebase : luci_homebase.css luci/site/luci/Extensions: cluster_adapters.py

Log message:
Allow a failover domain to be selected for services

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.182&r2=1.183
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/luci_homebase.css.diff?cvsroot=cluster&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.234&r2=1.235

luci/cluster/form-macros +35 -5
@@ -3920,6 +3920,18 @@
 						<input type="checkbox" name="autostart" checked="checked" />
 					</td>
 				</tr>
+				<tr class="systemsTable">
+					<td class="systemsTable">Failover Domain</td>
+					<td class="systemsTable">
+						<select name="domain">
+							<option value="" selected="selected">None</option>
+							<tal:block tal:repeat="f sinfo/fdoms">
+								<option tal:content="f"
+									tal:attributes="value f" />
+							</tal:block>
+						</select>
+					</td>
+				</tr>
 			</table>
 		</form>
 	</div>
@@ -3945,6 +3957,7 @@
 		<input type="hidden" name="svc_name" value="" />
 		<input type="hidden" name="autostart" value="-1" />
 		<input type="hidden" name="form_xml" />
+		<input type="hidden" name="domain" />
 		<input type="hidden" name="action" value="add" />
 		</form>
 	</div>
@@ -4167,11 +4180,27 @@
 	<div class="service_comp_list">
 		<form name="service_name_form">
 			<table class="rescfg">
-				<tr><td>
-				Automatically start this service
-				</td>
-				<td><input type="checkbox" name="autostart"
-						tal:attributes="checked python: ('autostart' in sinfo and sinfo['autostart'].lower() != 'false') and 'checked'" /></td></tr>
+				<tr>
+					<td>Automatically start this service</td>
+					<td><input type="checkbox" name="autostart"
+							tal:attributes="checked python: ('autostart' in sinfo and sinfo['autostart'].lower() != 'false') and 'checked'" />
+					</td>
+				</tr>
+				<tr>
+					<td>Failover Domain</td>
+					<td>
+						<select name="domain">
+							<option value=""
+								tal:attributes="selected python: (not 'domain' in sinfo or not sinfo['domain']) and 'selected' or ''">None</option>
+							<tal:block tal:repeat="f sinfo/fdoms">
+								<option tal:content="f"
+									tal:attributes="
+										value f;
+										selected python: ('domain' in sinfo and sinfo['domain'] == f) and 'selected' or ''" />
+							</tal:block>
+						</select>
+					</td>
+				</tr>
 			</table>
 			<input type="hidden" name="service_name"
 				tal:attributes="value sinfo/name | string:1" />
@@ -4195,6 +4224,7 @@
 		<input type="hidden" name="svc_name" value="" />
 		<input type="hidden" name="autostart" value="-1" />
 		<input type="hidden" name="form_xml" />
+		<input type="hidden" name="domain" />
 		<input type="hidden" name="action" value="edit" />
 		</form>
 	</div>
luci/cluster/resource_form_handlers.js +9 -0
@@ -423,6 +423,7 @@
 	var form_xml = '';
 	var svc_name = null;
 	var autostart = 1;
+	var domain = null;
 
 	var form = document.getElementsByTagName('form');
 	for (var i = 0 ; i < form.length ; i++) {
@@ -437,6 +438,12 @@
 			}
 			if (!form[i].autostart.checked)
 				autostart = 0;
+
+			if (form[i].domain) {
+				domain = form[i].domain.options[form[i].domain.options.selectedIndex].value;
+				if (str_is_blank(domain))
+					domain = null;
+			}
 			continue;
 		}
 
@@ -486,6 +493,8 @@
 	/* sort this out in the backend */
 	master_form.form_xml.value = '<formlist>' + form_xml + '</formlist>';
 	master_form.svc_name.value = svc_name;
+	if (domain)
+		master_form.domain.value = domain;
 	master_form.autostart.value = autostart;
 
 	var confirm_msg = null;
luci/homebase/luci_homebase.css +0 -2
@@ -336,7 +336,6 @@
 strong.cluster {
 	text-align: top;
 	font-size: 9pt;
-	letter-spacing: +.5px;
 }
 
 *.reshdr {
@@ -350,7 +349,6 @@
 strong.node_name,
 strong.cluster_name {
 	font-size: 10pt;
-	letter-spacing: +.5px;
 }
 
 td.service_name,
luci/site/luci/Extensions/cluster_adapters.py +22 -0
@@ -775,6 +775,14 @@
 	if len(errors) > 0:
 		return (False, {'errors': errors})
 
+	fdom = None
+	try:
+		fdom = request.form['domain'].strip()
+		if not fdom:
+			raise Exception, 'blank'
+	except:
+		fdom = None
+
 	try:
 		service_name = request.form['svc_name'].strip()
 	except Exception, e:
@@ -827,6 +835,8 @@
 
 	new_service = Service()
 	new_service.addAttribute('name', service_name)
+	if fdom:
+		new_service.addAttribute('domain', fdom)
 	if autostart is not None:
 		new_service.attr_hash['autostart'] = autostart
 
@@ -3270,6 +3280,11 @@
 		baseurl = '/luci/cluster/index_html'
 
 	try:
+		hmap['fdoms'] = map(lambda x: x.getName(), model.getFailoverDomains())
+	except:
+		hmap['fdoms'] = list()
+
+	try:
 		cluname = req['clustername']
 		if not cluname:
 			raise KeyError, 'is blank'
@@ -3334,6 +3349,11 @@
 	#Now build hashes for resources under service.
 	#first get service by name from model
 	svc = model.getService(servicename)
+	try:
+		hmap['domain'] = svc.getAttribute('domain')
+	except:
+		hmap['domain'] = None
+
 	resource_list = list()
 	if svc is not None:
 		indent_ctr = 0
@@ -3357,9 +3377,11 @@
 	#Note: Final version needs all resource attrs
 	if child.isRefObject() == True:
 		rc_map['ref_object'] = True
+		rc_map['tag_name'] = child.getObj().TAG_NAME
 		rc_map['type'] = child.getObj().getResourceType()
 		rc_map['attrs'] = child.getObj().getAttributes()
 	else:
+		rc_map['tag_name'] = child.TAG_NAME
 		rc_map['type'] = child.getResourceType()
 		rc_map['attrs'] = child.getAttributes()