zengxyz / rpms / anaconda

Forked from rpms/anaconda 4 months ago
Clone
Blob Blame History Raw
From 4808f43abc14396add62e9b0a92fbe8cf5b41346 Mon Sep 17 00:00:00 2001
From: Radek Vykydal <rvykydal@redhat.com>
Date: Tue, 21 Oct 2014 17:46:47 +0200
Subject: [PATCH 30/30] atomic: set up atomic specific partitioning defaults

Resolves: rhbz#1155452

/boot will be 300M and / LV will be 3G. LVs for docker will be created by special
service using root's VG.
---
 pyanaconda/installclasses/rhel.py | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/pyanaconda/installclasses/rhel.py b/pyanaconda/installclasses/rhel.py
index b7691cf..a9a99f6 100644
--- a/pyanaconda/installclasses/rhel.py
+++ b/pyanaconda/installclasses/rhel.py
@@ -24,11 +24,15 @@ from pyanaconda import network
 from pyanaconda import nm
 from pyanaconda import iutil
 import types
+from pyanaconda.kickstart import getAvailableDiskSpace
+from blivet.partspec import PartSpec
+from blivet.platform import platform
+from blivet.devicelibs import swap
 
 class RHELBaseInstallClass(BaseInstallClass):
     name = "Red Hat Enterprise Linux"
     sortPriority = 20000
-    if not productName.startswith(("Red Hat ", "RHEL Atomic")):
+    if not productName.startswith("Red Hat "):
         hidden = True
     defaultFS = "xfs"
 
@@ -45,7 +49,7 @@ class RHELBaseInstallClass(BaseInstallClass):
 
     def configure(self, anaconda):
         BaseInstallClass.configure(self, anaconda)
-        BaseInstallClass.setDefaultPartitioning(self, anaconda.storage)
+        self.setDefaultPartitioning(anaconda.storage)
 
     # Set first boot policy regarding ONBOOT value
     # (i.e. which network devices should be activated automatically after reboot)
@@ -84,3 +88,31 @@ class RHELBaseInstallClass(BaseInstallClass):
 
     def __init__(self):
         BaseInstallClass.__init__(self)
+
+class RHELAtomicInstallClass(RHELBaseInstallClass):
+    name = "RHEL Atomic Host"
+    if productName.startswith("RHEL Atomic"):
+        hidden = False
+
+    def setDefaultPartitioning(self, storage):
+        autorequests = [PartSpec(mountpoint="/", fstype=storage.defaultFSType,
+                                size=1024, maxSize=3*1024, grow=True, lv=True)]
+
+        bootreqs = platform.setDefaultPartitioning()
+        if bootreqs:
+            autorequests.extend(bootreqs)
+
+        disk_space = getAvailableDiskSpace(storage)
+        swp = swap.swapSuggestion(disk_space=disk_space)
+        autorequests.append(PartSpec(fstype="swap", size=swp, grow=False,
+                                    lv=True, encrypted=True))
+
+        for autoreq in autorequests:
+            if autoreq.fstype is None:
+                if autoreq.mountpoint == "/boot":
+                    autoreq.fstype = storage.defaultBootFSType
+                    autoreq.size = 300
+                else:
+                    autoreq.fstype = storage.defaultFSType
+
+        storage.autoPartitionRequests = autorequests
-- 
1.9.3