From e9f91bbebe66b316ba80b71fdb2be000bbdc68e4 Mon Sep 17 00:00:00 2001 From: Dohyung Kim Date: Mon, 6 Jul 2015 21:34:30 +0900 Subject: [PATCH] fix invalid ExtDiskMount.blocksize when "-b [BLOCKSIZE]" extoption is passed To set blocksize by parsing "-b [BLOCKSIZE]" from extoptions in ks file Change-Id: I0328cdae59a3466bde4d9a3bccb22026118544a1 Signed-off-by: Dohyung Kim --- mic/utils/fs_related.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/mic/utils/fs_related.py b/mic/utils/fs_related.py index 9be1a10..ce3d214 100755 --- a/mic/utils/fs_related.py +++ b/mic/utils/fs_related.py @@ -18,6 +18,7 @@ from __future__ import with_statement import os +import re import sys import errno import stat @@ -362,7 +363,7 @@ class SparseLoopbackDisk(LoopbackDisk): self.expand(create = True) LoopbackDisk.create(self) -class Mount: +class Mount(object): """A generic base class to deal with mounting things.""" def __init__(self, mountdir): self.mountdir = mountdir @@ -454,10 +455,25 @@ class ExtDiskMount(DiskMount): self.uuid = fsuuid or str(uuid.uuid4()) self.skipformat = skipformat self.fsopts = fsopts - self.extopts = None + self.__extopts = None self.dumpe2fs = find_binary_path("dumpe2fs") self.tune2fs = find_binary_path("tune2fs") + def __get_extopts(self): + return self.__extopts + + def __set_extopts(self, val): + if val is None: + self.__extopts = None + else: + m = re.search(r'-b\s*(?P\d+)', val) + if m: + self.blocksize = int(m.group('blocksize')) + val = val.replace(m.group(), '') + self.__extopts = val + + extopts = property(__get_extopts, __set_extopts) + def __parse_field(self, output, field): for line in output.split("\n"): if line.startswith(field + ":"): @@ -473,8 +489,8 @@ 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), "-U", self.uuid] - if self.extopts: - cmdlist.extend(self.extopts.split()) + if self.__extopts: + cmdlist.extend(self.__extopts.split()) cmdlist.extend([self.disk.device]) rc, errout = runner.runtool(cmdlist, catch=2) @@ -482,7 +498,7 @@ class ExtDiskMount(DiskMount): raise MountError("Error creating %s filesystem on disk %s:\n%s" % (self.fstype, self.disk.device, errout)) - if not self.extopts: + 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]) -- 2.7.4