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

[email protected] <[email protected]>
Newsgroups com.redhat.cluster-devel
Message-ID <[email protected]>
CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2008-01-23 04:34:24

Modified files:
	luci/cluster   : form-macros 
	luci/homebase  : validate_cluster_add_initial.js 
	luci/plone-custom: clusterportlet.css 
	luci/site/luci/Extensions: LuciClusterActions.py 
	                           LuciValidation.py ResourceHandler.py 
	                           RicciQueries.py cluster_adapters.py 
	                           homebase_adapters.py 
	luci/site/luci/var: Data.fs 
Added files:
	luci/plone-custom: clusterbanner.png 

Log message:
	sync some odds and ends

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.219&r2=1.220
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_cluster_add_initial.js.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/plone-custom/clusterbanner.png.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/plone-custom/clusterportlet.css.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterActions.py.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciValidation.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ResourceHandler.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/RicciQueries.py.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.279&r2=1.280
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/var/Data.fs.diff?cvsroot=cluster&r1=1.27&r2=1.28

--- conga/luci/cluster/form-macros	2008/01/22 15:02:33	1.219
+++ conga/luci/cluster/form-macros	2008/01/23 04:34:09	1.220
@@ -1071,13 +1071,12 @@
 		set_page_title('Luci ??? cluster ??? Add a new cluster node');
 	</script>
 
-	<script type="text/javascript"
-		src="/luci/homebase/homebase_common.js">
+	<script type="text/javascript" src="/luci/homebase/homebase_common.js">
 	</script>
-
-	<script type="text/javascript"
-		src="/luci/homebase/validate_cluster_add.js">
+	<script type="text/javascript" src="/luci/homebase/validate_cluster_add.js">
 	</script>
+	<script type="text/javascript" src="conga_ajax.js"></script>
+	<script type="text/javascript" src="update_hostinfo.js"></script>
 
 	<form name="add_node" action="" method="post"
 		tal:define="
@@ -1194,17 +1193,10 @@
 									name python: '__SYSTEM%d:Passwd' % cur_sysnum" />
 						</tal:block>
 					</td>
-					<td tal:condition="add_cluster" class="systemsTable">
-						<img
-							tal:attributes="
-								src python: 'trusted' in sys and 'lock-ok.png' or ('fp' in sys and 'lock-closed.png' or 'lock-open.png');
-								title sys/fp | string:no key fingerprint available" />
-						<input type="hidden"
-							tal:condition="exists: sys/fp"
-							tal:attributes="
-								id python: '__SYSTEM%dFingerprint' % cur_sysnum;
-								name python: '__SYSTEM%dFingerprint' % cur_sysnum;
-								value sys/fp | nothing" />
+					<td class="systemsTable">
+						<img tal:attributes="
+							src python: sys and sys.has_key('trusted') and 'lock-ok.png' or (sys and sys.has_key('fp') and 'lock-closed.png' or 'lock-open.png');
+							title sys/fp | string:no key fingerprint available" />
 					</td>
 					<td tal:condition="add_cluster" class="systemsTable">
 						<input type="checkbox" tal:attributes="
@@ -1239,6 +1231,10 @@
 							id="__SYSTEM0:Passwd" name="__SYSTEM0:Passwd" />
 					</td>
 					<td class="systemsTable">
+						<img src="lock-open.png" id="__SYSTEM0Fingerprint"
+							title="no key fingerprint available" />
+					</td>
+					<td class="systemsTable">
 						<img src="delete-row.png" class="deleteRow"
 							title="delete this row"
 							onclick="delete_element_id('__SYSTEM_ROW_0')" />
@@ -1251,6 +1247,12 @@
 		<input name="numStorage" id="numStorage" type="hidden"
 			tal:attributes="value cur_sysnum" />
 
+		<div class="hbSubmit">
+			<input type="button" name="View SSL cert fingerprints"
+				value="View SSL cert fingerprints"
+				onclick="get_system_info('retmsgsdiv', 'errmsgsdiv', 1)" />
+		</div>
+
 		<div class="hbSubmit" id="hbSubmit">
 			<input type="button" name="Submit" value="Submit"
 				onClick="validateForm(this.form)" />
--- conga/luci/homebase/validate_cluster_add_initial.js	2008/01/22 15:02:32	1.5
+++ conga/luci/homebase/validate_cluster_add_initial.js	2008/01/23 04:34:09	1.6
@@ -92,14 +92,12 @@
 	if (ret_status !== true) {
 		/* A communication error occurred. */
 		alert(obj);
-		form_elem.submit();
 		return;
 	}
 
 	var err = get_ricci_response_status(obj.responseXML);
 	if (err !== null && err.length > 0) {
 		alert(err.join('\n'));
-		form_elem.submit();
 		return;
 	}
 
@@ -107,7 +105,6 @@
 		obj = obj.responseXML.getElementsByTagName('dict')[0];
 	} catch (e) {
 		alert('Received a malformed response from the luci server.');
-		form_elem.submit();
 		return;
 	}
 
@@ -115,7 +112,6 @@
 	var query_host_elem = document.getElementById('__SYSTEM0:Addr');
 	if (!query_host_elem || str_is_blank(query_host_elem.value)) {
 		alert('No node was entered.');
-		form_elem.submit();
 		return;
 	}
 	query_host = query_host_elem.value;
/cvs/cluster/conga/luci/plone-custom/clusterbanner.png,v  -->  standard output
revision 1.1
Binary files /cvs/cluster/conga/luci/plone-custom/clusterbanner.png and - differ
co: output error: Broken pipe
co aborted
--- conga/luci/plone-custom/clusterportlet.css	2007/09/25 04:00:23	1.1
+++ conga/luci/plone-custom/clusterportlet.css	2008/01/23 04:34:09	1.2
@@ -173,7 +173,7 @@
 .cluConfigTreeLevel5 { margin-left: 0.75em; }
 
 #main-portal-logo {
-    background: url(./clusterbanner.png) no-repeat;
+    background: url(clusterbanner.png) no-repeat;
     border: 0;
     margin: 0.75em 0em 0.75em 1.5em;
     padding: 0;
--- conga/luci/site/luci/Extensions/LuciClusterActions.py	2007/10/09 21:41:46	1.8
+++ conga/luci/site/luci/Extensions/LuciClusterActions.py	2008/01/23 04:34:09	1.9
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
 #
 # This program is free software; you can redistribute
 # it and/or modify it under the terms of version 2 of the
@@ -19,11 +19,21 @@
 from conga_constants import CLUSTER_CONFIG, LUCI_DEBUG_MODE, \
 	NODE_DELETE, NODE_FORCE_DELETE, CLUSTER_DELETE, CLUSTERLIST, \
 	NODE_FENCE, NODE_JOIN_CLUSTER, NODE_LEAVE_CLUSTER, NODE_REBOOT, \
-	RESOURCE_ADD, RESOURCE_CONFIG, RESOURCE_REMOVE, \
-	SERVICE_DELETE, SERVICE_RESTART, SERVICE_START, SERVICE_STOP
+	RESOURCE_REMOVE, SERVICE_DELETE, SERVICE_RESTART, \
+	SERVICE_START, SERVICE_STOP
 
 luci_log = get_logger()
 
+def getRicciAgentForCluster(self, req):
+	from LuciZope import GetReqVars
+	fvar = GetReqVars(req, [ 'clustername' ])
+	clustername = fvar['clustername']
+	if clustername is None:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug('GRAFC0: no cluster name was found')
+		return None
+	return getRicciAgent(self, clustername)
+
 #
 # Cluster service tasks
 #
@@ -184,45 +194,6 @@
 	if ret[0] is False:
 		return ret
 
-def AddResource(self, rc, model, res):
-	resname = None
-	try:
-		resname = res.getName()
-		model.getResourcesPtr().addChild(res)
-	except Exception, e:
-		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('AddResource0: %r %s' % (e, str(e)))
-		if resname is not None:
-			errstr = 'Unable to add new resource "%s"' % resname
-		else:
-			errstr = 'Unable to add this new resource'
-		return (False, { 'errors': [ errstr ] })
-
-	ret = propagateClusterConfAsync(self, model, rc, RESOURCE_ADD,
-			'Creating new cluster resource "%s"' % resname)
-	if ret[0] is False:
-		return ret
-
-def EditResource(self, rc, model, res):
-	resname = None
-	try:
-		resname = res.getName()
-		model.getResourcesPtr().addChild(res)
-	except Exception, e:
-		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('EditResource0: %r %s' % (e, str(e)))
-		if resname is not None:
-			errstr = 'Unable to edit cluster resource "%s"' % resname
-		else:
-			errstr = 'Unable to edit this cluster resource'
-		return (False, { 'errors': [ errstr ] })
-
-	ret = propagateClusterConfAsync(self, model, rc, RESOURCE_CONFIG,
-				'Configuring cluster resource "%s"' % resname)
-
-	if ret[0] is False:
-		return ret
-
 #
 # Cluster node membership-related tasks
 #
--- conga/luci/site/luci/Extensions/LuciValidation.py	2008/01/22 15:05:17	1.5
+++ conga/luci/site/luci/Extensions/LuciValidation.py	2008/01/23 04:34:09	1.6
@@ -473,10 +473,11 @@
 			luci_log.debug_verbose('VRA0: type is blank')
 		return (False, { 'errors': [ 'No resource type was given']})
 
+	res = None
 	try:
 		res = create_resource(res_type, request.form, model)
 	except Exception, e:
-		return (False, { 'errors': e } )
+		return (False, { 'errors': e[0] } )
 
 	resname = ''
 	try:
--- conga/luci/site/luci/Extensions/ResourceHandler.py	2008/01/02 21:00:31	1.5
+++ conga/luci/site/luci/Extensions/ResourceHandler.py	2008/01/23 04:34:09	1.6
@@ -756,6 +756,7 @@
 }
 
 def create_resource(res_type, form, model):
+	errors = list()
 	if not resource_table.has_key(res_type):
 		raise Exception, [ 'Unknown resource type: "%s"' % res_type ]
 
@@ -785,14 +786,20 @@
 	else:
 		rname = form['ip_address'].strip()
 
+	if not form.has_key('edit'):
+		try:
+			dummy = getResourceForEdit(model, rname)
+			if dummy:
+				errors.append('A resource named "%s" already exists.' % rname)
+		except:
+			pass
+
+	if len(errors) > 0:
+		raise Exception, errors
+
 	errors = resource_table[res_type][0](res, rname, form, model)
-	try:
-		dummy = getResourceForEdit(model, rname)
-		if dummy:
-			errors.append('A resource named "%s" already exists.' % rname)
-	except:
-		pass
 
 	if len(errors) > 0:
 		raise Exception, errors
+
 	return res
--- conga/luci/site/luci/Extensions/RicciQueries.py	2007/10/09 20:20:02	1.9
+++ conga/luci/site/luci/Extensions/RicciQueries.py	2008/01/23 04:34:09	1.10
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2006-2008 Red Hat, Inc.
 #
 # This program is free software; you can redistribute
 # it and/or modify it under the terms of version 2 of the
@@ -10,6 +10,8 @@
 from LuciSyslog import get_logger
 from conga_constants import LUCI_DEBUG_MODE
 
+
+
 luci_log = get_logger()
 
 def addClusterNodeBatch(cluster_name,
@@ -18,11 +20,10 @@
 						install_shared_storage,
 						install_LVS,
 						upgrade_rpms,
-						gulm):
+						gulm,
+						reboot_nodes=False):
 	batch = list()
 
-	batch.append('<?xml version="1.0" ?>')
-	batch.append('<batch>')
 	batch.append('<module name="rpm">')
 	batch.append('<request API_version="1.0">')
 	batch.append('<function_call name="install">')
@@ -67,7 +68,7 @@
 	batch.append('</request>')
 	batch.append('</module>')
 
-	need_reboot = install_base or install_services or install_shared_storage or install_LVS
+	need_reboot = reboot_nodes or install_base or install_services or install_shared_storage or install_LVS
 	if need_reboot:
 		batch.append('<module name="reboot">')
 		batch.append('<request API_version="1.0">')
@@ -118,9 +119,9 @@
 	batch.append('</function_call>')
 	batch.append('</request>')
 	batch.append('</module>')
-	batch.append('</batch>')
 
-	return minidom.parseString(''.join(batch)).firstChild
+	return ''.join(batch)
+##	return minidom.parseString(''.join(batch)).firstChild
 
 def createClusterBatch( os_str,
 						cluster_name,
@@ -131,12 +132,10 @@
 						install_shared_storage,
 						install_LVS,
 						upgrade_rpms,
-						gulm_lockservers):
+						gulm_lockservers,
+						reboot_nodes=False):
 
 	batch = list()
-	batch.append('<?xml version="1.0" ?>')
-	batch.append('<batch>')
-
 	batch.append('<module name="rpm">')
 	batch.append('<request API_version="1.0">')
 	batch.append('<function_call name="install">')
@@ -184,7 +183,7 @@
 	batch.append('</request>')
 	batch.append('</module>')
 
-	need_reboot = install_base or install_services or install_shared_storage or install_LVS
+	need_reboot = reboot_nodes or install_base or install_services or install_shared_storage or install_LVS
 	if need_reboot:
 		batch.append('<module name="reboot">')
 		batch.append('<request API_version="1.0">')
@@ -253,9 +252,7 @@
 	batch.append('</function_call>')
 	batch.append('</request>')
 	batch.append('</module>')
-	batch.append('</batch>')
-
-	return minidom.parseString(''.join(batch)).firstChild
+	return ''.join(batch)
 
 def batchAttemptResult(doc):
 	if not doc:
@@ -689,17 +686,7 @@
 	if rc is None:
 		return None
 
-	doc = minidom.Document()
-	batch = doc.createElement('batch')
-	module = doc.createElement('module')
-	module.setAttribute('name', 'cluster')
-	request = doc.createElement('request')
-	request.setAttribute('API_version', '1.0')
-	call = doc.createElement('function_call')
-	call.setAttribute('name', 'get_cluster.conf')
-	request.appendChild(call)
-	module.appendChild(request)
-	batch.appendChild(module)
+	batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="get_cluster.conf"/></request></module>'
 
 	# temporary workaround for ricci bug
 	system_info = rc.hostname()
@@ -714,9 +701,9 @@
 		return None
 	# end workaround
 
+	ricci_xml = rc.batch_run(batch_str, async=False)
 	try:
-		ret = rc.process_batch(batch)
-		if not ret:
+		if not ricci_xml:
 			raise Exception, 'no XML response'
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
@@ -724,6 +711,7 @@
 				% (system_info, e, str(e)))
 		return None
 
+	ret = ricci_xml
 	var_nodes = ret.getElementsByTagName('var')
 	for i in var_nodes:
 		if i.getAttribute('name') == 'cluster.conf':
@@ -739,3 +727,22 @@
 	batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="set_xvm_key"><var mutable="false" name="key_base64" type="string" value="%s"/></function_call></request></module>' % key_base64
 	ricci_xml = rc.batch_run(batch_str)
 	return batchAttemptResult(ricci_xml)
+
+def create_cluster(	rc, 
+					os_str,
+					cluster_name,
+					cluster_alias,
+					nodeList,
+					install_base,
+					install_services,
+					install_shared_storage,
+					install_LVS,
+					upgrade_rpms,
+					gulm_lockservers):
+
+	batch_str = createClusterBatch(os_str, cluster_name, cluster_alias,
+                        nodeList, install_base, install_services,
+                        install_shared_storage, install_LVS, upgrade_rpms,
+                        gulm_lockservers)
+	ricci_xml = rc.batch_run(batch_str)
+	return batchAttemptResult(ricci_xml)
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2008/01/22 15:05:17	1.279
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2008/01/23 04:34:09	1.280
@@ -83,6 +83,8 @@
 	except:
 		shared_storage = False
 
+	reboot_nodes = request.form.has_key('reboot_nodes')
+
 	same_node_passwds = False
 	try:
 		same_node_passwds = request.form.has_key('allSameCheckBox')
@@ -95,7 +97,8 @@
 		'download_pkgs': download_pkgs,
 		'cluster_os': cluster_os,
 		'identical_passwds': same_node_passwds,
-		'check_certs': check_certs
+		'check_certs': check_certs,
+		'reboot_nodes': reboot_nodes
 	}
 
 	system_list, incomplete, errors, messages = parseHostForm(request, check_certs)
@@ -277,7 +280,7 @@
 	ret = send_batch_to_hosts(node_list, 10, rq.create_cluster, 
 			add_cluster['cluster_os'], clustername, clustername,
 			node_list, True, True, add_cluster['shared_storage'], False,
-			add_cluster['download_pkgs'], lockservers)
+			add_cluster['download_pkgs'], lockservers, add_cluster['reboot_nodes'])
 
 	batch_id_map = {}
 	for i in ret.iterkeys():
@@ -320,6 +323,8 @@
 	except:
 		download_pkgs = 1
 
+	reboot_nodes = request.form.has_key('reboot_nodes')
+
 	cluster_os = None
 	try:
 		cluster_os = request.form['cluster_os'].strip()
@@ -394,7 +399,8 @@
 		'download_pkgs': download_pkgs,
 		'cluster_os': cluster_os,
 		'identical_passwds': same_node_passwds,
-		'check_certs': check_certs
+		'check_certs': check_certs,
+		'reboot_nodes': reboot_nodes
 	}
 
 	system_list, incomplete, errors, messages = parseHostForm(request, check_certs)
@@ -549,7 +555,8 @@
 								shared_storage,
 								False,
 								download_pkgs,
-								model.GULM_ptr is not None)
+								model.GULM_ptr is not None,
+								reboot_nodes)
 				if not batch_node:
 					raise Exception, 'batch is blank'
 				system_list[x]['batch'] = batch_node
@@ -1419,18 +1426,18 @@
 		return {}
 
 	fvars = GetReqVars(request,
-				[ 'resourcename', 'type', 'value', 'clustername', 'URL' ])
+				[ 'resourcename', 'type', 'ip_address', 'clustername', 'URL' ])
 
 	baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
 
-	name = fvars['resourcename']
-	if name is None:
-		if fvars['type'] == 'ip':
-			name = fvars['value']
+	if fvars['type'] == 'ip':
+		name = fvars['ip_address']
+	else:
+		name = fvars['resourcename']
 
 	if name is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('GRI1: missing res name')
+			luci_log.debug_verbose('GRI1: missing res name: %s' % str(request.form.items()))
 		return {}
 
 	from LuciClusterInfo import getResourceInfo as gri
--- conga/luci/site/luci/Extensions/homebase_adapters.py	2008/01/22 15:05:18	1.56
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2008/01/23 04:34:09	1.57
@@ -240,10 +240,6 @@
 				request.SESSION.set('add_cluster_initial', cur_entry)
 				luci_log.info('SECURITY: %s' % errmsg)
 				return (False, { 'errors': [ errmsg ] })
-#			if trust_shown is True and cur_host_trusted is False:
-#				errmsg = 'You must elect to trust "%s" or abort the addition of the cluster to Luci.' % cur_host
-#				request.SESSION.set('add_cluster_initial', cur_entry)
-#				return (False, { 'errors': [ errmsg ] })
 			rc.trust()
 		except Exception, e:
 			if LUCI_DEBUG_MODE is True:
@@ -496,15 +492,9 @@
 				if not rc:
 					raise Exception, 'rc is None'
 
-				if not rc.trusted() and (trust_shown is True and cur_set_trust is False):
-					incomplete = True
-					cur_system['error'] = True
-					errors.append('You must either trust "%s" or remove it.' % cur_host)
-				else:
-					# The user doesn't care. Trust the system.
-					rc.trust()
-					cur_system['trusted'] = True
-					cur_system['prev_auth'] = rc.authed()
+				rc.trust()
+				cur_system['trusted'] = True
+				cur_system['prev_auth'] = rc.authed()
 			except Exception, e:
 				incomplete = True
 				cur_system['error'] = True
Binary files /cvs/cluster/conga/luci/site/luci/var/Data.fs	2007/06/27 08:14:13	1.27 and /cvs/cluster/conga/luci/site/luci/var/Data.fs	2008/01/23 04:34:10	1.28 differ
rcsdiff: /cvs/cluster/conga/luci/site/luci/var/Data.fs: diff failed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.