MCPcopy Create free account
hub / github.com/archlinux/archinstall / NetworkConfiguration

Class NetworkConfiguration

archinstall/lib/models/network.py:110–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109@dataclass
110class NetworkConfiguration(SubConfig):
111 type: NicType
112 nics: list[Nic] = field(default_factory=list)
113
114 @override
115 def json(self) -> _NetworkConfigurationSerialization:
116 config: _NetworkConfigurationSerialization = {'type': self.type.value}
117 if self.nics:
118 config['nics'] = [n.json() for n in self.nics]
119
120 return config
121
122 @override
123 def summary(self) -> str:
124 return self.type.display_msg()
125
126 @classmethod
127 def parse_arg(cls, config: _NetworkConfigurationSerialization) -> Self | None:
128 nic_type = config.get('type', None)
129 if not nic_type:
130 return None
131
132 match NicType(nic_type):
133 case NicType.ISO:
134 return cls(NicType.ISO)
135 case NicType.NM:
136 return cls(NicType.NM)
137 case NicType.NM_IWD:
138 return cls(NicType.NM_IWD)
139 case NicType.IWD:
140 return cls(NicType.IWD)
141 case NicType.MANUAL:
142 nics_arg = config.get('nics', [])
143 if nics_arg:
144 nics = [Nic.parse_arg(n) for n in nics_arg]
145 return cls(NicType.MANUAL, nics)
146
147 return None
148
149
150@dataclass

Callers 2

test_config_file_parsingFunction · 0.90
select_networkFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_config_file_parsingFunction · 0.72