}
run_test 12 "lmc --batch, with single/double quote, backslash in batchfile"
+test_13() {
+ OLDXMLCONFIG=$XMLCONFIG
+ XMLCONFIG="conf13-1.xml"
+ SECONDXMLCONFIG="conf13-2.xml"
+
+ # check long uuid will be truncated properly and uniquely
+ echo "To generate XML configuration file(with long ost name): $XMLCONFIG"
+ [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
+ do_lmc --add net --node localhost --nid localhost.localdomain --nettype tcp
+ do_lmc --add mds --node localhost --mds mds1_name_longer_than_31characters
+ do_lmc --add mds --node localhost --mds mds2_name_longer_than_31characters
+ if [ ! -f "$XMLCONFIG" ]; then
+ echo "Error:no file $XMLCONFIG created!"
+ return 1
+ fi
+ EXPECTEDMDS1UUID="e_longer_than_31characters_UUID"
+ EXPECTEDMDS2UUID="longer_than_31characters_UUID_2"
+ FOUNDMDS1UUID=`awk -F"'" '/<mds uuid=/{print $2}' $XMLCONFIG | sed -n '1p'`
+ FOUNDMDS2UUID=`awk -F"'" '/<mds uuid=/{print $2}' $XMLCONFIG | sed -n '2p'`
+ if [ $EXPECTEDMDS1UUID != $FOUNDMDS1UUID ]; then
+ echo "Error:expected uuid for mds1: $EXPECTEDMDS1UUID; found: $FOUNDMDS1UUID"
+ return 1
+ fi
+ if [ $EXPECTEDMDS2UUID != $FOUNDMDS2UUID ]; then
+ echo "Error:expected uuid for mds2: $EXPECTEDMDS2UUID; found: $FOUNDMDS2UUID"
+ return 1
+ fi
+ echo "Success:long uuid truncated successfully and being unique."
+
+ # check multiple invocations for lmc generate same XML configuration file
+ rm -f $XMLCONFIG
+ echo "Generate the first XML configuration file"
+ gen_config
+ echo "mv $XMLCONFIG to $SECONDXMLCONFIG"
+ mv $XMLCONFIG $SECONDXMLCONFIG || return $?
+ echo "Generate the second XML configuration file"
+ gen_config
+ if [ `diff $XMLCONFIG $SECONDXMLCONFIG | wc -l` -eq 0 ]; then
+ echo "Success:multiple invocations for lmc generate same XML file"
+ else
+ echo "Error: multiple invocations for lmc generate different XML file"
+ return 1
+ fi
+
+ rm -f $XMLCONFIG
+ rm -f $SECONDXMLCONFIG
+ XMLCONFIG=$OLDXMLCONFIG
+}
+run_test 13 "check new_uuid of lmc operating correctly"
+
equals_msg "Done"
"""
-import sys, os, getopt, string, exceptions, random, re
+import sys, os, getopt, string, exceptions, re
import xml.dom.minidom
from xml.dom.ext import PrettyPrint
DEFAULT_STRIPE_SZ = 65536
DEFAULT_STRIPE_CNT = 1
DEFAULT_STRIPE_PATTERN = 0
+UUID_MAX_LENGTH = 31
def reference():
print """usage: lmc --add object [object parameters]
return ret
def new_uuid(name):
- ret_uuid = '%05x_%.19s_%05x%05x' % (int(random.random() * 1048576),
- name,
- int(random.random() * 1048576),
- int(random.random() * 1048576))
- return ret_uuid[:36]
+ ctr = 2
+ ret = "%s_UUID" % (name)
+ if len(ret) > UUID_MAX_LENGTH:
+ ret = ret[-UUID_MAX_LENGTH:]
+ while uuids.has_key(ret):
+ ret = "%s_UUID_%d" % (name, ctr)
+ ctr = 1 + ctr
+ if len(ret) > UUID_MAX_LENGTH:
+ ret = ret[-UUID_MAX_LENGTH:]
+ uuids[ret] = 1
+ return ret
+
ldlm_name = 'ldlm'
ldlm_uuid = 'ldlm_UUID'
gen = GenConfig(doc)
- # the PRNG is normally seeded with time(), which is not so good for starting # time-synchronized clusters
- input = open('/dev/urandom', 'r')
- if not input:
- print 'Unable to open /dev/urandom!'
- sys.exit(1)
- seed = input.read(32)
- input.close()
- random.seed(seed)
-
if options.batch:
fp = open(options.batch)
batchCommands = fp.readlines()