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

[Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-11-05 00:59:10

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

Log message:
	propagate general cluster configuration changes

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

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/03 22:48:15	1.144
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/05 00:59:09	1.145
@@ -634,6 +634,15 @@
 	errors = list()
 
 	try:
+		cp = model.getClusterPtr()
+		old_name = model.getClusterAlias()
+		old_ver = cp.getConfigVersion()
+	except Exception, e:
+		luci_log.debug_verbose('getConfigVersion: %s' % str(e))
+		errors.append('unable to determine the current configuration version')
+		return (False, {'errors': errors})
+
+	try:
 		cluster_name = form['cluname'].strip()
 		if not cluster_name:
 			raise KeyError('cluname')
@@ -642,17 +651,28 @@
 
 	try:
 		version_num = int(form['cfgver'])
-		if version_num < 0:
-			raise ValueError('configuration version numbers must be 0 or greater.')
+		if version_num < old_ver:
+			raise ValueError, 'configuration version number must be %d or greater.' \
+								% old_ver
+		if version_num == old_ver:
+			version_num += 1
 	except KeyError, e:
 		errors.append('No cluster configuration version was given.')
 	except ValueError, e:
-		errors.append('An invalid configuration version was given: ' + e)
+		errors.append('An invalid configuration version was given: %s' % str(e))
+
+	if len(errors) < 1:
+		try:
+			if cluster_name != old_name:
+				cp.addAttribute('alias', cluster_name)
+			model.setConfigVersion(version_num)
+		except Exception, e:
+			luci_log.debug_verbose('unable to update general properties: %s' % str(e))
+			errors.append('Unable to update the cluster configuration.')
 
 	if len(errors) > 0:
 		return (False, {'errors': errors})
-
-	return (True, {'messages': ['Changes accepted. - FILL ME IN']})
+	return (True, {})
 
 def validateFenceConfig(model, form):
 	errors = list()
@@ -721,6 +741,42 @@
 	if 'messages' in ret[1]:
 		messages.extend(ret[1]['messages'])
 
+	if retcode == True:
+		try:
+			conf_str = str(model.exportModelAsString())
+			if not conf_str:
+				raise Exception, 'conf_str is none'
+		except Exception, e:
+			luci_log.debug_verbose('VCC4: export model as string failed: %s' \
+				% str(e))
+			errors.append('unable to store the new cluster configuration')
+
+	try:
+		clustername = model.getClusterName()
+		if not clustername:
+			raise Exception, 'cluster name from modelb.getClusterName() is blank'
+	except Exception, e:
+		luci_log.debug_verbose('VCC5: error: getClusterName: %s' % str(e))
+		errors.append('unable to determine cluster name from model') 
+
+	rc = getRicciAgent(self, clustername)
+	if not rc:
+		luci_log.debug_verbose('VCC6: unable to find a ricci agent for the %s cluster' % clustername)
+		errors.append('unable to contact a ricci agent for cluster %s' \
+			% clustername)
+	else:
+		batch_id, result = setClusterConf(rc, conf_str)
+		if batch_id is None or result is None:
+			luci_log.debug_verbose('VCC7: setCluserConf: batchid or result is None')
+			errors.append('unable to propagate the new cluster configuration for %s' \
+				% clustername)
+		else:
+			try:
+				set_node_flag(self, clustername, rc.hostname(), batch_id,
+					CLUSTER_CONFIG, 'Updating cluster configuration')
+			except:
+				pass
+
 	if len(errors) < 1:
 		messages.append('The cluster properties have been updated.')
 
@@ -4205,3 +4261,22 @@
 
 	modelb.setIsVirtualized(isVirtualized)
 	return modelb
+
+def set_node_flag(self, cluname, agent, batchid, task, desc):
+	path = str(CLUSTER_FOLDER_PATH + cluname)
+	batch_id = str(batchid)
+	objname = str(agent + '____flag')
+
+	try:
+		clusterfolder = self.restrictedTraverse(path)
+		clusterfolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
+		objpath = str(path + '/' + objname)
+		flag = self.restrictedTraverse(objpath)
+		flag.manage_addProperty(BATCH_ID, batchid, 'string')
+		flag.manage_addProperty(TASKTYPE, task, 'string')
+		flag.manage_addProperty(FLAG_DESC, desc)
+	except Exception, e:
+		errmsg = 'Error creating flag (%s,%s,%s) at %s: %s' \
+					% (batchid, task, desc, objpath, str(e))
+		luci_log.debug_verbose(errmsg)
+		raise Exception, errmsg


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