ExtDiskMount: fix the UUID feature for extX
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 24 Jun 2013 10:12:42 +0000 (13:12 +0300)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Tue, 25 Jun 2013 08:49:55 +0000 (11:49 +0300)
The current implementation of ExtDiskMount is strange. Instead of generating a
random UUID and then ask mkfs.extX to use that UUID, it run mkfs.extX without
-U, let's mkfs.extX generate a random UUID, and then uses e2fsdump and parses
its output.

This is not very logical, and this also does not work with the version of
mkfs that we use at the moment.

Change the logic and simply use mkfs.extX -U.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
mic/utils/fs_related.py

index 67a7dff..a5599c6 100644 (file)
@@ -24,6 +24,7 @@ import stat
 import random
 import string
 import time
+import uuid
 
 from mic import msger
 from mic.utils import runner
@@ -438,7 +439,7 @@ class ExtDiskMount(DiskMount):
         DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir)
         self.blocksize = blocksize
         self.fslabel = fslabel.replace("/", "")
-        self.uuid  = None
+        self.uuid = str(uuid.uuid4())
         self.skipformat = skipformat
         self.fsopts = fsopts
         self.extopts = None
@@ -459,7 +460,7 @@ class ExtDiskMount(DiskMount):
 
         msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
         cmdlist = [self.mkfscmd, "-F", "-L", self.fslabel, "-m", "1", "-b",
-                   str(self.blocksize)]
+                   str(self.blocksize), "-U", self.uuid]
         if self.extopts:
             cmdlist.extend(self.extopts.split())
         cmdlist.extend([self.disk.device])
@@ -473,17 +474,6 @@ class ExtDiskMount(DiskMount):
             msger.debug("Tuning filesystem on %s" % self.disk.device)
             runner.show([self.tune2fs, "-c0", "-i0", "-Odir_index", "-ouser_xattr,acl", self.disk.device])
 
-        rc, out = runner.runtool([self.dumpe2fs, '-h', self.disk.device],
-                                  catch=2)
-        if rc != 0:
-            raise MountError("Error dumpe2fs %s filesystem on disk %s:\n%s" %
-                             (self.fstype, self.disk.device, out))
-        # FIXME: specify uuid in mkfs parameter
-        try:
-            self.uuid = self.__parse_field(out, "Filesystem UUID")
-        except:
-            self.uuid = None
-
     def __resize_filesystem(self, size = None):
         current_size = os.stat(self.disk.lofile)[stat.ST_SIZE]