Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/models/network_configuration.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/models/network_configuration.py')
-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")