cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/form-macros site/luci/Exten ...
Date: 10 Jan 2007 21:40:06 -0000	[thread overview]
Message-ID: <20070110214006.17466.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at 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)



             reply	other threads:[~2007-01-10 21:40 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-10 21:40 rmccabe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-09-21  3:11 [Cluster-devel] conga/luci cluster/form-macros site/luci/Exten rmccabe
2007-06-19 15:54 rmccabe
2007-05-03 20:16 rmccabe
2007-03-15 16:41 rmccabe
2007-03-14 22:38 rmccabe
2007-03-14 22:37 rmccabe
2007-03-05 16:50 rmccabe
2007-03-05 16:50 rmccabe
2007-03-05 16:49 rmccabe
2007-02-15 22:44 rmccabe
2007-02-08  3:46 rmccabe
2007-02-07 17:02 rmccabe
2007-02-07 16:55 rmccabe
2007-02-02  4:34 rmccabe
2007-02-02  0:11 rmccabe
2007-02-01 20:49 rmccabe
2007-01-31 23:36 rmccabe
2007-01-31  5:26 rmccabe
2007-01-23 13:53 rmccabe
2007-01-15 18:21 rmccabe
2007-01-11 19:11 rmccabe
2007-01-06  3:29 rmccabe
2006-12-14 23:14 rmccabe
2006-12-14 18:22 rmccabe
2006-12-11 22:42 rmccabe
2006-12-11 21:51 rmccabe
2006-12-06 22:11 rmccabe
2006-12-06 21:16 rmccabe
2006-11-13 21:40 rmccabe
2006-11-12  2:10 rmccabe
2006-11-09 20:32 rmccabe
2006-11-03 22:48 rmccabe
2006-10-25  1:53 rmccabe
2006-10-25  1:11 rmccabe
2006-10-13 21:25 rmccabe
2006-08-03 18:36 shuennek
2006-07-21 14:49 rmccabe
2006-07-20 16:59 rmccabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070110214006.17466.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).