[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci cluster/form-macros cluster/resourc ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2007-02-08 16:00:36

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

Log message:
	Support fdoms, recovery, and running exclusive for services.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.183&r2=1.184
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.235&r2=1.236

--- conga/luci/cluster/form-macros	2007/02/08 05:05:21	1.183
+++ conga/luci/cluster/form-macros	2007/02/08 16:00:36	1.184
@@ -3820,6 +3820,41 @@
 				<p class="reshdr">Create a Virtual Machine Service</p>
 			</td></tr>
 		<tfoot class="systemsTable">
+			<tr class="systemsTable">
+				<td>Automatically start this service</td>
+				<td>
+					<input type="checkbox" name="autostart" checked="checked">
+				</td>
+			</tr>
+			<tr class="systemsTable">
+				<td>Run exclusive</td>
+				<td>
+					<input type="checkbox" name="exclusive">
+				</td>
+			</tr>
+			<tr class="systemsTable">
+				<td>Failover Domain</td>
+				<td>
+					<select name="domain">
+						<option value="" selected="selected">None</option>
+						<tal:block tal:repeat="f python:here.get_fdom_names(modelb)">
+							<option tal:content="f"
+								tal:attributes="value f" />
+						</tal:block>
+					</select>
+				</td>
+			</tr>
+			<tr class="systemsTable">
+				<td>Recovery policy</td>
+				<td>
+					<select name="recovery">
+						<option value="">Select a recovery policy</option>
+						<option name="relocate" value="relocate">Relocate</option>
+						<option name="restart" value="restart">Restart</option>
+						<option name="disable" value="disable">Disable</option>
+					</select>
+				</td>
+			</tr>
 			<tr class="systemsTable"><td colspan="2">
 				<div class="hbSubmit">
 					<input type="submit" value="Create Virtual Machine Service" />
@@ -3861,6 +3896,52 @@
 				<p class="reshdr">Properties for <tal:block tal:replace="vminfo/name | string:virtual machine service"/></p>
 			</td></tr>
 		<tfoot class="systemsTable">
+			<tr class="systemsTable">
+				<td>Automatically start this service</td>
+				<td>
+					<input type="checkbox" name="autostart"
+						tal:attributes="checked python: ('autostart' in vminfo and vminfo['autostart'] != '0') and 'checked' or ''" />
+				</td>
+			</tr>
+			<tr class="systemsTable">
+				<td>Run exclusive</td>
+				<td>
+					<input type="checkbox" name="exclusive"
+						tal:attributes="checked python: ('exclusive' in vminfo and vminfo['exclusive'] != '0') and 'checked' or ''" />
+				</td>
+			</tr>
+			<tr class="systemsTable">
+				<td>Failover Domain</td>
+				<td>
+					<select name="domain">
+						<option value="" tal:content="string:None"
+							tal:attributes="selected python: (not 'domain' in vminfo or not vminfo['domain']) and 'selected' or ''" />
+						<tal:block tal:repeat="f python:here.get_fdom_names(modelb)">
+							<option tal:content="f"
+								tal:attributes="
+									value f;
+									selected python: ('domain' in vminfo and vminfo['domain'] == f) and 'selected' or ''" />
+						</tal:block>
+					</select>
+				</td>
+			</tr>
+			<tr class="systemsTable">
+				<td>Recovery policy</td>
+				<td>
+					<select name="recovery">
+						<option value="">Select a recovery policy</option>
+						<option name="relocate" value="relocate"
+							tal:content="string:Relocate"
+							tal:attributes="selected python: ('recovery' in vminfo and vminfo['recovery'] == 'relocate') and 'selected' or ''" />
+						<option name="restart" value="restart"
+							tal:content="string:Restart"
+							tal:attributes="selected python: ('recovery' in vminfo and vminfo['recovery'] == 'restart') and 'selected' or ''" />
+						<option name="disable" value="disable"
+							tal:content="string:Disable"
+							tal:attributes="selected python: ('recovery' in vminfo and vminfo['recovery'] == 'disable') and 'selected' or ''" />
+					</select>
+				</td>
+			</tr>
 			<tr class="systemsTable"><td colspan="2">
 				<div class="hbSubmit">
 					<input name="submit" type="submit" value="Update Virtual Machine Service" />
@@ -3921,6 +4002,12 @@
 					</td>
 				</tr>
 				<tr class="systemsTable">
+					<td class="systemsTable">Run exclusive</td>
+					<td class="systemsTable">
+						<input type="checkbox" name="exclusive">
+					</td>
+				</tr>
+				<tr class="systemsTable">
 					<td class="systemsTable">Failover Domain</td>
 					<td class="systemsTable">
 						<select name="domain">
@@ -3932,6 +4019,17 @@
 						</select>
 					</td>
 				</tr>
+				<tr class="systemsTable">
+					<td class="systemsTable">Recovery policy</td>
+					<td class="systemsTable">
+						<select name="recovery">
+							<option value="">Select a recovery policy</option>
+							<option name="relocate" value="relocate">Relocate</option>
+							<option name="restart" value="restart">Restart</option>
+							<option name="disable" value="disable">Disable</option>
+						</select>
+					</td>
+				</tr>
 			</table>
 		</form>
 	</div>
@@ -3956,8 +4054,10 @@
 		<input type="hidden" name="tree_level" value="-1" />
 		<input type="hidden" name="svc_name" value="" />
 		<input type="hidden" name="autostart" value="-1" />
-		<input type="hidden" name="form_xml" />
+		<input type="hidden" name="exclusive" value="-1" />
+		<input type="hidden" name="recovery" />
 		<input type="hidden" name="domain" />
+		<input type="hidden" name="form_xml" />
 		<input type="hidden" name="action" value="add" />
 		</form>
 	</div>
@@ -4187,6 +4287,12 @@
 					</td>
 				</tr>
 				<tr>
+					<td>Run exclusive</td>
+					<td><input type="checkbox" name="exclusive"
+							tal:attributes="checked python: ('exclusive' in sinfo and sinfo['exclusive'].lower() != 'false') and 'checked'" />
+					</td>
+				</tr>
+				<tr>
 					<td>Failover Domain</td>
 					<td>
 						<select name="domain">
@@ -4201,6 +4307,23 @@
 						</select>
 					</td>
 				</tr>
+				<tr class="systemsTable">
+					<td>Recovery policy</td>
+					<td>
+						<select name="recovery">
+							<option value="">Select a recovery policy</option>
+							<option name="relocate" value="relocate"
+								tal:content="string:Relocate"
+								tal:attributes="selected python: ('recovery' in sinfo and sinfo['recovery'] == 'relocate') and 'selected' or ''" />
+							<option name="restart" value="restart"
+								tal:content="string:Restart"
+								tal:attributes="selected python: ('recovery' in sinfo and sinfo['recovery'] == 'restart') and 'selected' or ''" />
+							<option name="disable" value="disable"
+								tal:content="string:Disable"
+								tal:attributes="selected python: ('recovery' in sinfo and sinfo['recovery'] == 'disable') and 'selected' or ''" />
+						</select>
+					</td>
+				</tr>
 			</table>
 			<input type="hidden" name="service_name"
 				tal:attributes="value sinfo/name | string:1" />
@@ -4223,8 +4346,10 @@
 		<input type="hidden" name="tree_level" value="-1" />
 		<input type="hidden" name="svc_name" value="" />
 		<input type="hidden" name="autostart" value="-1" />
-		<input type="hidden" name="form_xml" />
+		<input type="hidden" name="exclusive" value="-1" />
+		<input type="hidden" name="recovery" />
 		<input type="hidden" name="domain" />
+		<input type="hidden" name="form_xml" />
 		<input type="hidden" name="action" value="edit" />
 		</form>
 	</div>
--- conga/luci/cluster/resource-form-macros	2007/01/29 16:56:50	1.31
+++ conga/luci/cluster/resource-form-macros	2007/02/08 16:00:36	1.32
@@ -129,11 +129,6 @@
 				</option>
 				<option name="TOMCAT-5" value="TOMCAT-5">Tomcat 5</option>
 			</tal:block>
-
-			<tal:block
-				tal:condition="python: os_version and os_version == 'rhel5'">
-				<option name="VM" value="VM">Virtual Machine</option>
-			</tal:block>
 		</select>
 		</form>
 	</p>
@@ -174,6 +169,17 @@
 			<option name="NFSX" value="NFSX">NFS export</option>
 			<option name="SCR" value="SCR">Script</option>
 			<option name="SMB" value="SMB">Samba</option>
+
+			<tal:block
+				tal:condition="python: os_version and os_version == 'rhel4'">
+				<option name="APACHE" value="APACHE">Apache</option>
+				<option name="MYSQL" value="MYSQL">MySQL</option>
+				<option name="OPENLDAP" value="OPENLDAP">Open LDAP</option>
+				<option name="POSTGRES-8" value="POSTGRES-8">
+					PostgreSQL 8
+				</option>
+				<option name="TOMCAT-5" value="TOMCAT-5">Tomcat 5</option>
+			</tal:block>
 		</select>
 		</form>
 	</p>
@@ -419,10 +425,10 @@
 
 					<option name="ext3" value="ext3"
 						tal:content="string: ext3"
-						tal:attributes="checked python: fstype == 'ext3' and 'checked'" />
+						tal:attributes="selected python: fstype == 'ext3' and 'selected'" />
 					<option name="ext2" value="ext2"
 						tal:content="string: ext2"
-						tal:attributes="checked python: fstype == 'ext2' and 'checked'" />
+						tal:attributes="selected python: fstype == 'ext2' and 'selected'" />
 				</select>
 			</td>
 		</tr>
--- conga/luci/cluster/resource_form_handlers.js	2007/02/08 05:05:21	1.30
+++ conga/luci/cluster/resource_form_handlers.js	2007/02/08 16:00:36	1.31
@@ -424,6 +424,8 @@
 	var svc_name = null;
 	var autostart = 1;
 	var domain = null;
+	var exclusive = 0;
+	var recovery = null;
 
 	var form = document.getElementsByTagName('form');
 	for (var i = 0 ; i < form.length ; i++) {
@@ -436,9 +438,21 @@
 				clr_form_err(form[i].service_name);
 				svc_name = form[i].service_name.value;
 			}
+
 			if (!form[i].autostart.checked)
 				autostart = 0;
 
+			if (!form[i].exclusive.checked)
+				exclusive = 0;
+			else
+				exclusive = 1;
+
+			if (form[i].recovery) {
+				recovery = form[i].recovery.options[form[i].recovery.options.selectedIndex].value;
+				if (str_is_blank(recovery))
+					recovery = null;
+			}
+
 			if (form[i].domain) {
 				domain = form[i].domain.options[form[i].domain.options.selectedIndex].value;
 				if (str_is_blank(domain))
@@ -487,6 +501,10 @@
 	if (!form_xml)
 		errors.push('No resource information was submitted.');
 
+	if (recovery && recovery != 'relocate' && recovery != 'restart' && recovery != 'disable') {
+		errors.push('You entered an invalid recovery option. Valid options are "relocate" "restart" and "disable"');
+	}
+
 	if (error_dialog(errors))
 		return (-1);
 
@@ -495,7 +513,10 @@
 	master_form.svc_name.value = svc_name;
 	if (domain)
 		master_form.domain.value = domain;
+	if (recovery)
+		master_form.recovery.value = recovery;
 	master_form.autostart.value = autostart;
+	master_form.exclusive.value = exclusive;
 
 	var confirm_msg = null;
 	if (master_form.action.value == 'add')
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/08 05:05:22	1.235
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/02/08 16:00:36	1.236
@@ -783,6 +783,17 @@
 	except:
 		fdom = None
 
+	recovery = None
+	try:
+		recovery = request.form['recovery'].strip()
+		if not recovery:
+			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\"')
+	except:
+		recovery = None
+
 	try:
 		service_name = request.form['svc_name'].strip()
 	except Exception, e:
@@ -797,6 +808,15 @@
 		autostart = None
 		luci_log.debug_verbose('vSA5a: error getting autostart: %s' % str(e))
 
+	exclusive = "0"
+	try:
+		if not request.form.has_key('exclusive') or request.form['exclusive'] != "1":
+			exclusive = "0"
+		else:
+			exclusive = "1"
+	except Exception, e:
+		exclusive = "0"
+
 	try:
 		cur_service = model.retrieveServiceByName(service_name)
 	except GeneralError, e:
@@ -837,6 +857,9 @@
 	new_service.addAttribute('name', service_name)
 	if fdom:
 		new_service.addAttribute('domain', fdom)
+	if recovery:
+		new_service.addAttribute('recovery', recovery)
+	new_service.addAttribute('exclusive', str(exclusive))
 	if autostart is not None:
 		new_service.attr_hash['autostart'] = autostart
 
@@ -2179,6 +2202,43 @@
 		luci_log.debug_verbose('validateVM1: no vm path: %s' % str(e))
 		errors.append('No path to the virtual machine configuration file was given.')
 
+	autostart = 1
+	try:
+		if request.form.has_key('autostart'):
+			autostart = 1
+		else:
+			autostart = 0
+	except:
+		autostart = 1
+
+	exclusive = 0
+	try:
+		if request.form.has_key('exclusive'):
+			exclusive = 1
+		else:
+			exclusive = 0
+	except:
+		exclusive = 0
+
+	recovery = None
+	try:
+		recovery = request.form['recovery'].strip()
+		if not recovery:
+			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\"')
+	except:
+		recovery = None
+
+	fdom = None
+	try:
+		fdom = request.form['domain'].strip()
+		if not fdom:
+			raise Exception, 'blank'
+	except:
+		fdom = None
+
 	if len(errors) > 0:
 		return (False, {'errors': errors })
 
@@ -2218,6 +2278,24 @@
 			xvm.addAttribute('name', vm_name)
 			xvm.addAttribute('path', vm_path)
 
+	xvm.addAttribute('autostart', str(autostart))
+	xvm.addAttribute('exclusive', str(exclusive))
+	if fdom:
+		xvm.addAttribute('domain', fdom)
+	else:
+		try:
+			xvm.removeAttribute('domain')
+		except:
+			pass
+
+	if recovery:
+		xvm.addAttribute('recovery', recovery)
+	else:
+		try:
+			xvm.removeAttribute('recovery')
+		except:
+			pass
+
 	try:
 		model.setModified(True)
 		stringbuf = str(model.exportModelAsString())
@@ -3240,9 +3318,15 @@
 		if item['type'] == "service":
 			itemmap = {}
 			itemmap['name'] = item['name']
+
 			if item['running'] == "true":
 				itemmap['running'] = "true"
 				itemmap['nodename'] = item['nodename']
+				itemmap['disableurl'] = baseurl + "?" + "clustername=" + cluname +"&servicename=" + item['name'] + "&pagetype=" + SERVICE_STOP
+				itemmap['restarturl'] = baseurl + "?" + "clustername=" + cluname +"&servicename=" + item['name'] + "&pagetype=" + SERVICE_RESTART
+			else:
+				itemmap['enableurl'] = baseurl + "?" + "clustername=" + cluname +"&servicename=" + item['name'] + "&pagetype=" + SERVICE_START
+
 			itemmap['autostart'] = item['autostart']
 
 			try:
@@ -3267,6 +3351,9 @@
 	map['services'] = maplist
 	return map
 
+def get_fdom_names(model):
+	return map(lambda x: x.getName(), model.getFailoverDomains())
+
 def getServiceInfo(self, status, model, req):
 	#set up struct for service config page
 	hmap = {}
@@ -3280,7 +3367,7 @@
 		baseurl = '/luci/cluster/index_html'
 
 	try:
-		hmap['fdoms'] = map(lambda x: x.getName(), model.getFailoverDomains())
+		hmap['fdoms'] = get_fdom_names(model)
 	except:
 		hmap['fdoms'] = list()
 
@@ -3354,6 +3441,19 @@
 	except:
 		hmap['domain'] = None
 
+	try:
+		hmap['recovery'] = svc.getAttribute('recovery')
+	except:
+		hmap['recovery'] = None
+
+	try:
+		if int(svc.getAttribute('exclusive')):
+			hmap['exclusive'] = 'true' 
+		else:
+			hmap['exclusive'] = 'false'
+	except:
+		hmap['exclusive'] = 'false'
+
 	resource_list = list()
 	if svc is not None:
 		indent_ctr = 0
@@ -5107,7 +5207,7 @@
       % vmname)
     return map
 
-  attrs= vm.getAttributes()
+  attrs = vm.getAttributes()
   keys = attrs.keys()
   for key in keys:
     map[key] = attrs[key]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]