All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/resource-form-macros cluste ...
Date: 15 Mar 2007 22:11:29 -0000	[thread overview]
Message-ID: <20070315221129.6279.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe at sourceware.org	2007-03-15 22:11:28

Modified files:
	luci/cluster   : resource-form-macros resource_form_handlers.js 
	luci/site/luci/Extensions: ModelBuilder.py TagObject.py 
	                           cluster_adapters.py 

Log message:
	Make the fsid field optional for fs and clusterfs resources. If the user provides nothing, an invalid id, or a duplicate, generate a unique fsid.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.21.2.5&r2=1.21.2.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.20.2.5&r2=1.20.2.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ModelBuilder.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.8.2.7&r2=1.8.2.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/TagObject.py.diff?cvsroot=cluster&only_with_tag=RHEL5&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=RHEL5&r1=1.120.2.26&r2=1.120.2.27

--- conga/luci/cluster/resource-form-macros	2007/03/07 18:02:54	1.21.2.5
+++ conga/luci/cluster/resource-form-macros	2007/03/15 22:11:28	1.21.2.6
@@ -463,7 +463,7 @@
 		</tr>
 
 		<tr class="systemsTable">
-			<td class="systemsTable">File system ID</td>
+			<td class="systemsTable">File system ID (optional)</td>
 			<td class="systemsTable">
 				<input type="text" size="20" name="fsid"
 					tal:attributes="
@@ -588,7 +588,7 @@
 		</tr>
 
 		<tr class="systemsTable">
-			<td class="systemsTable">File system ID</td>
+			<td class="systemsTable">File system ID (optional)</td>
 			<td class="systemsTable">
 				<input type="text" size="20" name="fsid"
 					tal:attributes="
--- conga/luci/cluster/resource_form_handlers.js	2007/03/07 18:02:55	1.20.2.5
+++ conga/luci/cluster/resource_form_handlers.js	2007/03/15 22:11:28	1.20.2.6
@@ -190,11 +190,6 @@
 	} else
 		clr_form_err(form.device);
 
-	if (!form.fsid || str_is_blank(form.fsid.value)) {
-		errors.push('No file system ID was given.');
-		set_form_err(form.fsid);
-	} else
-		clr_form_err(form.fsid);
 	return (errors);
 }
 
@@ -213,11 +208,6 @@
 	} else
 		clr_form_err(form.device);
 
-	if (!form.fsid || str_is_blank(form.fsid.value)) {
-		errors.push('No file system ID was given.');
-		set_form_err(form.fsid);
-	} else
-		clr_form_err(form.fsid);
 	return (errors);
 }
 
--- conga/luci/site/luci/Extensions/ModelBuilder.py	2007/03/01 00:31:08	1.8.2.7
+++ conga/luci/site/luci/Extensions/ModelBuilder.py	2007/03/15 22:11:28	1.8.2.8
@@ -1164,7 +1164,11 @@
         if found_one == True:
           break
           
-    
+  def searchObjectTree(self, tagtype):
+    objlist = list()
+    self.object_tree.searchTree(objlist, tagtype)
+
+    return objlist
  
    
 if __name__ == "__main__":
--- conga/luci/site/luci/Extensions/TagObject.py	2007/01/10 21:48:26	1.1.2.1
+++ conga/luci/site/luci/Extensions/TagObject.py	2007/03/15 22:11:28	1.1.2.2
@@ -78,3 +78,12 @@
 
   def isRefObject(self):
     return False
+
+  def searchTree(self, objlist, tagtype):
+    if self.TAG_NAME == tagtype:
+      objlist.append(self)
+    if len(self.children) > 0:
+      for child in self.children:
+        if child == None:
+          continue
+        child.searchTree(objlist, tagtype)
--- conga/luci/site/luci/Extensions/cluster_adapters.py	2007/03/13 03:06:24	1.120.2.26
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2007/03/15 22:11:28	1.120.2.27
@@ -55,6 +55,27 @@
 except:
 	pass
 
+def get_fsid_list(model):
+	obj_list = model.searchObjectTree('fs')
+	obj_list.extend(model.searchObjectTree('clusterfs'))
+	return map(lambda x: x.getAttribute('fsid') and int(x.getAttribute('fsid')) or 0, obj_list)
+
+def fsid_is_unique(fsid):
+	fsid_list = get_fsid_list
+	return fsid not in fsid_list
+
+def generate_fsid(model, name):
+	import binascii
+	from random import random
+	fsid_list = get_fsid_list(model)
+
+	fsid = binascii.crc32(name) & 0xffff
+	dupe = fsid in fsid_list
+	while dupe is True:
+		fsid = (fsid + random.randrange(1, 0xfffe)) & 0xffff
+		dupe = fsid in fsid_list
+	return fsid
+
 def buildClusterCreateFlags(self, batch_map, clusterName):
 	path = str(CLUSTER_FOLDER_PATH + clusterName)
 
@@ -6128,11 +6149,12 @@
 		fsid = form['fsid'].strip()
 		if not fsid:
 			raise Exception, 'No filesystem ID was given for this filesystem resource.'
-		res.addAttribute('fsid', fsid)
+		fsid_int = int(fsid)
+		if not fsid_is_unique(fsid_int):
+			raise Exception, 'The filesystem ID provided is not unique.'
 	except Exception, e:
-		err = str(e)
-		errors.append(err)
-		luci_log.debug_verbose('addFs10: %s' % err)
+		fsid = str(generate_fsid(model, name))
+	res.addAttribute('fsid', fsid)
 
 	if form.has_key('forceunmount'):
 		res.addAttribute('force_unmount', '1')
@@ -6244,11 +6266,12 @@
 		fsid = form['fsid'].strip()
 		if not fsid:
 			raise Exception, 'No filesystem ID was given for this cluster filesystem resource.'
-		res.addAttribute('fsid', fsid)
+		fsid_int = int(fsid)
+		if not fsid_is_unique(fsid_int):
+			raise Exception, 'The filesystem ID provided is not unique.'
 	except Exception, e:
-		err = str(e)
-		errors.append(err)
-		luci_log.debug_verbose('addGfs8: %s' % err)
+		fsid = str(generate_fsid(model, name))
+	res.addAttribute('fsid', fsid)
 
 	if form.has_key('forceunmount'):
 		res.addAttribute('force_unmount', '1')



             reply	other threads:[~2007-03-15 22:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-15 22:11 rmccabe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-06-14 19:30 [Cluster-devel] conga/luci cluster/resource-form-macros cluste rmccabe
2007-03-15 22:09 rmccabe
2007-03-15 22:08 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=20070315221129.6279.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.