Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/models
diff options
context:
space:
mode:
authorWerner Llácer <wllacer@gmail.com>2022-03-28 13:44:10 +0200
committerGitHub <noreply@github.com>2022-03-28 13:44:10 +0200
commite85c9b65315498ab4701ea31c079d198eba8d9ac (patch)
treee19c6066c3ba0d27f724f783431165199b98c991 /archinstall/lib/models
parent69bd88a7f9f537b8015915110ee9e4333be31fc1 (diff)
Issues with Network Management and user management in menu (#1036)
* A problem with default values treatment at superusers (and users) on the main menu * Solving issues when changing the selection of nic, ask_to_configure_network failed in several places. Solved, temporarily with the creation of __getitem__ and get methods at NetworkManager * Accept old style definitions for nic * flake8 complains * log string corrected (issue 1039) * Correct exit when no disk is selected and we don't wish to continue
Diffstat (limited to 'archinstall/lib/models')
-rw-r--r--archinstall/lib/models/network_configuration.py46
1 files changed, 44 insertions, 2 deletions
diff --git a/archinstall/lib/models/network_configuration.py b/archinstall/lib/models/network_configuration.py
index f1ee4c3f..4b57da00 100644
--- a/archinstall/lib/models/network_configuration.py
+++ b/archinstall/lib/models/network_configuration.py
@@ -40,11 +40,32 @@ class NetworkConfiguration:
return self.__dict__
@classmethod
- def parse_arguments(cls, config: Dict[str, str]) -> Optional["NetworkConfiguration"]:
+ def parse_arguments(cls, config: Union[str,Dict[str, str]]) -> Optional["NetworkConfiguration"]:
nic_type = config.get('type', None)
if not nic_type:
- return None
+ # old style definitions
+ if isinstance(config,str): # is a ISO network
+ return NetworkConfiguration(NicType.ISO)
+ elif config.get('NetworkManager'): # is a network manager configuration
+ return NetworkConfiguration(NicType.NM)
+ elif 'ip' in config:
+ return NetworkConfiguration(
+ NicType.MANUAL,
+ iface=config.get('nic', ''),
+ ip=config.get('ip'),
+ gateway=config.get('gateway', ''),
+ dns=config.get('dns', []),
+ dhcp=False
+ )
+ elif 'nic' in config:
+ return NetworkConfiguration(
+ NicType.MANUAL,
+ iface=config.get('nic', ''),
+ dhcp=True
+ )
+ else: # not recognized
+ return None
try:
type = NicType(nic_type)
@@ -95,3 +116,24 @@ class NetworkConfiguration:
installation.configure_nic(self)
installation.enable_service('systemd-networkd')
installation.enable_service('systemd-resolved')
+
+ def get(self, key :str, default_value :Any = None) -> Any:
+ result = self.__getitem__(key)
+ if result is None:
+ return default_value
+ else:
+ return result
+
+ def __getitem__(self, key :str) -> Any:
+ if key == 'type':
+ return self.type
+ elif key == 'iface':
+ return self.iface
+ elif key == 'gateway':
+ return self.gateway
+ elif key == 'dns':
+ return self.dns
+ elif key == 'dhcp':
+ return self.dhcp
+ else:
+ raise KeyError(f"key {key} not available at NetworkConfiguration")