[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[pykickstart][PATCHv2] Add --same-as-ram option for swap size specification (#744129)



---
 pykickstart/commands/partition.py |   36 ++++++++++++++++++++++++++++++++++++
 pykickstart/handlers/control.py   |    6 +++---
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/pykickstart/commands/partition.py b/pykickstart/commands/partition.py
index 70b2283..804ab10 100644
--- a/pykickstart/commands/partition.py
+++ b/pykickstart/commands/partition.py
@@ -180,6 +180,22 @@ class F12_PartData(F11_PartData):
 
         return retval
 
+class RHEL6_PartData(F12_PartData):
+    removedKeywords = F12_PartData.removedKeywords
+    removedAttrs = F12_PartData.removedAttrs
+
+    def __init__(self, *args, **kwargs):
+        F12_PartData.__init__(self, *args, **kwargs)
+
+        self.sameAsRam = kwargs.get("sameAsRam", False)
+
+    def _getArgsAsStr(self):
+        retval = F11_PartData._getArgsAsStr(self)
+
+        if self.sameAsRam:
+            retval += "--same-as-ram"
+
+        return retval
 
 class FC3_Partition(KickstartCommand):
     removedKeywords = KickstartCommand.removedKeywords
@@ -334,3 +350,23 @@ class F12_Partition(F11_Partition):
         op.add_option("--escrowcert")
         op.add_option("--backuppassphrase", action="store_true", default=False)
         return op
+
+class RHEL6_Partition(F12_Partition):
+    removedKeywords = F12_Partition.removedKeywords
+    removedAttrs = F12_Partition.removedAttrs
+
+    def _getParser(self):
+        op = F12_Partition._getParser(self)
+        op.add_option("--same-as-ram", dest="sameAsRam", action="store_true",
+                        default=False)
+        return op
+
+    def parse(self, args):
+        pd = F12_Partition.parse(self, args)
+
+        if pd.recommended and pd.sameAsRam:
+            raise KickstartValueError(formatErrorMsg(self.lineno,
+             msg=_("Options --recommended and --same-as-ram are mutually exclusive.")))
+
+        return pd
+
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index e89d10c..0ee97ad 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -845,8 +845,8 @@ commandMap = {
         "multipath": multipath.FC6_MultiPath,
         "network": network.RHEL6_Network,
         "nfs": method.RHEL6_Method,
-        "part": partition.F12_Partition,
-        "partition": partition.F12_Partition,
+        "part": partition.RHEL6_Partition,
+        "partition": partition.RHEL6_Partition,
         "poweroff": reboot.FC6_Reboot,
         "raid": raid.F13_Raid,
         "reboot": reboot.FC6_Reboot,
@@ -1071,7 +1071,7 @@ dataMap = {
         "LogVolData": logvol.F12_LogVolData,
         "MultiPathData": multipath.FC6_MultiPathData,
         "NetworkData": network.RHEL6_NetworkData,
-        "PartData": partition.F12_PartData,
+        "PartData": partition.RHEL6_PartData,
         "RaidData": raid.F13_RaidData,
         "RepoData": repo.RHEL6_RepoData,
         "SshPwData": sshpw.F13_SshPwData,
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]