From 75c6587a7d6e642f6f97a558555319eee00ee501 Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Sun, 9 Dec 2012 15:13:33 +0800 Subject: [PATCH] more compatible way to pass ext options and also catch mkfs error Signed-off-by: Gui Chen --- mic/utils/fs_related.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/mic/utils/fs_related.py b/mic/utils/fs_related.py index f582cd2..da1ffeb 100644 --- a/mic/utils/fs_related.py +++ b/mic/utils/fs_related.py @@ -444,22 +444,23 @@ class ExtDiskMount(DiskMount): return msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device)) - if self.extopts is None: - self.extopts = "" - cmdline = "%s -F -L %s -m 1 -b %s %s %s" % (self.mkfscmd, - self.fslabel, - self.blocksize, - self.extopts, - self.disk.device) - rc = runner.show(cmdline.split()) + cmdlist = [self.mkfscmd, "-F", "-L", self.fslabel, "-m", "1", "-b", + str(self.blocksize)] + if self.extopts: + cmdlist.extend(self.extopts.split()) + cmdlist.extend([self.disk.device]) + + rc, errout = runner.runtool(cmdlist, catch=2) if rc != 0: - raise MountError("Error creating %s filesystem on disk %s" % (self.fstype, self.disk.device)) + raise MountError("Error creating %s filesystem on disk %s:\n%s" % + (self.fstype, self.disk.device, errout)) - rc, out = runner.runtool([self.dumpe2fs, '-h', self.disk.device]) + if not self.extopts: + 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]) self.uuid = self.__parse_field(out, "Filesystem UUID") - msger.debug("Tuning filesystem on %s" % self.disk.device) - runner.show([self.tune2fs, "-c0", "-i0", "-Odir_index", "-ouser_xattr,acl", self.disk.device]) def __resize_filesystem(self, size = None): current_size = os.stat(self.disk.lofile)[stat.ST_SIZE] -- 2.7.4