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

[Cluster-devel] conga/luci cluster/form-macros site/luci/Exten ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2007-01-10 21:40:05

Modified files:
	luci/cluster   : form-macros 
	luci/site/luci/Extensions: cluster_adapters.py 

Log message:
	more node fencing bits

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.149&r2=1.150
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.197&r2=1.198

--- conga/luci/cluster/form-macros	2007/01/10 20:02:16	1.149
+++ conga/luci/cluster/form-macros	2007/01/10 21:40:05	1.150
@@ -2184,7 +2184,7 @@
 				</td>
 			</tr>
 			<tr>
-				<td>Switch</td>
+				<td>Switch (optional)</td>
 				<td>
 					<input name="switch" type="text"
 						tal:attributes="value cur_instance/switch | nothing" />
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/01/10 20:06:26	1.197
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/01/10 21:40:05	1.198
@@ -1485,9 +1485,6 @@
 
 	try:
 		doc = minidom.parseString(form_xml)
-		forms = doc.getElementsByTagName('form')
-		if len(forms) < 1:
-			raise
 	except Exception, e:
 		luci_log.debug_verbose('vNFC5: error: %s' % str(e))
 		return (False, {'errors': ['The fence data submitted is not properly formed.']})
@@ -1504,11 +1501,30 @@
 		method_id = levels[fence_level_num - 1].getAttribute('name')
 		if not method_id:
 			raise Exception, 'No method ID'
+		fence_method = Method()
+		fence_method.addAttribute('name', str(method_id))
+		node.children[0].children[fence_level_num - 1] = fence_method
 	except Exception, e:
 		method_id = fence_level
-	
-	fence_method = Method()
-	fence_method.addAttribute('name', str(method_id))
+		fence_method = Method()
+		fence_method.addAttribute('name', str(method_id))
+
+	forms = doc.getElementsByTagName('form')
+	if len(forms) < 1:
+		delete_target = None
+		for l in levels:
+			# delete the fence level
+			if l.getAttribute('name') == method_id:
+				delete_target = l
+				break
+		if delete_target is not None:
+			try:
+				node.getChildren()[0].removeChild(l)
+			except Exception, e:
+				luci_log.debug_verbose('vNFC6a: %s: %s' % (method_id, str(e)))
+				return (False, {'errors': ['An error occurred while deleting fence method %s' % method_id ]}) 
+		else:
+			return (True, {'messages': ['No changes were made.'] })
 
 	form_hash = {}
 	for i in forms:
@@ -1609,25 +1625,32 @@
 							% (fence_form['name'], str(e)))
 						return (False, {'errors': [ 'Unable to determine the original name for the device now named %s' % fencedev_name ]})
 
-					fence_dev_list = model.getFenceDevices()
 					fencedev_obj = None
+					fence_dev_list = model.getFenceDevices()
 					for fd in fence_dev_list:
-						if fd.getAttribute('name') == 'old_name':
+						if fd.getAttribute('name') == old_name:
 							fencedev_obj = fd
-							try:
-								model.fencedevices_ptr.removeChild(fd)
-							except Exception, e:
-								luci_log.debug_verbose('VNFC8a: %s: %s' \
-									% (old_name, str(e)))
-								return (False, {'errors': [ 'Unable to remove old fence device %s' % old_name ]})
 							break
+
 					if fencedev_obj is None:
 						luci_log.debug_verbose('vNFC14: no fence device named %s was found' % old_name)
 						return (False, {'errors': ['No fence device named %s was found' % old_name ] })
+					else:
+						try:
+							model.fencedevices_ptr.removeChild(fd)
+						except Exception, e:
+							luci_log.debug_verbose('VNFC8a: %s: %s' \
+								% (old_name, str(e)))
+							return (False, {'errors': [ 'Unable to remove old fence device %s' % old_name ]})
 
 					for k in fence_form.keys():
 						if fence_form[k]:
 							fencedev_obj.addAttribute(k, str(fence_form[k]))
+
+					# Add back the tags under the method block
+					# for the fence instance
+					instance_list.append({'name': fencedev_name })
+
 		else:
 			# The user created a new fence device.
 			fencedev_name = fence_form['name']
@@ -1636,6 +1659,12 @@
 				if fence_form[k]:
 					fencedev_obj.addAttribute(k, str(fence_form[k]))
 
+			# If it's not shared, we need to create an instance form
+			# so the appropriate XML goes into the <method> block inside
+			# <node><fence>. All we need for that is the device name.
+			if not 'sharable' in fence_form:
+				instance_list.append({'name': fencedev_name })
+
 		if fencedev_obj is not None:
 			# If a device with this name exists in the model
 			# already, replace it with the current object. If
@@ -1679,9 +1708,20 @@
 					device_obj.addAttribute(k, str(inst[k]))
 			fence_method.addChild(device_obj)
 
-		try:
-			levels[fence_level_num - 1] = fence_method
-		except:
+		if len(node.getChildren()) > 0:
+			# There's already a <fence> block
+			found_target = False
+			for idx in xrange(len(levels)):
+				if levels[idx].getAttribute('name') == method_id:
+					found_target = True
+					break
+
+			if found_target is False:
+				# There's a fence block, but no relevant method
+				# block
+				node.getChildren()[0].addChild(fence_method)
+		else:
+			# There is no <fence> tag under the node yet.
 			fence_node = Fence()
 			fence_node.addChild(fence_method)
 			node.addChild(fence_node)
@@ -1699,6 +1739,7 @@
 			% str(e))
 		return (False, {'errors': [ 'An error occurred while constructing the new cluster configuration.' ]})
 
+
 	rc = getRicciAgent(self, clustername)
 	if not rc:
 		luci_log.debug_verbose('vNFC18: unable to find a ricci agent for cluster %s' % clustername)


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