Skip to contentSkip to conversation

conga/luci/site/luci/Extensions LuciClusterAct ...

Cluster-devel [email protected] 1 participant 1 message May 14, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Branch: EXPERIMENTAL
Changes by: rmccabe at sourceware.org 2007-05-14 18:00:14

Modified files:
luci/site/luci/Extensions: LuciClusterActions.py
LuciClusterInfo.py LuciDB.py LuciSyslog.py LuciZope.py PropsObject.py ResourceHandler.py RicciQueries.py cluster_adapters.py homebase_adapters.py ricci_communicator.py system_adapters.py

Log message:
Next pass of cleanup and refactor

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciClusterActions.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/LuciClusterInfo.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/LuciDB.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.4&r2=1.1.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciSyslog.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.11&r2=1.11.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciZope.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/PropsObject.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2.8.1&r2=1.2.8.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ResourceHandler.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/RicciQueries.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/cluster_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.255.2.3&r2=1.255.2.4
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.2&r2=1.50.2.3
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.2&r2=1.25.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/system_adapters.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.2.2.1&r2=1.2.2.2

luci/site/luci/Extensions/Attic/LuciClusterActions.py +32 -10
@@ -1,7 +1,11 @@
 import RicciQueries as rq
-from conga_constants import CLUSTER_CONFIG
+from LuciDB import set_node_flag, getRicciAgent
+from LuciSyslog import get_logger
+from conga_constants import CLUSTER_CONFIG, LUCI_DEBUG_MODE
 
-def propagateClusterConfAsync(model, rc=None):
+luci_log = get_logger()
+
+def propagateClusterConfAsync(self, model, rc=None):
 	errors = list()
 	messages = list()
 
@@ -10,7 +14,8 @@
 		if not clustername:
 			raise Exception, 'cluster name from model.getClusterName() is blank'
 	except Exception, e:
-		luci_log.debug_verbose('PCC0: getClusterName: %r' % e)
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('PCC0: getClusterName: %r' % e)
 		errors.append('Unable to determine cluster name')
 		return (False, { 'errors': errors, 'messages': messages })
 
@@ -18,19 +23,36 @@
 		rc = getRicciAgent(self, clustername)
 
 	if not rc:
-		luci_log.debug_verbose('PCC1: unable to find a ricci agent for the %s cluster' % clustername)
-		errors.append('Unable to contact a ricci agent for cluster "%s"' % clustername)
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('PCC1: no ricci agent for the %s cluster' \
+				% clustername)
+		errors.append('Unable to contact a ricci agent for cluster "%s"' \
+			% clustername)
+		return (False, { 'errors': errors, 'messages': messages })
+
+	try:
+		conf_str = str(model.exportModelAsString()).strip()
+		if not conf_str:
+			raise Exception, 'The new cluster configuration is blank'
+	except Exception, e:
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('PCC2: %r' % e)
+		errors.append(repr(e))
 		return (False, { 'errors': errors, 'messages': messages })
 
-	batch_id, result = rq.setClusterConf(rc, str(conf_str))
+	batch_id, result = rq.setClusterConf(rc, conf_str)
 	if batch_id is None or result is None:
-		luci_log.debug_verbose('PCC2: setCluserConf: batchid or result is None')
-		errors.append('Unable to propagate the new cluster configuration for %s' % clustername)
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('PCC3: batchid or result is None')
+		errors.append('Unable to propagate a new cluster configuration for %s' \
+			% clustername)
 		return (False, { 'errors': errors, 'messages': messages })
 
 	try:
 		set_node_flag(self, clustername, rc.hostname(), batch_id,
-			CLUSTER_CONFIG, 'Adding new fence device "%s"' % retobj)
+			CLUSTER_CONFIG, 'Updating the cluster configuration for "%s"' %
+				clustername)
 	except Exception, e:
-		luci_log.debug_verbose('PCC3: set_node_flag: %r' % e)
+		if LUCI_DEBUG_MODE is True:
+			luci_log.debug_verbose('PCC4: set_node_flag: %r' % e)
 	return (True, { 'errors': errors, 'messages': messages, 'batchid': batch_id })
luci/site/luci/Extensions/Attic/LuciClusterInfo.py +21 -0
@@ -2,6 +2,7 @@
 import RicciQueries as rq
 from ricci_communicator import RicciCommunicator
 from FenceHandler import FENCE_OPTS
+from LuciSyslog import get_logger
 
 from conga_constants import CLUNAME, CLUSTER_CONFIG, CLUSTER_DELETE, \
 	CLUSTER_PROCESS, CLUSTER_RESTART, CLUSTER_START, CLUSTER_STOP, \
@@ -14,6 +15,15 @@
 	SERVICE, SERVICE_DELETE, SERVICE_MIGRATE, SERVICE_RESTART, \
 	SERVICE_START, SERVICE_STOP, VM_CONFIG
 
+luci_log = get_logger()
+
+def getnodes(self, model):
+	try:
+		return map(lambda x: str(x.getName()), model.getNodes())
+	except Exception, e:
+		luci_log.debug_verbose('getnodes0: %s' % str(e))
+	return []
+
 def getResourceInfo(model, name, res=None):
 	if res is None:
 		try:
@@ -1469,3 +1479,14 @@
 
 	#CALL
 	return {}
+
+def getClusterName(self, model):
+	return model.getClusterName()
+
+def getClusterAlias(self, model):
+	if not model:
+		return ''
+	alias = model.getClusterAlias()
+	if not alias:
+		return model.getClusterName()
+	return alias
luci/site/luci/Extensions/Attic/LuciDB.py +2 -1
@@ -2,13 +2,14 @@
 import RicciQuery as rq
 from ricci_communicator import RicciCommunicator
 from LuciZope import isAdmin
+from LuciSyslog import get_logger
 
 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, CLUSTER_NODE_NOT_MEMBER, \
 	LUCI_DEBUG_MODE
 
-from homebase_adapters import luci_log
+luci_log = get_logger()
 
 def getClusterNode(self, nodename, clustername):
 	try:
luci/site/luci/Extensions/LuciSyslog.py +16 -4
@@ -18,14 +18,20 @@
 		except:
 			raise LuciSyslogError, 'unable to setup syslog functionality.'
 
+	def __del__(self):
+		self.close()
+
+	def initialized(self):
+		return self.__init > 0
+
 	def info(self, msg):
 		if not self.__init:
 			return
 		try:
 			syslog(LOG_INFO, msg)
 		except:
-			pass
 			#raise LuciSyslogError, 'syslog info call failed'
+			pass
 
 	def warn(self, msg):
 		if not self.__init:
@@ -33,8 +39,8 @@
 		try:
 			syslog(LOG_WARNING, msg)
 		except:
-			pass
 			#raise LuciSyslogError, 'syslog warn call failed'
+			pass
 
 	def private(self, msg):
 		if not self.__init:
@@ -42,8 +48,8 @@
 		try:
 			syslog(LOG_AUTH, msg)
 		except:
-			pass
 			#raise LuciSyslogError, 'syslog private call failed'
+			pass
 
 	def debug_verbose(self, msg):
 		if not LUCI_DEBUG_MODE or LUCI_DEBUG_VERBOSITY < 2 or not self.__init:
@@ -73,8 +79,8 @@
 		try:
 			syslog(LOG_DEBUG, msg)
 		except:
-			pass
 			#raise LuciSyslogError, 'syslog debug call failed'
+			pass
 
 	def close(self):
 		try:
@@ -82,3 +88,9 @@
 			closelog()
 		except:
 			pass
+
+luci_logc = None
+def get_logger():
+	if luci_logc is None or luci_logc.initialized() is False:
+		luci_logc = LuciSyslog()
+	return luci_logc
luci/site/luci/Extensions/Attic/LuciZope.py +38 -0
@@ -87,3 +87,41 @@
 	if get_units_multiplier(units) > get_units_multiplier(p_units):
 		units = p_units
 	return (convert_bytes(bytes, units), units)
+
+def getTabs(self, req):
+	if not userAuthenticated(self):
+		return []
+
+	htab = {
+		'Title': 'homebase',
+		'Description': 'Home base for this luci server',
+		'Taburl': '/luci/homebase',
+		'isSelected': False
+	}
+	ctab = {
+		'Title': 'cluster',
+		'Description': 'Cluster configuration area',
+		'Taburl': '/luci/cluster/index_html?pagetype=3',
+		'isSelected': False
+	}
+	stab = {
+		'Title': 'storage',
+		'Description': 'Storage configuration page',
+		'Taburl': '/luci/storage',
+		'isSelected': False
+	}
+
+	try:
+		baseurl = req['URL']
+		if baseurl.find('cluster') > (-1):
+			ctab['isSelected'] = True
+		elif baseurl.find('storage') > (-1):
+			stab['isSelected'] = True
+		else:
+			htab['isSelected'] = True
+	except KeyError, e:
+		pass
+	except Exception, e:
+		htab['isSelected'] = True
+
+	return [ htab, ctab, stab ]
luci/site/luci/Extensions/PropsObject.py +2 -4
@@ -1,7 +1,5 @@
-
-from ricci_defines import *
-
-from Variable import Variable, parse_variable
+from Variable import parse_variable
+from ricci_defines import PROPS_TAG
 import xml
 import xml.dom
 
luci/site/luci/Extensions/Attic/ResourceHandler.py +125 -82

500 lines not on this page · raw message

luci/site/luci/Extensions/Attic/RicciQueries.py +60 -38

220 lines not on this page · raw message

luci/site/luci/Extensions/cluster_adapters.py +229 -314

1,206 lines not on this page · raw message

luci/site/luci/Extensions/homebase_adapters.py +70 -88

300 lines not on this page · raw message

luci/site/luci/Extensions/ricci_communicator.py +466 -443

551 lines not on this page · raw message

luci/site/luci/Extensions/system_adapters.py +2 -5

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.