reserved-space is an amount to reserve in MB reserved-percent is a percentage of total vg size to reserve Related: rhbz#663647 --- pykickstart/commands/volgroup.py | 46 ++++++++++++++++++++++++++++++++++--- pykickstart/handlers/control.py | 4 +- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/pykickstart/commands/volgroup.py b/pykickstart/commands/volgroup.py index 255c47f..c8fbd3d 100644 --- a/pykickstart/commands/volgroup.py +++ b/pykickstart/commands/volgroup.py @@ -18,6 +18,7 @@ # with the express permission of Red Hat, Inc. # from pykickstart.base import * +from pykickstart.errors import * from pykickstart.options import * import gettext @@ -39,10 +40,8 @@ class FC3_VolGroupData(BaseData): def __eq__(self, y): return self.vgname == y.vgname - def __str__(self): - retval = BaseData.__str__(self) - retval += "volgroup %s" % self.vgname - + def _getArgsAsStr(self): + retval = "" if not self.format: retval += " --noformat" if self.pesize != 0: @@ -50,8 +49,29 @@ class FC3_VolGroupData(BaseData): if self.preexist: retval += " --useexisting" + return retval + + def __str__(self): + retval = BaseData.__str__(self) + retval += "volgroup %s" % self.vgname + retval += self._getArgsAsStr() return retval + " " + " ".join(self.physvols) + "\n" +class F16_VolGroupData(FC3_VolGroupData): + def __init__(self, *args, **kwargs): + FC3_VolGroupData.__init__(self, *args, **kwargs) + self.reserved_space = kwargs.get("reserved-space", 0) + self.reserved_percent = kwargs.get("reserved-percent", 0) + + def _getArgsAsStr(self): + retval = FC3_VolGroupData._getArgsAsStr(self) + if self.reserved_space > 0: + retval += " --reserved-space=%d" % self.reserved_space + if self.reserved_percent > 0: + retval += " --reserved-percent=%d" % self.reserved_percent + + return retval + class FC3_VolGroup(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -100,3 +120,21 @@ class FC3_VolGroup(KickstartCommand): def dataList(self): return self.vgList + +class F16_VolGroup(FC3_VolGroup): + def _getParser(self): + op = FC3_VolGroup._getParser(self) + op.add_option("--reserved-space", dest="reserved_space", type="int", + nargs=1, default=0) + op.add_option("--reserved-percent", dest="reserved_percent", type="int", + nargs=1, default=0) + return op + + def parse(self, args): + vg = FC3_VolGroup.parse(self, args) + if vg.reserved_space < 0: + raise KickstartValueError(formatErrorMsg(vg.lineno, msg="Volume group reserved space must be a positive integer.")) + elif 0 < vg.reserved_percent < 100: + raise KickstartValueError(formatErrorMsg(vg.lineno, msg="Volume group reserved space percentage must be between 1 and 99.")) + + return vg diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py index 27cbaad..0dd7d1e 100644 --- a/pykickstart/handlers/control.py +++ b/pykickstart/handlers/control.py @@ -817,7 +817,7 @@ commandMap = { "url": method.F14_Method, "user": user.F12_User, "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, + "volgroup": volgroup.F16_VolGroup, "xconfig": xconfig.F14_XConfig, "zerombr": zerombr.F9_ZeroMbr, "zfcp": zfcp.F14_ZFCP, @@ -1251,7 +1251,7 @@ dataMap = { "RepoData": repo.F15_RepoData, "SshPwData": sshpw.F13_SshPwData, "UserData": user.F12_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, + "VolGroupData": volgroup.F16_VolGroupData, "ZFCPData": zfcp.F14_ZFCPData, }, RHEL3: { -- 1.7.6.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list