cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-10-16 15:18 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-10-16 15:18 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-16 15:18:32

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 
	                           cluster_adapters.py 

Log message:
	bz# 206567

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.114&r2=1.115

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/16 04:26:19	1.32
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/16 15:18:32	1.33
@@ -184,7 +184,7 @@
 	error = 'Unable to authenticate to the ricci agent on \"' + host + '\"'
 	return { 'host': host, 'ricci_host': systemName, 'prev_auth': False , 'cur_auth': False, 'errors': error, 'os': os_str }
 
-def validateAddClusterInitial(self, request):
+def validateAddClusterInitial(self, request, must_complete=True):
 	errors = list()
 	newNodeList = list()
 	nodeHash = {}
@@ -271,7 +271,10 @@
 		x['cur_auth'] - y['cur_auth'] or (('errors' in y) - ('errors' in x)) 
 	newNodeList.sort(sfn)
 
-	dfn = lambda x: not 'cur_auth' in x or x['cur_auth'] != True
+	if must_complete == True:
+		dfn = lambda x: not 'cur_auth' in x or x['cur_auth'] != True
+	else:
+		dfn = lambda x: False
 
 	cluster_properties = {
 		'clusterName': clusterName,
@@ -287,7 +290,7 @@
 	return (len(errors) < 1,
 		{'errors': errors, 'requestResults': cluster_properties })
 
-def validateAddCluster(self, request):
+def validateAddCluster(self, request, must_complete=True):
 	errors = list()
 	messages = list()
 	requestResults = None
@@ -392,7 +395,11 @@
 			oldNode['errors'] = True
 		i += 1
 
-	dfn = lambda x: not 'cur_auth' in x or x['cur_auth'] != True
+	if must_complete == True:
+		dfn = lambda x: not 'cur_auth' in x or x['cur_auth'] != True
+	else:
+		dfn = lambda x: False
+
 	clusterComplete = len(filter(dfn, nodeList)) == 0
 
 	if clusterComplete:
@@ -616,7 +623,11 @@
 		try: request.SESSION.set('checkRet', {})
 		except: pass
 		return homebasePortal(self, request, '.', '0')
-	ret = validatorFn(self, request)
+
+	if validatorFn == validateAddClusterInitial or validatorFn == validateAddCluster:
+		ret = validatorFn(self, request, must_complete=False)
+	else:
+		ret = validatorFn(self, request)
 	params = None
 
 	if 'params' in ret[1]:
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/16 05:27:59	1.114
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/16 15:18:32	1.115
@@ -1301,7 +1301,7 @@
 
 		if rc.authed():
 			return rc
-		setNodeFlag(node[1], CLUSTER_NODE_NEED_AUTH)
+		setNodeFlag(self, node[1], CLUSTER_NODE_NEED_AUTH)
 	return None
 
 def getRicciAgentForCluster(self, req):



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2008-04-21 18:19 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2008-04-21 18:19 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL4
Changes by:	rmccabe at sourceware.org	2008-04-21 18:19:45

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	Missed in last commit

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.48.2.4&r2=1.48.2.5

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2008/03/25 01:27:12	1.48.2.4
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2008/04/21 18:19:45	1.48.2.5
@@ -629,29 +629,29 @@
 					luci_log.debug_verbose('VAC5: %s' % err_msg)
 				continue
 
-			cur_os = resolveOSType(rc.os())
-			if cur_os != cluster_os:
-				if LUCI_DEBUG_MODE is True:
-					luci_log.debug_verbose('VAC5a: "%s" / "%s" -> "%s"' \
-						% (cluster_os, rc.os(), cur_os))
-				incomplete = True
-				cur_system['errors'] = True
-
-				if not prev_auth:
-					try:
-						rc.unauth()
-					except Exception, e:
-						if LUCI_DEBUG_MODE is True:
-							luci_log.debug_verbose('VAC6: %s: %r %s' \
-								% (cur_host, e, str(e)))
-
-				err_msg = 'Node %s reports its cluster version is %s and we expect %s' \
-					% (cur_host, cur_os, cluster_os)
-
-				errors.append(err_msg)
-				if LUCI_DEBUG_MODE is True:
-					luci_log.debug_verbose('VAC7: %s' % err_msg)
-				continue
+			#cur_os = resolveOSType(rc.os())
+			#if cur_os != cluster_os:
+			#	if LUCI_DEBUG_MODE is True:
+			#		luci_log.debug_verbose('VAC5a: "%s" / "%s" -> "%s"' \
+			#			% (cluster_os, rc.os(), cur_os))
+			#	incomplete = True
+			#	cur_system['errors'] = True
+
+			#	if not prev_auth:
+			#		try:
+			#			rc.unauth()
+			#		except Exception, e:
+			#			if LUCI_DEBUG_MODE is True:
+			#				luci_log.debug_verbose('VAC6: %s: %r %s' \
+			#					% (cur_host, e, str(e)))
+
+			#	err_msg = 'Node %s reports its cluster version is %s and we expect %s' \
+			#		% (cur_host, cur_os, cluster_os)
+
+			#	errors.append(err_msg)
+			#	if LUCI_DEBUG_MODE is True:
+			#		luci_log.debug_verbose('VAC7: %s' % err_msg)
+			#	continue
 		else:
 			incomplete = True
 



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2008-02-05 20:59 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2008-02-05 20:59 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2008-02-05 20:59:38

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	Enforce password minimum length on the backend.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.57&r2=1.58

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2008/01/23 04:34:09	1.57
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2008/02/05 20:59:38	1.58
@@ -133,6 +133,9 @@
 	passwd = request.form['newPassword']
 	pwconfirm = request.form['newPasswordConfirm']
 
+	if len(passwd) < 6:
+		return (False, { 'errors': [ 'Passwords must be@least six characters long.' ] })
+
 	if passwd != pwconfirm:
 		return (False, { 'errors': [ 'The passwords given do not match' ]})
 
@@ -203,12 +206,6 @@
 	except:
 		cur_host_trusted = not check_certs
 
-	trust_shown = False
-	try:
-		trust_shown = request.form.has_key('trust_shown')
-	except:
-		trust_shown = False
-
 	cur_host_fp = None
 	try:
 		cur_host_fp = request.form['host_fingerprint'].strip()
@@ -402,12 +399,6 @@
 				% (e, str(e)))
 		errors.append('The number of systems entered could not be determined.')
 
-	trust_shown = False
-	try:
-		trust_shown = request.form.has_key('trust_shown')
-	except:
-		trust_shown = False
-
 	incomplete = False
 	i = 0
 	while i < num_storage:



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2007-06-06 15:14 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2007-06-06 15:14 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	EXPERIMENTAL
Changes by:	rmccabe at sourceware.org	2007-06-06 15:14:12

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	Fix bz241727 (can't set user permissions in luci)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.50.2.8&r2=1.50.2.9

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2007/05/30 05:54:02	1.50.2.8
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2007/06/06 15:14:12	1.50.2.9
@@ -758,7 +758,7 @@
 	if not request.form.has_key('__CLUSTER'):
 		for i in clusters:
 			try:
-				if user.has_permission('View', i[1]):
+				if user.has_role('View', i[1]):
 					roles = list(i[1].get_local_roles_for_userid(user_id))
 					roles.remove('View')
 
@@ -776,7 +776,7 @@
 		for i in clusters:
 			if i[0] in request.form['__CLUSTER']:
 				try:
-					if not user.has_permission('View', i[1]):
+					if not user.has_role('View', i[1]):
 						roles = list(i[1].get_local_roles_for_userid(user_id))
 						roles.append('View')
 						i[1].manage_setLocalRoles(user_id, roles)
@@ -788,7 +788,7 @@
 					errors.append('Failed to add permission for user "%s" for cluster "%s"' % (user_id, i[0]))
 			else:
 				try:
-					if user.has_permission('View', i[1]):
+					if user.has_role('View', i[1]):
 						roles = list(i[1].get_local_roles_for_userid(user_id))
 						roles.remove('View')
 
@@ -809,7 +809,7 @@
 	if not request.form.has_key('__SYSTEM'):
 		for i in storage:
 			try:
-				if user.has_permission('View', i[1]):
+				if user.has_role('View', i[1]):
 					roles = list(i[1].get_local_roles_for_userid(user_id))
 					roles.remove('View')
 
@@ -824,7 +824,7 @@
 		for i in storage:
 			if i[0] in request.form['__SYSTEM']:
 				try:
-					if not user.has_permission('View', i[1]):
+					if not user.has_role('View', i[1]):
 						roles = list(i[1].get_local_roles_for_userid(user_id))
 						roles.append('View')
 						i[1].manage_setLocalRoles(user_id, roles)
@@ -833,7 +833,7 @@
 					errors.append('Failed to add permission for user "%s" for system "%s"' % (user_id, i[0]))
 			else:
 				try:
-					if user.has_permission('View', i[1]):
+					if user.has_role('View', i[1]):
 						roles = list(i[1].get_local_roles_for_userid(user_id))
 						roles.remove('View')
 
@@ -998,12 +998,12 @@
 	except:
 		pass
 
-	if 'ACTUAL_URL' in request:
+	if request.has_key('ACTUAL_URL'):
 		url = request['ACTUAL_URL']
 	else:
 		url = '.'
 
-	if 'pagetype' in request:
+	if request.has_key('pagetype'):
 		pagetype = request['pagetype']
 	else:
 		pagetype = '0'
@@ -1016,110 +1016,105 @@
 	index = 0
 	cur = None
 
-	pagetype = str(pagetype)
+	if pagetype is None:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('HBP0: pagetype is None')
 
-#
-# The Add System page
-#
+	pagetype = str(pagetype)
 
+	# The Add System page
 	try:
 		if havePermAddStorage(self):
 			addSystem = {}
 			addSystem['Title'] = 'Add a System'
-			addSystem['absolute_url'] = '%s?pagetype=%s' % (url, HOMEBASE_ADD_SYSTEM)
+			addSystem['absolute_url'] = '%s?pagetype=%s' \
+				% (url, HOMEBASE_ADD_SYSTEM)
 			addSystem['Description'] = 'Add a system to the Luci storage management interface.'
+
 			if pagetype == HOMEBASE_ADD_SYSTEM:
-				cur = addSystem
 				addSystem['currentItem'] = True
 				ret['curIndex'] = index
-			else:
-				addSystem['currentItem'] = False
+				cur = addSystem
 			index += 1
 			temp.append(addSystem)
-	except: pass
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('HBP1: %r %s' % (e, str(e)))
 
 	# Initial add cluster page
 	try:
 		if havePermAddCluster(self):
 			addCluster = {}
 			addCluster['Title'] = 'Add an Existing Cluster'
-			addCluster['absolute_url'] = '%s?pagetype=%s' % (url, HOMEBASE_ADD_CLUSTER_INITIAL)
+			addCluster['absolute_url'] = '%s?pagetype=%s' \
+				% (url, HOMEBASE_ADD_CLUSTER_INITIAL)
 			addCluster['Description'] = 'Add an existing cluster to the Luci cluster management interface.'
+
 			if pagetype == HOMEBASE_ADD_CLUSTER_INITIAL or pagetype == HOMEBASE_ADD_CLUSTER:
 				addCluster['currentItem'] = True
 				ret['curIndex'] = index
 				cur = addCluster
-			else:
-				addCluster['currentItem'] = False
 			index += 1
 			temp.append(addCluster)
-	except: pass
-
-#
-# The Remove Storage System page
-#
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('HBP2: %r %s' % (e, str(e)))
 
+	# The Remove Storage System page
 	try:
 		if (havePermRemStorage(self) and havePermRemCluster(self) and (getStorage(self) or getClusters(self))):
 			remSystem = {}
 			remSystem['Title'] = 'Manage Systems'
-			remSystem['absolute_url'] = '%s?pagetype=%s' % (url, HOMEBASE_DEL_SYSTEM)
+			remSystem['absolute_url'] = '%s?pagetype=%s' \
+				% (url, HOMEBASE_DEL_SYSTEM)
 			remSystem['Description'] = 'Update or remove storage systems and clusters.'
 			if pagetype == HOMEBASE_DEL_SYSTEM:
 				remSystem['currentItem'] = True
 				ret['curIndex'] = index
 				cur = remSystem
-			else:
-				remSystem['currentItem'] = False
 			index += 1
 			temp.append(remSystem)
-	except:
-		pass
-
-#
-# Add a Luci user.
-#
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('HBP3: %r %s' % (e, str(e)))
 
+	# Add a Luci user.
 	try:
 		if havePermAddUser(self):
 			addUser = {}
 			addUser['Title'] = 'Add a User'
-			addUser['absolute_url'] = '%s?pagetype=%s' % (url, HOMEBASE_ADD_USER)
+			addUser['absolute_url'] = '%s?pagetype=%s' \
+				% (url, HOMEBASE_ADD_USER)
 			addUser['Description'] = 'Add a user to the Luci interface.'
 			if pagetype == HOMEBASE_ADD_USER:
 				addUser['currentItem'] = True
 				ret['curIndex'] = index
 				cur = addUser
-			else:
-				addUser['currentItem'] = False
 			index += 1
 			temp.append(addUser)
-	except:
-		pass
-
-#
-# Delete a Luci user
-#
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('HBP4: %r %s' % (e, str(e)))
 
+	# Delete a Luci user
 	try:
 		if (self.portal_membership.listMembers() and havePermDelUser(self)):
 			delUser = {}
 			delUser['Title'] = 'Delete a User'
-			delUser['absolute_url'] = '%s?pagetype=%s' % (url, HOMEBASE_DEL_USER)
+			delUser['absolute_url'] = '%s?pagetype=%s' \
+				% (url, HOMEBASE_DEL_USER)
 			delUser['Description'] = 'Delete a Luci user.'
 			if pagetype == HOMEBASE_DEL_USER:
 				delUser['currentItem'] = True
 				ret['curIndex'] = index
 				cur = delUser
-			else:
-				delUser['currentItem'] = False
 			index += 1
 			temp.append(delUser)
-	except: pass
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('HBP5: %r %s' % (e, str(e)))
 
-#
-# The User Permissions Page
-#
+	# The User Permissions Page
 	try:
 		if (havePermEditPerms(self) and self.portal_membership.listMembers() and (getStorage(self) or getClusters(self))):
 			userPerm = {}
@@ -1130,35 +1125,34 @@
 				userPerm['currentItem'] = True
 				ret['curIndex'] = index
 				cur = userPerm
-			else:
-				userPerm['currentItem'] = False
 			index += 1
 			temp.append(userPerm)
-	except: pass
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('HBP6: %r %s' % (e, str(e)))
 
-	if not 'curIndex' in ret:
+	if not ret.has_key('curIndex'):
 		ret['curIndex'] = 0
 
-	if cur and 'absolute_url' in cur and params:
-		import cgi
+	if cur is not None and cur.has_key('absolute_url'):
 		cur['base_url'] = cur['absolute_url']
-		param_list = list()
-		for i in params:
-			param_list.append('&%s=%s' % (cgi.escape(i), cgi.escape(params[i])))
-		temp = '%s%s' % (cur['absolute_url'], ''.join(param_list))
-		cur['absolute_url'] = temp
-	elif cur and 'absolute_url' in cur:
-		cur['base_url'] = cur['absolute_url']
-	else:
-		cur = {}
-		cur['base_url'] = '#'
+
+		if params:
+			import cgi
+			param_list = list()
+			for i in params:
+				param_list.append('&%s=%s' \
+					% (cgi.escape(i), cgi.escape(params[i])))
+			temp = '%s%s' % (cur['absolute_url'], ''.join(param_list))
+			cur['absolute_url'] = temp
 
 	ret['children'] = temp
 	return ret
 
 def createSystem(self, host, passwd):
 	try:
-		dummy = self.restrictedTraverse('%s%s' % (STORAGE_FOLDER_PATH, host)).objectItems()
+		dummy = self.restrictedTraverse('%s%s' \
+			% (STORAGE_FOLDER_PATH, host)).objectItems()
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('CS0: %s already exists' % host)
 		return 'Storage system %s is already managed' % host
@@ -1171,7 +1165,7 @@
 			raise Exception, 'rc is None'
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('CS1: %s: %s' % (host, e))
+			luci_log.debug_verbose('CS2: %s: %r %s' % (host, e, str(e)))
 		return 'Unable to establish a secure connection to the ricci agent on %s: %s' % (host, str(e))
 
 	try:
@@ -1179,14 +1173,14 @@
 			rc.auth(passwd)
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('CS2: %s: %s' % (host, e))
+			luci_log.debug_verbose('CS3: %s: %r %s' % (host, e, str(e)))
 		return 'Unable to communicate with the ricci agent on %s for authentication' % host
 
 	try:
 		i = rc.authed()
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('CS3 %s: %r %s' % (host, e, str(e)))
+			luci_log.debug_verbose('CS4 %s: %r %s' % (host, e, str(e)))
 		return 'Unable to authenticate to the ricci agent on %s' % host
 
 	if i is not True:
@@ -1233,10 +1227,9 @@
 			user = request['user']
 		except:
 			try:
-				members = list()
-				members.extend(self.portal_membership.listMembers())
+				members = map(lambda x: x.getUserName(), self.portal_membership.listMembers())
 				members.sort()
-				user = members[0].getUserName()
+				user = members[0]
 			except Exception, e:
 				if LUCI_DEBUG_MODE is True:
 					luci_log.debug_verbose('getDefaultUser0: %r %s' \
@@ -1280,14 +1273,14 @@
 
 		for c in clusters:
 			try:
-				perms[userName]['cluster'][c[0]] = i.has_permission('View', c[1])
+				perms[userName]['cluster'][c[0]] = i.has_role('View', c[1])
 			except Exception, e:
 				if LUCI_DEBUG_MODE is True:
 					luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %r %s' % (userName, c[0], e, str(e)))
 
 		for s in storage:
 			try:
-				perms[userName]['storage'][s[0]] = i.has_permission('View', s[1])
+				perms[userName]['storage'][s[0]] = i.has_role('View', s[1])
 			except Exception, e:
 				if LUCI_DEBUG_MODE is True:
 					luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %r %s' % (userName, s[0], e, str(e)))



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2007-01-29 22:06 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2007-01-29 22:06 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-01-29 22:06:02

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	fix for '"%s" reports is not a member of any cluster.' error message bug.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.46&r2=1.47

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2007/01/08 21:58:34	1.46
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2007/01/29 22:06:02	1.47
@@ -278,7 +278,7 @@
 		if not cluster_info:
 			errmsg = 'An error occurred while attempting to retrieve the cluster.conf file from \"%s\"' % cur_host
 		else:
-			errmsg = '\"%s\" reports is not a member of any cluster.'
+			errmsg = '\"%s\" reports is not a member of any cluster.' % cur_host
 		return (False, { 'errors': [ errmsg ] })
 
 	cluster_name = cluster_info[0]



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2007-01-08 19:49 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2007-01-08 19:49 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe at sourceware.org	2007-01-08 19:49:20

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py ricci_bridge.py 

Log message:
	fix two small bugs related to bz201394

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.34.2.9&r2=1.34.2.10
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.30.2.16&r2=1.30.2.17

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2007/01/04 00:22:13	1.34.2.9
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2007/01/08 19:49:20	1.34.2.10
@@ -549,7 +549,7 @@
 					% (cur_host, str(e)))
 				incomplete = True
 				cur_system['errors'] = True
-				luci_log.debug_verbose('VAC3: %s: %s' % cur_host, str(e))
+				luci_log.debug_verbose('VAC3: %s: %s' % (cur_host, str(e)))
 				continue
 
 			cluster_info = rc.cluster_info()
--- conga/luci/site/luci/Extensions/ricci_bridge.py	2007/01/04 00:22:13	1.30.2.16
+++ conga/luci/site/luci/Extensions/ricci_bridge.py	2007/01/08 19:49:20	1.30.2.17
@@ -271,6 +271,7 @@
 			raise Exception, 'no batch tag was found'
 	except Exception, e:
 		luci_log.debug_verbose('batchAttemptResult: %s' % str(e))
+		return (None, None)
 
 	for i in batch:
 		try:



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2007-01-08 19:46 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2007-01-08 19:46 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-01-08 19:46:50

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py ricci_bridge.py 

Log message:
	fix two small bugs related to bz201394

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.53&r2=1.54

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2007/01/04 00:19:49	1.44
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2007/01/08 19:46:50	1.45
@@ -549,7 +549,7 @@
 					% (cur_host, str(e)))
 				incomplete = True
 				cur_system['errors'] = True
-				luci_log.debug_verbose('VAC3: %s: %s' % cur_host, str(e))
+				luci_log.debug_verbose('VAC3: %s: %s' % (cur_host, str(e)))
 				continue
 
 			cluster_info = rc.cluster_info()
--- conga/luci/site/luci/Extensions/ricci_bridge.py	2007/01/04 00:19:49	1.53
+++ conga/luci/site/luci/Extensions/ricci_bridge.py	2007/01/08 19:46:50	1.54
@@ -271,6 +271,7 @@
 			raise Exception, 'no batch tag was found'
 	except Exception, e:
 		luci_log.debug_verbose('batchAttemptResult: %s' % str(e))
+		return (None, None)
 
 	for i in batch:
 		try:



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-11-02 21:12 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-11-02 21:12 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-11-02 21:12:07

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	if node unauthentication fails and debugging is enabled, print a message to syslog

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.39&r2=1.40

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/11/02 03:17:07	1.39
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/11/02 21:12:07	1.40
@@ -137,8 +137,12 @@
 				rc = RicciCommunicator(host)
 				rc.unauth()
 				i['cur_auth'] = False
-		except:
-			pass
+		except Exception, e:
+			try:
+				luci_log.debug_verbose('unauth for %s failed: %s' \
+					% (i['host'], str(e)))
+			except:
+				pass
 
 def nodeAuth(cluster, host, passwd):
 	messages = list()



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-11-01 20:34 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-11-01 20:34 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-11-01 20:34:02

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py ricci_bridge.py 
	                           ricci_communicator.py 

Log message:
	fixes for bz# 213504

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.16&r2=1.17

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/30 20:42:03	1.37
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/11/01 20:34:02	1.38
@@ -13,6 +13,12 @@
 from ricci_communicator import CERTS_DIR_PATH
 from clusterOS import resolveOSType
 from conga_constants import *
+from LuciSyslog import LuciSyslog, LuciSyslogError
+
+try:
+	luci_log = LuciSyslog()
+except LuciSyslogError, e:
+	pass
 
 def siteIsSetup(self):
 	try:
@@ -136,20 +142,27 @@
 			pass
 
 def nodeAuth(cluster, host, passwd):
+	messages = list()
 	systemName = host
 	os_str = 'rhel5'
 
 	try:
 		rc = RicciCommunicator(host)
 		if not rc:
-			raise
-		systemName = rc.system_name()
-	except:
-		error = 'Unable to establish a connection to the ricci agent on \"' + host + '\"'
-		return { 'host': host, 'ricci_host': systemName, 'errors': error, 'cur_auth': False, 'os': os_str }
+			luci_log.debug_verbose('nodeAuth0: rc is None')
+			raise Exception, 'unknown error'
+	except Exception, e:
+		try:
+			error = 'Ricci connection to %s failed: %s' % (host, str(e))
+		except:
+			error = 'Ricci connection to %s failed' % host
+		luci_log.debug_verbose('nodeAuth1: rc failed: %s' % error)
+
+		return { 'host': host, 'ricci_host': host, 'errors': error, 'cur_auth': False, 'os': os_str }
 
 	if rc.authed():
 		prevAuth = True
+		messages.append('Luci is already authenticated to %s -- not checking password' % host)
 	else:
 		prevAuth = False
 		if not passwd:
@@ -157,11 +170,15 @@
 		else:
 			try:
 				rc.auth(passwd)
-			except: pass
+			except:
+				pass
 
 	if rc.authed():
-		os_str = resolveOSType(rc.os())
-		if not os_str:
+		try:
+			os_str = resolveOSType(rc.os())
+			if not os_str:
+				raise
+		except:
 			os_str = "rhel5"  #Backup plan in case all is almost lost...
 
 		systemName = rc.system_name()
@@ -183,6 +200,7 @@
 
 def validateAddClusterInitial(self, request, must_complete=True):
 	errors = list()
+	messages = list()
 	newNodeList = list()
 	nodeHash = {}
 	rnodeHash = {}
@@ -196,8 +214,10 @@
 
 	try:
 		rc = RicciCommunicator(sysData[0])
-	except:
-		return (False, { 'errors': [ 'Unable to establish a connection to the Ricci agent on \"' + sysData[0] + '\"' ] })
+		if not rc:
+			raise Exception, 'unknown error'
+	except Exception, e:
+		return (False, { 'errors': [ 'Unable to establish a connection to the Ricci agent on %s: %s' % (sysData[0], str(e)) ] })
 
 	prevAuth = 0
 	if not rc.authed():
@@ -241,7 +261,7 @@
 	if systemName[:9] == 'localhost':
 		systemName = sysData[0]
 
-	node = { 'host': sysData[0], 'ricci_host': systemName, 'prev_auth': prevAuth, 'cur_auth': rc.authed(), 'os': os_str }
+	node = { 'host': rc.hostname(), 'ricci_host': systemName, 'prev_auth': prevAuth, 'cur_auth': rc.authed(), 'os': os_str }
 	nodeHash[sysData[0]] = node
 	rnodeHash[systemName] = node
 	newNodeList.append(node)
@@ -253,6 +273,8 @@
 		
 	for i in nodeList:
 		node = nodeAuth(clusterName, i, passwd)
+		if 'messages' in node:
+			messages.extend(node['messages'])
 		if node['host'] in nodeHash or node['ricci_host'] in rnodeHash:
 			continue
 		nodeHash[node['host']] = node
@@ -281,11 +303,11 @@
 		'isComplete': len(filter(dfn, newNodeList)) == 0
 	}
 
-	if len(errors) < 1:
+	if len(errors) < len(nodeList):
 		cluster_properties['redirect'] = HOMEBASE_ADD_CLUSTER
 
 	return (len(errors) < 1,
-		{'errors': errors, 'requestResults': cluster_properties })
+		{'messages': messages, 'errors': errors, 'requestResults': cluster_properties })
 
 def validateAddCluster(self, request, must_complete=True):
 	errors = list()
@@ -296,7 +318,8 @@
 	try:
 		sessionData = request.SESSION.get('checkRet')
 		requestResults = sessionData['requestResults']
-	except:
+	except Exception, e:
+		luci_log.debug_verbose('VAC0: error getting session obj: %s' % str(e))
 		try:
 			clusterName = request.form['clusterName']
 		except:
@@ -304,24 +327,27 @@
 
 		try:
 			nodeList = requestResults['nodeList']
+			luci_log.debug_verbose('VAC1: unauth to node list')
 			nodeUnauth(nodeList)
 		except:
 			pass
 
-		return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName, 'isComplete': False, 'nodeList': [] } })
+		return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName, 'isComplete': False, 'nodeList': [], 'redirect': HOMEBASE_ADD_CLUSTER_INITIAL } })
 		
 	try:
 		clusterName = request.form['clusterName']
 		if not clusterName:
-			raise
-	except:
+			raise Exception, 'no cluster name was found'
+	except Exception, e:
+		luci_log.debug_verbose('VAC2: no cluser name found: %s', str(e))
 		return (False, { 'errors': ['No cluster name was given.'], 'requestResults': requestResults })
 
 	try:
 		nodeList = requestResults['nodeList']
 		if not nodeList or len(nodeList) < 1:
-			raise
-	except:
+			raise Exception, 'no node list found'
+	except Exception, e:
+		luci_log.debug_verbose('VAC3: no nodeList found: %s', str(e))
 		return (False, { 'errors': ['No cluster nodes were given.'], 'requestResults': requestResults })
 
 	try:
@@ -338,13 +364,15 @@
 	try:
 		numStorage = int(request.form['numStorage'])
 		if numStorage != len(nodeList):
-			raise
-	except:
-		nodeUnauth(nodeList)
+			raise Exception, 'numstorage != len(nodelist)'
+	except Exception, e:
 		try:
 			requestResults['isComplete'] = False
+			luci_log.debug_verbose('VAC4: error: %s' % str(e))
 		except:
 			pass
+
+		nodeUnauth(nodeList)
 		return (False, {
 				'errors': [ 'Unknown number of nodes entered' ],
 				'requestResults': requestResults })
@@ -372,8 +400,9 @@
 					oldNode = rnodeHash[k]
 
 		if not oldNode:
+			luci_log.debug_verbose('VAC5: node %s not found', sysData[0])
 			nodeUnauth(nodeList)
-			return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName, 'nodeList': nodeList, 'isComplete': False } })
+			return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName, 'nodeList': nodeList, 'isComplete': False, 'redirect': HOMEBASE_ADD_CLUSTER_INITIAL } })
 
 		if oldNode['host'] != node['host']:
 			del nodeHash[oldNode['host']]
@@ -587,8 +616,11 @@
 
 		try:
 			rc = RicciCommunicator(sysData[0])
-		except:
-			errors.append('Unable to contact the ricci agent for ' + host)
+			if rc is None:
+				raise Exception, 'unknown error'
+		except Exception, e:
+			errors.append('Unable to contact the ricci agent for %s: %s' \
+				% (sysData[0], str(e)))
 			i += 1
 			continue
 
@@ -658,20 +690,23 @@
 	except:
 		sessionData = None
 
-	try:
-		request.SESSION.delete('checkRet')
-	except:
-		pass
-
 	if 'ACTUAL_URL' in request:
 		url = request['ACTUAL_URL']
 	else:
 		url = '.'
 
-	try:
+	if 'pagetype' in request.form:
 		pagetype = int(request.form['pagetype'])
+	else:
+		try: request.SESSION.set('checkRet', {})
+		except: pass
+		return homebasePortal(self, request, '.', '0')
+
+	try:
 		validatorFn = formValidators[pagetype - 1]
 	except:
+		try: request.SESSION.set('checkRet', {})
+		except: pass
 		return homebasePortal(self, request, '.', '0')
 
 	if validatorFn == validateAddClusterInitial or validatorFn == validateAddCluster:
@@ -699,7 +734,7 @@
 		return homebaseControlPost(self, request)
 
 	try:
-		request.SESSION.delete('checkRet')
+		request.SESSION.set('checkRet', {})
 	except:
 		pass
 
@@ -948,8 +983,11 @@
 
 	try:
 		rc = RicciCommunicator(host)
-	except:
-		return 'Unable to establish a connection to the ricci agent on \"' + host + '\"'
+		if rc is None:
+			raise Exception, 'unknown error'
+	except Exception, e:
+		return 'Unable to establish a connection to the ricci agent on %s: %s' \
+			% (host, str(e))
 
 	try:
 		if not rc.authed():
@@ -977,20 +1015,20 @@
 
 	try:
 		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
-	except:
-		return 'Unable to create storage system \"' + host + '\"'
+	except Exception, e:
+		return 'Unable to create storage system %s: %s' % (host, str(e))
 
 	try:
 		ssystem.manage_addFolder(host, '__luci__:system')
 		newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host)
-	except:
-		return 'Unable to create storage system \"' + host + '\"'
+	except Exception, e:
+		return 'Unable to create storage system %s: %s' % (host, str(e))
 
 	try:
 		newSystem.manage_acquiredPermissions([])
 		newSystem.manage_role('View', ['Access contents information','View'])
-	except:
-		return 'Unable to set permissions on new system \"' + host + '\"'
+	except Exception, e:
+		return 'Unable to set permissions on storage system %s: %s' % (host, str(e))
 
 	return None
 
@@ -1003,11 +1041,12 @@
 
 def manageCluster(self, clusterName, nodeList):
 	clusterName = str(clusterName)
+	luci_log.debug_verbose('manageCluster for %s' % clusterName)
 
 	try:
 		clusters = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/')
 		if not clusters:
-			raise
+			raise Exception, 'cannot find the cluster entry in the DB'
 	except:
 		nodeUnauth(nodeList)
 		return 'Unable to create cluster \"' + clusterName + '\": the cluster directory is missing.'
@@ -1024,28 +1063,29 @@
 		clusters.manage_addFolder(clusterName, '__luci__:cluster')
 		newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
 		if not newCluster:
-			raise
-	except:
+			raise Exception, 'unable to find cluster folder for %s' % clusterName
+	except Exception, e:
 		nodeUnauth(nodeList)
-		return 'Unable to create cluster \"' + clusterName + '\"'
+		return 'Unable to create cluster %s: %s' % (clusterName, str(e))
 
 	try:
 		newCluster.manage_acquiredPermissions([])
 		newCluster.manage_role('View', ['Access Contents Information','View'])
-	except:
+	except Exception, e:
 		nodeUnauth(nodeList)
 		try:
 			clusters.manage_delObjects([clusterName])
 		except:
 			pass
-		return 'Unable to set permissions on new cluster \"' + clusterName + '\"-- Cluster creation failed'
+		return 'Unable to set permissions on new cluster: %s: %s' % (clusterName, str(e))
 
-	# XXX this needs to be improved.
 	try:
 		cluster_os = nodeList[0]['os']
 		if not cluster_os:
 			raise KeyError, 'Cluster OS is blank'
 	except KeyError, e:
+		luci_log.debug_verbose('Warning adding cluster %s: %s' \
+			% (clusterName, str(e)))
 		cluster_os = 'rhel5'
 
 	try:
@@ -1063,23 +1103,24 @@
 			newCluster.manage_addFolder(host, '__luci__:csystem:' + clusterName)
 			newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName + '/' + host)
 			if not newSystem:
-				raise 'not there'
+				raise Exception, 'unable to create cluster system DB entry'
 			newSystem.manage_acquiredPermissions([])
 			newSystem.manage_role('View', [ 'Access contents information' , 'View' ])
-		except:
+		except Exception, e:
 			nodeUnauth(nodeList)
 			try:
 				clusters.manage_delObjects([clusterName])
 			except:
 				pass
-			return 'Unable to create cluster node \"' + host + '\" for cluster \"' + clusterName + '\" -- Cluster creation failed."'
+			return 'Unable to create cluster node %s for cluster %s: %s' \
+				% (host, clusterName, str(e))
 
 	try:
 		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
 		if not ssystem:
-			raise
-	except:
-		return 'The storage directory is missing.'
+			raise Exception, 'The storage DB entry is missing'
+	except Exception, e:
+		return 'Error adding storage node %s: %s' % (host, str(e))
 
 	# Only add storage systems if the cluster and cluster node DB
 	# objects were added successfully.
@@ -1106,7 +1147,7 @@
 	try:
 		clusterObj = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
 		if not clusterObj:
-			raise
+			raise Exception, 'cluster %s DB entry is missing' % clusterName
 	except:
 		nodeUnauth(nodeList)
 		return 'No cluster named \"' + clusterName + '\" is managed by Luci'
@@ -1121,18 +1162,22 @@
 			clusterObj.manage_addFolder(host, '__luci__:csystem:' + clusterName)
 			newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName + '/' + host)
 			if not newSystem:
-				raise
+				raise Exception, 'cluster node DB entry for %s disappeared from under us' % host
+					
 			newSystem.manage_acquiredPermissions([])
 			newSystem.manage_role('View', [ 'Access contents information' , 'View' ])
-		except:
+		except Exception, e:
 			nodeUnauth(nodeList)
-			return 'Unable to create cluster node \"' + host + '\" for cluster \"' + clusterName + '\"'
+			return 'Unable to create cluster node %s for cluster %s: %s' \
+				% (host, clusterName, str(e))
 
 	try:
 		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
 		if not ssystem:
-			raise
-	except:
+			raise Exception, 'storage DB entry is missing'
+	except Exception, e:
+		luci_log.debug_verbose('Error: adding storage DB node for %s: %s' \
+			% (host, str(e)))
 		return
 
 	# Only add storage systems if the and cluster node DB
@@ -1160,19 +1205,20 @@
 	try:
 		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
 		if not ssystem:
-			raise
-	except:
-		return 'Unable to find storage system \"' + systemName + '\"'
+			raise Exception, 'storage DB entry is missing'
+	except Exception, e:
+		return 'Unable to find storage system %s: %s' % (systemName, str(e))
 
 	try:
 		rc = RicciCommunicator(systemName)
-		if not rc:
-			raise
-	except:
+		if rc is None:
+			raise Exception, 'unknown error'
+	except Exception, e:
 		try:
 			ssystem.manage_delObjects([systemName])
 		except:
 			return 'Unable to delete the storage system \"' + systemName + '\"'
+		luci_log.debug_verbose('ricci error for %s: %s' % (systemName, str(e)))
 		return
 
 	# Only unauthenticate if the system isn't a member of
@@ -1190,8 +1236,9 @@
 
 	try:
 		ssystem.manage_delObjects([systemName])
-	except:
-		return 'Unable to delete storage system \"' + systemName + '\"'
+	except Exception, e:
+		return 'Unable to delete storage system %s: %s' \
+			% (systemName, str(e))
 
 def delCluster(self, clusterName):
 	try:
@@ -1218,25 +1265,33 @@
 		try:
 			rc = RicciCommunicator(systemName)
 			rc.unauth()
-		except: pass
-	cluster.manage_delObjects([systemName])
+		except Exception, e:
+			luci_log.debug_verbose('ricci error for %s: %s' \
+				% (systemName, str(e)))
+
+	try:
+		cluster.manage_delObjects([systemName])
+	except Exception, e:
+		err_str = 'Error deleting cluster object %s: %s' % (systemName, str(e))
+		luci_log.debug_verbose(err_str)
+		return err_str
 
 def delClusterSystems(self, clusterName):
 	try:
 		cluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
 		if not cluster:
-			raise
+			raise Exception, 'cluster DB entry is missing'
 		csystems = getClusterSystems(self, clusterName)
-	except:
+	except Exception, e:
+		luci_log.debug_verbose('delCluSysterms: error for %s: %s' \
+			% (clusterName, str(e)))
 		return 'Unable to find any systems for cluster \"' + clusterName + '\"'
 
 	errors = ''
 	for i in csystems:
-		try:
-			delClusterSystem(self, cluster, i[0])
-		except:
-			errors += 'Unable to delete the cluster system \"' + i[0] + '\"\n'
-
+		err = delClusterSystem(self, cluster, i[0])
+		if err:
+			errors += 'Unable to delete the cluster system %s: %s\n' % (i[0], err)
 	return errors
 
 def getDefaultUser(self, request):
--- conga/luci/site/luci/Extensions/ricci_bridge.py	2006/10/31 13:51:53	1.39
+++ conga/luci/site/luci/Extensions/ricci_bridge.py	2006/11/01 20:34:02	1.40
@@ -507,13 +507,22 @@
 	batch.appendChild(module)
 
 	# temporary workaround for ricci bug
-	system_info = rc.system_name()
-	rc = RicciCommunicator(system_info)
+	system_info = rc.hostname()
+	try:
+		rc = RicciCommunicator(system_info)
+		if rc is None:
+			raise Exception, 'unknown error'
+	except Exception, e:
+		luci_log.debug_verbose('Ricci error while connecting to %s: %s' \
+			% (system_info, str(e)))
+		return None
 	# end workaround
 
 	try:
 		ret = rc.process_batch(batch)
 	except Exception, e:
+		luci_log.debug_verbose('process_batch error for %s: %s' \
+			% (system_info, str(e)))
 		return None
 
 	if not ret:
--- conga/luci/site/luci/Extensions/ricci_communicator.py	2006/10/31 17:18:12	1.16
+++ conga/luci/site/luci/Extensions/ricci_communicator.py	2006/11/01 20:34:02	1.17
@@ -32,6 +32,10 @@
         except Exception, e:
             raise RicciError, 'Error connecting to %s:%d: %s' \
                     % (self.__hostname, self.__port, str(e))
+        except:
+            raise RicciError, 'Error connecting to %s:%d: unknown error' \
+                    % (self.__hostname, self.__port)
+
         luci_log.debug_verbose('Connected to %s:%d' \
             % (self.__hostname, self.__port))
         try:
@@ -42,6 +46,9 @@
         except Exception, e:
             raise RicciError, 'Error setting up SSL for connection to %s: %s' \
                 % (self.__hostname, str(e))
+        except:
+            raise RicciError, 'Error setting up SSL for connection to %s' \
+                % self.__hostname
         
         # receive ricci header
         hello = self.__receive()
@@ -168,6 +175,8 @@
                 % (doc.toxml(), self.__hostname))
             raise RicciError, 'Error sending XML to host %s: %s' \
                     % (self.__hostname, str(e))
+        except:
+            raise RicciError, 'Error sending XML to host %s' % self.__hostname
         
         # receive response
         doc = self.__receive()
@@ -264,8 +273,11 @@
             try:
                 pos = self.ss.write(buff)
             except Exception, e:
-                luci_log.debug('Error sending XML \"%s\" to %s' \
-                    % (buff, self.__hostname))
+                luci_log.debug('Error sending XML \"%s\" to %s: %s' \
+                    % (buff, self.__hostname, str(e)))
+                raise RicciError, 'write error while sending XML to host %s' \
+                        % self.__hostname
+            except:
                 raise RicciError, 'write error while sending XML to host %s' \
                         % self.__hostname
             buff = buff[pos:]
@@ -294,8 +306,9 @@
         except Exception, e:
             luci_log.debug('Error reading data from %s: %s' \
                 % (self.__hostname, str(e)))
-            raise RicciError, 'Error reading data from host %s' \
-                    % self.__hostname
+            raise RicciError, 'Error reading data from host %s' % self.__hostname
+        except:
+            raise RicciError, 'Error reading data from host %s' % self.__hostname
         luci_log.debug_verbose('Received XML \"%s\" from host %s' \
             % (xml_in, self.__hostname))
 



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-10-30 20:20 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-10-30 20:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe at sourceware.org	2006-10-30 20:20:04

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	ref bz# 212440

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.34.2.1&r2=1.34.2.2

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/24 16:36:23	1.34.2.1
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/30 20:20:04	1.34.2.2
@@ -971,9 +971,9 @@
 	if i != True:
 		return 'Authentication for storage system \"' + host + '\" failed'
 
-	rhost = rc.system_name()
-	if rhost and rhost != host and rhost[:9] != 'localhost' and rhost[:5] != '127.0':
-		host = str(rhost)
+#	rhost = rc.system_name()
+#	if rhost and rhost != host and rhost[:9] != 'localhost' and rhost[:5] != '127.0':
+#		host = str(rhost)
 
 	try:
 		exists = self.restrictedTraverse(PLONE_ROOT +'/systems/storage/' + host)
@@ -1060,10 +1060,10 @@
 		pass # we were unable to set the OS property string on this cluster
 
 	for i in nodeList:
-		if 'ricci_host' in i:
-			host = str(i['ricci_host'])
-		else:
-			host = str(i['host'])
+		#if 'ricci_host' in i:
+		#	host = str(i['ricci_host'])
+		#else:
+		host = str(i['host'])
 
 		try:
 			newCluster.manage_addFolder(host, '__luci__:csystem:' + clusterName)
@@ -1090,10 +1090,10 @@
 	# Only add storage systems if the cluster and cluster node DB
 	# objects were added successfully.
 	for i in nodeList:
-		if 'ricci_host' in i:
-			host = str(i['ricci_host'])
-		else:
-			host = str(i['host'])
+		#if 'ricci_host' in i:
+		#	host = str(i['ricci_host'])
+		#else:
+		host = str(i['host'])
 
 		try:
 			# It's already there, as a storage system, no problem.
@@ -1118,10 +1118,10 @@
 		return 'No cluster named \"' + clusterName + '\" is managed by Luci'
 
 	for i in nodeList:
-		if 'ricci_host' in i:
-			host = str(i['ricci_host'])
-		else:
-			host = str(i['host'])
+		#if 'ricci_host' in i:
+		#	host = str(i['ricci_host'])
+		#else:
+		host = str(i['host'])
 
 		try:
 			clusterObj.manage_addFolder(host, '__luci__:csystem:' + clusterName)
@@ -1144,10 +1144,10 @@
 	# Only add storage systems if the and cluster node DB
 	# objects were added successfully.
 	for i in nodeList:
-		if 'ricci_host' in i:
-			host = str(i['ricci_host'])
-		else:
-			host = str(i['host'])
+		#if 'ricci_host' in i:
+		#	host = str(i['ricci_host'])
+		#else:
+		host = str(i['host'])
 
 		try:
 			# It's already there, as a storage system, no problem.
@@ -1189,7 +1189,7 @@
 		except: pass
 	else:
 		try:
-			newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster_info[0] + '/' + rc.system_name())
+			newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster_info[0] + '/' + systemName)
 		except:
 			try: rc.unauth()
 			except: pass



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-10-26 16:57 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-10-26 16:57 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-26 16:57:12

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	use the hostnames or IP addresses users enter to address systems and cluster nodes rather than the host ricci provides in rc.system_info()

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.35&r2=1.36

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/18 23:12:31	1.35
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/26 16:57:12	1.36
@@ -971,9 +971,9 @@
 	if i != True:
 		return 'Authentication for storage system \"' + host + '\" failed'
 
-	rhost = rc.system_name()
-	if rhost and rhost != host and rhost[:9] != 'localhost' and rhost[:5] != '127.0':
-		host = str(rhost)
+#	rhost = rc.system_name()
+#	if rhost and rhost != host and rhost[:9] != 'localhost' and rhost[:5] != '127.0':
+#		host = str(rhost)
 
 	try:
 		exists = self.restrictedTraverse(PLONE_ROOT +'/systems/storage/' + host)
@@ -1060,10 +1060,10 @@
 		pass # we were unable to set the OS property string on this cluster
 
 	for i in nodeList:
-		if 'ricci_host' in i:
-			host = str(i['ricci_host'])
-		else:
-			host = str(i['host'])
+		#if 'ricci_host' in i:
+		#	host = str(i['ricci_host'])
+		#else:
+		host = str(i['host'])
 
 		try:
 			newCluster.manage_addFolder(host, '__luci__:csystem:' + clusterName)
@@ -1090,10 +1090,10 @@
 	# Only add storage systems if the cluster and cluster node DB
 	# objects were added successfully.
 	for i in nodeList:
-		if 'ricci_host' in i:
-			host = str(i['ricci_host'])
-		else:
-			host = str(i['host'])
+		#if 'ricci_host' in i:
+		#	host = str(i['ricci_host'])
+		#else:
+		host = str(i['host'])
 
 		try:
 			# It's already there, as a storage system, no problem.
@@ -1118,10 +1118,10 @@
 		return 'No cluster named \"' + clusterName + '\" is managed by Luci'
 
 	for i in nodeList:
-		if 'ricci_host' in i:
-			host = str(i['ricci_host'])
-		else:
-			host = str(i['host'])
+		#if 'ricci_host' in i:
+		#	host = str(i['ricci_host'])
+		#else:
+		host = str(i['host'])
 
 		try:
 			clusterObj.manage_addFolder(host, '__luci__:csystem:' + clusterName)
@@ -1144,10 +1144,10 @@
 	# Only add storage systems if the and cluster node DB
 	# objects were added successfully.
 	for i in nodeList:
-		if 'ricci_host' in i:
-			host = str(i['ricci_host'])
-		else:
-			host = str(i['host'])
+		#if 'ricci_host' in i:
+		#	host = str(i['ricci_host'])
+		#else:
+		host = str(i['host'])
 
 		try:
 			# It's already there, as a storage system, no problem.
@@ -1189,7 +1189,7 @@
 		except: pass
 	else:
 		try:
-			newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster_info[0] + '/' + rc.system_name())
+			newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster_info[0] + '/' + systemName)
 		except:
 			try: rc.unauth()
 			except: pass



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-10-13 17:12 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-10-13 17:12 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-13 17:12:41

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	allow removing a storage system, even if we're unable to talk to the ricci node that's [supposed to be] running on it

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.30&r2=1.31

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/13 17:04:11	1.30
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/13 17:12:41	1.31
@@ -1107,7 +1107,11 @@
 		if not rc:
 			raise
 	except:
-		return 'Unable to connect to the ricci agent on \"' + systemName + '\" to unauthenticate'
+		try:
+			ssystem.manage_delObjects([systemName])
+		except:
+			return 'Unable to delete the storage system \"' + systemName + '\"'
+		return
 
 	# Only unauthenticate if the system isn't a member of
 	# a managed cluster.



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-10-11 21:48 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-10-11 21:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-11 21:48:04

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py clusterOS.py 

Log message:
	workaround ricci supplying a blank os; assume rhel5

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/clusterOS.py.diff?cvsroot=cluster&r1=1.1&r2=1.2

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/11 18:44:05	1.27
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/11 21:48:04	1.28
@@ -172,7 +172,7 @@
 
 	if rc.authed():
 		os_str = resolveOSType(rc.os())
-		if os_str == None:
+		if not os_str:
 			os_str = "rhel5"  #Backup plan in case all is almost lost...
 
 		systemName = rc.system_name()
@@ -226,7 +226,7 @@
 		cluster_info = None
 
 	os_str = resolveOSType(rc.os())
-	if os_str == None:
+	if not os_str:
 		os_str = "rhel5"  #Backup plan in case all is almost lost...
 
 	if not cluster_info or not cluster_info[0]:
--- conga/luci/site/luci/Extensions/clusterOS.py	2006/10/06 20:45:26	1.1
+++ conga/luci/site/luci/Extensions/clusterOS.py	2006/10/11 21:48:04	1.2
@@ -1,5 +1,5 @@
-def resolveOSType(os):
-	if os.find("Tikanga") != (-1) or os.find("FC6") != (-1):
-		return "rhel5"
+def resolveOSType(os_str):
+	if not os_str or os_str.find('Tikanga') != (-1) or os_str.find('FC6') != (-1):
+		return 'rhel5'
 	else:
-		return "rhel4"
+		return 'rhel4'



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-10-11 18:44 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-10-11 18:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-11 18:44:06

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	more robustness improvements

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.26&r2=1.27

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/11 17:29:46	1.26
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/11 18:44:05	1.27
@@ -925,9 +925,11 @@
 
 	try:
 		clusters = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/')
+		if not clusters:
+			raise
 	except:
 		nodeUnauth(nodeList)
-		return 'Unable to create cluster \"' + clusterName + '\"'
+		return 'Unable to create cluster \"' + clusterName + '\": the cluster directory is missing.'
 
 	try:
 		newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
@@ -940,6 +942,8 @@
 	try:
 		clusters.manage_addFolder(clusterName, '__luci__:cluster')
 		newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
+		if not newCluster:
+			raise
 	except:
 		nodeUnauth(nodeList)
 		return 'Unable to create cluster \"' + clusterName + '\"'
@@ -949,8 +953,10 @@
 		newCluster.manage_role('View', ['Access Contents Information','View'])
 	except:
 		nodeUnauth(nodeList)
-		try: clusters.manage_delObjects([clusterName])
-		except: pass
+		try:
+			clusters.manage_delObjects([clusterName])
+		except:
+			pass
 		return 'Unable to set permissions on new cluster \"' + clusterName + '\"-- Cluster creation failed'
 
 	for i in nodeList:
@@ -968,8 +974,10 @@
 			newSystem.manage_role('View', [ 'Access contents information' , 'View' ])
 		except:
 			nodeUnauth(nodeList)
-			try: clusters.manage_delObjects([clusterName])
-			except: pass
+			try:
+				clusters.manage_delObjects([clusterName])
+			except:
+				pass
 			return 'Unable to create cluster node \"' + host + '\" for cluster \"' + clusterName + '\" -- Cluster creation failed."'
 
 	try:
@@ -977,7 +985,7 @@
 		if not ssystem:
 			raise
 	except:
-		return
+		return 'The storage directory is missing.'
 
 	# Only add storage systems if the cluster and cluster node DB
 	# objects were added successfully.
@@ -1057,6 +1065,8 @@
 def delSystem(self, systemName):
 	try:
 		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
+		if not ssystem:
+			raise
 	except:
 		return 'Unable to find storage system \"' + systemName + '\"'
 
@@ -1088,6 +1098,8 @@
 def delCluster(self, clusterName):
 	try:
 		clusters = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/')
+		if not clusters:
+			raise
 	except:
 		return 'Unable to find cluster \"' + clusterName + '\"'
 
@@ -1114,6 +1126,8 @@
 def delClusterSystems(self, clusterName):
 	try:
 		cluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
+		if not cluster:
+			raise
 		csystems = getClusterSystems(self, clusterName)
 	except:
 		return 'Unable to find any systems for cluster \"' + clusterName + '\"'



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-10-06 20:45 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-10-06 20:45 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-06 20:45:27

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 
	                           cluster_adapters.py 
Added files:
	luci/site/luci/Extensions: clusterOS.py UnknownClusterError.py 

Log message:
	move resolveOSType to a new file clusterOS.py to break a circular import dependency
	create UnknownClusterError as a couple of functions in cluster_adapters try to throw this kind of exception
	fix a few other small bugs

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/clusterOS.py.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/UnknownClusterError.py.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.84&r2=1.85

/cvs/cluster/conga/luci/site/luci/Extensions/clusterOS.py,v  -->  standard output
revision 1.1
--- conga/luci/site/luci/Extensions/clusterOS.py
+++ -	2006-10-06 20:45:27.366723000 +0000
@@ -0,0 +1,5 @@
+def resolveOSType(os):
+	if os.find("Tikanga") != (-1) or os.find("FC6") != (-1):
+		return "rhel5"
+	else:
+		return "rhel4"
/cvs/cluster/conga/luci/site/luci/Extensions/UnknownClusterError.py,v  -->  standard output
revision 1.1
--- conga/luci/site/luci/Extensions/UnknownClusterError.py
+++ -	2006-10-06 20:45:27.449955000 +0000
@@ -0,0 +1,14 @@
+"""Exception class for throwing except on an 
+   unknown cluster error that occurred during
+   a batch command.
+"""
+
+class UnknownClusterError:
+    def __init__(self, severity, message):
+        self.__severity     = severity
+        self.__msg          = message
+    def getSeverity(self):
+        return self.__severity
+    def getMessage(self):
+        return self.__msg
+
--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/06 18:58:51	1.23
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/06 20:45:26	1.24
@@ -9,7 +9,8 @@
 
 from ricci_defines import *
 from ricci_communicator import RicciCommunicator
-from cluster_adapters import resolveOSType
+from ricci_communicator import CERTS_DIR_PATH
+from clusterOS import resolveOSType
 
 HOMEBASE_ADD_USER="1"
 HOMEBASE_ADD_SYSTEM="2"
@@ -24,7 +25,6 @@
 class InCluster(Exception):
 	pass
 
-from ricci_communicator import CERTS_DIR_PATH
 def siteIsSetup(self):
 	try:
 		if os.path.isfile(CERTS_DIR_PATH + 'privkey.pem') and os.path.isfile(CERTS_DIR_PATH + 'cacert.pem'):
@@ -301,6 +301,10 @@
 		sessionData = request.SESSION.get('checkRet')
 		requestResults = sessionData['requestResults']
 	except:
+		try:
+			clusterName = request.form['clusterName']
+		except:
+			clusterName = ''
 		return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName } })
 		
 	if not 'clusterName' in request.form or request.form['clusterName'] == '':
@@ -357,7 +361,7 @@
 			if oldNode['ricci_host'] in rnodeHash:
 				del rnodeHash[oldNode['ricci_host']]
 				oldNode['ricci_host'] = node['ricci_host']
-				rnodeHashnode[node['ricci_host']] = oldNode
+				rnodeHash[node['ricci_host']] = oldNode
 
 		oldNode['cur_auth'] = node['cur_auth']
 		if 'errors' in node:
@@ -903,9 +907,10 @@
 		newSystem.manage_role('View', ['Access contents information','View'])
 	except:
 		return 'Unable to set permissions on new system \"' + host + '\"'
+
 	return None
 
-def abortManageCluster(self):
+def abortManageCluster(self, request):
 	try:
 		sessionData = request.SESSION.get('checkRet')
 		nodeUnauth(sessionData['requestResults']['nodeList'])
@@ -1076,38 +1081,6 @@
 	except:
 		return 'Unable to delete storage system \"' + systemName + '\"'
 
-
-def delSystem(self, systemName):
-	try:
-		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
-	except:
-		return 'Unable to find storage system \"' + systemName + '\"'
-
-	try:
-		rc = RicciCommunicator(systemName)
-		if not rc:
-			raise
-	except:
-		return 'Unable to connect to the ricci agent on \"' + systemName + '\" to unauthenticate'
-
-	# Only unauthenticate if the system isn't a member of
-	# a managed cluster.
-	cluster_info = rc.cluster_info()
-	if not cluster_info[0]:
-		try: rc.unauth()
-		except: pass
-	else:
-		try:
-			newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster_info[0] + '/' + rc.system_name())
-		except:
-			try: rc.unauth()
-			except: pass
-
-	try:
-		ssystem.manage_delObjects([systemName])
-	except:
-		return 'Unable to delete storage system \"' + systemName + '\"'
-
 def delCluster(self, clusterName):
 	try:
 		clusters = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/')
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/06 18:58:51	1.84
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/06 20:45:26	1.85
@@ -12,10 +12,14 @@
 from Clusterfs import Clusterfs
 from Fs import Fs
 from NFSClient import NFSClient
+from NFSExport import NFSExport
 from Netfs import Netfs
 from Script import Script
 from Samba import Samba
+from clusterOS import resolveOSType
 from GeneralError import GeneralError
+from UnknownClusterError import UnknownClusterError
+from homebase_adapters import nodeUnauth, nodeAuth, manageCluster, createClusterSystems, havePermCreateCluster
 
 #Policy for showing the cluster chooser menu:
 #1) If there are no clusters in the ManagedClusterSystems
@@ -25,8 +29,6 @@
 #then only display chooser if the current user has
 #permissions on at least one. If the user is admin, show ALL clusters
 
-from homebase_adapters import nodeAuth, nodeUnauth, manageCluster, createClusterSystems, havePermCreateCluster
-
 CLUSTER_FOLDER_PATH = '/luci/systems/cluster/'
 
 def validateClusterNodes(request, sessionData, clusterName, numStorage):
@@ -136,6 +138,7 @@
 	except:
 		errors.append('A cluster must contain at least one node')
 
+	cluster_os = None
 	try:
 		cluster_os = nodeList[0]['os']
 		if not cluster_os:
@@ -154,7 +157,7 @@
 		return (False, {'errors': errors, 'requestResults':cluster_properties })
 
 	if cluster_properties['isComplete'] == True:
-		batchNode = createClusterBatch(os_str, clusterName, clusterName, map(lambda x: x['ricci_host'], nodeList), True, False, False)
+		batchNode = createClusterBatch(cluster_os, clusterName, clusterName, map(lambda x: x['ricci_host'], nodeList), True, False, False)
 		if not batchNode:
 			nodeUnauth(nodeList)
 			cluster_properties['isComplete'] = False
@@ -350,7 +353,7 @@
 	except KeyError, e:
 		errors.append('No Interval value was given.')
 	except ValueError, e:
-		errros.append('An invalid Interval value was given: ' + e)
+		errors.append('An invalid Interval value was given: ' + e)
 
 	try:
 		votes = int(form['votes'])
@@ -2186,12 +2189,6 @@
 	map['isVirtualized'] = rc.dom0()
 	return map
 
-def resolveOSType(os):
-  if os.find("Tikanga") != (-1) or os.find("FC6") != (-1):
-    return "rhel5"
-  else:
-    return "rhel4"
-
 def getResourcesInfo(modelb, request):
 	resList = list()
 	baseurl = request['URL']



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-10-06 18:58 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-10-06 18:58 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-06 18:58:51

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 
	                           cluster_adapters.py 

Log message:
	- enforce os homogeneity when deploying a cluster
	- allow 1 node clusters (used to require 2)
	- fix a few cases where code was returning a string instead of a list

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.83&r2=1.84

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/04 13:25:48	1.22
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/06 18:58:51	1.23
@@ -9,6 +9,7 @@
 
 from ricci_defines import *
 from ricci_communicator import RicciCommunicator
+from cluster_adapters import resolveOSType
 
 HOMEBASE_ADD_USER="1"
 HOMEBASE_ADD_SYSTEM="2"
@@ -155,7 +156,7 @@
 		systemName = rc.system_name()
 	except:
 		error = 'Unable to establish a connection to the ricci agent on \"' + host + '\"'
-		return { 'host': host, 'ricci_host': systemName, 'errors': error, 'cur_auth': False }
+		return { 'host': host, 'ricci_host': systemName, 'errors': error, 'cur_auth': False, 'os': None }
 
 
 	if rc.authed():
@@ -163,17 +164,21 @@
 	else:
 		prevAuth = False
 		if not passwd:
-			return { 'host': host, 'ricci_host': systemName, 'prev_auth': False, 'cur_auth': False }
+			return { 'host': host, 'ricci_host': systemName, 'prev_auth': False, 'cur_auth': False, 'os': None}
 		else:
 			try:
 				rc.auth(passwd)
 			except: pass
 
 	if rc.authed():
+		os_str = resolveOSType(rc.os())
+		if os_str == None:
+			os_str = "rhel5"  #Backup plan in case all is almost lost...
+
 		systemName = rc.system_name()
 		if systemName[:9] == 'localhost' or systemName[:5] == '127.0':
 			systemName = host
-		node = { 'host': host, 'ricci_host': systemName, 'prev_auth': prevAuth, 'cur_auth': True }
+		node = { 'host': host, 'ricci_host': systemName, 'prev_auth': prevAuth, 'cur_auth': True, 'os': os_str }
 
 		cluster_info = rc.cluster_info()
 		if cluster and ((not cluster_info) or (cluster_info[0] != cluster)):
@@ -185,7 +190,7 @@
 		return node
 
 	error = 'Unable to authenticate to the ricci agent on \"' + host + '\"'
-	return { 'host': host, 'ricci_host': systemName, 'prev_auth': False , 'cur_auth': False, 'errors': error }
+	return { 'host': host, 'ricci_host': systemName, 'prev_auth': False , 'cur_auth': False, 'errors': error, 'os': None }
 
 def validateAddClusterInitial(self, request):
 	errors = list()
@@ -1181,6 +1186,9 @@
 
 # In case we want to give access to non-admin users in the future
 
+def havePermCreateCluster(self):
+	return isAdmin(self)
+
 def havePermAddStorage(self):
 	return isAdmin(self)
 
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/04 16:20:22	1.83
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/06 18:58:51	1.84
@@ -25,7 +25,7 @@
 #then only display chooser if the current user has
 #permissions on at least one. If the user is admin, show ALL clusters
 
-from homebase_adapters import nodeAuth, nodeUnauth, manageCluster, createClusterSystems
+from homebase_adapters import nodeAuth, nodeUnauth, manageCluster, createClusterSystems, havePermCreateCluster
 
 CLUSTER_FOLDER_PATH = '/luci/systems/cluster/'
 
@@ -105,6 +105,9 @@
 	messages = list()
 	requestResults = {}
 
+	if not havePermCreateCluster(self):
+		return (False, {'errors': ['You do not have sufficient rights to create a cluster.']})
+
 	try:
 	 	sessionData = request.SESSION.get('checkRet')
 	except:
@@ -119,8 +122,8 @@
 	except:
 		return (False, { 'errors': ['Unknown number of systems entered'], 'requestResults': requestResults })
 
-	if numStorage < 2:
-		return (False, { 'errors': ['A cluster must contain at least two nodes'], 'requestResults': requestResults })
+	if numStorage < 1:
+		return (False, { 'errors': ['A cluster must contain at least one node'], 'requestResults': requestResults })
 
 	ret = validateClusterNodes(request, sessionData, clusterName, numStorage)
 	errors.extend(ret[0])
@@ -128,22 +131,29 @@
 
 	try:
 		nodeList = cluster_properties['nodeList']
-		if len(nodeList) < 2:
+		if len(nodeList) < 1:
+			raise
+	except:
+		errors.append('A cluster must contain@least one node')
+
+	try:
+		cluster_os = nodeList[0]['os']
+		if not cluster_os:
+			raise
+		if len(filter(lambda x: x != cluster_os, nodeList[1:])) > 0:
 			raise
+	except KeyError, e:
+		errors.append('Unable to identify the operating system running on the first cluster node.')
+		cluster_properties['isComplete'] = False
 	except:
-		errors.append('A cluster must contain at least two nodes')
+		errors.append('Cluster nodes must be running compatible operating systems.')
+		cluster_properties['isComplete'] = False
 
 	if cluster_properties['isComplete'] != True:
 		nodeUnauth(nodeList)
 		return (False, {'errors': errors, 'requestResults':cluster_properties })
 
 	if cluster_properties['isComplete'] == True:
-		from ricci_communicator import RicciCommunicator
-		rc = RicciCommunicator(nodeList[0]['ricci_host'])
-		os_str = resolveOSType(rc.os())
-		if os_str == None:
-			os_str = "rhel5"  #Backup plan in case all is almost lost...
-
 		batchNode = createClusterBatch(os_str, clusterName, clusterName, map(lambda x: x['ricci_host'], nodeList), True, False, False)
 		if not batchNode:
 			nodeUnauth(nodeList)
@@ -298,23 +308,23 @@
 		else:
 			mcast_val = 0
 	except KeyError, e:
-		return (False, {'errors': 'An invalid multicast selection was made.'})
+		return (False, {'errors': ['An invalid multicast selection was made.']})
 
 	if not mcast_val:
-		return (True, {'messages': 'Changes accepted. - FILL ME IN'})
+		return (True, {'messages': ['Changes accepted. - FILL ME IN']})
 
 	try:
 		addr_str = form['mcast_addr'].strip()
 		socket.inet_pton(socket.AF_INET, addr_str)
 	except KeyError, e:
-		return (False, {'errors': 'No multicast address was given'})
+		return (False, {'errors': ['No multicast address was given']})
 	except socket.error, e:
 		try:
 			socket.inet_pton(socket.AF_INET6, addr_str)
 		except socket.error, e6:
-			return (False, {'errors': 'An invalid multicast address was given: ' + e})
+			return (False, {'errors': ['An invalid multicast address was given: ' + e]})
 
-	return (True, {'messages': 'Changes accepted. - FILL ME IN'})
+	return (True, {'messages': ['Changes accepted. - FILL ME IN']})
 
 def validateQDiskConfig(self, form):
 	errors = list()
@@ -328,10 +338,10 @@
 		else:
 			qdisk_val = 0
 	except KeyError, e:
-		return (False, {'errors': 'An invalid quorum partition selection was made.'})
+		return (False, {'errors': ['An invalid quorum partition selection was made.']})
 
 	if not qdisk_val:
-		return (True, {'messages': 'Changes accepted. - FILL ME IN'})
+		return (True, {'messages': ['Changes accepted. - FILL ME IN']})
 
 	try:
 		interval = int(form['interval'])
@@ -436,7 +446,7 @@
 
 	if len(errors) > 0:
 		return (False, {'errors': errors })
-	return (True, {'messages': 'Changes accepted. - FILL ME IN'})
+	return (True, {'messages': ['Changes accepted. - FILL ME IN']})
 
 def validateGeneralConfig(self, form):
 	errors = list()
@@ -460,7 +470,7 @@
 	if len(errors) > 0:
 		return (False, {'errors': errors})
 
-	return (True, {'messages': 'Changes accepted. - FILL ME IN'})
+	return (True, {'messages': ['Changes accepted. - FILL ME IN']})
 
 def validateFenceConfig(self, form):
 	errors = list()
@@ -486,7 +496,7 @@
 	if len(errors) > 0:
 		return (False, {'errors': errors })
 
-	return (True, {'messages': 'Changes accepted. - FILL ME IN'})
+	return (True, {'messages': ['Changes accepted. - FILL ME IN']})
 
 configFormValidators = {
 	'general': validateGeneralConfig,
@@ -500,11 +510,11 @@
 	messages = list()
 
 	if not 'form' in request:
-		return (False, {'errors': 'No form was submitted.' })
+		return (False, {'errors': ['No form was submitted.']})
 	if not 'configtype' in request.form:
-		return (False, {'errors': 'No configuration type was submitted.' })
+		return (False, {'errors': ['No configuration type was submitted.']})
 	if not request.form['configtype'] in configFormValidators:
-		return (False, {'errors': 'An invalid configuration type was submitted.' })
+		return (False, {'errors': ['An invalid configuration type was submitted.']})
 
 	val = configFormValidators[request.form['configtype']]
 	ret = val(self, request.form)
@@ -588,15 +598,17 @@
   else:
     cldata['currentItem'] = False
 
-  cladd = {}
-  cladd['Title'] = "Create a New Cluster"
-  cladd['cfg_type'] = "clusteradd"
-  cladd['absolute_url'] = url + "?pagetype=" + CLUSTER_ADD
-  cladd['Description'] = "Create a Cluster"
-  if pagetype == CLUSTER_ADD:
-    cladd['currentItem'] = True
-  else:
-    cladd['currentItem'] = False
+
+  if havePermCreateCluster(self):
+    cladd = {}
+    cladd['Title'] = "Create a New Cluster"
+    cladd['cfg_type'] = "clusteradd"
+    cladd['absolute_url'] = url + "?pagetype=" + CLUSTER_ADD
+    cladd['Description'] = "Create a Cluster"
+    if pagetype == CLUSTER_ADD:
+      cladd['currentItem'] = True
+    else:
+      cladd['currentItem'] = False
 
   clcfg = {}
   clcfg['Title'] = "Configure"
@@ -2692,21 +2704,21 @@
 
 def addResource(self, request, ragent):
 	if not request.form:
-		return (False, {'errors': 'No form was submitted.'})
+		return (False, {'errors': ['No form was submitted.']})
 
 	try:
 		type = request.form['type'].strip()
 		if not type or not type in resourceAddHandler:
 			raise
 	except:
-		return (False, {'errors': 'Form type is missing.'})
+		return (False, {'errors': ['Form type is missing.']})
 
 	try:
 		resname = request.form['resourceName']
 	except KeyError, e:
 		# For IP, the IP address itself is the name.
 		if request.form['type'] != 'ip':
-			return (False, {'errors': 'No resource name was given.'})
+			return (False, {'errors': ['No resource name was given.']})
 
 	res = resourceAddHandler[type](request)
 	modelb = request.SESSION.get('model')



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-10-04 13:25 jparsons
  0 siblings, 0 replies; 27+ messages in thread
From: jparsons @ 2006-10-04 13:25 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	jparsons at sourceware.org	2006-10-04 13:25:48

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	minor relabelling

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.21&r2=1.22

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/09/25 22:59:15	1.21
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/10/04 13:25:48	1.22
@@ -656,9 +656,9 @@
 			raise
 		if havePermAddCluster(self):
 			addCluster = {}
-			addCluster['Title'] = 'Add a Cluster'
+			addCluster['Title'] = 'Add an Existing Cluster'
 			addCluster['absolute_url'] = url + '?pagetype=' + HOMEBASE_ADD_CLUSTER_INITIAL
-			addCluster['Description'] = 'Add a cluster to the Luci cluster management interface.'
+			addCluster['Description'] = 'Add an existing cluster to the Luci cluster management interface.'
 			if pagetype == HOMEBASE_ADD_CLUSTER_INITIAL:
 				addCluster['currentItem'] = True
 				ret['curIndex'] = index



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-08-01 16:27 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-08-01 16:27 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-08-01 16:27:55

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	ui and wording tweaks

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.19&r2=1.20

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/07/27 13:37:01	1.19
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/08/01 16:27:53	1.20
@@ -630,38 +630,6 @@
 
 	pagetype = str(pagetype)
 
-	try:
-		if havePermAddUser(self):
-			addUser = {}
-			addUser['Title'] = 'Add a User'
-			addUser['absolute_url'] = url + '?pagetype=' + HOMEBASE_ADD_USER
-			addUser['Description'] = 'Add a User'
-			if pagetype == HOMEBASE_ADD_USER:
-				addUser['currentItem'] = True
-				ret['curIndex'] = index
-				cur = addUser
-			else:
-				addUser['currentItem'] = False
-			index += 1
-			temp.append(addUser)
-	except: pass
-
-	try:
-		if (self.portal_membership.listMembers() and havePermDelUser(self)):
-			delUser = {}
-			delUser['Title'] = 'Delete a User'
-			delUser['absolute_url'] = url + '?pagetype=' + HOMEBASE_DEL_USER
-			delUser['Description'] = 'Delete a User'
-			if pagetype == HOMEBASE_DEL_USER:
-				delUser['currentItem'] = True
-				ret['curIndex'] = index
-				cur = delUser
-			else:
-				delUser['currentItem'] = False
-			index += 1
-			temp.append(delUser)
-	except: pass
-
 #
 # The Add System page
 #
@@ -671,7 +639,7 @@
 			addSystem = {}
 			addSystem['Title'] = 'Add a System'
 			addSystem['absolute_url'] = url + '?pagetype=' + HOMEBASE_ADD_SYSTEM
-			addSystem['Description'] = 'Add a System'
+			addSystem['Description'] = 'Add a system to the Luci storage management interface.'
 			if pagetype == HOMEBASE_ADD_SYSTEM:
 				cur = addSystem
 				addSystem['currentItem'] = True
@@ -688,9 +656,9 @@
 			raise
 		if havePermAddCluster(self):
 			addCluster = {}
-			addCluster['Title'] = 'Manage a Cluster'
+			addCluster['Title'] = 'Add a Cluster'
 			addCluster['absolute_url'] = url + '?pagetype=' + HOMEBASE_ADD_CLUSTER_INITIAL
-			addCluster['Description'] = 'Manage a Cluster'
+			addCluster['Description'] = 'Add a cluster to the Luci cluster management interface.'
 			if pagetype == HOMEBASE_ADD_CLUSTER_INITIAL:
 				addCluster['currentItem'] = True
 				ret['curIndex'] = index
@@ -707,9 +675,9 @@
 			raise
 		if havePermAddCluster(self):
 			addCluster = {}
-			addCluster['Title'] = 'Manage a Cluster'
+			addCluster['Title'] = 'Add a Cluster'
 			addCluster['absolute_url'] = url + '?pagetype=' + HOMEBASE_ADD_CLUSTER
-			addCluster['Description'] = 'Manage a Cluster'
+			addCluster['Description'] = 'Add a cluster to the Luci cluster management interface.'
 			if pagetype == HOMEBASE_ADD_CLUSTER:
 				addCluster['currentItem'] = True
 				ret['curIndex'] = index
@@ -727,9 +695,9 @@
 	try:
 		if (havePermRemStorage(self) and havePermRemCluster(self) and (getStorage(self) or getClusters(self))):
 			remSystem = {}
-			remSystem['Title'] = 'Remove a Managed System'
+			remSystem['Title'] = 'Manage Systems'
 			remSystem['absolute_url'] = url + '?pagetype=' + HOMEBASE_DEL_SYSTEM
-			remSystem['Description'] = 'Remove a Managed System'
+			remSystem['Description'] = 'Update or remove storage systems and clusters.'
 			if pagetype == HOMEBASE_DEL_SYSTEM:
 				remSystem['currentItem'] = True
 				ret['curIndex'] = index
@@ -741,6 +709,46 @@
 	except: pass
 
 #
+# Add a Luci user.
+#
+
+	try:
+		if havePermAddUser(self):
+			addUser = {}
+			addUser['Title'] = 'Add a User'
+			addUser['absolute_url'] = url + '?pagetype=' + HOMEBASE_ADD_USER
+			addUser['Description'] = 'Add a user to the Luci interface.'
+			if pagetype == HOMEBASE_ADD_USER:
+				addUser['currentItem'] = True
+				ret['curIndex'] = index
+				cur = addUser
+			else:
+				addUser['currentItem'] = False
+			index += 1
+			temp.append(addUser)
+	except: pass
+
+#
+# Delete a Luci user
+#
+
+	try:
+		if (self.portal_membership.listMembers() and havePermDelUser(self)):
+			delUser = {}
+			delUser['Title'] = 'Delete a User'
+			delUser['absolute_url'] = url + '?pagetype=' + HOMEBASE_DEL_USER
+			delUser['Description'] = 'Delete a Luci user.'
+			if pagetype == HOMEBASE_DEL_USER:
+				delUser['currentItem'] = True
+				ret['curIndex'] = index
+				cur = delUser
+			else:
+				delUser['currentItem'] = False
+			index += 1
+			temp.append(delUser)
+	except: pass
+
+#
 # The User Permissions Page
 #
 	try:
@@ -748,7 +756,7 @@
 			userPerm = {}
 			userPerm['Title'] = 'User Permissions'
 			userPerm['absolute_url'] = url + '?pagetype=' + HOMEBASE_PERMS
-			userPerm['Description'] = 'Set permissions for users'
+			userPerm['Description'] = 'Set permissions for Luci users.'
 			if pagetype == HOMEBASE_PERMS:
 				userPerm['currentItem'] = True
 				ret['curIndex'] = index



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-07-27 13:37 jparsons
  0 siblings, 0 replies; 27+ messages in thread
From: jparsons @ 2006-07-27 13:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	jparsons at sourceware.org	2006-07-27 13:37:01

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	Changed title for remove storage system to remove a system

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.18&r2=1.19

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/07/26 19:50:40	1.18
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/07/27 13:37:01	1.19
@@ -727,9 +727,9 @@
 	try:
 		if (havePermRemStorage(self) and havePermRemCluster(self) and (getStorage(self) or getClusters(self))):
 			remSystem = {}
-			remSystem['Title'] = 'Remove a Storage System'
+			remSystem['Title'] = 'Remove a Managed System'
 			remSystem['absolute_url'] = url + '?pagetype=' + HOMEBASE_DEL_SYSTEM
-			remSystem['Description'] = 'Remove a Storage System'
+			remSystem['Description'] = 'Remove a Managed System'
 			if pagetype == HOMEBASE_DEL_SYSTEM:
 				remSystem['currentItem'] = True
 				ret['curIndex'] = index



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-07-26 19:50 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-07-26 19:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-07-26 19:50:41

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	fix for permissions bug

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.17&r2=1.18

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/07/25 17:45:51	1.17
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/07/26 19:50:40	1.18
@@ -628,6 +628,8 @@
 	index = 0
 	cur = None
 
+	pagetype = str(pagetype)
+
 	try:
 		if havePermAddUser(self):
 			addUser = {}



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-07-25 17:45 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-07-25 17:45 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-07-25 17:45:51

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	refactored delete cluster / system page

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.16&r2=1.17

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/07/19 22:28:17	1.16
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/07/25 17:45:51	1.17
@@ -410,10 +410,7 @@
 			break
 
 		if len(sysData) == 2 and sysData[0] != '' and sysData[1] != '':
-			try:
-				csResult = createSystem(self, sysData[0], sysData[1])
-			except:
-				pass
+			csResult = createSystem(self, sysData[0], sysData[1])
 
 			if csResult:
 				errors.append(csResult)
@@ -862,9 +859,12 @@
 	except:
 		return 'Unable to authenticate to the ricci agent on \"' + host + '\"'
 
-#	rhost = rc.system_name()
-#	if rhost and rhost != host:
-#		host = rhost
+	if i != True:
+		return 'Authentication for storage system \"' + host + '\" failed'
+
+	rhost = rc.system_name()
+	if rhost and rhost != host and rhost[:9] != 'localhost' and rhost[:5] != '127.0':
+		host = str(rhost)
 
 	try:
 		exists = self.restrictedTraverse(PLONE_ROOT +'/systems/storage/' + host)
@@ -872,9 +872,6 @@
 	except:
 		pass
 
-	if i != True:
-		return 'Authentication for storage system \"' + host + '\" failed'
-
 	try:
 		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
 	except:
@@ -891,6 +888,7 @@
 		newSystem.manage_role('View', ['Access contents information','View'])
 	except:
 		return 'Unable to set permissions on new system \"' + host + '\"'
+	return None
 
 def abortManageCluster(self):
 	try:
@@ -1169,10 +1167,6 @@
 
 	for i in clusters:
 		cSystems = map(zeroindex, getClusterSystems(self, i[0]))
-		for c in cSystems:
-			try:
-				del storageList[storageList.index(c)]
-			except ValueError: pass
 		ret[0][i[0]] = cSystems
 
 	if storageList:



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-07-18 19:26 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-07-18 19:26 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-07-18 19:26:04

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	pull in clusters using cluster.conf from a cluster node

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.12&r2=1.13

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/07/05 20:13:03	1.12
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/07/18 19:26:03	1.13
@@ -16,6 +16,7 @@
 HOMEBASE_DEL_USER="4"
 HOMEBASE_DEL_SYSTEM="5"
 HOMEBASE_ADD_CLUSTER="6"
+HOMEBASE_ADD_CLUSTER_INITIAL="7"
 
 PLONE_ROOT='luci'
 
@@ -37,9 +38,6 @@
 	errors = list()
 	messages = list()
 
-	sys.stdout = sys.stderr
-	print request.form
-
 	if '__SYSTEM' in request.form:
 		sysNames = request.form['__SYSTEM']
 		for i in sysNames:
@@ -136,50 +134,258 @@
 	messages.append('Added new user \"' + user + '\" successfully')
 	return (True, {'messages': messages, 'params': { 'user': user }})
 
+def nodeUnauth(nodeList):
+	for i in nodeList:
+		try:
+			if i['prev_auth'] == True:
+				host = i['host']
+				rc = RicciCommunicator(host)
+				rc.unauth()
+		except:
+			pass
+
+def nodeAuth(cluster, host, passwd):
+	systemName = host
+
+	try:
+		rc = RicciCommunicator(host)
+		if not rc:
+			raise
+		systemName = rc.system_name()
+	except:
+		error = 'Unable to establish a connection to the ricci agent on \"' + host + '\"'
+		return { 'host': host, 'ricci_host': systemName, 'errors': error, 'cur_auth': False }
+
+
+	if rc.authed():
+		prevAuth = True
+	else:
+		prevAuth = False
+		if not passwd:
+			return { 'host': host, 'ricci_host': systemName, 'prev_auth': False, 'cur_auth': False }
+		else:
+			try:
+				rc.auth(passwd)
+			except: pass
+
+	if rc.authed():
+		systemName = rc.system_name()
+		if systemName[:9] == 'localhost' or systemName[:5] == '127.0':
+			systemName = host
+		node = { 'host': host, 'ricci_host': systemName, 'prev_auth': prevAuth, 'cur_auth': True }
+		cluster_info = rc.cluster_info()
+		if not cluster_info or cluster_info[0] != cluster:
+			node['errors'] = 'Node ' + host + ' is reporting it is not a member of cluster \"' + cluster + '\"'
+		return node
+
+	error = 'Unable to authenticate to the ricci agent on \"' + host + '\"'
+	return { 'host': host, 'ricci_host': systemName, 'prev_auth': False , 'cur_auth': False, 'errors': error }
+
+def validateAddClusterInitial(self, request):
+	errors = list()
+	newNodeList = list()
+	nodeHash = {}
+	rnodeHash = {}
+
+	try:
+		sysData = request.form['__SYSTEM0']
+		if not sysData or len(sysData) < 2:
+			raise
+	except:
+		return (False, { 'errors': [ 'At least one system and its root password must be given' ] })
+
+	try:
+		rc = RicciCommunicator(sysData[0])
+	except:
+		return (False, { 'errors': [ 'Unable to establish a connection to the Ricci agent on \"' + sysData[0] + '\"' ] })
+
+	prevAuth = 0
+	if not rc.authed():
+		try:
+			rc.auth(sysData[1])
+		except: pass
+		if not rc.authed():
+			return (False, { 'errors': [ 'Unable to authenticate to the Ricci agent on \"' + sysData[0] + '\"' ] })
+	else:
+		prevAuth = 1
+
+	try:
+		cluster_info = rc.cluster_info()
+	except:
+		cluster_info = None
+
+	if not cluster_info or not cluster_info[0]:
+		if not prevAuth:
+			rc.unauth()
+		if not cluster_info:
+			errmsg = 'An error occurred while attempting to retrieve the cluster.conf file for \"' + sysData[0] + '\"'
+		else:
+			errmsg = '\"' + sysData[0] + '\" is not a member of a cluster'
+		return (False, { 'errors': [ errmsg ] })
+
+	clusterName = cluster_info[0]
+	cluConf = getClusterConf(rc)
+	if cluConf:
+		nodeList = getClusterConfNodes(cluConf)
+
+	if not cluConf or not nodeList or len(nodeList) < 2:
+		if not prevAuth:
+			rc.unauth()
+		return (False, { 'errors': [ 'Error retrieving member nodes for cluster \"' + clusterName + '\"' ] })
+
+	systemName = rc.system_name()
+	if systemName[:9] == 'localhost':
+		systemName = sysData[0]
+
+	node = { 'host': sysData[0], 'ricci_host': systemName, 'prev_auth': prevAuth, 'cur_auth': rc.authed() }
+	nodeHash[sysData[0]] = node
+	rnodeHash[systemName] = node
+	newNodeList.append(node)
+
+	if 'allSameCheckBox' in request.form:
+		passwd = sysData[1]
+	else:
+		passwd = None
+		
+	for i in nodeList:
+		node = nodeAuth(clusterName, i, passwd)
+		if node['host'] in nodeHash or node['ricci_host'] in rnodeHash:
+			continue
+		nodeHash[node['host']] = node
+		if 'ricci_host' in node:
+			rnodeHash[node['ricci_host']] = node
+
+		if 'errors' in node:
+			errors.append(node['errors'])
+			node['errors'] = True
+		newNodeList.append(node)
+
+	sfn = lambda x, y: \
+		x['cur_auth'] - y['cur_auth'] or (('errors' in y) - ('errors' in x)) 
+	newNodeList.sort(sfn)
+
+	dfn = lambda x: not 'cur_auth' in x or x['cur_auth'] != True
+
+	cluster_properties = {
+		'clusterName': clusterName,
+		'nodeList': newNodeList,
+		'nodeHash': nodeHash,
+		'rnodeHash': rnodeHash,
+		'isComplete': len(filter(dfn, newNodeList)) == 0
+	}
+
+	if len(errors) < 1:
+		cluster_properties['redirect'] = HOMEBASE_ADD_CLUSTER
+
+	return (len(errors) < 1,
+		{'errors': errors, 'requestResults': cluster_properties })
+
 def validateAddCluster(self, request):
 	errors = list()
 	messages = list()
+	requestResults = None
+	nodeList = None
 
-	if not 'clusterName' in request.form:
-		return (False, ['No cluster name given'])
-
-	# This should never fail
 	try:
-		numStorage = request.form['numStorage']
+		sessionData = request.SESSION.get('checkRet')
+		requestResults = sessionData['requestResults']
 	except:
-		return (False, {'errors': ['Unknown number of systems entered']})
+		return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName } })
+		
+	if not 'clusterName' in request.form or request.form['clusterName'] == '':
+		return (False, { 'errors': ['No cluster name given'], 'requestResults': requestResults })
 
 	clusterName = request.form['clusterName']
-	if clusterName == '':
-		return (False, ['No cluster name given'])
+	nodeList = requestResults['nodeList']
+	nodeHash = requestResults['nodeHash']
+	rnodeHash = requestResults['rnodeHash']
 
-	cclRet = createCluster(self, clusterName)
-	if cclRet:
-		return (False, {'errors': [cclRet] })
-	else:
-		messages.append('Created cluster \"' + clusterName + '\" successfully')
+	# This should never fail
+	try:
+		numStorage = int(request.form['numStorage'])
+		if numStorage != len(nodeList):
+			raise
+	except:
+		nodeUnauth(nodeList)
+		return (False, {
+				'errors': [ 'Unknown number of nodes entered' ],
+				'requestResults': requestResults })
 
 	i = 0
 	while i < numStorage:
-		try:
-			sysData = request.form['__SYSTEM' + str(i)]
-		except:
-			break
-
-		if len(sysData) == 2 and sysData[0] != '' and sysData[1] != '':
-			csResult = createClusterSystem(self, clusterName, sysData[0], sysData[1])
-			if csResult:
-				errors.append(csResult)
-			else:
-				messages.append('Added storage system \"' + sysData[0] + '\" successfully')
+		sysData = request.form['__SYSTEM' + str(i)]
+		if not sysData:
+			i += 1
+			continue
+
+		oldNode = None
+		node = nodeAuth(clusterName, sysData[0], sysData[1])
+		if node['host'] in nodeHash:
+			oldNode = nodeHash[node['host']]
+		elif 'ricci_host' in node and node['ricci_host'] in rnodeHash:
+			oldNode = rnodeHash[node['ricci_host']]
+		elif not oldNode:
+			for k in nodeHash.keys():
+				if node['host'][:len(k) + 1] == k + '.':
+					oldNode = nodeHash[k]
+		elif not oldNode:
+			for k in rnodeHash.keys():
+				if node['host'][:len(k) + 1] == k + '.':
+					oldNode = rnodeHash[k]
+
+		if not oldNode:
+			nodeUnauth(nodeList)
+			return (False, { 'errors': [ 'A data integrity error has occurred. Please attempt adding the cluster again.' ], 'requestResults': { 'clusterName': clusterName } })
+
+		if oldNode['host'] != node['host']:
+			del nodeHash[oldNode['host']]
+			oldNode['host'] = node['host']
+			nodeHash[node['host']] = oldNode
+
+		if 'ricci_host' in node and (not 'ricci_host' in oldNode or node['ricci_host'] != oldNode['ricci_host']):
+			if oldNode['ricci_host'] in rnodeHash:
+				del rnodeHash[oldNode['ricci_host']]
+				oldNode['ricci_host'] = node['ricci_host']
+				rnodeHashnode[node['ricci_host']] = oldNode
+
+		oldNode['cur_auth'] = node['cur_auth']
+		if 'errors' in node:
+			errors.append(node['errors'])
+			oldNode['errors'] = True
 		i += 1
 
-	if len(errors) > 0:
-		retCode = False
+	dfn = lambda x: not 'cur_auth' in x or x['cur_auth'] != True
+	clusterComplete = len(filter(dfn, nodeList)) == 0
+
+	if clusterComplete:
+		err = manageCluster(self, clusterName, nodeList)
+		if err:
+			errors.append(err)
+		else:
+			messages.append('Cluster \"' + clusterName + '\" has been added to the Luci management interface.') 
 	else:
-		retCode = True
+		sfn = lambda x, y: \
+			x['cur_auth'] - y['cur_auth'] or (('errors' in y) - ('errors' in x)) 
+		nodeList.sort(sfn)
+
+	ret = { 'messages': messages, 'errors': errors }
+
+	if len(errors) > 0 or not clusterComplete:
+		ret['requestResults'] = {
+			'clusterName': clusterName,
+			'nodeList': nodeList,
+			'nodeHash': nodeHash,
+			'rnodeHash': rnodeHash,
+			'isComplete': clusterComplete
+		}
+	else:
+		ret['requestResults'] = {
+			'redirect': HOMEBASE_ADD_CLUSTER_INITIAL,
+			'clusterName': clusterName,
+			'isComplete': True
+		}
 
-	return (retCode, {'messages': messages, 'errors': errors })
+	return (len(errors) < 1, ret)
 
 def validateAddSystem(self, request):
 	errors = list()
@@ -188,7 +394,7 @@
 	try:
 		numStorage = request.form['numStorage']
 	except:
-		return (False, {'errors': ['Unknown number of systems entered']})
+		return (False, { 'errors': ['Unknown number of systems entered'] })
 
 	i = 0
 	while i < numStorage:
@@ -200,22 +406,8 @@
 		if len(sysData) == 2 and sysData[0] != '' and sysData[1] != '':
 			try:
 				csResult = createSystem(self, sysData[0], sysData[1])
-			except InCluster, e:
-				csResult = None
-				host = str(e)
-				rc = RicciCommunicator(e)
-				if not rc.authed():
-					rc.auth(sysData[1])
-				try:
-					cluConf = getClusterConf(rc)
-					if cluConf:
-						nodeList = getClusterConfNodes(cluConf)
-						if NodeList:
-							pass
-							# XXX fix this
-							#print "other nodes in",cluster_info[0],"::",nodeList
-				except:
-					pass
+			except:
+				pass
 
 			if csResult:
 				errors.append(csResult)
@@ -341,7 +533,8 @@
 	validatePerms,
 	validateDelUser,
 	validateDelSystem,
-	validateAddCluster
+	validateAddCluster,
+	validateAddClusterInitial
 ]
 
 def userAuthenticated(self):
@@ -365,6 +558,12 @@
 	return False
 
 def homebaseControlPost(self, request):
+	try:
+		sessionData = request.SESSION.get('checkRet')
+	except:
+		sessionData = None
+
+
 	if 'ACTUAL_URL' in request:
 		url = request['ACTUAL_URL']
 	else:
@@ -373,30 +572,42 @@
 	if 'pagetype' in request.form:
 		pagetype = request.form['pagetype']
 	else:
+		try: request.SESSION.set('checkRet', {})
+		except: pass
 		return homebasePortal(self, request, '.', '0')
 
 	try:
 		validatorFn = formValidators[int(request.form['pagetype']) - 1]
 	except:
+		try: request.SESSION.set('checkRet', {})
+		except: pass
 		return homebasePortal(self, request, '.', '0')
-
 	ret = validatorFn(self, request)
 	params = None
+
 	if 'params' in ret[1]:
 		params = ret[1]['params']
 
+	if 'requestResults' in ret[1]:
+		requestResults = ret[1]['requestResults']
+
+		if 'redirect' in requestResults:
+			pagetype = requestResults['redirect']
+			request['pagetype'] = pagetype
+			request.form['pagetype'] = pagetype
+
 	request.SESSION.set('checkRet', ret[1])
 	return homebasePortal(self, request, url, pagetype, params)
 
 def homebaseControl(self, request):
+	if request.REQUEST_METHOD == 'POST':
+		return homebaseControlPost(self, request)
+
 	try:
 		request.SESSION.set('checkRet', {})
 	except:
 		pass
 
-	if request.REQUEST_METHOD == 'POST':
-		return homebaseControlPost(self, request)
-
 	if 'ACTUAL_URL' in request:
 		url = request['ACTUAL_URL']
 	else:
@@ -467,12 +678,34 @@
 			temp.append(addSystem)
 	except: pass
 
+	# Initial add cluster page
+	try:
+		if pagetype == HOMEBASE_ADD_CLUSTER:
+			raise
+		if havePermAddCluster(self):
+			addCluster = {}
+			addCluster['Title'] = 'Manage a Cluster'
+			addCluster['absolute_url'] = url + '?pagetype=' + HOMEBASE_ADD_CLUSTER_INITIAL
+			addCluster['Description'] = 'Manage a Cluster'
+			if pagetype == HOMEBASE_ADD_CLUSTER_INITIAL:
+				addCluster['currentItem'] = True
+				ret['curIndex'] = index
+				cur = addCluster
+			else:
+				addCluster['currentItem'] = False
+			index += 1
+			temp.append(addCluster)
+	except: pass
+
+	# Add cluster - screen 2
 	try:
+		if pagetype != HOMEBASE_ADD_CLUSTER:
+			raise
 		if havePermAddCluster(self):
 			addCluster = {}
-			addCluster['Title'] = 'Add a Cluster'
+			addCluster['Title'] = 'Manage a Cluster'
 			addCluster['absolute_url'] = url + '?pagetype=' + HOMEBASE_ADD_CLUSTER
-			addCluster['Description'] = 'Add a Cluster'
+			addCluster['Description'] = 'Manage a Cluster'
 			if pagetype == HOMEBASE_ADD_CLUSTER:
 				addCluster['currentItem'] = True
 				ret['curIndex'] = index
@@ -490,9 +723,9 @@
 	try:
 		if (havePermRemStorage(self) and havePermRemCluster(self) and (getStorage(self) or getClusters(self))):
 			remSystem = {}
-			remSystem['Title'] = 'Remove a System'
+			remSystem['Title'] = 'Remove a Storage System'
 			remSystem['absolute_url'] = url + '?pagetype=' + HOMEBASE_DEL_SYSTEM
-			remSystem['Description'] = 'Remove a system'
+			remSystem['Description'] = 'Remove a Storage System'
 			if pagetype == HOMEBASE_DEL_SYSTEM:
 				remSystem['currentItem'] = True
 				ret['curIndex'] = index
@@ -529,9 +762,11 @@
 		cur['base_url'] = cur['absolute_url']
 		for i in params:
 			cur['absolute_url'] += '&' + cgi.escape(i) + '=' + cgi.escape(params[i])
+	elif cur and 'absolute_url' in cur:
+		cur['base_url'] = cur['absolute_url']
 	else:
-		if cur and 'absolute_url' in cur:
-			cur['base_url'] = cur['absolute_url']
+		cur = {}
+		cur['base_url'] = '#'
 
 	ret['children'] = temp
 	return ret
@@ -652,21 +887,20 @@
 	except:
 		return 'Unable to set permissions on new system \"' + host + '\"'
 
-#	cluster_info = rc.cluster_info()
-#	if cluster_info[0] != '':
-#		raise InCluster, host
-
+def manageCluster(self, clusterName, nodeList):
+	clusterName = str(clusterName)
 
-def createCluster(self, clusterName):
 	try:
 		clusters = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/')
 	except:
+		nodeUnauth(nodeList)
 		return 'Unable to create cluster \"' + clusterName + '\"'
 
 	try:
 		newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
 		if newCluster:
-			return 'Cluster \"' + clusterName + '\" is already managed by Luci'
+			nodeUnauth(nodeList)
+			return 'A cluster named \"' + clusterName + '\" is already managed by Luci'
 	except:
 		pass
 
@@ -674,89 +908,55 @@
 		clusters.manage_addFolder(clusterName, '__luci__:cluster')
 		newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
 	except:
+		nodeUnauth(nodeList)
 		return 'Unable to create cluster \"' + clusterName + '\"'
 
 	try:
 		newCluster.manage_acquiredPermissions([])
 		newCluster.manage_role('View', ['Access Contents Information','View'])
 	except:
-		return 'Unable to set permissions on new cluster \"' + clusterName + '\"'
-
-def createClusterSystem(self, cluster, host, passwd):
-	try:
-		rc = RicciCommunicator(host)
-	except:
-		return 'Unable to establish connection to the ricci agent on \"' + host + '\"'
-
-	try:
-		if not rc.authed():
-			rc.auth(passwd)
-	except:
-		return 'Unable to communicate with the ricci agent on \"' + host + '\" for authentication'
-
-	try:
-		i = rc.authed()
-	except:
-		return 'Unable to authenticate to the ricci agent on \"' + host + '\"'
-
-	if i != True:
-		return 'Authentication for host \"' + host + '\" failed'
-
-#	rhost = rc.system_name()
-#	if rhost and rhost != host:
-#		host = rhost
-
-	cluster_info = rc.cluster_info()
-	if len(cluster_info) > 0 and cluster_info[0] != '' and cluster_info[0] != cluster:
-		return 'The host \"' + host + '\" is already a member of the cluster \"' + cluster_info[0] + '\"'
-
-	try:
-		exists = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster + '/' + host)
-		if exists:
-			return None
-	except:
-		pass
-
-	try:
-		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster)
-	except:
-		return 'Unable to create storage system \"' + host + '\" for cluster \"' + cluster + '\": Cannot find cluster'
-
-	try:
-		ssystem.manage_addFolder(host, '__luci__:csystem:' + cluster)
-		newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster + '/' + host)
-	except:
-		return 'Unable to create storage system \"' + host + '\" for cluster \"' + cluster + '\"'
+		nodeUnauth(nodeList)
+		try: clusters.manage_delObjects([clusterName])
+		except: pass
+		return 'Unable to set permissions on new cluster \"' + clusterName + '\"-- Cluster creation failed'
 
 	try:
 		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
 	except:
-		return 'Unable to create storage system \"' + host + '\"'
+		ssystem = None
 
-	try:
-		newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host)
-		# It's already there.
-		return None
-	except:
-		pass
+	for i in nodeList:
+		if 'ricci_host' in i:
+			host = str(i['ricci_host'])
+		else:
+			host = str(i['host'])
 
-	try:
-		ssystem.manage_addFolder(host, '__luci__:system')
-	except:
-		pass
+		try:
+			newCluster.manage_addFolder(host, '__luci__:csystem:' + clusterName)
+			newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName + '/' + host)
+			if not newSystem:
+				raise 'not there'
+			newSystem.manage_acquiredPermissions([])
+			newSystem.manage_role('View', [ 'Access contents information' , 'View' ])
+		except Exception, e:
+			nodeUnauth(nodeList)
+			try: clusters.manage_delObjects([clusterName])
+			except: pass
+			return 'Unable to create cluster node \"' + host + '\" for cluster \"' + clusterName + '\" -- Cluster creation failed."'
 
-	try:
-		newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host)
-		if not newSystem:
-			raise
-	except:
-		return 'Unable to create storage system \"' + host + '\"'
+		if ssystem:
+			try:
+				# It's already there, as a storage system, no problem.
+				exists = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host)
+				continue
+			except: pass
 
-	try:
-		newSystem.manage_acquiredPermissions([])
-		newSystem.manage_role('View', ['Access contents information','View'])
-	except:
-		return 'Unable to set permissions on new storage system \"' + host + '\"'
+			try:
+				ssystem.manage_addFolder(host, '__luci__:system')
+				newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host)
+				newSystem.manage_acquiredPermissions([])
+				newSystem.manage_role('View', [ 'Access contents information' , 'View' ])
+			except: pass
 
 def delSystem(self, systemName):
 	try:
@@ -798,6 +998,10 @@
 	except:
 		return 'Unable to find cluster \"' + clusterName + '\"'
 
+	err = delClusterSystems(self, clusterName)
+	if err:
+		return err
+
 	try:
 		clusters.manage_delObjects([clusterName])
 	except:
@@ -805,6 +1009,14 @@
 
 def delClusterSystem(self, clusterName, systemName):
 	cluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
+	try:
+		if not self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + systemName):
+			raise
+	except:
+		try:
+			rc = RicciCommunicator(systemName)
+			rc.unauth()
+		except: pass
 	cluster.manage_delObjects([systemName])
 
 def delClusterSystems(self, clusterName):
@@ -817,7 +1029,6 @@
 	errors = ''
 	for i in csystems:
 		try:
-			delSystem(i)
 			cluster.manage_delObjects([i])
 			delClusterSystem(i)
 		except:
@@ -895,7 +1106,15 @@
 	module.appendChild(request)
 	batch.appendChild(module)
 
-	ret = rc.process_batch(batch)
+	# temporary workaround for ricci bug
+	system_info = rc.system_name()
+	rc = RicciCommunicator(system_info)
+	# end workaround
+
+	try:
+		ret = rc.process_batch(batch)
+	except Exception, e:
+		return str(e)
 
 	if not ret:
 		return None



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-06-27 20:53 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-06-27 20:53 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-06-27 20:53:13

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	fix indentation error..

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.8&r2=1.9

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/27 20:47:34	1.8
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/27 20:53:12	1.9
@@ -776,10 +776,10 @@
 		except:
 			return 'Unable to delete cluster storage system \"' + systemName + '\"'
 
-		try:
-			ssystem.manage_delObjects([systemName])
-		except:
-			return 'Unable to delete storage system \"' + systemName + '\"'
+	try:
+		ssystem.manage_delObjects([systemName])
+	except:
+		return 'Unable to delete storage system \"' + systemName + '\"'
 
 def delCluster(self, clusterName):
 	try:



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-06-27 20:47 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-06-27 20:47 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-06-27 20:47:35

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	fix adding hosts in clusters, use user-supplied hostname instead of the one ricci returns

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.7&r2=1.8

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/27 17:49:17	1.7
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/27 20:47:34	1.8
@@ -611,9 +611,9 @@
 	except:
 		return 'Unable to authenticate to the ricci agent on \"' + host + '\"'
 
-	rhost = rc.system_name()
-	if rhost and rhost != host:
-		host = rhost
+#	rhost = rc.system_name()
+#	if rhost and rhost != host:
+#		host = rhost
 
 	try:
 		exists = self.restrictedTraverse(PLONE_ROOT +'/systems/storage/' + host)
@@ -641,9 +641,9 @@
 	except:
 		return 'Unable to set permissions on new system \"' + host + '\"'
 
-	cluster_info = rc.cluster_info()
-	if cluster_info[0] != '':
-		raise InCluster, host
+#	cluster_info = rc.cluster_info()
+#	if cluster_info[0] != '':
+#		raise InCluster, host
 
 
 def createCluster(self, clusterName):
@@ -691,9 +691,9 @@
 	if i != True:
 		return 'Authentication for host \"' + host + '\" failed'
 
-	rhost = rc.system_name()
-	if rhost and rhost != host:
-		host = rhost
+#	rhost = rc.system_name()
+#	if rhost and rhost != host:
+#		host = rhost
 
 	cluster_info = rc.cluster_info()
 	if len(cluster_info) > 0 and cluster_info[0] != '' and  cluster_info[0] != cluster:



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-06-27 17:49 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-06-27 17:49 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-06-27 17:49:18

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	add missing except block

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.6&r2=1.7

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/26 20:10:15	1.6
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/27 17:49:17	1.7
@@ -656,6 +656,8 @@
 		newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
 		if newCluster:
 			return 'Cluster \"' + clusterName + '\" is already managed by Luci'
+	except:
+		pass
 
 	try:
 		clusters.manage_addFolder(clusterName, '__luci__:cluster')



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-06-26 20:10 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-06-26 20:10 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-06-26 20:10:15

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.5&r2=1.6

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/22 03:58:41	1.5
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/26 20:10:15	1.6
@@ -18,6 +18,9 @@
 
 PLONE_ROOT='luci'
 
+class InCluster(Exception):
+	pass
+
 from ricci_communicator import CERTS_DIR_PATH
 def siteIsSetup(self):
 	try:
@@ -122,7 +125,7 @@
 		return (False, {'errors': ['The passwords do not match']})
 
 	try:
-		self.portal_registration.addMember(user, passwd, properties={ 'username': user, 'password': passwd, 'confirm': passwd, 'roles': ['Member'], 'domains':[], 'email': user + '@example.com'})
+		self.portal_registration.addMember(user, passwd, properties = { 'username': user, 'password': passwd, 'confirm': passwd, 'roles': ['Member'], 'domains':[], 'email': user + '@example.com' })
 	except:
 		return (False, {'errors': [ 'Unable to add new user \"' + user + '\"' ] })
 
@@ -163,11 +166,7 @@
 			break
 
 		if len(sysData) == 2 and sysData[0] != '' and sysData[1] != '':
-			try:
-				csResult = createClusterSystem(self, clusterName, sysData[0], sysData[1])
-			except string, e:
-				dialog_str = 'The system \"' + sysData[0] + '\" is a member of the cluster \"' + e + '\"\nDo you want to manage the whole cluster?'
-				return (True, {'dialog': dialog_str })
+			csResult = createClusterSystem(self, clusterName, sysData[0], sysData[1])
 			if csResult:
 				errors.append(csResult)
 			else:
@@ -198,7 +197,25 @@
 			break
 
 		if len(sysData) == 2 and sysData[0] != '' and sysData[1] != '':
-			csResult = createSystem(self, sysData[0], sysData[1])
+			try:
+				csResult = createSystem(self, sysData[0], sysData[1])
+			except InCluster, e:
+				csResult = None
+				host = str(e)
+				rc = RicciCommunicator(e)
+				if not rc.authed():
+					rc.auth(sysData[1])
+				try:
+					cluConf = getClusterConf(rc)
+					if cluConf:
+						nodeList = getClusterConfNodes(cluConf)
+						if NodeList:
+							pass
+							# XXX fix this
+							#print "other nodes in",cluster_info[0],"::",nodeList
+				except:
+					pass
+
 			if csResult:
 				errors.append(csResult)
 			else:
@@ -584,7 +601,8 @@
 		return 'Unable to establish a connection to the ricci agent on \"' + host + '\"'
 
 	try:
-		rc.auth(passwd)
+		if not rc.authed():
+			rc.auth(passwd)
 	except:
 		return 'Unable to communicate with the ricci agent on \"' + host + '\" for authentication'
 
@@ -593,6 +611,16 @@
 	except:
 		return 'Unable to authenticate to the ricci agent on \"' + host + '\"'
 
+	rhost = rc.system_name()
+	if rhost and rhost != host:
+		host = rhost
+
+	try:
+		exists = self.restrictedTraverse(PLONE_ROOT +'/systems/storage/' + host)
+		return 'Storage system \"' +  host + '\" is already managed.'
+	except:
+		pass
+
 	if i != True:
 		return 'Authentication for storage system \"' + host + '\" failed'
 
@@ -613,15 +641,10 @@
 	except:
 		return 'Unable to set permissions on new system \"' + host + '\"'
 
-#	sys.stdout = sys.stderr
-#	cluster_info = rc.cluster_info()
-#	if cluster_info[0] != '':
-#		cluConf = getClusterConf(rc)
-#		if cluConf:
-#			print cluConf.toxml()
-#			nodeList = getClusterConfNodes(cluConf)
-#			sys.stdout = sys.stderr
-#			print "other nodes in",cluster_info[0],"::",nodeList
+	cluster_info = rc.cluster_info()
+	if cluster_info[0] != '':
+		raise InCluster, host
+
 
 def createCluster(self, clusterName):
 	try:
@@ -630,6 +653,11 @@
 		return 'Unable to create cluster \"' + clusterName + '\"'
 
 	try:
+		newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
+		if newCluster:
+			return 'Cluster \"' + clusterName + '\" is already managed by Luci'
+
+	try:
 		clusters.manage_addFolder(clusterName, '__luci__:cluster')
 		newCluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
 	except:
@@ -648,7 +676,8 @@
 		return 'Unable to establish connection to the ricci agent on \"' + host + '\"'
 
 	try:
-		rc.auth(passwd)
+		if not rc.authed():
+			rc.auth(passwd)
 	except:
 		return 'Unable to communicate with the ricci agent on \"' + host + '\" for authentication'
 
@@ -660,6 +689,10 @@
 	if i != True:
 		return 'Authentication for host \"' + host + '\" failed'
 
+	rhost = rc.system_name()
+	if rhost and rhost != host:
+		host = rhost
+
 	cluster_info = rc.cluster_info()
 	if len(cluster_info) > 0 and cluster_info[0] != '' and  cluster_info[0] != cluster:
 		return 'The host \"' + host + '\" is already a member of the cluster \"' + cluster_info[0] + '\"'
@@ -688,6 +721,13 @@
 		return 'Unable to create storage system \"' + host + '\"'
 
 	try:
+		newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host)
+		# It's already there.
+		return None
+	except:
+		pass
+
+	try:
 		ssystem.manage_addFolder(host, '__luci__:system')
 	except:
 		pass



^ permalink raw reply	[flat|nested] 27+ messages in thread
* [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt ...
@ 2006-06-22  3:58 rmccabe
  0 siblings, 0 replies; 27+ messages in thread
From: rmccabe @ 2006-06-22  3:58 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-06-22 03:58:41

Modified files:
	luci/site/luci/Extensions: homebase_adapters.py 

Log message:
	

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.4&r2=1.5

--- conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/08 19:56:35	1.4
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2006/06/22 03:58:41	1.5
@@ -4,9 +4,7 @@
 import os
 from AccessControl import getSecurityManager
 from ZPublisher import HTTPRequest
-import xml
 import xml.dom
-from xml.dom import minidom
 
 from ricci_defines import *
 from ricci_communicator import RicciCommunicator
@@ -35,6 +33,9 @@
 	errors = list()
 	messages = list()
 
+	sys.stdout = sys.stderr
+	print request.form
+
 	if '__SYSTEM' in request.form:
 		sysNames = request.form['__SYSTEM']
 		for i in sysNames:
@@ -110,6 +111,10 @@
 		return (False, {'errors': ['You didn\'t confirm the password'] })
 
 	user = request.form['newUserName']
+
+	if self.portal_membership.getMemberById(user):
+		return (False, {'errors': ['The user \"' + user + '\" already exists']})
+
 	passwd = request.form['newPassword']
 	pwconfirm = request.form['newPasswordConfirm']
 
@@ -136,7 +141,7 @@
 
 	# This should never fail
 	try:
-		numSystems = request.form['numSystems']
+		numStorage = request.form['numStorage']
 	except:
 		return (False, {'errors': ['Unknown number of systems entered']})
 
@@ -146,19 +151,23 @@
 
 	cclRet = createCluster(self, clusterName)
 	if cclRet:
-		return (False, {'errors': cclRet })
+		return (False, {'errors': [cclRet] })
 	else:
 		messages.append('Created cluster \"' + clusterName + '\" successfully')
 
 	i = 0
-	while i < numSystems:
+	while i < numStorage:
 		try:
 			sysData = request.form['__SYSTEM' + str(i)]
 		except:
 			break
 
 		if len(sysData) == 2 and sysData[0] != '' and sysData[1] != '':
-			csResult = createSystem(self, sysData[0], sysData[1])
+			try:
+				csResult = createClusterSystem(self, clusterName, sysData[0], sysData[1])
+			except string, e:
+				dialog_str = 'The system \"' + sysData[0] + '\" is a member of the cluster \"' + e + '\"\nDo you want to manage the whole cluster?'
+				return (True, {'dialog': dialog_str })
 			if csResult:
 				errors.append(csResult)
 			else:
@@ -177,12 +186,12 @@
 	messages = list()
 
 	try:
-		numSystems = request.form['numSystems']
+		numStorage = request.form['numStorage']
 	except:
 		return (False, {'errors': ['Unknown number of systems entered']})
 
 	i = 0
-	while i < numSystems:
+	while i < numStorage:
 		try:
 			sysData = request.form['__SYSTEM' + str(i)]
 		except:
@@ -220,7 +229,7 @@
 	userId = user.getUserId()
 
 	clusters = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/objectItems')()
-	if not request.form.__contains__('__CLUSTER'):
+	if not '__CLUSTER' in request.form:
 		for i in clusters:
 			try:
 				if user.has_role('View', i[1]):
@@ -261,7 +270,7 @@
 						errors.append('Failed to remove permission for ' + userId + ' for cluster ' + i[0])
 
 	storage = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/objectItems')()
-	if not request.form.__contains__('__STORAGE'):
+	if not '__SYSTEM' in request.form:
 		for i in storage:
 			try:
 				if user.has_role('View', i[1]):
@@ -277,7 +286,7 @@
 				errors.append('Failed to remove permission for ' + userId + ' for ' + i[0])
 	else:
 		for i in storage:
-			if i[0] in request.form['__STORAGE']:
+			if i[0] in request.form['__SYSTEM']:
 				try:
 					if not user.has_role('View', i[1]):
 						roles = list(i[1].get_local_roles_for_userid(userId))
@@ -338,37 +347,28 @@
 	return False
 
 def homebaseControlPost(self, request):
-	if 'ACTUAL_URL' in request:
+	if 'absoluteURL' in request.form:
+		url = request.form['absoluteURL']
+	elif 'ACTUAL_URL' in request:
 		url = request['ACTUAL_URL']
+	elif 'URL' in request:
+		url = request['URL']
 	else:
-		try:
-			url = request.form['absoluteURL']
-		except:
-			if 'URL' in request:
-				url = request['URL']
-			else:
-				url = '.'
+		url = '.'
 
-	try:
+	if 'pagetype' in request.form:
 		pagetype = request.form['pagetype']
-	except:
+	else:
 		return homebasePortal(self, request, '.', '0')
 
-	validatorFn = formValidators[int(request.form['pagetype']) - 1]
-	# Invalid request, send them to homebase
+	try:
+		validatorFn = formValidators[int(request.form['pagetype']) - 1]
+	except:
+		return homebasePortal(self, request, '.', '0')
 
 	ret = validatorFn(self, request)
-
 	request.SESSION.set('checkRet', ret[1])
-
-	if ret[0] == True:
-		# No errors occurred
-		return homebasePortal(self, request, url, pagetype, ret[1])
-
-		return homebasePortal(self, request, url, pagetype, ret[1])
-	else:
-		# Errors occurred
-		return homebasePortal(self, request, url, pagetype, ret[1])
+	return homebasePortal(self, request, url, pagetype, ret[1])
 
 def homebaseControl(self, request):
 	try:
@@ -380,23 +380,21 @@
 		return homebaseControlPost(self, request)
 
 	try:
-		url = request['URL']
+		url = request.form['absoluteURL']
 	except:
-		url = '.'
+		try:
+			url = request['URL']
+		except:
+			url = '.'
 
 	try:
 		pagetype = request.form['pagetype']
 	except:
 		pagetype = '0'
 
-	return homebasePortal(self, request,  url, pagetype)
+	return homebasePortal(self, request, url, pagetype)
 
 def homebasePortal(self, request=None, url=None, pagetype=None, params=None):
-#
-# The add user page
-#
-#	if params and 'dest' in params:
-#		pagetype = params['dest']
 	ret = {}
 	temp = list()
 	index = 0
@@ -471,17 +469,17 @@
 
 	try:
 		if (havePermRemStorage(self) and havePermRemCluster(self) and (getStorage(self) or getClusters(self))):
-			delSystem = {}
-			delSystem['Title'] = 'Remove a System'
-			delSystem['absolute_url'] = url + '?pagetype=' + HOMEBASE_DEL_SYSTEM
-			delSystem['Description'] = 'Remove a system'
+			remSystem = {}
+			remSystem['Title'] = 'Remove a System'
+			remSystem['absolute_url'] = url + '?pagetype=' + HOMEBASE_DEL_SYSTEM
+			remSystem['Description'] = 'Remove a system'
 			if pagetype == HOMEBASE_DEL_SYSTEM:
-				delSystem['currentItem'] = True
+				remSystem['currentItem'] = True
 				ret['curIndex'] = index
 			else:
-				delSystem['currentItem'] = False
+				remSystem['currentItem'] = False
 			index += 1
-			temp.append(delSystem)
+			temp.append(remSystem)
 	except: pass
 
 #
@@ -494,8 +492,8 @@
 			userPerm['absolute_url'] = url + '?pagetype=' + HOMEBASE_PERMS
 			userPerm['Description'] = 'Set permissions for users'
 			if pagetype == HOMEBASE_PERMS:
-#				if params and 'user' in params:
-#					userPerm['absolute_url'] += '&user=' + params['user']
+				if params and 'user' in params:
+					userPerm['curUser'] += params['user']
 				userPerm['currentItem'] = True
 				ret['curIndex'] = index
 			else:
@@ -510,13 +508,34 @@
 	ret['children'] = temp
 	return ret
 
+def getClusterSystems(self, clusterName):
+	if isAdmin(self):
+		return self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName + '/objectItems')()
+
+	try:
+		i = getSecurityManager().getUser()
+		if not i:
+			raise
+	except:
+		return None
+
+	csystems = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName + '/objectItems')()
+	if not csystems:
+		return None
+
+	allowedCSystems = list()
+	for c in csystems:
+		if i.has_role('View', c[1]):
+			allowedCSystems.append(c)
+	return (c)
+
 def getClusters(self):
 	if isAdmin(self):
 		return self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/objectItems')()
 	try:
 		i = getSecurityManager().getUser()
 		if not i:
-			return None
+			raise
 	except:
 		return None
 
@@ -554,6 +573,12 @@
 
 def createSystem(self, host, passwd):
 	try:
+		exists = self.restrictedTraverse(PLONE_ROOT +'/systems/storage/' + host)
+		return 'Storage system \"' +  host + '\" is already managed.'
+	except:
+		pass
+
+	try:
 		rc = RicciCommunicator(host)
 	except:
 		return 'Unable to establish a connection to the ricci agent on \"' + host + '\"'
@@ -588,6 +613,16 @@
 	except:
 		return 'Unable to set permissions on new system \"' + host + '\"'
 
+#	sys.stdout = sys.stderr
+#	cluster_info = rc.cluster_info()
+#	if cluster_info[0] != '':
+#		cluConf = getClusterConf(rc)
+#		if cluConf:
+#			print cluConf.toxml()
+#			nodeList = getClusterConfNodes(cluConf)
+#			sys.stdout = sys.stderr
+#			print "other nodes in",cluster_info[0],"::",nodeList
+
 def createCluster(self, clusterName):
 	try:
 		clusters = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/')
@@ -625,22 +660,27 @@
 	if i != True:
 		return 'Authentication for host \"' + host + '\" failed'
 
+	cluster_info = rc.cluster_info()
+	if len(cluster_info) > 0 and cluster_info[0] != '' and  cluster_info[0] != cluster:
+		return 'The host \"' + host + '\" is already a member of the cluster \"' + cluster_info[0] + '\"'
+
 	try:
-		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster)
+		exists = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster + '/' + host)
+		if exists:
+			return None
 	except:
-		return 'Unable to create storage system \"' + host + '\" for cluster \"' + cluster + '\"'
+		pass
 
 	try:
-		ssystem.manage_addFolder(host, '__luci__:system')
-		newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host)
+		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster)
 	except:
-		return 'Unable to create storage system \"' + host + '\" for cluster \"' + cluster + '\"'
+		return 'Unable to create storage system \"' + host + '\" for cluster \"' + cluster + '\": Cannot find cluster'
 
 	try:
-		newSystem.manage_acquiredPermissions([])
-		newSystem.manage_role('View', ['Access contents information','View'])
+		ssystem.manage_addFolder(host, '__luci__:csystem:' + cluster)
+		newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + cluster + '/' + host)
 	except:
-		return 'Unable to set permissions on new system \"' + host + '\" for cluster \"' + cluster + '\"'
+		return 'Unable to create storage system \"' + host + '\" for cluster \"' + cluster + '\"'
 
 	try:
 		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
@@ -649,7 +689,13 @@
 
 	try:
 		ssystem.manage_addFolder(host, '__luci__:system')
+	except:
+		pass
+
+	try:
 		newSystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/' + host)
+		if not newSystem:
+			raise
 	except:
 		return 'Unable to create storage system \"' + host + '\"'
 
@@ -660,16 +706,38 @@
 		return 'Unable to set permissions on new storage system \"' + host + '\"'
 
 def delSystem(self, systemName):
-	# should rikki revoke certs?
 	try:
 		ssystem = self.restrictedTraverse(PLONE_ROOT + '/systems/storage/')
 	except:
 		return 'Unable to find storage system \"' + systemName + '\"'
 
+	rc = RicciCommunicator(systemName)
+	cluster_info = rc.cluster_info()
+
 	try:
-		ssystem.manage_delObjects([systemName])
-	except:
-		return 'Unable to delete storage system \"' + systemName + '\"'
+		rc.unauth()
+	except Exception, e:
+		e = str(e)
+		if str(e) != '5':
+			# If it's simply a case where we're not authed in the first
+			# place, an attempt to unauthorize failing isn't a problem.
+			return 'Unable to unauthenticate to storage system \"' + systemName + '\"'
+		pass
+
+	if len(cluster_info) > 0 and cluster_info[0] != '':
+		try:
+			delClusterSystem(self, str(cluster_info[0]), systemName)
+		except KeyError:
+			# The cluster may have been deleted, but the system
+			# may still exist in the storage dir.
+			pass
+		except:
+			return 'Unable to delete cluster storage system \"' + systemName + '\"'
+
+		try:
+			ssystem.manage_delObjects([systemName])
+		except:
+			return 'Unable to delete storage system \"' + systemName + '\"'
 
 def delCluster(self, clusterName):
 	try:
@@ -681,7 +749,29 @@
 		clusters.manage_delObjects([clusterName])
 	except:
 		return 'Unable to delete cluster \"' + clusterName + '\"'
-	
+
+def delClusterSystem(self, clusterName, systemName):
+	cluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
+	cluster.manage_delObjects([systemName])
+
+def delClusterSystems(self, clusterName):
+	try:
+		cluster = self.restrictedTraverse(PLONE_ROOT + '/systems/cluster/' + clusterName)
+		csystems = getClusterSystems(self, clusterName)
+	except:
+		return 'Unable to find any systems for cluster \"' + clusterName + '\"'
+
+	errors = ''
+	for i in csystems:
+		try:
+			delSystem(i)
+			cluster.manage_delObjects([i])
+			delClusterSystem(i)
+		except:
+			errors += 'Unable to delete the cluster system \"' + i + '\"\n'
+
+	return errors
+
 def getDefaultUser(self):
 	try:
 		return self.portal_membership.listMembers()[0].getUserName()
@@ -732,7 +822,7 @@
 	return isAdmin(self) 
 
 def getClusterConf(rc):
-	doc = minidom.Document()
+	doc = xml.dom.minidom.Document()
 	batch = doc.createElement('batch')
 	module = doc.createElement('module')
 	module.setAttribute('name', 'cluster')
@@ -743,8 +833,12 @@
 	request.appendChild(call)
 	module.appendChild(request)
 	batch.appendChild(module)
+
 	ret = rc.process_batch(batch)
 
+	if not ret:
+		return None
+
 	cur = ret
 	while len(cur.childNodes) > 0:
 		for i in cur.childNodes:
@@ -753,10 +847,9 @@
 					return i.childNodes[1].cloneNode(True)
 				else:
 					cur = i
-		
 	return None
 
-def getClusterNodes(clusterConfDom):
+def getClusterConfNodes(clusterConfDom):
 	cur = clusterConfDom
 	clusterNodes = list()
 
@@ -768,3 +861,25 @@
 					clusterNodes.append(i.getAttribute('name'))
 			return clusterNodes
 	return clusterNodes
+
+def getSystems(self):
+	storage = getStorage(self)
+	clusters = getClusters(self)
+	storageList = None
+	ret = [{}, None]
+	zeroindex = lambda i: i[0]
+
+	if storage and len(storage) > 0:
+		storageList = map(zeroindex, storage)
+
+	for i in clusters:
+		cSystems = map(zeroindex, getClusterSystems(self, i[0]))
+		for c in cSystems:
+			try:
+				del storageList[storageList.index(c)]
+			except ValueError: pass
+		ret[0][i[0]] = cSystems
+
+	if storageList:
+		ret[1] = storageList
+	return ret



^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2008-04-21 18:19 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-16 15:18 [Cluster-devel] conga/luci/site/luci/Extensions homebase_adapt rmccabe
  -- strict thread matches above, loose matches on Subject: below --
2008-04-21 18:19 rmccabe
2008-02-05 20:59 rmccabe
2007-06-06 15:14 rmccabe
2007-01-29 22:06 rmccabe
2007-01-08 19:49 rmccabe
2007-01-08 19:46 rmccabe
2006-11-02 21:12 rmccabe
2006-11-01 20:34 rmccabe
2006-10-30 20:20 rmccabe
2006-10-26 16:57 rmccabe
2006-10-13 17:12 rmccabe
2006-10-11 21:48 rmccabe
2006-10-11 18:44 rmccabe
2006-10-06 20:45 rmccabe
2006-10-06 18:58 rmccabe
2006-10-04 13:25 jparsons
2006-08-01 16:27 rmccabe
2006-07-27 13:37 jparsons
2006-07-26 19:50 rmccabe
2006-07-25 17:45 rmccabe
2006-07-18 19:26 rmccabe
2006-06-27 20:53 rmccabe
2006-06-27 20:47 rmccabe
2006-06-27 17:49 rmccabe
2006-06-26 20:10 rmccabe
2006-06-22  3:58 rmccabe

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