Refactor network config installer (#4143)
* Refactor network config installer * Update * Move network menu * Remove singleton
This commit is contained in:
parent
5fe42bd2f5
commit
316251f6e0
|
|
@ -5,6 +5,7 @@ from archinstall.lib.disk.disk_menu import DiskLayoutConfigurationMenu
|
||||||
from archinstall.lib.models.application import ApplicationConfiguration, ZramConfiguration
|
from archinstall.lib.models.application import ApplicationConfiguration, ZramConfiguration
|
||||||
from archinstall.lib.models.authentication import AuthenticationConfiguration
|
from archinstall.lib.models.authentication import AuthenticationConfiguration
|
||||||
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType, FilesystemType, PartitionModification
|
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType, FilesystemType, PartitionModification
|
||||||
|
from archinstall.lib.network.network_menu import ask_to_configure_network
|
||||||
from archinstall.lib.packages import list_available_packages
|
from archinstall.lib.packages import list_available_packages
|
||||||
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
|
from archinstall.tui.ui.menu_item import MenuItem, MenuItemGroup
|
||||||
|
|
||||||
|
|
@ -21,7 +22,6 @@ from .interactions.general_conf import (
|
||||||
ask_hostname,
|
ask_hostname,
|
||||||
ask_ntp,
|
ask_ntp,
|
||||||
)
|
)
|
||||||
from .interactions.network_menu import ask_to_configure_network
|
|
||||||
from .interactions.system_conf import ask_for_swap, select_kernel
|
from .interactions.system_conf import ask_for_swap, select_kernel
|
||||||
from .locale.locale_menu import LocaleMenu
|
from .locale.locale_menu import LocaleMenu
|
||||||
from .menu.abstract_menu import CONFIG_KEY, AbstractMenu
|
from .menu.abstract_menu import CONFIG_KEY, AbstractMenu
|
||||||
|
|
|
||||||
|
|
@ -14,18 +14,15 @@ from .general_conf import (
|
||||||
ask_ntp,
|
ask_ntp,
|
||||||
select_archinstall_language,
|
select_archinstall_language,
|
||||||
)
|
)
|
||||||
from .network_menu import ManualNetworkConfig, ask_to_configure_network
|
|
||||||
from .system_conf import ask_for_swap, select_driver, select_kernel
|
from .system_conf import ask_for_swap, select_driver, select_kernel
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'ManualNetworkConfig',
|
|
||||||
'add_number_of_parallel_downloads',
|
'add_number_of_parallel_downloads',
|
||||||
'ask_additional_packages_to_install',
|
'ask_additional_packages_to_install',
|
||||||
'ask_for_a_timezone',
|
'ask_for_a_timezone',
|
||||||
'ask_for_swap',
|
'ask_for_swap',
|
||||||
'ask_hostname',
|
'ask_hostname',
|
||||||
'ask_ntp',
|
'ask_ntp',
|
||||||
'ask_to_configure_network',
|
|
||||||
'get_default_partition_layout',
|
'get_default_partition_layout',
|
||||||
'select_archinstall_language',
|
'select_archinstall_language',
|
||||||
'select_devices',
|
'select_devices',
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,11 @@ from __future__ import annotations
|
||||||
import re
|
import re
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import TYPE_CHECKING, NotRequired, Self, TypedDict, override
|
from typing import NotRequired, Self, TypedDict, override
|
||||||
|
|
||||||
from archinstall.lib.output import debug
|
from archinstall.lib.output import debug
|
||||||
from archinstall.lib.translationhandler import tr
|
from archinstall.lib.translationhandler import tr
|
||||||
|
|
||||||
from ..models.profile import ProfileConfiguration
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from archinstall.lib.installer import Installer
|
|
||||||
|
|
||||||
|
|
||||||
class NicType(Enum):
|
class NicType(Enum):
|
||||||
ISO = 'iso'
|
ISO = 'iso'
|
||||||
|
|
@ -140,42 +135,6 @@ class NetworkConfiguration:
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def install_network_config(
|
|
||||||
self,
|
|
||||||
installation: Installer,
|
|
||||||
profile_config: ProfileConfiguration | None = None,
|
|
||||||
) -> None:
|
|
||||||
match self.type:
|
|
||||||
case NicType.ISO:
|
|
||||||
installation.copy_iso_network_config(
|
|
||||||
enable_services=True, # Sources the ISO network configuration to the install medium.
|
|
||||||
)
|
|
||||||
case NicType.NM | NicType.NM_IWD:
|
|
||||||
# Install NetworkManager package for both cases
|
|
||||||
packages = ['networkmanager']
|
|
||||||
# Default back-end only for non-iwd
|
|
||||||
if self.type == NicType.NM:
|
|
||||||
packages.append('wpa_supplicant')
|
|
||||||
|
|
||||||
installation.add_additional_packages(packages)
|
|
||||||
|
|
||||||
# Desktop profile -> Always add applet
|
|
||||||
if profile_config and profile_config.profile:
|
|
||||||
if profile_config.profile.is_desktop_profile():
|
|
||||||
installation.add_additional_packages('network-manager-applet')
|
|
||||||
|
|
||||||
installation.enable_service('NetworkManager.service')
|
|
||||||
if self.type == NicType.NM_IWD:
|
|
||||||
# NM_IWD special handling
|
|
||||||
installation.configure_nm_iwd()
|
|
||||||
installation.disable_service('iwd.service')
|
|
||||||
|
|
||||||
case NicType.MANUAL:
|
|
||||||
for nic in self.nics:
|
|
||||||
installation.configure_nic(nic)
|
|
||||||
installation.enable_service('systemd-networkd')
|
|
||||||
installation.enable_service('systemd-resolved')
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class WifiNetwork:
|
class WifiNetwork:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
from archinstall.lib.installer import Installer
|
||||||
|
from archinstall.lib.models.network import NetworkConfiguration, NicType
|
||||||
|
from archinstall.lib.models.profile import ProfileConfiguration
|
||||||
|
|
||||||
|
|
||||||
|
class NetworkHandler:
|
||||||
|
def install_network_config(
|
||||||
|
self,
|
||||||
|
network_config: NetworkConfiguration,
|
||||||
|
installation: Installer,
|
||||||
|
profile_config: ProfileConfiguration | None = None,
|
||||||
|
) -> None:
|
||||||
|
match network_config.type:
|
||||||
|
case NicType.ISO:
|
||||||
|
_ = installation.copy_iso_network_config(
|
||||||
|
enable_services=True, # Sources the ISO network configuration to the install medium.
|
||||||
|
)
|
||||||
|
case NicType.NM | NicType.NM_IWD:
|
||||||
|
# Install NetworkManager package for both cases
|
||||||
|
packages = ['networkmanager']
|
||||||
|
# Default back-end only for non-iwd
|
||||||
|
if network_config.type == NicType.NM:
|
||||||
|
packages.append('wpa_supplicant')
|
||||||
|
|
||||||
|
installation.add_additional_packages(packages)
|
||||||
|
|
||||||
|
# Desktop profile -> Always add applet
|
||||||
|
if profile_config and profile_config.profile:
|
||||||
|
if profile_config.profile.is_desktop_profile():
|
||||||
|
installation.add_additional_packages('network-manager-applet')
|
||||||
|
|
||||||
|
installation.enable_service('NetworkManager.service')
|
||||||
|
if network_config.type == NicType.NM_IWD:
|
||||||
|
# NM_IWD special handling
|
||||||
|
installation.configure_nm_iwd()
|
||||||
|
installation.disable_service('iwd.service')
|
||||||
|
|
||||||
|
case NicType.MANUAL:
|
||||||
|
for nic in network_config.nics:
|
||||||
|
installation.configure_nic(nic)
|
||||||
|
installation.enable_service('systemd-networkd')
|
||||||
|
installation.enable_service('systemd-resolved')
|
||||||
|
|
@ -19,6 +19,7 @@ from archinstall.lib.models.device import (
|
||||||
EncryptionType,
|
EncryptionType,
|
||||||
)
|
)
|
||||||
from archinstall.lib.models.users import User
|
from archinstall.lib.models.users import User
|
||||||
|
from archinstall.lib.network.network_handler import NetworkHandler
|
||||||
from archinstall.lib.output import debug, error, info
|
from archinstall.lib.output import debug, error, info
|
||||||
from archinstall.lib.packages.packages import check_version_upgrade
|
from archinstall.lib.packages.packages import check_version_upgrade
|
||||||
from archinstall.lib.profile.profiles_handler import profile_handler
|
from archinstall.lib.profile.profiles_handler import profile_handler
|
||||||
|
|
@ -115,12 +116,9 @@ def perform_installation(
|
||||||
|
|
||||||
installation.add_bootloader(config.bootloader_config.bootloader, config.bootloader_config.uki, config.bootloader_config.removable)
|
installation.add_bootloader(config.bootloader_config.bootloader, config.bootloader_config.uki, config.bootloader_config.removable)
|
||||||
|
|
||||||
# If user selected to copy the current ISO network configuration
|
if config.network_config:
|
||||||
# Perform a copy of the config
|
NetworkHandler().install_network_config(
|
||||||
network_config = config.network_config
|
config.network_config,
|
||||||
|
|
||||||
if network_config:
|
|
||||||
network_config.install_network_config(
|
|
||||||
installation,
|
installation,
|
||||||
config.profile_config,
|
config.profile_config,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from archinstall.lib.installer import Installer
|
||||||
from archinstall.lib.models import Bootloader
|
from archinstall.lib.models import Bootloader
|
||||||
from archinstall.lib.models.profile import ProfileConfiguration
|
from archinstall.lib.models.profile import ProfileConfiguration
|
||||||
from archinstall.lib.models.users import Password, User
|
from archinstall.lib.models.users import Password, User
|
||||||
|
from archinstall.lib.network.network_handler import NetworkHandler
|
||||||
from archinstall.lib.output import debug, error, info
|
from archinstall.lib.output import debug, error, info
|
||||||
from archinstall.lib.profile.profiles_handler import profile_handler
|
from archinstall.lib.profile.profiles_handler import profile_handler
|
||||||
|
|
||||||
|
|
@ -35,10 +36,9 @@ def perform_installation(mountpoint: Path) -> None:
|
||||||
installation.set_hostname('minimal-arch')
|
installation.set_hostname('minimal-arch')
|
||||||
installation.add_bootloader(Bootloader.Systemd)
|
installation.add_bootloader(Bootloader.Systemd)
|
||||||
|
|
||||||
network_config = config.network_config
|
if config.network_config:
|
||||||
|
NetworkHandler().install_network_config(
|
||||||
if network_config:
|
config.network_config,
|
||||||
network_config.install_network_config(
|
|
||||||
installation,
|
installation,
|
||||||
config.profile_config,
|
config.profile_config,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue