[Drobo-utils-devel] SF.net SVN: drobo-utils:[186] trunk
Brought to you by:
peter_silva
|
From: <pet...@us...> - 2009-01-27 02:59:54
|
Revision: 186
http://drobo-utils.svn.sourceforge.net/drobo-utils/?rev=186&view=rev
Author: peter_silva
Date: 2009-01-27 01:33:29 +0000 (Tue, 27 Jan 2009)
Log Message:
-----------
Made umount a separate method, added invocation from setlunsize so it will work more often.
Added format command to drobom.
format_script now iterates through all LUNS of a Drobo.
Modified Paths:
--------------
trunk/Drobo.py
trunk/drobom
Modified: trunk/Drobo.py
===================================================================
--- trunk/Drobo.py 2009-01-27 01:31:41 UTC (rev 185)
+++ trunk/Drobo.py 2009-01-27 01:33:29 UTC (rev 186)
@@ -399,34 +399,36 @@
else:
ptype='gpt'
- fd.write( "parted %s mklabel %s\n" % (self.char_dev_file, ptype) )
+ for cd in self.char_devs:
+ fd.write( "parted %s mklabel %s\n" % (cd, ptype) )
- # there is a bit of a race condition creating the partition special file.
- # the parted print gives a little time before starting the mkfs, to ensure
- # file is there...
+ # there is a bit of a race condition creating the partition special file.
+ # the parted print gives a little time before starting the mkfs, to ensure
+ # file is there...
- if fstype == 'ext3':
- # -m 0 -- Drobo takes care of complaining when near the size limit.
- # little point in complaining early, pretending you have less space.
- # ^resize_inode -- Drobo makes the file system much bigger than the actual space
- # available ( >= 2TB ) , so it doesn't make sense to allow space for future
- # inode expansion beyond that. only makes sense in LVM, that's why this
- # option is 'off' (the '^' at the beginning.)
- # sparse_super -- there are lots too many superblock copies made by default.
- # safe enough with fewer.
- fd.write( "parted %s mkpart ext2 0 100%%\n" % self.char_dev_file )
- fd.write( "parted %s print; sleep 5\n" % self.char_dev_file )
- fd.write( 'mke2fs -j -i 262144 -L Drobo01 -m 0 -O sparse_super,^resize_inode %s1\n' % self.char_dev_file )
- elif fstype == 'ntfs':
- fd.write( "parted %s mkpart ntfs 0 100%%\n" % self.char_dev_file )
- fd.write( "parted %s print; sleep 5\n" % self.char_dev_file )
- fd.write( 'mkntfs -f -L Drobo01 %s1\n' % self.char_dev_file )
- elif fstype == 'FAT32':
- fd.write( "parted %s mkpart primary fat32 0 100%%\n" % self.char_dev_file )
- fd.write( "parted %s print; sleep 5\n" % self.char_dev_file )
- fd.write( 'mkdosfs -v -v -F 32 -S 4096 -n Drobo01 %s1\n' % self.char_dev_file )
- else:
- print 'unsupported partition type %s, sorry...' % fstype
+ if fstype == 'ext3':
+ # -m 0 -- Drobo takes care of complaining when near the size limit.
+ # little point in complaining early, pretending you have less space.
+ # ^resize_inode -- Drobo makes the file system much bigger than the actual space
+ # available ( >= 2TB ) , so it doesn't make sense to allow space for future
+ # inode expansion beyond that. only makes sense in LVM, that's why this
+ # option is 'off' (the '^' at the beginning.)
+ # sparse_super -- there are lots too many superblock copies made by default.
+ # safe enough with fewer.
+ fd.write( "parted %s mkpart ext2 0 100%%\n" % cd )
+ fd.write( "parted %s print; sleep 5\n" % cd )
+ fd.write( 'mke2fs -j -i 262144 -L Drobo01 -m 0 -O sparse_super,^resize_inode %s1\n' % cd )
+ elif fstype == 'ntfs':
+ fd.write( "parted %s mkpart ntfs 0 100%%\n" % cd )
+ fd.write( "parted %s print; sleep 5\n" % cd )
+ fd.write( 'mkntfs -f -L Drobo01 %s1\n' % cd )
+ elif fstype == 'FAT32':
+ fd.write( "parted %s mkpart primary fat32 0 100%%\n" % cd )
+ fd.write( "parted %s print; sleep 5\n" % cd )
+ fd.write( 'mkdosfs -v -v -F 32 -S 4096 -n Drobo01 %s1\n' % cd )
+ else:
+ print 'unsupported partition type %s, sorry...' % fstype
+
fd.close()
os.chmod(format_script,0700)
@@ -549,6 +551,11 @@
if (DEBUG & DBG_Chatty):
print 'set lunsize to %d TiB' % tb
+ if not self.umount():
+ if (DEBUG & DBG_Chatty):
+ print 'cannot free up Drobo to set lunsize'
+ return
+
buffer=struct.pack( ">l", tb )
sblen=len(buffer)
@@ -575,18 +582,10 @@
STATUS: command itself works, no issues.... only light tests so far.
still testing umount code.
"""
- toumount = self.DiscoverMounts()
- if len(toumount) > 0:
- for i in toumount:
- if DEBUG & DBG_Chatty:
- print "unmounting: ", i
- umresult=os.system("umount " + i )
- if umresult != 0:
- return
+ if self.umount():
+ self.__issueCommand(0x0d)
- self.__issueCommand(0x0d)
-
def GetDiagRecord(self,diagcode,decrypt=0):
""" returns diagnostics as a string...
diagcodes are either 4 or 7 for the two different Records available.
@@ -1240,6 +1239,21 @@
except:
return ( 0,0,0 )
+ def umount(self):
+ """
+ umount all file systems using the given Drobo.
+ return true on success, false on failure.
+ """
+ toumount = self.DiscoverMounts()
+ if len(toumount) > 0:
+ for i in toumount:
+ if DEBUG & DBG_Chatty:
+ print "unmounting: ", i
+ umresult=os.system("umount " + i )
+ if umresult != 0:
+ return False
+ return True
+
def DiscoverMounts(self):
"""
return the list of mounted file systems using the unit.
Modified: trunk/drobom
===================================================================
--- trunk/drobom 2009-01-27 01:31:41 UTC (rev 185)
+++ trunk/drobom 2009-01-27 01:33:29 UTC (rev 186)
@@ -26,6 +26,10 @@
print "\ncommand is one of: "
print "\tblink\tidentify the drobo by making the lights blink"
print "\tdiag\tdump diagnostics file into /tmp directory"
+ print "\tformat\tPrepares a script to format LUNS from a device. Arguments:"
+ print "\t\t<fstype>\tfile system type. One of: ext3,ntfs,FAT32"
+ print "\t\t<confirmation>\tSpecify 'PleaseEraseMyData' if you really mean it"
+ print "\t\tNote: After execution, there is a script in /tmp. Upto you to run it."
print "\tfwcheck\tquery drobo.com for updates to firmware for the given Drobo"
print "\tfwload\tload a specific firmware for the given Drobo. Arguments:"
print "\t\t<fwimage>\tthe firmware file to load."
@@ -229,6 +233,7 @@
if debug & Drobo.DBG_Detection:
print "found ", l
+
for u in l:
d=Drobo.Drobo(u,debug)
#assert d is a valid drobo object...
@@ -240,6 +245,20 @@
f=d.dumpDiagnostics()
print "diagnostics in ", f
+ elif cmd == "format":
+ if len(args) < 3 :
+ print 'This is guaranteed to erase your disk, so you must say: PleaseEraseMyData'
+ sys.exit()
+
+ if args[2] != 'PleaseEraseMyData':
+ print 'This is guaranteed to erase your disk, so you must say: PleaseEraseMyData'
+ sys.exit()
+
+ print 'You asked nicely, so I will format %s as you requested' % args[1]
+ d.format_script(args[1])
+ print 'OK, I built the script but nothing is erased yet...'
+ print 'If you are really sure, go ahead and do: sh /tmp/fmtscript'
+
elif cmd == 'fwcheck':
tuple=d.PickLatestFirmware()
print tuple[3]
@@ -273,13 +292,18 @@
print 'lun size needs to be a power of 2 TiB, %d is invalid' % lunsize
sys.exit()
- if args[2] == 'PleaseEraseMyData':
- print 'You asked nicely, so I will set the lunsize to %d as you requested' % lunsize
- d.SetLunSize(lunsize)
- print 'Done... Drobo is likely now rebooting. In a few minutes, it will come back with the new LUN size.'
- else:
+ if len(args) < 3 :
print 'This is guaranteed to erase your disk, so you must say: PleaseEraseMyData'
+ sys.exit()
+ if args[2] != 'PleaseEraseMyData':
+ print 'This is guaranteed to erase your disk, so you must say: PleaseEraseMyData'
+ sys.exit()
+
+ print 'You asked nicely, so I will set the lunsize to %d as you requested' % lunsize
+ d.SetLunSize(lunsize)
+ print 'Done... Drobo is likely now rebooting. In a few minutes, it will come back with the new LUN size.'
+
elif cmd == "settime":
d.Sync()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|