[Cluster-devel] conga/luci cluster/resource-form-macros cluste ...
rmccabe at sourceware.org
rmccabe at sourceware.org
Thu Mar 15 22:11:29 UTC 2007
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')
More information about the Cluster-devel
mailing list