neil / rpms / anaconda

Forked from rpms/anaconda a year ago
Clone
e3e71a
From f8a9fe6ffe25d5a9b07be899b0ebe52556d2ecd4 Mon Sep 17 00:00:00 2001
e3e71a
From: Jim Perrin <jperrin@centos.org>
e3e71a
Date: Fri, 20 Nov 2015 15:01:37 -0600
e3e71a
Subject: [PATCH] add centos install class
e3e71a
e3e71a
---
e3e71a
 pyanaconda/installclasses/centos.py | 95 +++++++++++++++++++++++++++++++++++++
e3e71a
 1 file changed, 95 insertions(+)
e3e71a
 create mode 100644 pyanaconda/installclasses/centos.py
e3e71a
e3e71a
diff --git a/pyanaconda/installclasses/centos.py b/pyanaconda/installclasses/centos.py
e3e71a
new file mode 100644
e3e71a
index 0000000..14a178d
e3e71a
--- /dev/null
e3e71a
+++ b/pyanaconda/installclasses/centos.py
e3e71a
@@ -0,0 +1,95 @@
9d7c21
+#
9d7c21
+# rhel.py
9d7c21
+#
9d7c21
+# Copyright (C) 2010  Red Hat, Inc.  All rights reserved.
9d7c21
+#
9d7c21
+# This program is free software; you can redistribute it and/or modify
9d7c21
+# it under the terms of the GNU General Public License as published by
9d7c21
+# the Free Software Foundation; either version 2 of the License, or
9d7c21
+# (at your option) any later version.
9d7c21
+#
9d7c21
+# This program is distributed in the hope that it will be useful,
9d7c21
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
9d7c21
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9d7c21
+# GNU General Public License for more details.
9d7c21
+#
9d7c21
+# You should have received a copy of the GNU General Public License
9d7c21
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
9d7c21
+#
9d7c21
+
9d7c21
+from pyanaconda.installclass import BaseInstallClass
e3e71a
+from pyanaconda.product import productName
9d7c21
+from pyanaconda import network
9d7c21
+from pyanaconda import nm
e3e71a
+from pyanaconda.kickstart import getAvailableDiskSpace
e3e71a
+from blivet.partspec import PartSpec
e3e71a
+from blivet.platform import platform
e3e71a
+from blivet.devicelibs import swap
e3e71a
+from blivet.size import Size
9d7c21
+
e3e71a
+class RHELBaseInstallClass(BaseInstallClass):
e3e71a
+    name = "CentOS Linux"
e3e71a
+    sortPriority = 20000
e3e71a
+    if not productName.startswith("CentOS "):
e3e71a
+        hidden = True
9d7c21
+    defaultFS = "xfs"
9d7c21
+
9d7c21
+    bootloaderTimeoutDefault = 5
9d7c21
+
9d7c21
+    ignoredPackages = ["ntfsprogs", "reiserfs-utils"]
9d7c21
+
9d7c21
+    installUpdates = False
9d7c21
+
9d7c21
+    _l10n_domain = "comps"
9d7c21
+
e3e71a
+    efi_dir = "centos"
e3e71a
+
9d7c21
+
9d7c21
+    def configure(self, anaconda):
9d7c21
+        BaseInstallClass.configure(self, anaconda)
e3e71a
+        self.setDefaultPartitioning(anaconda.storage)
9d7c21
+
9d7c21
+    def setNetworkOnbootDefault(self, ksdata):
e3e71a
+        if network.has_some_wired_autoconnect_device():
9d7c21
+            return
e3e71a
+        # choose the device used during installation
e3e71a
+        # (ie for majority of cases the one having the default route)
e3e71a
+        dev = network.default_route_device() \
e3e71a
+              or network.default_route_device(family="inet6")
e3e71a
+        if not dev:
9d7c21
+            return
e3e71a
+        # ignore wireless (its ifcfgs would need to be handled differently)
e3e71a
+        if nm.nm_device_type_is_wifi(dev):
9d7c21
+            return
e3e71a
+        network.update_onboot_value(dev, "yes", ksdata)
9d7c21
+
9d7c21
+    def __init__(self):
9d7c21
+        BaseInstallClass.__init__(self)
e3e71a
+
e3e71a
+class RHELAtomicInstallClass(RHELBaseInstallClass):
e3e71a
+    name = "CentOS Linux Atomic Host"
e3e71a
+    sortPriority=21000
e3e71a
+    hidden = not productName.startswith(("CentOS Atomic Host", "CentOS Linux Atomic"))
e3e71a
+
e3e71a
+    def setDefaultPartitioning(self, storage):
e3e71a
+        autorequests = [PartSpec(mountpoint="/", fstype=storage.defaultFSType,
e3e71a
+                                size=Size("1GiB"), maxSize=Size("3GiB"), grow=True, lv=True)]
e3e71a
+
e3e71a
+        bootreqs = platform.setDefaultPartitioning()
e3e71a
+        if bootreqs:
e3e71a
+            autorequests.extend(bootreqs)
e3e71a
+
e3e71a
+        disk_space = getAvailableDiskSpace(storage)
e3e71a
+        swp = swap.swapSuggestion(disk_space=disk_space)
e3e71a
+        autorequests.append(PartSpec(fstype="swap", size=swp, grow=False,
e3e71a
+                                    lv=True, encrypted=True))
e3e71a
+
e3e71a
+        for autoreq in autorequests:
e3e71a
+            if autoreq.fstype is None:
e3e71a
+                if autoreq.mountpoint == "/boot":
e3e71a
+                    autoreq.fstype = storage.defaultBootFSType
e3e71a
+                    autoreq.size = Size("300MiB")
e3e71a
+                else:
e3e71a
+                    autoreq.fstype = storage.defaultFSType
e3e71a
+
e3e71a
+        storage.autoPartitionRequests = autorequests
e3e71a
-- 
e3e71a
1.8.3.1
e3e71a