Guest User

Asianux

a guest
Dec 3rd, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.10 KB | None | 0 0
  1. #
  2. # rhel.py
  3. #
  4. # Copyright (C) 2010  Red Hat, Inc.  All rights reserved.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18. #
  19.  
  20. from pyanaconda.installclass import BaseInstallClass
  21. from pyanaconda.constants import *
  22. from pyanaconda.product import *
  23. from pyanaconda import network
  24. from pyanaconda import nm
  25. import types
  26.  
  27. class InstallClass(BaseInstallClass):
  28.     # name has underscore used for mnemonics, strip if you dont need it
  29.     id = "asianux"
  30.     name = N_("Asianux Server")
  31.     sortPriority = 20000
  32.     if not productName.startswith("Red Hat ") or productName.startswith("Fedora "):
  33.         hidden = 1
  34.     defaultFS = "ext4"
  35.  
  36.     bootloaderTimeoutDefault = 5
  37.     bootloaderExtraArgs = []
  38.  
  39.     ignoredPackages = ["ntfsprogs", "reiserfs-utils"]
  40.  
  41.     installUpdates = False
  42.  
  43.     _l10n_domain = "comps"
  44.  
  45.     efi_dir = "asianux"
  46.  
  47.     def configure(self, anaconda):
  48.         BaseInstallClass.configure(self, anaconda)
  49.         BaseInstallClass.setDefaultPartitioning(self, anaconda.storage)
  50.  
  51.     # Set first boot policy regarding ONBOOT value
  52.     # (i.e. which network devices should be activated automatically after reboot)
  53.     # After switch root we set ONBOOT=no as default for all devices not activated
  54.     # in initramfs. Here, at the end of installation, we check and modify it eventually.
  55.     def setNetworkOnbootDefault(self, ksdata):
  56.         # if there is no device to be autoactivated after reboot
  57.         for devName in nm.nm_devices():
  58.             if nm.nm_device_type_is_wifi(devName):
  59.                 continue
  60.             try:
  61.                 onboot = nm.nm_device_setting_value(devName, "connection", "autoconnect")
  62.             except nm.SettingsNotFoundError:
  63.                 continue
  64.             if not onboot == False:
  65.                 return
  66.  
  67.         # set ONBOOT=yes for the device used during installation
  68.         # (ie for majority of cases the one having the default route)
  69.         devName = network.default_route_device()
  70.         if not devName:
  71.             return
  72.         if nm.nm_device_type_is_wifi(devName):
  73.             return
  74.         ifcfg_path = network.find_ifcfg_file_of_device(devName, root_path=ROOT_PATH)
  75.         if not ifcfg_path:
  76.             return
  77.         ifcfg = network.IfcfgFile(ifcfg_path)
  78.         ifcfg.read()
  79.         ifcfg.set(('ONBOOT', 'yes'))
  80.         ifcfg.write()
  81.         for nd in ksdata.network.network:
  82.             if nd.device == devName:
  83.                 nd.onboot = True
  84.                 break
  85.  
  86.     def __init__(self):
  87.         BaseInstallClass.__init__(self)
Advertisement
Add Comment
Please, Sign In to add comment