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

[Cluster-devel] conga/luci/utils luci_admin



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-06-16 18:17:25

Modified files:
	luci/utils     : luci_admin 

Log message:
	

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/utils/luci_admin.diff?cvsroot=cluster&r1=1.9&r2=1.10

--- conga/luci/utils/luci_admin	2006/06/16 17:44:17	1.9
+++ conga/luci/utils/luci_admin	2006/06/16 18:17:24	1.10
@@ -44,7 +44,6 @@
 
 INITUSER_FILE_PATH = '/var/lib/luci/inituser'
 
-
 examine_classes = [
 	'OFS.Folder.Folder',
 	'AccessControl.User.User',
@@ -77,15 +76,16 @@
 		stderr.write('Unable to open the luci backup file \"'+ backupfn +'\"\n')
 		sys.exit(1)
 
-	node = node.getElementsByName('luci')
-	if not node:
+	node = node.getElementsByTagName('luci')
+	if not node or len(node) < 1:
 		sys.stderr.write('Backup file is missing the \'luci\' tag\n')
 		sys.exit(1)
 
-	node = node.getElementsByName('backupData')
-	if not node:
+	node = node[0].getElementsByTagName('backupData')
+	if not node or len(node) < 1:
 		sys.stderr.write('Backup file is missing the \'backupData\' tag\n')
 		sys.exit(1)
+	node = node[0]
 
 	tempuser = AccessControl.User.UnrestrictedUser('admin', '',
 				('manage','Manager', 'Owner', 'View', 'Authenticated'), [])
@@ -96,8 +96,11 @@
 	AppInitializer(app).initialize()
 
 	portal_mem = app.unrestrictedTraverse('/luci/portal_membership')
+	portal_reg = app.unrestrictedTraverse('/luci/portal_registration')
 
-	userList = node.getElementsByTagName('user')
+	userList = node.getElementsByTagName('userList')
+	if userList and len(userList) > 0:
+		userList = userList[0].getElementsByTagName('user')
 	for u in userList:
 		id = u.getAttribute('id')
 		if not id:
@@ -136,10 +139,11 @@
 
 	x = app.unrestrictedTraverse('/luci/systems/storage')
 	systemList = node.getElementsByTagName('systemList')
-	if not systemList:
+	if not systemList or len(systemList) < 1:
 		sys.write.stderr('No storage systems to add')
 	else:
-		systemList = systemList.getElementsByTagName('system')
+		systemList = systemList[0].getElementsByTagName('system')
+
 	for s in systemList:
 		id = s.getAttribute('id')
 		if not id:
@@ -148,7 +152,7 @@
 		id = str(id)
 		title = str(s.getAttribute('title'))
 
-		x.manage_addFolder(id)
+		x.manage_addFolder(id, title)
 		try:
 			new_system = app.unrestrictedTraverse('/luci/systems/storage/' + id)
 			if not new_system:
@@ -159,16 +163,16 @@
 			sys.exit(1)
 
 		userPerms = s.getElementsByTagName('permList')
-		if not userPerms:
+		if not userPerms or len(userPerms) < 1:
 			continue
-		userPerms = userPerms.getElementsByTagName('ref')
+		userPerms = userPerms[0].getElementsByTagName('ref')
 		for i in userPerms:
 			if i.nodeType != xml.dom.Node.ELEMENT_NODE:
 				continue
 			newuser = i.getAttribute('name')
 			if not newuser:
 				continue
-			new_system.setLocalRoles(newuser, ['View'])
+			new_system.manage_setLocalRoles(newuser, ['View'])
 		#transaction.commit()
 
 	x = app.unrestrictedTraverse('/luci/systems/cluster')
@@ -182,38 +186,45 @@
 		title = str(c.getAttribute('title'))
 
 		try:
+			x.manage_addFolder(id, title)
 			new_cluster = app.unrestrictedTraverse('/luci/systems/cluster/'+ id)
 			if not new_cluster:
 				raise
 		except:
 			sys.stderr.write('Error adding cluster \"' + id + '\"\n')
-			tranaction.abort()
+			transaction.abort()
 			sys.exit(1)
 
 		userPerms = c.getElementsByTagName('permList')
-		if not userPerms:
+		if not userPerms or len(userPerms) < 1:
 			continue
-		userPerms = userPerms.getElementsByTagName('ref')
+		userPerms = userPerms[0].getElementsByTagName('ref')
 		for i in userPerms:
 			if i.nodeType != xml.dom.Node.ELEMENT_NODE:
 				continue
 			newuser = i.getAttribute('name')
 			if not newuser:
 				continue
-			new_cluster.setLocalRoles(newuser, ['View'])
+			new_cluster.manage_setLocalRoles(newuser, ['View'])
 
 		clusterSystems = c.getElementsByTagName('systemsList')
-		if not clusterSystems:
+		if not clusterSystems or len(clusterSystems) < 1:
 			sys.stderr.write('No cluster storage systems to add\n')
 			continue
-		clusterSystems = clusterSystems.getElementsByTagName('ref')
+		clusterSystems = clusterSystems[0].getElementsByTagName('ref')
 		for i in clusterSystems:
 			newsys = i.getAttribute('name')
 			if not newsys:
 				sys.stderr.write('Cluster system element missing name tag\n')
 				continue
 			newsys = str(newsys)
-			x.manage_addFolder(newsys)
+			stitle = i.getAttribute('title')
+			if stitle:
+				stitle = str(stitle)
+			else:
+				stitle = None
+				x.manage_addFolder(newsys, stitle)
+			
 		#transaction.commit()
 
 	transaction.abort()


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