cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] conga/luci/site/luci/Extensions HelperFunction ...
@ 2007-09-24 21:19 rmccabe
  0 siblings, 0 replies; 4+ messages in thread
From: rmccabe @ 2007-09-24 21:19 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-09-24 21:19:43

Modified files:
	luci/site/luci/Extensions: HelperFunctions.py LuciZopeAsync.py 
	                           PropsObject.py ResourceHandler.py 
	                           StorageReport.py Variable.py 
	                           conga_constants.py conga_ssl.py 
	                           conga_storage_constants.py 
	                           ricci_communicator.py 
	                           ricci_defines.py storage_adapters.py 

Log message:
	More cleanup.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/HelperFunctions.py.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeAsync.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ResourceHandler.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/Variable.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_ssl.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_storage_constants.py.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_defines.py.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/storage_adapters.py.diff?cvsroot=cluster&r1=1.12&r2=1.13

--- conga/luci/site/luci/Extensions/HelperFunctions.py	2007/08/08 21:00:07	1.9
+++ conga/luci/site/luci/Extensions/HelperFunctions.py	2007/09/24 21:19:42	1.10
@@ -79,8 +79,8 @@
 
 def get_system_info(self, system_list):
 	mutex = threading.RLock()
-	hive  = [] # workers
-	ss	= {} # storage systems (will store riccis and then use them to retrieve real info)
+	hive = [] # workers
+	ss = {} # storage systems (will store riccis and then use them to retrieve real info)
 	hosts = [] # hostnames
 
 	for system in system_list:
--- conga/luci/site/luci/Extensions/LuciZopeAsync.py	2007/08/08 21:00:07	1.1
+++ conga/luci/site/luci/Extensions/LuciZopeAsync.py	2007/09/24 21:19:42	1.2
@@ -38,7 +38,7 @@
 					pyobj_to_xml(i, element[i], xml_elem)
 			else:
 				xml_elem = None
-		elif type(element) in [ types.ListType, types.TupleType ]:
+		elif type(element) in ( types.ListType, types.TupleType ):
 			if len(element) > 0:
 				xml_elem = root.createElement('list')
 				xml_elem.setAttribute('name', str(element_name))
--- conga/luci/site/luci/Extensions/PropsObject.py	2007/07/27 16:43:47	1.7
+++ conga/luci/site/luci/Extensions/PropsObject.py	2007/09/24 21:19:42	1.8
@@ -11,41 +11,42 @@
 import xml.dom
 
 class PropsObject:
+	def __init__(self):
+		self.__vars = {}
 
-    def __init__(self):
-        self.__vars = {}
-
-    def add_prop(self, variable):
-        self.__vars[variable.get_name()] = variable
-    def get_prop(self, name):
-        if name in self.__vars:
-            return self.__vars[name].get_value()
-        else:
-            return None
-
-    def get_props(self):
-        return self.__vars
-
-    def export_xml(self, doc, parent_node):
-        props = doc.createElement(str(PROPS_TAG))
-        parent_node.appendChild(props)
-        for var in self.__vars:
-            props.appendChild(self.__vars[var].export_xml(doc))
-        return props
-
-    def import_xml(self, parent_node):
-        props = None
-        for node in parent_node.childNodes:
-            if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                if node.nodeName == str(PROPS_TAG):
-                    props = node
-        if props is None:
-            return self
-        for node in props.childNodes:
-            try:
-                var = parse_variable(node)
-                self.__vars[var.get_name()] = var
-            except:
-                continue
-        return self
+	def add_prop(self, variable):
+		self.__vars[variable.get_name()] = variable
 
+	def get_prop(self, name):
+		if name in self.__vars:
+			return self.__vars[name].get_value()
+		else:
+			return None
+
+	def get_props(self):
+		return self.__vars
+
+	def export_xml(self, doc, parent_node):
+		props = doc.createElement(str(PROPS_TAG))
+		parent_node.appendChild(props)
+		for var in self.__vars:
+			props.appendChild(self.__vars[var].export_xml(doc))
+		return props
+
+	def import_xml(self, parent_node):
+		props = None
+		for node in parent_node.childNodes:
+			if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+				if node.nodeName == str(PROPS_TAG):
+					props = node
+
+		if props is None:
+			return self
+
+		for node in props.childNodes:
+			try:
+				var = parse_variable(node)
+				self.__vars[var.get_name()] = var
+			except:
+				continue
+		return self
--- conga/luci/site/luci/Extensions/ResourceHandler.py	2007/09/18 21:49:46	1.3
+++ conga/luci/site/luci/Extensions/ResourceHandler.py	2007/09/24 21:19:42	1.4
@@ -684,7 +684,7 @@
 
 	try:
 		dbtype = form['DBTYPE'].strip()
-		if not dbtype in [ 'ORA', 'DB6', 'ADA' ]:
+		if not dbtype in ( 'ORA', 'DB6', 'ADA' ):
 			raise Exception, 'You gave an invalid database type: %s' % dbtype
 		res.addAttribute('DBTYPE', dbtype)
 	except Exception, e:
@@ -699,7 +699,7 @@
 		res.removeAttribute('DBJ2EE_ONLY')
 
 	# Optional string parameters
-	for param in [ 'DIR_EXECUTABLE', 'NETSERVICENAME', 'DIR_BOOTSTRAP', 'DIR_SECSTORE' ]:
+	for param in ( 'DIR_EXECUTABLE', 'NETSERVICENAME', 'DIR_BOOTSTRAP', 'DIR_SECSTORE' ):
 		try:
 			pval = form[param].strip()
 			if not pval:
@@ -721,7 +721,7 @@
 	res.addAttribute('InstanceName', rname)
 
 	# Optional string parameters
-	for param in [ 'DIR_EXECUTABLE', 'DIR_PROFILE', 'START_PROFILE' ]:
+	for param in ( 'DIR_EXECUTABLE', 'DIR_PROFILE', 'START_PROFILE' ):
 		try:
 			pval = form[param].strip()
 			if not pval:
--- conga/luci/site/luci/Extensions/StorageReport.py	2007/09/24 19:48:34	1.27
+++ conga/luci/site/luci/Extensions/StorageReport.py	2007/09/24 21:19:42	1.28
@@ -1624,7 +1624,7 @@
 		value = var.getAttribute('value')
 
 		d_units = ''
-		if name in ['size', 'extent_size', 'block_size', 'size_free', 'partition_begin']:
+		if name in ('size', 'extent_size', 'block_size', 'size_free', 'partition_begin' ):
 			d_units = 'bytes'
 		if 'percent' in name:
 			d_units = '%'
@@ -1686,7 +1686,7 @@
 			d_value = str(value)
 
 		hidden = False
-		if var_type == 'hidden' or name in ['partition_begin', 'snapshot']:
+		if var_type == 'hidden' or name in ( 'partition_begin', 'snapshot' ):
 			hidden = True
 
 		if name == 'removable':
--- conga/luci/site/luci/Extensions/Variable.py	2007/06/25 16:03:38	1.5
+++ conga/luci/site/luci/Extensions/Variable.py	2007/09/24 21:19:42	1.6
@@ -14,268 +14,271 @@
 	VARIABLE_TYPE_STRING_SEL, VARIABLE_TYPE_XML
 
 def parse_variable(node):
-    if node.nodeType != xml.dom.Node.ELEMENT_NODE:
-        raise Exception, 'not a variable'
-    if node.nodeName != str(VARIABLE_TAG):
-        raise Exception, 'not a variable'
-
-    attrs_dir = {}
-    attrs = node.attributes
-    for attrName in attrs.keys():
-        attrNode = attrs.get(attrName)
-        attrValue = attrNode.nodeValue
-        attrs_dir[attrName.strip()] = attrValue
-    if ('name' not in attrs_dir) or ('type' not in attrs_dir):
-        raise Exception, 'incomplete variable'
-    if (attrs_dir['type'] != VARIABLE_TYPE_LIST_INT and attrs_dir['type'] != VARIABLE_TYPE_LIST_STR and attrs_dir['type'] != VARIABLE_TYPE_LIST_XML and attrs_dir['type'] != VARIABLE_TYPE_XML) and ('value' not in attrs_dir):
-        raise Exception, 'incomplete variable'
-
-    mods = {}
-    for mod in attrs_dir:
-        if mod not in ['name', 'value', 'type']:
-            mods[mod] = attrs_dir[mod]
-
-    value = ''
-    if attrs_dir['type'] == VARIABLE_TYPE_LIST_STR:
-        value = []
-        for entry in node.childNodes:
-            v = None
-            if entry.nodeType == xml.dom.Node.ELEMENT_NODE and entry.nodeName == str(VARIABLE_TYPE_LISTENTRY):
-                attrs = entry.attributes
-                for attrName in attrs.keys():
-                    attrNode = attrs.get(attrName)
-                    attrValue = attrNode.nodeValue
-                    if attrName == 'value':
-                        v = attrValue
-            else:
-                continue
-            if v is None:
-                raise Exception, 'invalid listentry'
-            value.append(v)
-        return VariableList(attrs_dir['name'], value, mods, VARIABLE_TYPE_LIST_STR)
-    elif attrs_dir['type'] == VARIABLE_TYPE_LIST_XML:
-        value = []
-        for kid in node.childNodes:
-            if kid.nodeType == xml.dom.Node.ELEMENT_NODE:
-                value.append(kid)#.cloneNode(True))
-        return VariableList(attrs_dir['name'], value, mods, VARIABLE_TYPE_LIST_XML)
-    elif attrs_dir['type'] == VARIABLE_TYPE_XML:
-        for kid in node.childNodes:
-            if kid.nodeType == xml.dom.Node.ELEMENT_NODE:
-                value = kid#.cloneNode(True)
-                break
-    elif attrs_dir['type'] == VARIABLE_TYPE_INT:
-        value = int(attrs_dir['value'])
-    elif attrs_dir['type'] == VARIABLE_TYPE_INT_SEL:
-        value = int(attrs_dir['value'])
-        if 'valid_values' not in mods:
-            raise Exception, 'missing valid_values'
-    elif attrs_dir['type'] == VARIABLE_TYPE_FLOAT:
-        value = float(attrs_dir['value'])
-    elif attrs_dir['type'] == VARIABLE_TYPE_STRING:
-        value = attrs_dir['value']
-    elif attrs_dir['type'] == VARIABLE_TYPE_STRING_SEL:
-        value = attrs_dir['value']
-        if 'valid_values' not in mods:
-            raise Exception, 'missing valid_values'
-    elif attrs_dir['type'] == VARIABLE_TYPE_BOOL:
-        value = (attrs_dir['value'] == 'true')
-    else:
-        raise Exception, 'invalid variable'
+	if node.nodeType != xml.dom.Node.ELEMENT_NODE:
+		raise Exception, 'not a variable'
 
-    return Variable(attrs_dir['name'], value, mods)
+	if node.nodeName != str(VARIABLE_TAG):
+		raise Exception, 'not a variable'
 
+	attrs_dir = {}
+	attrs = node.attributes
+	for attrName in attrs.keys():
+		attrNode = attrs.get(attrName)
+		attrValue = attrNode.nodeValue
+		attrs_dir[attrName.strip()] = attrValue
+
+	if ('name' not in attrs_dir) or ('type' not in attrs_dir):
+		raise Exception, 'incomplete variable'
+
+	if attrs_dir['type'] not in ( VARIABLE_TYPE_LIST_INT, VARIABLE_TYPE_LIST_STR, VARIABLE_TYPE_LIST_XML, VARIABLE_TYPE_XML) and 'value' not in attrs_dir:
+		raise Exception, 'incomplete variable'
+
+	mods = {}
+	for mod in attrs_dir:
+		if mod not in ( 'name', 'value', 'type' ):
+			mods[mod] = attrs_dir[mod]
+
+	value = ''
+	if attrs_dir['type'] == VARIABLE_TYPE_LIST_STR:
+		value = []
+		for entry in node.childNodes:
+			v = None
+			if entry.nodeType == xml.dom.Node.ELEMENT_NODE and entry.nodeName == str(VARIABLE_TYPE_LISTENTRY):
+				attrs = entry.attributes
+				for attrName in attrs.keys():
+					attrNode = attrs.get(attrName)
+					attrValue = attrNode.nodeValue
+					if attrName == 'value':
+						v = attrValue
+			else:
+				continue
+			if v is None:
+				raise Exception, 'invalid listentry'
+			value.append(v)
+		return VariableList(attrs_dir['name'], value, mods, VARIABLE_TYPE_LIST_STR)
+	elif attrs_dir['type'] == VARIABLE_TYPE_LIST_XML:
+		value = []
+		for kid in node.childNodes:
+			if kid.nodeType == xml.dom.Node.ELEMENT_NODE:
+				value.append(kid)#.cloneNode(True))
+		return VariableList(attrs_dir['name'], value, mods, VARIABLE_TYPE_LIST_XML)
+	elif attrs_dir['type'] == VARIABLE_TYPE_XML:
+		for kid in node.childNodes:
+			if kid.nodeType == xml.dom.Node.ELEMENT_NODE:
+				value = kid#.cloneNode(True)
+				break
+	elif attrs_dir['type'] == VARIABLE_TYPE_INT:
+		value = int(attrs_dir['value'])
+	elif attrs_dir['type'] == VARIABLE_TYPE_INT_SEL:
+		value = int(attrs_dir['value'])
+		if 'valid_values' not in mods:
+			raise Exception, 'missing valid_values'
+	elif attrs_dir['type'] == VARIABLE_TYPE_FLOAT:
+		value = float(attrs_dir['value'])
+	elif attrs_dir['type'] == VARIABLE_TYPE_STRING:
+		value = attrs_dir['value']
+	elif attrs_dir['type'] == VARIABLE_TYPE_STRING_SEL:
+		value = attrs_dir['value']
+		if 'valid_values' not in mods:
+			raise Exception, 'missing valid_values'
+	elif attrs_dir['type'] == VARIABLE_TYPE_BOOL:
+		value = (attrs_dir['value'] == 'true')
+	else:
+		raise Exception, 'invalid variable'
 
+	return Variable(attrs_dir['name'], value, mods)
 
-class Variable:
-    def __init__(self, name, value, mods={}):
-        self.__name = str(name)
-        self.__mods = mods
-        self.__value = None
-        self.__type = None
-        self.set_value(value)
-
-    def get_name(self):
-        return self.__name
-
-    def get_value(self):
-        return self.__value
-
-    def set_value(self, value):
-        if self.__is_bool(value):
-            self.__type = VARIABLE_TYPE_BOOL
-            self.__value = value
-
-        elif self.__is_int(value):
-            self.__type = VARIABLE_TYPE_INT
-            self.__value = int(value)
-
-        elif self.__is_float(value):
-            self.__type = VARIABLE_TYPE_FLOAT
-            self.__value = float(value)
-
-        elif self.__is_list(value):
-            raise Exception, "lists not implemented"
-            if self.__is_int(value[0]):
-                self.__type = VARIABLE_TYPE_LIST_INT
-                self.__value = value
-            elif self.__is_string(value[0]):
-                self.__type = VARIABLE_TYPE_LIST_STR
-                self.__value = value
-            else:
-                raise Exception, "not valid list type"
-        elif self.__is_xml(value):
-            self.__type = VARIABLE_TYPE_XML
-            self.__value = value
-
-        else:
-            self.__value = str(value)
-            self.__type = VARIABLE_TYPE_STRING
-
-    def type(self):
-        if 'valid_values' in self.__mods:
-            if self.__type == VARIABLE_TYPE_INT:
-                return VARIABLE_TYPE_INT_SEL
-            elif self.__type == VARIABLE_TYPE_STRING:
-                return VARIABLE_TYPE_STRING_SEL
-        return self.__type
-
-    def get_modifiers(self):
-        return self.__mods
-    def set_modifier(self, mod_name, mod_value):
-        self.__mods[mod_name] = mod_value
-        return
-
-    def export_xml(self, doc):
-        elem = doc.createElement(VARIABLE_TAG)
-        elem.setAttribute('name', self.__name)
-        elem.setAttribute('type', self.type())
-        if not self.__is_list(self.__value):
-            if self.__is_bool(self.__value):
-                if self.__value:
-                    elem.setAttribute('value', 'true')
-                else:
-                    elem.setAttribute('value', 'false')
-            elif self.__is_xml(self.__value):
-                elem.appendChild(self.__value)
-            else:
-                elem.setAttribute('value', str(self.__value))
-        else:
-            raise Exception, "lists not implemented"
-            l = self.__value
-            for i in xrange(len(l)):
-                x = l[i]
-                e2 = doc.createElement(VARIABLE_TYPE_LISTENTRY)
-                e2.setAttribute('type', str(self.__get_type(x)))
-                e2.setAttribute('value', str(x))
-                e2.setAttribute('list_index', str(i))
-                elem.appendChild(e2)
-        for mod in self.__mods:
-            elem.setAttribute(str(mod), str(self.__mods[mod]))
-        return elem
-    def __get_type(self, value):
-        if self.__is_bool(value):
-            return VARIABLE_TYPE_BOOL
-        elif self.__is_int(value):
-            return VARIABLE_TYPE_INT
-        elif self.__is_float(value):
-            return VARIABLE_TYPE_FLOAT
-        elif self.__is_list(value):
-            if self.__is_int(value[0]):
-                return VARIABLE_TYPE_LIST_INT
-            elif self.__is_string(value[0]):
-                return VARIABLE_TYPE_LIST_STR
-            else:
-                raise Exception, "not valid list type"
-        elif self.__is_xml(value):
-            return VARIABLE_TYPE_XML
-        else:
-            return VARIABLE_TYPE_STRING
-
-
-
-
-    def __is_xml(self, value):
-        try:
-            value.toxml()
-            return True
-        except:
-            return False
-    def __is_bool(self, value):
-        try:
-            if value.__class__ == bool().__class__:
-                return True
-            return False
-        except:
-            return False
-    def __is_int(self, value):
-        try:
-            int(value)
-            return True
-        except:
-            return False
-    def __is_float(self, value):
-        try:
-            float(value)
-            return True
-        except:
-            return False
-    def __is_string(self, var):
-        if self.__is_int(var):
-            return False
-        elif self.__is_float(var):
-            return False
-        return True
-    def __is_list(self, value):
-        try:
-            if value.__class__ == [].__class__:
-                return True
-        except:
-            pass
-        return False
 
+class Variable:
+	def __init__(self, name, value, mods={}):
+		self.__name = str(name)
+		self.__mods = mods
+		self.__value = None
+		self.__type = None
+		self.set_value(value)
+
+	def get_name(self):
+		return self.__name
+
+	def get_value(self):
+		return self.__value
+
+	def set_value(self, value):
+		if self.__is_bool(value):
+			self.__type = VARIABLE_TYPE_BOOL
+			self.__value = value
+		elif self.__is_int(value):
+			self.__type = VARIABLE_TYPE_INT
+			self.__value = int(value)
+		elif self.__is_float(value):
+			self.__type = VARIABLE_TYPE_FLOAT
+			self.__value = float(value)
+		elif self.__is_list(value):
+			raise Exception, "lists not implemented"
+			if self.__is_int(value[0]):
+				self.__type = VARIABLE_TYPE_LIST_INT
+				self.__value = value
+			elif self.__is_string(value[0]):
+				self.__type = VARIABLE_TYPE_LIST_STR
+				self.__value = value
+			else:
+				raise Exception, "not valid list type"
+		elif self.__is_xml(value):
+			self.__type = VARIABLE_TYPE_XML
+			self.__value = value
+		else:
+			self.__value = str(value)
+			self.__type = VARIABLE_TYPE_STRING
+
+	def type(self):
+		if 'valid_values' in self.__mods:
+			if self.__type == VARIABLE_TYPE_INT:
+				return VARIABLE_TYPE_INT_SEL
+			elif self.__type == VARIABLE_TYPE_STRING:
+				return VARIABLE_TYPE_STRING_SEL
+		return self.__type
+
+	def get_modifiers(self):
+		return self.__mods
+
+	def set_modifier(self, mod_name, mod_value):
+		self.__mods[mod_name] = mod_value
+		return
+
+	def export_xml(self, doc):
+		elem = doc.createElement(VARIABLE_TAG)
+		elem.setAttribute('name', self.__name)
+		elem.setAttribute('type', self.type())
+		if not self.__is_list(self.__value):
+			if self.__is_bool(self.__value):
+				if self.__value:
+					elem.setAttribute('value', 'true')
+				else:
+					elem.setAttribute('value', 'false')
+			elif self.__is_xml(self.__value):
+				elem.appendChild(self.__value)
+			else:
+				elem.setAttribute('value', str(self.__value))
+		else:
+			raise Exception, "lists not implemented"
+			l = self.__value
+			for i in xrange(len(l)):
+				x = l[i]
+				e2 = doc.createElement(VARIABLE_TYPE_LISTENTRY)
+				e2.setAttribute('type', str(self.__get_type(x)))
+				e2.setAttribute('value', str(x))
+				e2.setAttribute('list_index', str(i))
+				elem.appendChild(e2)
+		for mod in self.__mods:
+			elem.setAttribute(str(mod), str(self.__mods[mod]))
+		return elem
+
+	def __get_type(self, value):
+		if self.__is_bool(value):
+			return VARIABLE_TYPE_BOOL
+		elif self.__is_int(value):
+			return VARIABLE_TYPE_INT
+		elif self.__is_float(value):
+			return VARIABLE_TYPE_FLOAT
+		elif self.__is_list(value):
+			if self.__is_int(value[0]):
+				return VARIABLE_TYPE_LIST_INT
+			elif self.__is_string(value[0]):
+				return VARIABLE_TYPE_LIST_STR
+			else:
+				raise Exception, "not valid list type"
+		elif self.__is_xml(value):
+			return VARIABLE_TYPE_XML
+		else:
+			return VARIABLE_TYPE_STRING
+
+	def __is_xml(self, value):
+		try:
+			value.toxml()
+			return True
+		except:
+			return False
+
+	def __is_bool(self, value):
+		try:
+			if value.__class__ == bool().__class__:
+				return True
+			return False
+		except:
+			return False
+
+	def __is_int(self, value):
+		try:
+			int(value)
+			return True
+		except:
+			return False
+
+	def __is_float(self, value):
+		try:
+			float(value)
+			return True
+		except:
+			return False
+
+	def __is_string(self, var):
+		if self.__is_int(var):
+			return False
+		elif self.__is_float(var):
+			return False
+		return True
+
+	def __is_list(self, value):
+		try:
+			if value.__class__ == [].__class__:
+				return True
+		except:
+			pass
+		return False
 
 class VariableList(Variable):
-    def __init__(self, name, value, mods, list_type):
-        if list_type != VARIABLE_TYPE_LIST_STR and list_type != VARIABLE_TYPE_LIST_XML:
-            raise Exception, 'invalid list type'
-        #if ! self.__is_list(value):
-        #    raise Exception, 'value not a list'
-        self.__name = name
-        self.__mods = mods
-        self.__type = list_type
-        self.__value = value
-
-    def get_name(self):
-        return self.__name
-
-    def get_value(self):
-        return self.__value
-    def set_value(self, value):
-        raise Exception, 'VariableList.set_value() not implemented'
-
-    def type(self):
-        return self.__type
-
-    def get_modifiers(self):
-        return self.__mods
-    def set_modifier(self, mod_name, mod_value):
-        self.__mods[mod_name] = mod_value
-        return
-
-    def export_xml(self, doc):
-        elem = doc.createElement(VARIABLE_TAG)
-        elem.setAttribute('name', self.__name)
-        elem.setAttribute('type', self.type())
-
-        l = self.get_value()
-        for x in l:
-            if self.type() == VARIABLE_TYPE_LIST_XML:
-                elem.appendChild(x)#.cloneNode(True))
-            else:
-                e2 = doc.createElement(VARIABLE_TYPE_LISTENTRY)
-                e2.setAttribute('value', str(x))
-                elem.appendChild(e2)
-        for mod in self.__mods:
-            elem.setAttribute(str(mod), str(self.__mods[mod]))
-        return elem
+	def __init__(self, name, value, mods, list_type):
+		if list_type != VARIABLE_TYPE_LIST_STR and list_type != VARIABLE_TYPE_LIST_XML:
+			raise Exception, 'invalid list type'
+		#if ! self.__is_list(value):
+		#	raise Exception, 'value not a list'
+		self.__name = name
+		self.__mods = mods
+		self.__type = list_type
+		self.__value = value
+
+	def get_name(self):
+		return self.__name
+
+	def get_value(self):
+		return self.__value
+
+	def set_value(self, value):
+		raise Exception, 'VariableList.set_value() not implemented'
+
+	def type(self):
+		return self.__type
+
+	def get_modifiers(self):
+		return self.__mods
+
+	def set_modifier(self, mod_name, mod_value):
+		self.__mods[mod_name] = mod_value
+		return
+
+	def export_xml(self, doc):
+		elem = doc.createElement(VARIABLE_TAG)
+		elem.setAttribute('name', self.__name)
+		elem.setAttribute('type', self.type())
+
+		l = self.get_value()
+		for x in l:
+			if self.type() == VARIABLE_TYPE_LIST_XML:
+				elem.appendChild(x)#.cloneNode(True))
+			else:
+				e2 = doc.createElement(VARIABLE_TYPE_LISTENTRY)
+				e2.setAttribute('value', str(x))
+				elem.appendChild(e2)
+		for mod in self.__mods:
+			elem.setAttribute(str(mod), str(self.__mods[mod]))
+		return elem
--- conga/luci/site/luci/Extensions/conga_constants.py	2007/08/08 21:00:07	1.43
+++ conga/luci/site/luci/Extensions/conga_constants.py	2007/09/24 21:19:42	1.44
@@ -122,7 +122,7 @@
 START_NODE				= 6
 RICCI_CONNECT_FAILURE	= (-1000)
 
-RICCI_CONNECT_FAILURE_MSG = 'Currently unable to reach the ricci agent on this node.  '
+RICCI_CONNECT_FAILURE_MSG = 'Currently unable to reach the ricci agent on this node. '
 
 # cluster/node create error messages
 CLUNODE_CREATE_ERRORS = [
--- conga/luci/site/luci/Extensions/conga_ssl.py	2007/06/25 16:03:39	1.3
+++ conga/luci/site/luci/Extensions/conga_ssl.py	2007/09/24 21:19:42	1.4
@@ -16,36 +16,35 @@
 # timeouts are in seconds (int)
 
 class SSLSocket:
+	def __init__(self, hostname, port, timeout):
+		self.__id = -1
+		self.__id = conga_ssl_lib.connect(hostname, port, timeout)
+		self.__hostname = hostname
+
+	def __del__(self):
+		self.disconnect()
+
+	def disconnect(self):
+		if self.__id != -1:
+			conga_ssl_lib.disconnect(self.__id)
+			self.__id = -1
+
+	def peer_fingerprint(self):
+		return conga_ssl_lib.peer_fingerprint(self.__id)
+
+	def trusted(self):
+		return conga_ssl_lib.trusted(self.__id) == 1
+
+	def trust(self):
+		if self.trusted():
+			return True
+		return conga_ssl_lib.trust(self.__id, self.__hostname) == 1
 
-    def __init__(self,
-                 hostname,
-                 port,
-                 timeout):
-        self.__id = -1
-        self.__id = conga_ssl_lib.connect(hostname, port, timeout)
-        self.__hostname = hostname
-
-    def __del__(self):
-        self.disconnect()
-
-    def disconnect(self):
-        if self.__id != -1:
-            conga_ssl_lib.disconnect(self.__id)
-            self.__id = -1
-
-    def peer_fingerprint(self):
-        return conga_ssl_lib.peer_fingerprint(self.__id)
-
-    def trusted(self):
-        return conga_ssl_lib.trusted(self.__id) == 1
-    def trust(self):
-        if self.trusted():
-            return True
-        return conga_ssl_lib.trust(self.__id, self.__hostname) == 1
-    def untrust(self):
-        return conga_ssl_lib.untrust(self.__id) == 1
-
-    def send(self, msg, timeout):
-        conga_ssl_lib.send(self.__id, msg, timeout)
-    def recv(self, timeout):
-        return conga_ssl_lib.recv(self.__id, timeout)
+	def untrust(self):
+		return conga_ssl_lib.untrust(self.__id) == 1
+
+	def send(self, msg, timeout):
+		conga_ssl_lib.send(self.__id, msg, timeout)
+
+	def recv(self, timeout):
+		return conga_ssl_lib.recv(self.__id, timeout)
--- conga/luci/site/luci/Extensions/conga_storage_constants.py	2007/06/25 16:03:39	1.9
+++ conga/luci/site/luci/Extensions/conga_storage_constants.py	2007/09/24 21:19:42	1.10
@@ -11,174 +11,156 @@
 
 ## request vars ##
 
-PAGETYPE = "pagetype"
-CLUNAME = "clustername"
+PAGETYPE = 'pagetype'
+CLUNAME = 'clustername'
 STONAME = 'storagename'
 
-
-# storage pagetypes #
-
 PT_MAPPER_ID = 'mapper_id'
 PT_MAPPER_TYPE = 'mapper_type'
 PT_PATH = 'bd_path'
 
-STORAGESYS = "0"
-STORAGE_CONFIG = "43"
-STORAGE = "44"
-CLUSTER_STORAGE = "45"
-
 STORAGE_COMMIT_CHANGES = 'commit_changes'
 
-
-VIEW_MAPPERS = '51'
-VIEW_MAPPER = '52'
-
-VIEW_BDS = '61'
-VIEW_BD = '62'
-
-
-CREATE_MAPPER = '101'
-ADD_SOURCES   = '102'
-
-
-
-# pretty names
-
-PRETTY_MAPPER_INFO = {MAPPER_SYS_TYPE         : ('Hard Drives',     'Hard Drive',     'BUG: source not defined'),
-                      MAPPER_VG_TYPE          : ('Volume Group',    'Logical Volume', 'Physical Volume'),
-                      MAPPER_PT_TYPE          : ('Partition Table', 'Partition',      'Disk'),
-                      MAPPER_MDRAID_TYPE      : ('Software RAID',   'Volume',         'Disk'),
-                      MAPPER_ATARAID_TYPE     : ('ATA-RAID',        'Volume',         'Disk'),
-                      MAPPER_MULTIPATH_TYPE   : ('Multipath',       'Multipath',      'Path'),
-                      MAPPER_CRYPTO_TYPE      : ('Encryption',      'Volume',         'Device'),
-                      MAPPER_iSCSI_TYPE       : ('iSCSI',           'Volume',         'BUG: source not defined')}
+# storage pagetypes #
+STORAGESYS		= '0'
+STORAGE_CONFIG	= '43'
+STORAGE			= '44'
+CLUSTER_STORAGE	= '45'
+VIEW_MAPPERS	= '51'
+VIEW_MAPPER		= '52'
+VIEW_BDS		= '61'
+VIEW_BD			= '62'
+CREATE_MAPPER	= '101'
+ADD_SOURCES		= '102'
+
+# mapper pretty names
+PRETTY_MAPPER_INFO = {
+	MAPPER_SYS_TYPE:		( 'Hard Drives',		'Hard Drive',		'BUG: source not defined' ),
+	MAPPER_VG_TYPE:			( 'Volume Group',		'Logical Volume',	'Physical Volume' ),
+	MAPPER_PT_TYPE:			( 'Partition Table',	'Partition',		'Disk' ),
+	MAPPER_MDRAID_TYPE:		( 'Software RAID',		'Volume',			'Disk' ),
+	MAPPER_ATARAID_TYPE:	( 'ATA-RAID',			'Volume', 			'Disk' ),
+	MAPPER_MULTIPATH_TYPE:	( 'Multipath', 			'Multipath',		'Path' ),
+	MAPPER_CRYPTO_TYPE:		( 'Encryption', 		'Volume',			'Device' ),
+	MAPPER_iSCSI_TYPE:		( 'iSCSI',				'Volume',			'BUG: source not defined' )
+}
 
 def get_pretty_mapper_info(mapper_type):
-    try:
-        return PRETTY_MAPPER_INFO[mapper_type]
-    except:
-        return ('Mapper ' + mapper_type, mapper_type + '\s target', mapper_type + '\s source')
-
-PRETTY_PROP_NAMES = {'active'                  : "Active",
-                     'attrs'                   : 'Attributes',
-                     'bd'                      : "Block Device",
-                     'block_count'             : "Number of Blocks",
-                     'block_size'              : "Block Size",
-                     'bootable'                : "Bootable",
-                     'cluster_name'            : "Cluster Name",
-                     'clustered'               : "Clustered",
-                     'dir_index'               : "Use Hashed Binary Trees",
-                     'disklabel'               : "Partition Table Type",
-                     'extents_free'            : "Free Extents",
-                     'extent_size'             : "Extent Size",
-                     'extents_total'           : "Total Extents",
-                     'extents_used'            : "Used Extents",
-                     'failed'                  : "Failed",
-                     'format'                  : "Format",
-                     'fstab'                   : "List in /etc/fstab",
-                     'fstabpoint'              : "/etc/fstab Mountpoint",
-                     'gfs_fsname'              : "Unique GFS Name",
-                     'has_journal'             : "Journaling Enabled - ext3",
-                     'journals_num'            : "Number Of Journals",
-                     'journal_size'            : "Journal Size",
-                     'label'                   : "Label",
-                     'level'                   : "Level",
-                     'locking_protocol'        : "Locking Protocol",
-                     'lvname'                  : "Logical Volume Name",
-                     'max_lvs'                 : "Maximum Logical Volumes",
-                     'max_pvs'                 : "Maximum Physical Volumes",
-                     'max_sources'             : "Maximum Disks",
-                     'min_sources'             : "Minimum Disks",
-                     'mirrored'                : "Mirrored",
-                     'model'                   : "Model",
-                     'mount'                   : "Mount",
-                     'mountable'               : "Mountable",
-                     'mountpoint'              : "Mountpoint",
-                     'num_devices'             : "Number of Devices",
-                     'num_spares'              : "Number of Spares",
-                     'partition_begin'         : "Partition Begin",
-                     'partition_num'           : "Partition Number",
-                     'partition_type'          : "Partition Type",
-                     'path'                    : "Path",
-                     'raid'                    : "Raid",
-                     'raid_level'              : "Raid Level",
-                     'removable'               : "Removable",
-                     'scsi_bus'                : "SCSI Address",
-                     'scsi_id'                 : "SCSI ID",
-                     'size'                    : "Size",
-                     'size_free'               : "Unused",
-                     'snapshot'                : "Snapshot",
-                     'snapshot_origin'         : "Snapshot Origin",
-                     'snapshots'               : "Snapshots",
-                     'snapshot_usage_percent'  : "Snapshot Usage",
-                     'state'                   : "State",
-                     'swapon'                  : "Active Swap",
-                     'type'                    : "Type",
-                     'uuid'                    : "UUID",
-                     'vendor'                  : "Vendor",
-                     'vgname'                  : "Volume Group Name"}
-
-def get_pretty_prop_name(name):
-    try:
-        return PRETTY_PROP_NAMES[name]
-    except:
-        return name
-
-PRETTY_FS_NAMES = {'ext'      : "Linux Extended FS",
-                   'swap'     : "Swap",
-                   'gfs1'     : "GFS1 - Global FS v.1",
-                   'gfs2'     : "GFS2 - Global FS v.2",
-                   'minix'    : "Minix FS",
-                   'ufs'      : "Unix Fast FS",
-                   'xfs'      : "SGI XFS",
-                   'isofs'    : "ISO 9660 CD-ROM FS",
-                   'cramfs'   : "Cram FS",
-                   'raiserfs' : "Reiser FS",
-                   'jffs'     : "Journalled Flash FS v.1",
-                   'jffs2'    : "Journalled Flash FS v.2",
-                   'squashfs' : "Squash FS",
-                   'vfat'     : "MS vfat FS",
-                   'msdos'    : "MS-DOS FS",
-                   'affs'     : "Amiga FS",
-                   'befs'     : "BeOS FS",
-                   'bfs'      : "SCO UnixWare BFS",
-                   'jfs'      : "Journaled Filesystem (JFS)",
-                   'efs'      : "efs",
-                   'freevxfs' : "Veritas Filesystem (VxFS)",
-                   'hfsplus'  : "Macintosh extended FS",
-                   'hfs'      : "Macintosh FS",
-                   'ncpfs'    : "ncpfs",
-                   'ocfs2'    : "Oracle Clustered FS v.2",
-                   'relayfs'  : "Relay FS",
-                   'udf'      : "Universal Disk Format"}
+	return PRETTY_MAPPER_INFO.get(mapper_type) or \
+			( 'Mapper ' + mapper_type, mapper_type + '\s target', mapper_type + '\s source' )
 
-def get_pretty_fs_name(name):
-    try:
-        return PRETTY_FS_NAMES[name]
-    except:
-        return name
+PRETTY_PROP_NAMES = {
+	'active':					'Active',
+	'attrs':					'Attributes',
+	'bd':						'Block Device',
+	'block_count':				'Number of Blocks',
+	'block_size':				'Block Size',
+	'bootable':					'Bootable',
+	'cluster_name':				'Cluster Name',
+	'clustered':				'Clustered',
+	'dir_index':				'Use Hashed Binary Trees',
+	'disklabel':				'Partition Table Type',
+	'extents_free':				'Free Extents',
+	'extent_size':				'Extent Size',
+	'extents_total':			'Total Extents',
+	'extents_used':				'Used Extents',
+	'failed':					'Failed',
+	'format':					'Format',
+	'fstab':					'List in /etc/fstab',
+	'fstabpoint':				'/etc/fstab Mountpoint',
+	'gfs_fsname':				'Unique GFS Name',
+	'has_journal':				'Journaling Enabled - ext3',
+	'journals_num':				'Number of Journals',
+	'journal_size':				'Journal Size',
+	'label':					'Label',
+	'level':					'Level',
+	'locking_protocol':			'Locking Protocol',
+	'lvname':					'Logical Volume Name',
+	'max_lvs':					'Maximum Logical Volumes',
+	'max_pvs':					'Maximum Physical Volumes',
+	'max_sources':				'Maximum Disks',
+	'min_sources':				'Minimum Disks',
+	'mirrored':					'Mirrored',
+	'model':					'Model',
+	'mount':					'Mount',
+	'mountable':				'Mountable',
+	'mountpoint':				'Mountpoint',
+	'num_devices':				'Number of Devices',
+	'num_spares':				'Number of Spares',
+	'partition_begin':			'Partition Begin',
+	'partition_num':			'Partition Number',
+	'partition_type':			'Partition Type',
+	'path':						'Path',
+	'raid':						'Raid',
+	'raid_level':				'Raid Level',
+	'removable':				'Removable',
+	'scsi_bus':					'SCSI Address',
+	'scsi_id':					'SCSI ID',
+	'size':						'Size',
+	'size_free':				'Unused',
+	'snapshot':					'Snapshot',
+	'snapshot_origin':			'Snapshot Origin',
+	'snapshots':				'Snapshots',
+	'snapshot_usage_percent':	'Snapshot Usage',
+	'state':					'State',
+	'swapon':					'Active Swap',
+	'type':						'Type',
+	'uuid':						'UUID',
+	'vendor':					'Vendor',
+	'vgname':					'Volume Group Name'
+}
 
+def get_pretty_prop_name(name):
+	return PRETTY_PROP_NAMES.get(name) or name
 
+PRETTY_FS_NAMES = {
+	'ext':			'Linux Extended FS',
+	'swap':			'Swap',
+	'gfs1':			'GFS1 - Global FS v.1',
+	'gfs2':			'GFS2 - Global FS v.2',
+	'minix':		'Minix FS',
+	'ufs':			'Unix Fast FS',
+	'xfs':			'SGI XFS',
+	'isofs':		'ISO 9660 CD-ROM FS',
+	'cramfs':		'Cram FS',
+	'reiserfs':		'Reiser FS',
+	'jffs':			'Journalled Flash FS v.1',
+	'jffs2':		'Journalled Flash FS v.2',
+	'squashfs':		'Squash FS',
+	'vfat':			'MS vfat FS',
+	'msdos':		'MS-DOS FS',
+	'affs':			'Amiga FS',
+	'befs':			'BeOS FS',
+	'bfs':			'SCO UnixWare BFS',
+	'jfs':			'Journaled Filesystem (JFS)',
+	'efs':			'efs',
+	'freevxfs':		'Veritas Filesystem (VxFS)',
+	'hfsplus':		'Macintosh extended FS',
+	'hfs':			'Macintosh FS',
+	'ncpfs':		'ncpfs',
+	'ocfs2':		'Oracle Clustered FS v.2',
+	'relayfs':		'Relay FS',
+	'udf':			'Universal Disk Format'
+}
 
+def get_pretty_fs_name(name):
+	return PRETTY_FS_NAMES.get(name) or name
 
 # icons
-
-MAPPER_ICONS = {MAPPER_SYS_TYPE         : ('',                          'icon_bd_ide.png',       ''),
-                MAPPER_VG_TYPE          : ('icon_mapper_VG.png',        'icon_bd_LV.png',        'icon_content_PV.png'),
-                MAPPER_PT_TYPE          : ('icon_mapper_PT.png',        'icon_bd_partition.png', ''),
-                MAPPER_MDRAID_TYPE      : ('icon_mapper_raid.png',      'icon_bd_raid.png',      ''),
-                MAPPER_ATARAID_TYPE     : ('icon_mapper_raid.png',      'icon_bd_raid.png',      ''),
-                MAPPER_MULTIPATH_TYPE   : ('icon_mapper_multipath.png', 'icon_bd_multipath.png', ''),
-                MAPPER_CRYPTO_TYPE      : ('icon_mapper_crypto.png',    'icon_bd_crypto.png',    ''),
-                MAPPER_iSCSI_TYPE       : ('',                          'icon_bd_net.png',       '')}
+MAPPER_ICONS = {
+	MAPPER_SYS_TYPE:		( '',							'icon_bd_ide.png',			''),
+	MAPPER_VG_TYPE:			( 'icon_mapper_VG.png',			'icon_bd_LV.png',			'icon_content_PV.png'),
+	MAPPER_PT_TYPE:			( 'icon_mapper_PT.png',			'icon_bd_partition.png',	''),
+	MAPPER_MDRAID_TYPE:		( 'icon_mapper_raid.png',		'icon_bd_raid.png',			''),
+	MAPPER_ATARAID_TYPE:	( 'icon_mapper_raid.png',		'icon_bd_raid.png',			''),
+	MAPPER_MULTIPATH_TYPE:	( 'icon_mapper_multipath.png',	'icon_bd_multipath.png',	''),
+	MAPPER_CRYPTO_TYPE:		( 'icon_mapper_crypto.png',		'icon_bd_crypto.png',		''),
+	MAPPER_iSCSI_TYPE:		( '',							'icon_bd_net.png',			'')
+}
 
 def get_mapper_icons(mapper_type):
-    try:
-        return MAPPER_ICONS[mapper_type]
-    except:
-        return ('', '', '')
-
+	return MAPPER_ICONS.get(mapper_type) or ('', '', '')
 
-def get_fs_icon(fstype):
-    # all fss have the same icon
-    return 'icon_content_FS.png'
+def get_fs_icon(dummy):
+	# all fss have the same icon
+	return 'icon_content_FS.png'
--- conga/luci/site/luci/Extensions/ricci_communicator.py	2007/07/12 22:35:40	1.29
+++ conga/luci/site/luci/Extensions/ricci_communicator.py	2007/09/24 21:19:42	1.30
@@ -21,10 +21,10 @@
 		self.__hostname = hostname
 		self.__port = port
 
-		self.__timeout_init  = 4
-		self.__timeout_auth  = 4
+		self.__timeout_init = 4
+		self.__timeout_auth = 4
 		self.__timeout_short = 6
-		self.__timeout_long  = 600
+		self.__timeout_long = 600
 
 		self.__privkey_file = '%sprivkey.pem' % CERTS_DIR_PATH
 		self.__cert_file = '%scacert.pem' % CERTS_DIR_PATH
@@ -497,7 +497,7 @@
 		raise RicciError, 'Not an XML batch node'
 
 	total = 0
-	last  = 0
+	last = 0
 	for node in batch_xml.childNodes:
 		if node.nodeType == Node.ELEMENT_NODE:
 			if node.nodeName == 'module':
@@ -536,8 +536,8 @@
 #		 -1 - undefined error occured (msg not necesarily very informative)
 #		  0 - no error (msg is empty string)
 #		 >0 - predefined error has occured
-#						(check respective API, msg will be fully descriptive)
-# * error_msg:  error message
+#				(check respective API, msg will be fully descriptive)
+# * error_msg: error message
 
 def extract_module_status(batch_xml, module_num=1):
 	if batch_xml.nodeName != 'batch':
--- conga/luci/site/luci/Extensions/ricci_defines.py	2007/06/25 16:03:39	1.2
+++ conga/luci/site/luci/Extensions/ricci_defines.py	2007/09/24 21:19:42	1.3
@@ -5,74 +5,64 @@
 # GNU General Public License as published by the
 # Free Software Foundation.
 
-REQUEST_TAG   = 'request'
-RESPONSE_TAG  = 'response'
+REQUEST_TAG					= 'request'
+RESPONSE_TAG				= 'response'
 
-FUNC_CALL_TAG = 'function_call'
-FUNC_RESP_TAG = 'function_response'
-SEQUENCE_TAG  = 'sequence'
+FUNC_CALL_TAG				= 'function_call'
+FUNC_RESP_TAG				= 'function_response'
+SEQUENCE_TAG				= 'sequence'
+
+VARIABLE_TAG				= 'var'
+
+VARIABLE_TYPE_INT			= 'int'
+VARIABLE_TYPE_INT_SEL		= 'int_select'
+VARIABLE_TYPE_BOOL			= 'boolean'
+VARIABLE_TYPE_STRING		= 'string'
+VARIABLE_TYPE_STRING_SEL	= 'string_select'
+VARIABLE_TYPE_XML			= 'xml'
+
+VARIABLE_TYPE_LIST_INT		= 'list_int'
+VARIABLE_TYPE_LIST_STR		= 'list_str'
+VARIABLE_TYPE_LIST_XML		= 'list_xml'
+
+VARIABLE_TYPE_LISTENTRY		= 'listentry'
+VARIABLE_TYPE_FLOAT			= 'float'
+
+BD_TYPE						= 'block_device'
+BD_HD_TYPE					= 'hard_drive'
+BD_LV_TYPE					= 'logical_volume'
+BD_PARTITION_TYPE			= 'partition'
+
+BD_TEMPLATE					= 'block_device_template'
+
+MAPPER_TYPE					= 'mapper'
+MAPPER_SYS_TYPE				= 'hard_drives'
+MAPPER_VG_TYPE				= 'volume_group'
+MAPPER_PT_TYPE				= 'partition_table'
+MAPPER_MDRAID_TYPE			= 'mdraid'
+MAPPER_ATARAID_TYPE			= 'ataraid'
+MAPPER_MULTIPATH_TYPE		= 'multipath'
+MAPPER_CRYPTO_TYPE			= 'crypto'
+MAPPER_iSCSI_TYPE			= 'iSCSI'
+
+SYSTEM_PREFIX				= ':%s' % MAPPER_SYS_TYPE
+VG_PREFIX					= ':%s' % MAPPER_VG_TYPE
+PT_PREFIX					= ':%s' % MAPPER_PT_TYPE
+MDRAID_PREFIX				= ':%s' % MAPPER_MDRAID_TYPE
+
+MAPPER_SOURCES_TAG			= 'sources'
+MAPPER_TARGETS_TAG			= 'targets'
+MAPPER_MAPPINGS_TAG			= 'mappings'
+MAPPER_NEW_SOURCES_TAG		= 'new_sources'
+MAPPER_NEW_TARGETS_TAG		= 'new_targets'
+
+CONTENT_TYPE				= 'content'
+CONTENT_FS_TYPE				= 'filesystem'
+CONTENT_NONE_TYPE			= 'none'
+CONTENT_MS_TYPE				= 'mapper_source'
+CONTENT_HIDDEN_TYPE			= 'hidden'
 
-VARIABLE_TAG  = 'var'
+SOURCE_PV_TYPE				= 'physical_volume'
+SOURCE_PT_TYPE				= 'partition_table_source'
 
-VARIABLE_TYPE_INT        = 'int'
-VARIABLE_TYPE_INT_SEL    = 'int_select'
-VARIABLE_TYPE_BOOL       = 'boolean'
-VARIABLE_TYPE_STRING     = 'string'
-VARIABLE_TYPE_STRING_SEL = 'string_select'
-VARIABLE_TYPE_XML        = 'xml'
-
-VARIABLE_TYPE_LIST_INT   = 'list_int'
-VARIABLE_TYPE_LIST_STR   = 'list_str'
-VARIABLE_TYPE_LIST_XML   = 'list_xml'
-
-VARIABLE_TYPE_LISTENTRY  = 'listentry'
-VARIABLE_TYPE_FLOAT      = 'float'
-
-
-BD_TYPE				= 'block_device'
-BD_HD_TYPE			= 'hard_drive'
-BD_LV_TYPE			= 'logical_volume'
-BD_PARTITION_TYPE	= 'partition'
-
-BD_TEMPLATE			= 'block_device_template'
-
-
-MAPPER_TYPE           = 'mapper'
-MAPPER_SYS_TYPE       = 'hard_drives'
-MAPPER_VG_TYPE        = 'volume_group'
-MAPPER_PT_TYPE        = 'partition_table'
-MAPPER_MDRAID_TYPE    = 'mdraid'
-MAPPER_ATARAID_TYPE   = 'ataraid'
-MAPPER_MULTIPATH_TYPE = 'multipath'
-MAPPER_CRYPTO_TYPE    = 'crypto'
-MAPPER_iSCSI_TYPE     = 'iSCSI'
-
-
-SYSTEM_PREFIX = ':%s' % MAPPER_SYS_TYPE
-VG_PREFIX     = ':%s' % MAPPER_VG_TYPE
-PT_PREFIX     = ':%s' % MAPPER_PT_TYPE
-MDRAID_PREFIX = ':%s' % MAPPER_MDRAID_TYPE
-
-
-MAPPER_SOURCES_TAG = 'sources'
-MAPPER_TARGETS_TAG = 'targets'
-MAPPER_MAPPINGS_TAG = 'mappings'
-MAPPER_NEW_SOURCES_TAG = 'new_sources'
-MAPPER_NEW_TARGETS_TAG = 'new_targets'
-
-
-
-CONTENT_TYPE = 'content'
-CONTENT_FS_TYPE = 'filesystem'
-CONTENT_NONE_TYPE = 'none'
-CONTENT_MS_TYPE = 'mapper_source'
-CONTENT_HIDDEN_TYPE = 'hidden'
-
-
-
-SOURCE_PV_TYPE = 'physical_volume'
-SOURCE_PT_TYPE = 'partition_table_source'
-
-
-
-PROPS_TAG = 'properties'
+PROPS_TAG					= 'properties'
--- conga/luci/site/luci/Extensions/storage_adapters.py	2007/09/24 19:48:34	1.12
+++ conga/luci/site/luci/Extensions/storage_adapters.py	2007/09/24 21:19:42	1.13
@@ -136,7 +136,7 @@
 	srs_p['absolute_url'] = '%s?%s=%s&%s=%s&%s=%s' \
 		% (url, PAGETYPE, VIEW_MAPPERS, STONAME, hostname, PT_MAPPER_TYPE, mapper_type)
 	srs_p['Description'] = pretty_names_desc
-	if pagetype_req in [ VIEW_MAPPERS, VIEW_MAPPER, ADD_SOURCES, CREATE_MAPPER, VIEW_BD ] and mapper_type_req == mapper_type:
+	if pagetype_req in ( VIEW_MAPPERS, VIEW_MAPPER, ADD_SOURCES, CREATE_MAPPER, VIEW_BD ) and mapper_type_req == mapper_type:
 		srs_p['show_children'] = True
 	else:
 		srs_p['show_children'] = False
@@ -181,7 +181,7 @@
 			% (url, PAGETYPE, VIEW_MAPPER, STONAME, hostname, PT_MAPPER_TYPE, mapper_type, PT_MAPPER_ID, sr_id)
 		sr['Description'] = pretty_name_desc
 
-		if pagetype_req in [ VIEW_MAPPER, ADD_SOURCES, VIEW_BD ] and mapper_id_req == sr_id:
+		if pagetype_req in ( VIEW_MAPPER, ADD_SOURCES, VIEW_BD ) and mapper_id_req == sr_id:
 			sr['currentItem'] = True
 		else:
 			sr['currentItem'] = False



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

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2008-01-22 15:05:18

Modified files:
	luci/site/luci/Extensions: HelperFunctions.py LuciValidation.py 
	                           LuciZopeAsync.py LuciZopeExternal.py 
	                           cluster_adapters.py 
	                           homebase_adapters.py 

Log message:
	sync up with my local tree
	- fixes for 252348 and 230462

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/HelperFunctions.py.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciValidation.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeAsync.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeExternal.py.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.278&r2=1.279
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/homebase_adapters.py.diff?cvsroot=cluster&r1=1.55&r2=1.56

--- conga/luci/site/luci/Extensions/HelperFunctions.py	2008/01/15 04:41:40	1.13
+++ conga/luci/site/luci/Extensions/HelperFunctions.py	2008/01/22 15:05:17	1.14
@@ -9,8 +9,7 @@
 import threading
 
 def resolveOSType(os_str):
-	rhel5_clu_ver = [ 'Tikanga', 'Zod', 'Moonshine', 'Werewolf' ]
-	if not os_str or os_str in rhel5_clu_ver:
+	if not os_str or os_str.find('Tikanga') != (-1) or os_str.find('FC6') != (-1) or os_str.find('Zod') != (-1) or os_str.find('Moonshine') != (-1) or os_str.find('Werewolf') != (-1):
 		return 'rhel5'
 	else:
 		return 'rhel4'
@@ -18,6 +17,46 @@
 def add_commas(self, str1, str2):
 	return '%s; %s' % (str1, str2)
 
+class PWorker(threading.Thread):
+	# triple := [ host, function, *args ]
+	def __init__(self, mutex, ret, host_triples):
+		threading.Thread.__init__(self)
+		self.mutex = mutex
+		self.ret = ret
+		self.triples = host_triples
+
+	def run(self):
+		while True:
+			self.mutex.acquire()
+			if len(self.triples) == 0:
+				self.mutex.release()
+				return
+			triple = self.triples.pop()
+			self.mutex.release()
+
+			r = { 'ricci': None }
+
+			try:
+				rc = RicciCommunicator(triple[0], enforce_trust=False)
+				rc.trust()
+				r['ricci'] = rc
+
+				if triple[1] is not None:
+					if triple[2]:
+						args = list(triple[2])
+					else:
+						args = list()
+					args.insert(0, rc)
+					r['batch_result'] = triple[1](*args)
+			except Exception, e:
+				r['error'] = True
+				r['err_msg'] = str(e)
+				r['ricci'] = None
+
+			self.mutex.acquire()
+			self.ret[triple[0]] = r
+			self.mutex.release()
+
 class Worker(threading.Thread):
 	def __init__(self, mutex, hosts, riccis, func=None, *args):
 		threading.Thread.__init__(self)
@@ -39,7 +78,8 @@
 			r = { 'ricci': None }
 
 			try:
-				rc = RicciCommunicator(host)
+				rc = RicciCommunicator(host, enforce_trust=False)
+				rc.trust()
 				r['ricci'] = rc
 				try:
 					r['cluster_name'] = rc.cluster_info()[0]
@@ -55,7 +95,8 @@
 					r['batch_result'] = self.query_func(*args)
 			except Exception, e:
 				r['error'] = True
-				r['err_msg'] = '%s' % str(e)
+				r['err_msg'] = str(e)
+				r['ricci'] = None
 
 			self.mutex.acquire()
 			self.riccis[host] = r
@@ -73,6 +114,26 @@
 		num_hosts += 1
 		if num_hosts <= max_threads:
 			threads.append(Worker(mutex, hosts, ret, func, *args))
+
+	for thread in threads:
+		thread.start()
+	for thread in threads:
+		thread.join()
+	return ret
+
+def send_batch_parallel(triples, max_threads):
+	mutex = threading.RLock()
+	threads = list()
+	num_trips = 0
+	trips = list()
+	ret = {}
+
+	for trip in triples:
+		trips.append(trip)
+		num_trips += 1
+		if num_trips <= max_threads:
+			threads.append(PWorker(mutex, ret, triples))
+
 	for thread in threads:
 		thread.start()
 	for thread in threads:
@@ -111,7 +172,7 @@
 			cluname = ricci.cluster_info()[0]
 			cluali = ricci.cluster_info()[1]
 			authed = ricci.authed()
-			key_fp = ricci.fingerprint()
+			key_fp = ricci.fingerprint()[1]
 			trusted = ricci.trusted()
 		else:
 			OS = 'System not accessible'
@@ -124,7 +185,8 @@
 			'clualias'	: cluali,
 			'available'	: ricci is not None,
 			'trusted'	: trusted,
-			'authed'	: authed
+			'authed'	: authed,
+			'err_msg'	: ss[hostname].get('err_msg')
 		}
 
 		# replace ricci with system's info
--- conga/luci/site/luci/Extensions/LuciValidation.py	2008/01/17 16:36:30	1.4
+++ conga/luci/site/luci/Extensions/LuciValidation.py	2008/01/22 15:05:17	1.5
@@ -1189,3 +1189,66 @@
 		return (False, { 'errors': [ 'Error removing fence device %s: %s' \
 										% (fencedev_name, str(e)) ]})
 	return (True, { 'name': fencedev_name })
+
+def validate_auth(self, request):
+	from types import ListType
+	from ricci_communicator import RicciCommunicator
+	from HelperFunctions import send_batch_parallel
+
+	fvars = GetReqVars(request, [ 'numStorage' ])
+
+	num_storage = fvars['numStorage']
+	form = None
+	try:
+		form = request.form
+		if not form:
+			raise Exception, 'no form was submitted'
+		num_storage = int(num_storage)
+	except Exception, e:
+		return (False, { 'errors': [ 'Unable to determine the number of systems given' ] })
+
+	if num_storage < 0:
+		return (False, { 'errors': [ 'A negative number of systems was given' ] })
+	if num_storage < 1:
+		return (False, { 'errors': [ 'No systems were given' ] })
+
+	host_trips = []
+	for i in map(lambda x: '__SYSTEM%d' % x, xrange(num_storage)):
+		cur_system = form.get(i)
+		if not cur_system or type(cur_system) != ListType or not cur_system[0]:
+			continue
+		cur_system[0] = cur_system[0].strip()
+		if not cur_system[0]:
+			continue
+		host_trips.append((cur_system[0], RicciCommunicator.auth, [ cur_system[1] ]))
+
+	ret = send_batch_parallel(host_trips, 10)
+
+	ret_code = False
+	system_list = list()
+	for i in ret.keys():
+		r = { 'hostname': i }
+		try:
+			cur_system = ret[i]
+			rc = cur_system.get('ricci')
+			if rc:
+				r['available'] = True
+				r['authed'] = rc.authed()
+				r['trusted'] = rc.trusted()
+				r['hostname'] = rc.hostname()
+				r['os'] = rc.os()
+				r['system_name'] = rc.system_name()
+				r['cluname'] = rc.cluster_info()[0]
+				r['clualias'] = rc.cluster_info()[1]
+				r['key_fp'] = rc.fingerprint()[1]
+				ret_code = True
+			else:
+				r['hostname'] = i
+				r['available'] = False
+				r['authed'] = False
+				r['err_msg'] = cur_system['err_msg']
+		except Exception, e:
+			if LUCI_DEBUG_MODE is True:
+				luci_log.debug_verbose('VALAUTH0: %s: %r %s' % (i, e, str(e)))
+		system_list.append(r)
+	return (ret_code, {'clusternodes': system_list })
--- conga/luci/site/luci/Extensions/LuciZopeAsync.py	2008/01/02 21:00:31	1.5
+++ conga/luci/site/luci/Extensions/LuciZopeAsync.py	2008/01/22 15:05:17	1.6
@@ -99,7 +99,7 @@
 	fvars = GetReqVars(request, [ 'QUERY_STRING' ])
 	if fvars['QUERY_STRING'] is None:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('GCNA: No query string was given')
+			luci_log.debug_verbose('GCNA0: No query string was given')
 		write_err_async(request, 'No node names were given')
 		return None
 
@@ -126,10 +126,9 @@
 				continue
 		except Exception, e:
 			if LUCI_DEBUG_MODE is True:
-				luci_log.debug_verbose('GCNA0: ricci: %s: %r %s' \
+				luci_log.debug_verbose('GCNA1: ricci: %s: %r %s' \
 					% (node_host, e, str(e)))
-			errors.append('Unable to communicate with the ricci agent on %s' \
-				% node_host)
+			errors.append('Unable to communicate with the ricci agent on %s: %s' % (node_host, str(e)))
 			continue
 
 		try:
@@ -139,11 +138,11 @@
 				raise Exception, 'no nodes'
 		except Exception, e:
 			if LUCI_DEBUG_MODE is True:
-				luci_log.debug_verbose('GCNA1: ricci: %s: %r %s' \
+				luci_log.debug_verbose('GCNA2: ricci: %s: %r %s' \
 					% (node_host, e, str(e)))
-			errors.append('Unable to retrieve a list of cluster nodes from %s' \
-				% node_host)
+			errors.append('Unable to retrieve a list of cluster nodes from %s: %s' % (node_host, str(e)))
 			continue
+
 		ret[cluster_name] = {
 			'cluster': cluster_name,
 			'num_nodes': len(node_names),
@@ -158,9 +157,11 @@
 	from HelperFunctions import get_system_info
 
 	fvars = GetReqVars(request, [ 'QUERY_STRING' ])
+	query_str = fvars['QUERY_STRING']
+
 	try:
-		nodes = fvars['QUERY_STRING'].split('&')
-		node_list = map(lambda x: x[1], filter(lambda x: x[0][:4] == 'node', map(lambda x: x.split('='), nodes)))
+		nodes = query_str.split('&')
+		node_list = map(lambda x: (x[1], None), filter(lambda x: x[0][:4] == 'node', map(lambda x: x.split('='), nodes)))
 		if not node_list or len(node_list) < 1:
 			raise Exception, 'No node list'
 	except Exception, e:
@@ -174,15 +175,21 @@
 		ret = get_system_info(self, node_list)
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
-			luci_log.debug_verbose('GNFPA %r: %r %s' \
-				% (request['nodenames'], e, str(e)))
-		write_err_async(request, 'Error retrieving information')
+			luci_log.debug_verbose('GSIA1: %r %s' % (e, str(e)))
+		write_err_async(request, 'Error retrieving information: %s' % str(e))
 		return None
-	xml_obj = result_to_xml((True, { 'result': ret }))
+
+	xml_obj = result_to_xml((True, {'clusternodes':ret}))
+	write_xml_resp(request, xml_obj)
+
+def validate_auth_async(self, request):
+	from LuciValidation import validate_auth
+	ret = validate_auth(self, request)
+	xml_obj = result_to_xml(ret)
 	write_xml_resp(request, xml_obj)
 
 def validate_clusvc_async(self, request):
 	from LuciValidation import validate_clusvc_add
 	ret = validate_clusvc_add(self, request)
-	xml_obj = result_to_xml((True, { 'result': ret }))
+	xml_obj = result_to_xml(ret)
 	write_xml_resp(request, xml_obj)
--- conga/luci/site/luci/Extensions/LuciZopeExternal.py	2008/01/15 04:41:40	1.6
+++ conga/luci/site/luci/Extensions/LuciZopeExternal.py	2008/01/22 15:05:17	1.7
@@ -54,4 +54,5 @@
 
 from system_adapters import get_sys_svc_list, validate_manage_svc
 
-from LuciZopeAsync import get_cluster_nodes_async, get_sysinfo_async, validate_clusvc_async
+from LuciZopeAsync import get_cluster_nodes_async, get_sysinfo_async, \
+	validate_clusvc_async
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2008/01/14 20:51:42	1.278
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2008/01/22 15:05:17	1.279
@@ -15,7 +15,8 @@
 from homebase_adapters import parseHostForm
 from LuciClusterActions import propagateClusterConfAsync
 
-from LuciZopeAsync import validate_clusvc_async
+from LuciZopeAsync import validate_clusvc_async, get_sysinfo_async, \
+	validate_auth_async
 
 from LuciClusterInfo import getClusterInfo, \
 	getModelBuilder, LuciExtractCluModel
@@ -1207,7 +1208,9 @@
 	60: validate_xvm_key_dist,
 	61: validate_stop_waiting,
 	80: process_cluster_conf_editor,
-	1001: validate_clusvc_async 
+	1001: validate_clusvc_async,
+	1002: get_sysinfo_async,
+	1003: validate_auth_async,
 }
 
 def validatePost(self, request):
--- conga/luci/site/luci/Extensions/homebase_adapters.py	2008/01/15 04:41:40	1.55
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2008/01/22 15:05:18	1.56
@@ -240,10 +240,10 @@
 				request.SESSION.set('add_cluster_initial', cur_entry)
 				luci_log.info('SECURITY: %s' % errmsg)
 				return (False, { 'errors': [ errmsg ] })
-			if trust_shown is True and cur_host_trusted is False:
-				errmsg = 'You must elect to trust "%s" or abort the addition of the cluster to Luci.' % cur_host
-				request.SESSION.set('add_cluster_initial', cur_entry)
-				return (False, { 'errors': [ errmsg ] })
+#			if trust_shown is True and cur_host_trusted is False:
+#				errmsg = 'You must elect to trust "%s" or abort the addition of the cluster to Luci.' % cur_host
+#				request.SESSION.set('add_cluster_initial', cur_entry)
+#				return (False, { 'errors': [ errmsg ] })
 			rc.trust()
 		except Exception, e:
 			if LUCI_DEBUG_MODE is True:
@@ -532,6 +532,7 @@
 	except:
 		pass
 
+	cluster_name = '[unknown]'
 	try:
 		cluster_name = request.form['clustername'].strip()
 	except:
@@ -539,6 +540,7 @@
 			luci_log.debug_verbose('VAC0: no cluster name')
 		errors.append('No cluster name was given.')
 
+	cluster_os = '[unknown]'
 	try:
 		cluster_os = request.form['cluster_os'].strip()
 	except:
@@ -617,7 +619,7 @@
 
 				if cur_cluster_name:
 					err_msg = 'Node %s reports it is in cluster "%s" and we expect "%s"' \
-						% (cur_host, cur_cluster_name % cluster_name)
+						% (cur_host, cur_cluster_name, cluster_name)
 				else:
 					err_msg = 'Node %s reports it is not a member of any cluster' % cur_host
 



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

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe at sourceware.org	2007-08-08 21:14:38

Modified files:
	luci/site/luci/Extensions: HelperFunctions.py LuciClusterInfo.py 
	                           LuciZope.py LuciZopeExternal.py 
	                           RicciQueries.py cluster_adapters.py 
	                           conga_constants.py 
	                           homebase_adapters.py 
Added files:
	luci/site/luci/Extensions: LuciZopeAsync.py 

Log message:
	Fix 230451, pass 2
	- luci backend support for managing fence_xvm keys, pass 1

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeAsync.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/HelperFunctions.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.4&r2=1.4.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterInfo.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.4.6&r2=1.1.4.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZope.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.4.2&r2=1.1.4.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZopeExternal.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.4.1&r2=1.1.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/RicciQueries.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.4.5&r2=1.1.4.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.120.2.35&r2=1.120.2.36
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.19.2.13&r2=1.19.2.14
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.13&r2=1.34.2.14

/cvs/cluster/conga/luci/site/luci/Extensions/LuciZopeAsync.py,v  -->  standard output
revision 1.1.2.1
--- conga/luci/site/luci/Extensions/HelperFunctions.py	2007/06/27 06:19:22	1.4.2.4
+++ conga/luci/site/luci/Extensions/HelperFunctions.py	2007/08/08 21:14:38	1.4.2.5
@@ -40,6 +40,10 @@
 			try:
 				rc = RicciCommunicator(host)
 				r['ricci'] = rc
+				try:
+					r['cluster_name'] = rc.cluster_info()[0]
+				except:
+					pass
 
 				if self.query_func is not None:
 					if self.query_args:
--- conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/07/27 22:07:54	1.1.4.6
+++ conga/luci/site/luci/Extensions/LuciClusterInfo.py	2007/08/08 21:14:38	1.1.4.7
@@ -1609,3 +1609,12 @@
 		clu_map['os'] = 'rhel5'
 		clu_map['isVirtualized'] = False
 	return clu_map
+
+def getClusterConfNodes(conf_dom):
+	try:
+		cluster_nodes = conf_dom.getElementsByTagName('clusternode')
+		return map(lambda x: str(x.getAttribute('name')), cluster_nodes)
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('GCCN0: %r %s' % (e, str(e)))
+	return None
--- conga/luci/site/luci/Extensions/LuciZope.py	2007/07/26 05:32:38	1.1.4.2
+++ conga/luci/site/luci/Extensions/LuciZope.py	2007/08/08 21:14:38	1.1.4.3
@@ -126,15 +126,21 @@
 
 def GetReqVars(req, varlist):
 	ret = {}
+	from types import ListType;
+
 	for i in varlist:
 		pval = None
 		if req and req.has_key(i):
-			pval = req[i].strip()
+			pval = req[i]
+			if type(req[i]) is not ListType:
+				pval = req[i].strip()
 			if not pval:
 				pval = None
 		if req and pval is None:
 			if req.form and req.form.has_key(i):
-				pval = req.form[i].strip()
+				pval = req.form[i]
+				if type(req.form[i]) is not ListType:
+					pval.strip()
 				if not pval:
 					pval = None
 		ret[i] = pval
--- conga/luci/site/luci/Extensions/LuciZopeExternal.py	2007/06/18 18:39:32	1.1.4.1
+++ conga/luci/site/luci/Extensions/LuciZopeExternal.py	2007/08/08 21:14:38	1.1.4.2
@@ -49,3 +49,5 @@
 	get_mappings_info, get_storage_batch_result, get_storage_report, \
 	group_systems_by_cluster, is_storage_report_cached, validate, \
 	get_content_data
+
+from LuciZopeAsync import get_cluster_nodes_async, get_sysinfo_async
--- conga/luci/site/luci/Extensions/RicciQueries.py	2007/07/27 21:17:41	1.1.4.5
+++ conga/luci/site/luci/Extensions/RicciQueries.py	2007/08/08 21:14:38	1.1.4.6
@@ -721,3 +721,8 @@
 	if LUCI_DEBUG_MODE is True:
 		luci_log.debug_verbose('GCC2: no conf node found')
 	return None
+
+def set_xvm_key(rc, key_base64):
+	batch_str = '<module name="cluster"><request API_version="1.0"><function_call name="set_xvm_key"><var mutable="false" name="key_base64" type="string" value="%s"/></function_call></request></module>' % key_base64
+	ricci_xml = rc.batch_run(batch_str)
+	return batchAttemptResult(ricci_xml)
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/07/27 19:11:32	1.120.2.35
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/08/08 21:14:38	1.120.2.36
@@ -21,12 +21,14 @@
 from ClusterModel.Method import Method
 
 import RicciQueries as rq
-from HelperFunctions import resolveOSType
+from HelperFunctions import resolveOSType, send_batch_to_hosts
 from LuciSyslog import get_logger
 from ResourceHandler import create_resource
 from homebase_adapters import parseHostForm
 from LuciClusterActions import propagateClusterConfAsync
 
+from LuciZopeAsync import get_cluster_nodes_async
+
 from LuciClusterInfo import getClusterInfo, \
 	getModelBuilder, LuciExtractCluModel
 
@@ -41,7 +43,7 @@
 	PRE_JOIN, REBOOT_TASK, REDIRECT_MSG, RESOURCES, RICCI_CONNECT_FAILURE, \
 	RICCI_CONNECT_FAILURE_MSG, SEND_CONF, SERVICE_ADD, SERVICE_CONFIG, \
 	SERVICE_LIST, SERVICES, START_NODE, TASKTYPE, VM_ADD, VM_CONFIG, \
-	REDIRECT_SEC, LUCI_CLUSTER_BASE_URL
+	REDIRECT_SEC, LUCI_CLUSTER_BASE_URL, FENCE_XVM_KEY_CREATE
 
 from FenceHandler import validateNewFenceDevice, \
 	validateFenceDevice, validate_fenceinstance, FD_VAL_SUCCESS
@@ -2125,6 +2127,56 @@
 	request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&busyfirst=true' \
 		% (baseurl, SERVICES, clustername))
 
+def validate_xvm_key_dist(self, request):
+	fvars = GetReqVars(request, [ '__NODE_HOSTNAME__', 'URL', 'clustername' ])
+
+	clustername = fvars['clustername']
+	if clustername is None:
+		return (False, { 'errors': [ 'No cluster name was given' ]})
+
+	host_list = fvars['__NODE_HOSTNAME__']
+	if not host_list:
+		return (False, { 'errors': [ 'No cluster node addresses were given' ]})
+
+	baseurl = fvars['URL'] or LUCI_CLUSTER_BASE_URL
+
+	try:
+		import base64
+		f = open('/dev/urandom', 'r')
+		new_key = f.read(4096)
+		f.close()
+		new_key = base64.encodestring(new_key)
+		if not new_key:
+			raise Exception, 'base64 encode failed'
+		new_key = new_key.replace('\n', '')
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('VXKD0: /dev/urandom: %r %s' % (e, str(e)))
+		return (False, { 'errors': [ 'Unable to create a new fence_xvm key' ]})
+
+	errors = list()
+	ret = send_batch_to_hosts(host_list, 10, rq.set_xvm_key, new_key)
+	del new_key
+
+	for i in ret.iterkeys():
+		batch_num = None
+		batch_res = None
+
+		if ret[i].has_key('batch_result'):
+			batch_num, batch_res = ret[i]['batch_result']
+
+		if batch_num is None or batch_res is None:
+			errors.append('fence_xvm key creation failed for node "%s"' % i)
+			if LUCI_DEBUG_MODE is True:
+				luci_log.info('Setting fence_xvm key for node "%s" failed' % i)
+			continue
+
+		set_node_flag(self, clustername, i, batch_num,
+			FENCE_XVM_KEY_CREATE, 'Creating a fence_xvm key file')
+
+	request.RESPONSE.redirect('%s?pagetype=%s&clustername=%s&tab=2&busyfirst=true' \
+		% (baseurl, CLUSTER_CONFIG, clustername))
+
 def process_cluster_conf_editor(self, req):
 	if req.has_key('clustername'):
 		clustername = req['clustername'].strip() or None
@@ -2203,6 +2255,7 @@
 	55: validateDaemonProperties,
 	57: deleteFenceDevice,
 	58: validateNodeFenceConfig,
+	60: validate_xvm_key_dist,
 	80: process_cluster_conf_editor
 }
 
--- conga/luci/site/luci/Extensions/conga_constants.py	2007/07/26 04:20:59	1.19.2.13
+++ conga/luci/site/luci/Extensions/conga_constants.py	2007/08/08 21:14:38	1.19.2.14
@@ -54,6 +54,7 @@
 FENCEDEV_DELETE			= '57'
 FENCEDEV_NODE_CONFIG	= '58'
 SERVICE_MIGRATE			= '59'
+FENCE_XVM_KEY_CREATE	= '60'
 CONF_EDITOR				= '80'
 SYS_SERVICE_MANAGE		= '90'
 SYS_SERVICE_UPDATE		= '91'
--- conga/luci/site/luci/Extensions/homebase_adapters.py	2007/06/18 18:39:33	1.34.2.13
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2007/08/08 21:14:38	1.34.2.14
@@ -17,6 +17,8 @@
 	manageCluster, \
 	CLUSTER_NODE_NEED_AUTH
 
+from LuciClusterInfo import getClusterConfNodes
+
 from LuciZopePerm import havePermAddCluster, havePermRemCluster, \
 	havePermAddUser, havePermDelUser, havePermEditPerms, \
 	havePermRemStorage, havePermAddStorage
@@ -39,7 +41,7 @@
 	errors = list()
 	messages = list()
 
-	if '__SYSTEM' in request.form:
+	if request.form.has_key('__SYSTEM'):
 		system_names = request.form['__SYSTEM']
 		for i in system_names:
 			if not i:
@@ -50,7 +52,7 @@
 			else:
 				messages.append('Removed storage system "%s" successfully' % i)
 
-	if '__CLUSTER' in request.form:
+	if request.form.has_key('__CLUSTER'):
 		cluster_names = request.form['__CLUSTER']
 		for i in cluster_names:
 			if not i:
@@ -70,9 +72,8 @@
 	if not request.form.has_key('deluserId'):
 		return (False, { 'errors': [ 'No User ID given' ] })
 
-	userId = request.form['deluserId']
-
 	try:
+		userId = request.form['deluserId'].strip()
 		user = self.portal_membership.getMemberById(userId)
 		if not user:
 			raise Exception, 'user %s does not exist' % userId
@@ -117,8 +118,10 @@
 
 	if not request.form.has_key('newUserName'):
 		return (False, { 'errors': [ 'No user name given' ] })
+
 	if not request.form.has_key('newPassword'):
 		return (False, { 'errors': [ 'No password given' ] })
+
 	if not request.form.has_key('newPasswordConfirm'):
 		return (False, { 'errors': [ 'You didn\'t confirm the password' ] })
 
@@ -133,12 +136,21 @@
 	if passwd != pwconfirm:
 		return (False, { 'errors': [ 'The passwords given do not match' ]})
 
+	user_props = {
+		'username': user,
+		'password': passwd,
+		'confirm': passwd,
+		'roles': [ 'Member' ],
+		'domains': [],
+		'email': '%s at conga.example.com' % user
+	}
+
 	try:
-		self.portal_registration.addMember(user, passwd, properties = { 'username': user, 'password': passwd, 'confirm': passwd, 'roles': [ 'Member' ], 'domains': [], 'email': '%s at conga.example.com' % user })
+		self.portal_registration.addMember(user, passwd, properties=user_props)
 	except Exception, e:
 		if LUCI_DEBUG_MODE is True:
 			luci_log.debug_verbose('VAU0: %s: %r %s' % (user, e, str(e)))
-		return (False, { 'errors': [ 'Unable to add new user "%s"' % user ] })
+		return (False, { 'errors': [ 'Unable to add new user "%s": %s ' % (user, str(e)) ] })
 
 	if not self.portal_membership.getMemberById(user):
 		return (False, { 'errors': [ 'Unable to add new user "%s"' % user ] })
@@ -542,11 +554,13 @@
 	except:
 		pass_num = 1
 
-	add_cluster = { 'name': cluster_name,
-					'pass': pass_num,
-					'cluster_os': cluster_os,
-					'identical_passwds': same_node_passwds,
-					'check_certs': check_certs }
+	add_cluster = {
+		'name': cluster_name,
+		'pass': pass_num,
+		'cluster_os': cluster_os,
+		'identical_passwds': same_node_passwds,
+		'check_certs': check_certs
+	}
 
 	system_list, incomplete, new_errors, messages = parseHostForm(request, check_certs)
 	errors.extend(new_errors)
@@ -1285,7 +1299,3 @@
 				if LUCI_DEBUG_MODE is True:
 					luci_log.debug_verbose('getUserPerms2: user %s, obj %s: %r %s' % (userName, s[0], e, str(e)))
 	return perms
-
-def getClusterConfNodes(conf_dom):
-	cluster_nodes = conf_dom.getElementsByTagName('clusternode')
-	return map(lambda x: str(x.getAttribute('name')), cluster_nodes)



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

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	EXPERIMENTAL
Changes by:	rmccabe at sourceware.org	2007-05-04 19:10:24

Modified files:
	luci/site/luci/Extensions: HelperFunctions.py LuciDB.py 
	                           PropsObject.py StorageReport.py 
	                           Variable.py cluster_adapters.py 
	                           conga_constants.py conga_ssl.py 
	                           homebase_adapters.py 
	                           ricci_communicator.py 
	                           storage_adapters.py 
Added files:
	luci/site/luci/Extensions: LuciZope.py 
Removed files:
	luci/site/luci/Extensions: NodeData.py 

Log message:
	Cleanup/refactor, part 2

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZope.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/HelperFunctions.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.6.4.1&r2=1.6.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciDB.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.1&r2=1.1.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2&r2=1.2.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.23.2.1&r2=1.23.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/Variable.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.4.8.1&r2=1.4.8.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.255.2.1&r2=1.255.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.39.2.1&r2=1.39.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_ssl.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2&r2=1.2.4.1
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.1&r2=1.50.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.25.2.1&r2=1.25.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/storage_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.9.4.1&r2=1.9.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/NodeData.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1&r2=NONE

--- conga/luci/site/luci/Extensions/HelperFunctions.py	2007/05/03 20:16:38	1.6.4.1
+++ conga/luci/site/luci/Extensions/HelperFunctions.py	2007/05/04 19:10:24	1.6.4.2
@@ -1,236 +1,135 @@
-from AccessControl import getSecurityManager
-from ricci_communicator import RicciCommunicator, CERTS_DIR_PATH
-from conga_constants import PLONE_ROOT
+from ricci_communicator import RicciCommunicator
 import threading
 
-def siteIsSetup(self):
-	import os
-	try:
-		return os.path.isfile('%sprivkey.pem' % CERTS_DIR_PATH) and os.path.isfile('%scacert.pem' % CERTS_DIR_PATH)
-	except:
-		pass
-	return False
-
-def strFilter(regex, replaceChar, arg):
-	import re
-	return re.sub(regex, replaceChar, arg)
-
-def userAuthenticated(self):
-	try:
-		if (isAdmin(self) or getSecurityManager().getUser().has_role('Authenticated', self.restrictedTraverse(PLONE_ROOT))):
-			return True
-	except Exception, e:
-		luci_log.debug_verbose('UA0: %s' % str(e)) 
-	return False
-
-def isAdmin(self):
-	try:
-		return getSecurityManager().getUser().has_role('Owner', self.restrictedTraverse(PLONE_ROOT))
-	except Exception, e:
-		luci_log.debug_verbose('IA0: %s' % str(e)) 
-	return False
-
-def userIsAdmin(self, userId):
-	try:
-		return self.portal_membership.getMemberById(userId).has_role('Owner', self.restrictedTraverse(PLONE_ROOT))
-	except Exception, e:
-		luci_log.debug_verbose('UIA0: %s: %s' % (userId, str(e)))
-	return False
-
 def resolveOSType(os_str):
-	if not os_str or os_str.find('Tikanga') != (-1) or os_str.find('FC6') != (-1) or os_str.find('Zod') != (-1):
+	if not os_str or os_str.find('Tikanga') != (-1) or os_str.find('FC6') != (-1) or os_str.find('Zod') != (-1) or os_str.find('Fedora release 6.9') != (-1):
 		return 'rhel5'
 	else:
 		return 'rhel4'
 
 def add_commas(self, str1, str2):
-  return '%s; %s' % (str1, str2)
-
-def allowed_systems(self, user, systems):
-  allowed = []
-  sm = getSecurityManager()
-  user = sm.getUser()
-  for system in systems:
-    #Does this take too long?
-    if user.has_permission('View', system[1]):
-      allowed.append(system)
-  return allowed
-
-def access_to_host_allowed(self, hostname, allowed_systems_list):
-  for system in allowed_systems_list:
-    if system[0] == hostname:
-      if len(self.allowed_systems(None, [system])) == 1:
-          return True
-      else:
-          return False
-  return False
-
-
+	return '%s; %s' % (str1, str2)
 
 class Worker(threading.Thread):
-    def __init__(self,
-                 mutex,
-                 hosts,
-                 riccis):
-        threading.Thread.__init__(self)
-        self.mutex = mutex
-        self.hosts = hosts
-        self.riccis = riccis
-        return
-    def run(self):
-        while True:
-            self.mutex.acquire()
-            if len(self.hosts) == 0:
-                self.mutex.release()
-                return
-            host = self.hosts.pop()
-            self.mutex.release()
-            r = None
-            try:
-                r = RicciCommunicator(host)
-                #print host, 'done'
-            except Exception, e:
-                #print host, 'failed', str(e)
-                pass
-            except:
-                #print host, 'failed'
-                pass
-            self.mutex.acquire()
-            self.riccis[host] = r
-            self.mutex.release()
-        
-        
-                 
-# removes systems that user is not authorized access to
-def get_systems_statuses(self, systems, from_cache=False):
-    CACHED_INDEX = '_get_systems_statuses()_cached_result_'
-    session = self.REQUEST.SESSION
-    if session.has_key(CACHED_INDEX):
-        res = session[CACHED_INDEX]
-        if res != None:
-            session.set(CACHED_INDEX, None)
-            if from_cache:
-                return res
-        pass
-    
-    ass = self.allowed_systems(self, None, systems)
-    
-    mutex = threading.RLock()
-    hive  = [] # workers
-    ss    = {} # storage systems (will store riccis, and then use them to retrieve real info)
-    hosts = [] # hostnames
-    for system in ass:
-        hosts.append(system[0])
-        if len(hosts) < 10:
-            hive.append(Worker(mutex, hosts, ss))
-    
-    for bee in hive:
-        bee.start()
-    for bee in hive:
-        bee.join()
-    
-    for hostname in ss.keys():
-        OS = ''
-        cluname = ''
-        cluali = ''
-        authed = False
-        ricci = ss[hostname]
-        if ricci != None:
-            OS = ricci.os()
-            cluname = ricci.cluster_info()[0]
-            cluali = ricci.cluster_info()[1]
-            authed = ricci.authed()
-        else:
-            OS = 'System not accessible'
-        s = {'hostname' : hostname,
-             'OS'       : OS,
-             'cluname'  : cluname,
-             'clualias' : cluali, 
-             'available': ricci != None,
-             'authed'   : authed}
-        # replace ricci with system's info
-        ss[hostname] = s
-        pass
-    ss_list = []
-    sorted_keys = ss.keys()
-    sorted_keys.sort()
-    for name in sorted_keys:
-        ss_list.append(ss[name])
-    
-    session.set(CACHED_INDEX, ss_list)
-    
-    return ss_list
-
-
-
-
-def set_persistant_var(self,
-                       var_name,
-                       default_value):
-    request = self.REQUEST
-    response = request.RESPONSE
-    session = request.SESSION
-    
-    # TODO: add username into cookie_prefix, so users don't overwrite each other
-    cookie_prefix = '__luci_storage_cookie_'
-    
-    value = default_value
-    if request.has_key(var_name):
-        value = request[var_name]
-    elif session.has_key(var_name):
-        value = session[var_name]
-    elif request.cookies.has_key(cookie_prefix + var_name):
-        value = request.cookies[cookie_prefix + var_name]
-    
-    session.set(var_name,
-                value)
-    response.setCookie(cookie_prefix + var_name,
-                       value, 
-                       expires='Tue, 30 Jun 2060 12:00:00 GMT')
-    return value
-
-
+	def __init__(self, mutex, hosts, riccis):
+		threading.Thread.__init__(self)
+		self.mutex = mutex
+		self.hosts = hosts
+		self.riccis = riccis
+
+	def run(self):
+		while True:
+			self.mutex.acquire()
+			if len(self.hosts) == 0:
+				self.mutex.release()
+				return
+			host = self.hosts.pop()
+			self.mutex.release()
+			r = None
+
+			try:
+				r = RicciCommunicator(host)
+			except Exception, e:
+				#print host, 'failed', str(e)
+				pass
+			except:
+				#print host, 'failed'
+				pass
+
+			self.mutex.acquire()
+			self.riccis[host] = r
+			self.mutex.release()
+
+def get_system_info(self, system_list):
+	mutex = threading.RLock()
+	hive  = [] # workers
+	ss	= {} # storage systems (will store riccis and then use them to retrieve real info)
+	hosts = [] # hostnames
+
+	for system in system_list:
+		hosts.append(system[0])
+		if len(hosts) < 10:
+			hive.append(Worker(mutex, hosts, ss))
+
+	for bee in hive:
+		bee.start()
+
+	for bee in hive:
+		bee.join()
+
+	for hostname in ss.keys():
+		OS = ''
+		cluname = ''
+		cluali = ''
+		key_fp = ''
+		trusted = ''
+		authed = False
+		trusted = False
+		ricci = ss[hostname]
+
+		if ricci != None:
+			OS = ricci.os()
+			cluname = ricci.cluster_info()[0]
+			cluali = ricci.cluster_info()[1]
+			authed = ricci.authed()
+			key_fp = ricci.fingerprint()
+			trusted = ricci.trusted()
+		else:
+			OS = 'System not accessible'
+
+		s = {
+			'hostname'	: hostname,
+			'OS'		: OS,
+			'cluname'	: cluname,
+			'key_fp'	: key_fp, 
+			'clualias'	: cluali, 
+			'available'	: ricci != None,
+			'trusted'	: trusted,
+			'authed'	: authed
+		}
+
+		# replace ricci with system's info
+		ss[hostname] = s
+
+	ss_list = []
+	sorted_keys = ss.keys()
+	sorted_keys.sort()
+
+	for name in sorted_keys:
+		ss_list.append(ss[name])
+	return ss_list
 
+def convert_bytes(bytes, units):
+	c = int(bytes) / get_units_multiplier(units)
+	c = repr(c)
+	c = c[:c.find('.') + 3]
+	return c
 
 # returns (str(float), units) that fits best,
 # ignores prefered units
-def bytes_to_value_units(bytes):
-    units = 'TB'
-    if float(convert_bytes(bytes, 'GB')) < 1024:
-        units = 'GB'
-    if float(convert_bytes(bytes, 'MB')) < 1024:
-        units = 'MB'
-    if float(convert_bytes(bytes, 'KB')) < 1024:
-        units = 'KB'
-    if float(convert_bytes(bytes, 'bytes')) < 1024:
-        units = 'bytes'
-    return (convert_bytes(bytes, units), units)
 
-# returns (str(float), units) that fits best,
-# takes prefered units into account
-def bytes_to_value_prefunits(self, bytes):
-    p_units = self.REQUEST.SESSION.get('preferred_size_units')
-    dummy, units = bytes_to_value_units(bytes)
-    if get_units_multiplier(units) > get_units_multiplier(p_units):
-        units = p_units
-    return (convert_bytes(bytes, units), units)
+def bytes_to_value_units(bytes):
+	units = 'TB'
+	if float(convert_bytes(bytes, 'GB')) < 1024:
+		units = 'GB'
+	if float(convert_bytes(bytes, 'MB')) < 1024:
+		units = 'MB'
+	if float(convert_bytes(bytes, 'KB')) < 1024:
+		units = 'KB'
+	if float(convert_bytes(bytes, 'bytes')) < 1024:
+		units = 'bytes'
+	return (convert_bytes(bytes, units), units)
 
 def get_units_multiplier(units):
-    if units.lower() == 'bytes':
-        return 1.0
-    elif units.lower() == 'kb':
-        return 1024.0
-    elif units.lower() == 'mb':
-        return 1024*1024.0
-    elif units.lower() == 'gb':
-        return 1024*1024*1024.0
-    elif units.lower() == 'tb':
-        return 1024*1024*1024*1024.0
-    else:
-        raise Exception, 'invalid size unit'
-
-def convert_bytes(bytes, units):
-    c = int(bytes) / get_units_multiplier(units)
-    c = repr(c)
-    c = c[:c.find('.') + 3]
-    return c
+	if units.lower() == 'bytes':
+		return 1.0
+	elif units.lower() == 'kb':
+		return 1024.0
+	elif units.lower() == 'mb':
+		return 1024*1024.0
+	elif units.lower() == 'gb':
+		return 1024*1024*1024.0
+	elif units.lower() == 'tb':
+		return 1024*1024*1024*1024.0
+	else:
+		raise Exception, 'Invalid size unit: %s' % units
--- conga/luci/site/luci/Extensions/Attic/LuciDB.py	2007/05/03 20:16:38	1.1.2.1
+++ conga/luci/site/luci/Extensions/Attic/LuciDB.py	2007/05/04 19:10:24	1.1.2.2
@@ -2,7 +2,7 @@
 from conga_constants import CLUSTER_FOLDER_PATH, BATCH_ID, TASKTYPE, FLAG_DESC, CLUSTER_ADD, CLUSTER_NODE_ADDED, CLUSTER_NODE_NEED_AUTH, LAST_STATUS, PLONE_ROOT, STORAGE_FOLDER_PATH
 import RicciQuery as rq
 from ricci_communicator import RicciCommunicator
-from HelperFunctions import isAdmin
+from LuciZope import isAdmin
 
 from homebase_adapters import luci_log
 
--- conga/luci/site/luci/Extensions/PropsObject.py	2006/10/16 04:26:19	1.2
+++ conga/luci/site/luci/Extensions/PropsObject.py	2007/05/04 19:10:24	1.2.8.1
@@ -18,7 +18,6 @@
             return self.__vars[name].get_value()
         else:
             return None
-        pass
     
     def get_props(self):
         return self.__vars
--- conga/luci/site/luci/Extensions/StorageReport.py	2007/05/03 20:16:38	1.23.2.1
+++ conga/luci/site/luci/Extensions/StorageReport.py	2007/05/04 19:10:24	1.23.2.2
@@ -9,6 +9,8 @@
 from conga_storage_constants import *
 from HelperFunctions import *
 
+from LuciZope import bytes_to_value_prefunits, get_systems_statuses
+
 from ricci_communicator import get_ricci_communicator, batch_status, extract_module_status
 
 
@@ -203,11 +205,6 @@
         return None
     
     
-    pass
-
-
-
-
 def is_storage_report_cached(session, storagename):
     if session.has_key(SESSION_STORAGE_XML_REPORT):
         reports_dir = session[SESSION_STORAGE_XML_REPORT]
@@ -594,12 +591,6 @@
     
     mdata['targets_all'] = targets_all
     
-    pass
-
-
-
-
-
 def get_mapper_template_data(self, storage_report, mapper_type):
     if self == None or storage_report == None or mapper_type == None:
         return None
@@ -719,7 +710,6 @@
         if sources_num < int(data['min_sources']) or sources_num > int(data['max_sources']):
             return 'BAD: Invalid number of %s selected' % data['pretty_sources_name']
         props = data['props']
-        pass
     elif object_type == 'add_sources':
         data = get_mapper_data(self, storage_report, mapper_id)
         # find sources
@@ -730,8 +720,7 @@
                     sources_num += 1
         if sources_num == 0 or sources_num > len(data['new_sources']):
             return 'BAD: Invalid number of %s selected' % data['pretty_sources_name']
-        pass
-    
+
     if props != None:
         res = check_props(self, props, request)
         if res[0] == False:
@@ -863,7 +852,6 @@
             
             res = ricci.process_batch(batch, True)
             batch_id = res.getAttribute('batch_id')
-            pass
         
         
         elif action_type == 'Apply':
@@ -985,8 +973,6 @@
             
             res = ricci.process_batch(batch, True)
             batch_id = res.getAttribute('batch_id')
-            pass
-        
     
     
     elif object_type == 'bd_template':
@@ -1115,7 +1101,6 @@
             
             res = ricci.process_batch(batch, True)
             batch_id = res.getAttribute('batch_id')
-            pass
         
     
     
@@ -1142,7 +1127,6 @@
             
             res = ricci.process_batch(batch, True)
             batch_id = res.getAttribute('batch_id')
-            pass
         
         
         elif action_type == 'Apply':
@@ -1197,8 +1181,7 @@
             
             res = ricci.process_batch(batch, True)
             batch_id = res.getAttribute('batch_id')
-            pass
-        
+
     
     
     elif object_type == 'mapper_template':
@@ -1270,7 +1253,6 @@
             
             res = ricci.process_batch(batch, True)
             batch_id = res.getAttribute('batch_id')
-            pass
         
     
     
@@ -1311,8 +1293,6 @@
             
             res = ricci.process_batch(batch, True)
             batch_id = res.getAttribute('batch_id')
-            pass
-        pass
     
     
     if batch_id == '':
@@ -1496,7 +1476,6 @@
             vars[var.get_name()] = var
         except:
             pass
-        pass
     
     
     mapper_id   = ''
@@ -1724,7 +1703,6 @@
         if not mutable and d_type != 'label' and d_type != 'hidden':
             d_type = 'label'
             d_value = str(value)
-            pass
         
         hidden = False
         if type == 'hidden' or name in ['partition_begin', 'snapshot']:
@@ -1742,7 +1720,6 @@
                           'units'       : d_units,
                           'validation'  : validation_data,
                           'hidden'      : hidden}
-        pass
     
     return (removable, data)
 
@@ -1915,7 +1892,6 @@
         name = 'Extended Partition'
     else:
         name = "Unknown type"
-        pass
     
     return name, id
 
--- conga/luci/site/luci/Extensions/Variable.py	2007/05/03 20:16:38	1.4.8.1
+++ conga/luci/site/luci/Extensions/Variable.py	2007/05/04 19:10:24	1.4.8.2
@@ -77,7 +77,6 @@
 
 
 class Variable:
-    
     def __init__(self, name, value, mods={}):
         self.__name = str(name)
         self.__mods = mods
@@ -88,6 +87,7 @@
     
     def get_value(self):
         return self.__value
+
     def set_value(self, value):
         if self.__is_bool(value):
             self.__type = VARIABLE_TYPE_BOOL
@@ -223,8 +223,8 @@
     
         
 class VariableList(Variable):
-    
     def __init__(self, name, value, mods, list_type):
+        Variable.__init__(name, value, mods=mods)
         if list_type != VARIABLE_TYPE_LIST_STR and list_type != VARIABLE_TYPE_LIST_XML:
             raise Exception, 'invalid list type'
         #if ! self.__is_list(value):
@@ -233,7 +233,6 @@
         self.__mods = mods
         self.__type = list_type
         self.__value = value
-        pass
     
     def get_name(self):
         return self.__name
@@ -268,6 +267,3 @@
         for mod in self.__mods:
             elem.setAttribute(str(mod), str(self.__mods[mod]))
         return elem
-    
-    
-    
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/05/03 20:16:38	1.255.2.1
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/05/04 19:10:24	1.255.2.2
@@ -25,7 +25,11 @@
 from FenceHandler import validateNewFenceDevice, FENCE_OPTS, validateFenceDevice, validate_fenceinstance, FD_VAL_FAIL, FD_VAL_SUCCESS
 
 from system_adapters import validate_svc_update
-from homebase_adapters import manageCluster, createClusterSystems, havePermCreateCluster, setNodeFlag, delNodeFlag, userAuthenticated, getStorageNode, getClusterNode, delCluster, parseHostForm
+
+from homebase_adapters import parseHostForm
+from LuciZope import userAuthenticated
+
+from LuciDB import manageCluster, createClusterSystems, havePermCreateCluster, setNodeFlag, delNodeFlag, getStorageNode, getClusterNode, delCluster, buildClusterCreateFlags, noNodeFlagsPresent, resolve_nodename, set_node_flag
 
 try:
 	luci_log = LuciSyslog()
@@ -693,7 +697,6 @@
 				dummy_form[str(i.getAttribute('name'))] = str(i.getAttribute('value'))
 			except Exception, e:
 				luci_log.debug_verbose('vSA2: parsing XML: %s' % str(e))
-				pass
 
 		try:
 			res_type = dummy_form['type'].strip()
--- conga/luci/site/luci/Extensions/conga_constants.py	2007/05/03 20:16:38	1.39.2.1
+++ conga/luci/site/luci/Extensions/conga_constants.py	2007/05/04 19:10:24	1.39.2.2
@@ -142,5 +142,5 @@
 
 # Debugging parameters. Set LUCI_DEBUG_MODE to 1 and LUCI_DEBUG_VERBOSITY
 # to >= 2 to get full debugging output in syslog (LOG_DAEMON/LOG_DEBUG).
-LUCI_DEBUG_MODE			= 0
-LUCI_DEBUG_VERBOSITY	= 0
+LUCI_DEBUG_MODE			= 1
+LUCI_DEBUG_VERBOSITY	= 2
--- conga/luci/site/luci/Extensions/conga_ssl.py	2006/12/21 21:32:00	1.2
+++ conga/luci/site/luci/Extensions/conga_ssl.py	2007/05/04 19:10:24	1.2.4.1
@@ -1,17 +1,13 @@
-
-
 import sys
 sys.path.append('/usr/lib/luci/ssl')
 sys.path.append('/usr/lib64/luci/ssl')
+
 import conga_ssl_lib
 sys.path.remove('/usr/lib/luci/ssl')
 sys.path.remove('/usr/lib64/luci/ssl')
 
-
-
 # timeouts are in seconds (int)
 
-
 class SSLSocket:
     
     def __init__(self,
@@ -21,10 +17,10 @@
         self.__id = -1
         self.__id = conga_ssl_lib.connect(hostname, port, timeout)
         self.__hostname = hostname
-        pass
+
     def __del__(self):
         self.disconnect()
-        pass
+
     def disconnect(self):
         if self.__id != -1:
             conga_ssl_lib.disconnect(self.__id)
@@ -42,7 +38,6 @@
     def untrust(self):
         return conga_ssl_lib.untrust(self.__id) == 1
     
-    
     def send(self, msg, timeout):
         conga_ssl_lib.send(self.__id, msg, timeout)
     def recv(self, timeout):
--- conga/luci/site/luci/Extensions/homebase_adapters.py	2007/05/03 20:16:38	1.50.2.1
+++ conga/luci/site/luci/Extensions/homebase_adapters.py	2007/05/04 19:10:24	1.50.2.2
@@ -5,6 +5,15 @@
 from LuciSyslog import LuciSyslog
 from HelperFunctions import resolveOSType
 
+from LuciDB import	delCluster, delNodeFlag, delSystem, getClusterNode, \
+					getClusters, getStorage, getStorageNode, \
+					havePermAddCluster, havePermAddUser, havePermDelUser, \
+					havePermEditPerms, havePermRemCluster, havePermRemStorage, \
+					havePermAddStorage, manageCluster
+
+from ricci_communicator import RicciCommunicator
+
+
 # Homebase area page types
 HOMEBASE_ADD_USER				= '1'
 HOMEBASE_ADD_SYSTEM				= '2'
--- conga/luci/site/luci/Extensions/ricci_communicator.py	2007/05/03 20:16:38	1.25.2.1
+++ conga/luci/site/luci/Extensions/ricci_communicator.py	2007/05/04 19:10:24	1.25.2.2
@@ -56,8 +56,6 @@
         self.__os = hello.firstChild.getAttribute('os')
         self.__dom0 = hello.firstChild.getAttribute('xen_host') == 'true'
         
-        pass
-
     def hostname(self):
         luci_log.debug_verbose('RC:hostname: [auth %d] reported hostname = %s' \
             % (self.__authed, self.__hostname))
@@ -344,8 +342,6 @@
     except Exception, e:
         luci_log.debug_verbose('RC:GRC0: Error creating a ricci connection to %s: %s' % (hostname, str(e)))
         return None
-    pass
-
 
 def ricci_get_called_hostname(self, ricci):
     return ricci.hostname()
@@ -473,7 +469,6 @@
                                                                 msg = var.getAttribute('value')
                                                 return code, msg
                                             
-                        pass
                     elif status == '1':
                         return -102, 'module scheduled for execution'
                     elif status == '2':
--- conga/luci/site/luci/Extensions/storage_adapters.py	2007/05/03 20:16:38	1.9.4.1
+++ conga/luci/site/luci/Extensions/storage_adapters.py	2007/05/04 19:10:24	1.9.4.2
@@ -8,7 +8,7 @@
 from conga_storage_constants import *
 from ricci_defines import *
 from Variable import parse_variable
-from HelperFunctions import get_systems_statuses
+from LuciZope import get_systems_statuses
 
 
 



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

end of thread, other threads:[~2008-01-22 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-24 21:19 [Cluster-devel] conga/luci/site/luci/Extensions HelperFunction rmccabe
  -- strict thread matches above, loose matches on Subject: below --
2008-01-22 15:05 rmccabe
2007-08-08 21:14 rmccabe
2007-05-04 19:10 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).