cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci homebase/form-macros homebase/valid ...
Date: 16 Oct 2006 20:46:47 -0000	[thread overview]
Message-ID: <20061016204647.18894.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-16 20:46:46

Modified files:
	luci/homebase  : form-macros validate_sys_remove.js 
	luci/site/luci/Extensions: conga_constants.py 
	                           homebase_adapters.py 

Log message:
	add a reauth form at the top of the manage systems page

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/form-macros.diff?cvsroot=cluster&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_sys_remove.js.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.33&r2=1.34

--- conga/luci/homebase/form-macros	2006/10/16 15:35:27	1.43
+++ conga/luci/homebase/form-macros	2006/10/16 20:46:46	1.44
@@ -1,7 +1,7 @@
 <html>
 
 <tal:comment tal:replace="nothing">
-	$Id: form-macros,v 1.43 2006/10/16 15:35:27 rmccabe Exp $
+	$Id: form-macros,v 1.44 2006/10/16 20:46:46 rmccabe Exp $
 </tal:comment>
 
 <head>
@@ -298,19 +298,91 @@
 					global num_systems python:-1"
 	/>
 
+	<h2 class="homebase">Manage Systems and Clusters</h2>
+
+	<h3>Authenticate to Storage or Cluster Systems</h3>
+
+	<form name="authform" method="post" action="">
+		<input type="hidden" name="pagetype" value="8" />
+		<table id="systemsTable" class="systemsTable" border="0" cellspacing="0">
+			<thead class="systemsTable">
+				<tr class="systemsTable">
+					<th class="systemsTable">System Hostname</th>
+					<th class="systemsTable">Root Password</th>
+				</tr>
+			</thead>
+
+			<tfoot class="systemsTable">
+				<tr class="systemsTable"><td colspan="2" class="systemsTable">
+					<div id="allSameDiv" class="invisible">
+						<input type="checkbox" class="allSameCheckBox" name="allSameCheckBox" id="allSameCheckBox" onClick="allPasswdsSame(this.form);"/><span>Check if storage system passwords are identical.</span>
+					</div>
+				</td></tr>
+
+				<tr class="systemsTable"><td class="systemsTable" colspan="2">
+					<div class="systemsTableEnd">
+						<input type="button" value="Add another entry" onClick="addSystem(this.form);" />
+					</div>
+				</td></tr>
+			</tfoot>
+
+			<tbody class="systemsTable">
+				<tr class="systemsTable">
+					<td class="systemsTable">
+						<input class="hbInputSys" type="text"
+							id="__SYSTEM0:Addr" name="__SYSTEM0:Addr" />
+					</td>
+					<td class="systemsTable">
+						<input type="password" autocomplete="off"
+							id="__SYSTEM0:Passwd" name="__SYSTEM0:Passwd"
+							class="hbInputPass"
+							onChange="pwd0Change(this.form);" />
+					</td>
+				</tr>
+
+				<tal:block tal:define="global numsys python: 0" />
+
+				<tal:block tal:repeat="s python:systems[2]">
+					<tal:block tal:define="global numsys python: numsys + 1" />
+					<tr class="systemsTable">
+						<td class="systemsTable">
+							<input class="hbInputSys" type="text"
+								tal:attributes="
+									id python: '__SYSTEM' + str(numsys) + ':Addr';
+									name python: '__SYSTEM' + str(numsys) + ':Addr'" />
+						</td>
+
+						<td class="systemsTable">
+							<input type="password" autocomplete="off"
+								onChange="pwd0Change(this.form);"
+								class="hbInputPass"
+								tal:attributes="
+									id python: '__SYSTEM' + str(numsys) + ':Password';
+									name python: '__SYSTEM' + str(numsys) + ':Password'" />
+						</td>
+					</tr>
+				</tal:block>
+			</tbody>
+		</table>
+
+		<input type="hidden" name="numStorage" value="1" />
+
+		<div class="hbSubmit" id="hbSubmit">
+			<input type="button" name="Submit" value="Submit"
+				onClick="validateAuth(this.form)" />
+		</div>
+	</form>
+
 	<form name="adminform" method="post" action=""
 		tal:condition="python:(systems[0] and len(systems[0]) > 0) or (systems[1] and len(systems[1]) > 0)">
 
 		<span tal:omit-tag="" tal:define="global blankForm python:0" />
 
-		<h2 class="homebase" tal:condition="python:systems">
-			Manage Systems and Clusters
-		</h2>
 
 		<input type="hidden" name="pagetype"
 			tal:attributes="value request/form/pagetype | request/pagetype | nothing" />
 
-		Check storage systems and clusters to remove from the Luci management interface.
+		<h3>Check storage systems and clusters to remove from the Luci management interface.</h3>
 
 		<h3 class="homebase" tal:condition="python: systems[0] and len(systems[0]) > 0">
 			Clusters
--- conga/luci/homebase/validate_sys_remove.js	2006/06/30 18:06:10	1.1
+++ conga/luci/homebase/validate_sys_remove.js	2006/10/16 20:46:46	1.2
@@ -43,3 +43,24 @@
 		form.submit();
 	return (0);
 }
+
+function validateAuth(form) {
+	var errors = new Array();
+
+	if (!form)
+		return (-1);
+
+	var added_storage = validate_systems(form, errors);
+
+	if (error_dialog(errors))
+		return (-1);
+
+	if (!added_storage || added_storage.length < 1)
+		errors.push('You have not specified any hosts.');
+
+	if (error_dialog(errors))
+		return (-1);
+
+	form.submit();
+	return (0);
+}
--- conga/luci/site/luci/Extensions/conga_constants.py	2006/10/16 19:17:13	1.18
+++ conga/luci/site/luci/Extensions/conga_constants.py	2006/10/16 20:46:46	1.19
@@ -98,13 +98,14 @@
 
 
 # Homebase-specific constants
-HOMEBASE_ADD_USER="1"
-HOMEBASE_ADD_SYSTEM="2"
-HOMEBASE_PERMS="3"
-HOMEBASE_DEL_USER="4"
-HOMEBASE_DEL_SYSTEM="5"
-HOMEBASE_ADD_CLUSTER="6"
-HOMEBASE_ADD_CLUSTER_INITIAL="7"
+HOMEBASE_ADD_USER = "1"
+HOMEBASE_ADD_SYSTEM = "2"
+HOMEBASE_PERMS = "3"
+HOMEBASE_DEL_USER = "4"
+HOMEBASE_DEL_SYSTEM = "5"
+HOMEBASE_ADD_CLUSTER = "6"
+HOMEBASE_ADD_CLUSTER_INITIAL = "7"
+HOMEBASE_AUTH = "8"
 
 # Cluster node exception attribute flags
 CLUSTER_NODE_NEED_AUTH = 0x01
--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/16 15:18:32	1.33
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/16 20:46:46	1.34
@@ -569,6 +569,61 @@
 
 	return (returnCode, {'errors': errors, 'messages': messages, 'params': {'user': userId }})
 
+def validateAuthenticate(self, request):
+	errors = list()
+	messages = list()
+
+	try:
+		numStorage = int(request.form['numStorage'])
+	except:
+		return (False, {'errors': [ 'Unknown number of nodes entered']})
+
+	i = 0
+	while i < numStorage:
+		sysData = request.form['__SYSTEM' + str(i)]
+		if not sysData or len(sysData) < 2 or not sysData[0] or not sysData[1]:
+			i += 1
+			continue
+
+		host = str(sysData[0])
+		passwd = str(sysData[1])
+
+		try:
+			rc = RicciCommunicator(sysData[0])
+		except:
+			errors.append('Unable to contact the ricci agent for ' + host)
+			i += 1
+			continue
+
+		if rc.authed():
+			messages.append(host + ' is already authenticated.')
+		else:
+			try:
+				rc.auth(passwd)
+			except:
+				errors.append('Error authenticating to the ricci agent on ' + host)
+				i += 1
+				continue
+
+			if not rc.authed():
+				errors.append('Error authenticating to the ricci agent on ' + host)
+			else:
+				messages.append(host + ' was successfully authenticated.')
+
+			if rc.authed():
+				try:
+					delNodeFlag(self, getStorageNode(self, host), CLUSTER_NODE_NEED_AUTH)
+				except:
+					pass
+
+				try:
+					delNodeFlag(self, getClusterNode(self, host, rc.cluster_info()[0]), CLUSTER_NODE_NEED_AUTH)
+				except:
+					pass
+		i += 1
+			
+	return (len(errors) > 0, {'errors': errors, 'messages': messages })
+
 formValidators = [
 	validateAddUser,
 	validateAddSystem,
@@ -576,7 +631,8 @@
 	validateDelUser,
 	validateDelSystem,
 	validateAddCluster,
-	validateAddClusterInitial
+	validateAddClusterInitial,
+	validateAuthenticate
 ]
 
 def userAuthenticated(self):
@@ -1265,19 +1321,28 @@
 def getSystems(self):
 	storage = getStorage(self)
 	clusters = getClusters(self)
-	storageList = None
-	ret = [{}, None]
-	zeroindex = lambda i: i[0]
+	storageList = list()
+	ret = [{}, [], {}]
 
-	if storage and len(storage) > 0:
-		storageList = map(zeroindex, storage)
+	need_auth_hash = {}
+	for i in storage:
+		storageList.append(i[0])
+		if testNodeFlag(i[1], CLUSTER_NODE_NEED_AUTH) != False:
+			need_auth_hash[i[0]] = i[1]
 
+	chash = {}
 	for i in clusters:
-		cSystems = map(zeroindex, getClusterSystems(self, i[0]))
-		ret[0][i[0]] = cSystems
-
-	if storageList:
-		ret[1] = storageList
+		csystems = getClusterSystems(self, i[0])
+		cslist = list()
+		for c in csystems:
+			if testNodeFlag(c[1], CLUSTER_NODE_NEED_AUTH) != False:
+				need_auth_hash[c[0]] = c[1]
+			cslist.append(c[0])
+		chash[i[0]] = cslist
+
+	ret[0] = chash
+	ret[1] = storageList
+	ret[2] = need_auth_hash
 	return ret
 
 def getClusterNode(self, nodename, clustername):
@@ -1294,6 +1359,14 @@
 	except:
 		return None
 
+def testNodeFlag(node, flag_mask):
+	try:
+		flags = node.getProperty('flags')
+		return flags & flag_mask != 0
+	except:
+		pass
+	return False
+
 def setNodeFlag(self, node, flag_mask):
 	try:
 		flags = node.getProperty('flags')



             reply	other threads:[~2006-10-16 20:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-16 20:46 rmccabe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-06-30 23:07 [Cluster-devel] conga/luci homebase/form-macros homebase/valid rmccabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061016204647.18894.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).