From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 16 Oct 2006 20:46:47 -0000 Subject: [Cluster-devel] conga/luci homebase/form-macros homebase/valid ... Message-ID: <20061016204647.18894.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 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 @@ - $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 $ @@ -298,19 +298,91 @@ global num_systems python:-1" /> +

Manage Systems and Clusters

+ +

Authenticate to Storage or Cluster Systems

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
System HostnameRoot Password
+ +
+
+ +
+
+ + + +
+ + + +
+ + + +
+ +
+
+
-

- Manage Systems and Clusters -

- Check storage systems and clusters to remove from the Luci management interface. +

Check storage systems and clusters to remove from the Luci management interface.

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')