Configure the network on the newly installed system
(preset: NetworkConfiguration | None)
| 167 | |
| 168 | |
| 169 | async def select_network(preset: NetworkConfiguration | None) -> NetworkConfiguration | None: |
| 170 | """ |
| 171 | Configure the network on the newly installed system |
| 172 | """ |
| 173 | |
| 174 | items = [MenuItem(n.display_msg(), value=n) for n in NicType] |
| 175 | group = MenuItemGroup(items, sort_items=False) |
| 176 | |
| 177 | if preset: |
| 178 | group.set_selected_by_value(preset.type) |
| 179 | |
| 180 | header = tr('Choose network configuration') + '\n' |
| 181 | header += tr('Recommended: Network Manager for desktop, Manual for server') + '\n' |
| 182 | |
| 183 | result = await Selection[NicType]( |
| 184 | group, |
| 185 | header=header, |
| 186 | allow_reset=True, |
| 187 | allow_skip=True, |
| 188 | ).show() |
| 189 | |
| 190 | match result.type_: |
| 191 | case ResultType.Skip: |
| 192 | return preset |
| 193 | case ResultType.Reset: |
| 194 | return None |
| 195 | case ResultType.Selection: |
| 196 | config = result.get_value() |
| 197 | |
| 198 | match config: |
| 199 | case NicType.ISO: |
| 200 | return NetworkConfiguration(NicType.ISO) |
| 201 | case NicType.NM: |
| 202 | return NetworkConfiguration(NicType.NM) |
| 203 | case NicType.NM_IWD: |
| 204 | return NetworkConfiguration(NicType.NM_IWD) |
| 205 | case NicType.IWD: |
| 206 | return NetworkConfiguration(NicType.IWD) |
| 207 | case NicType.MANUAL: |
| 208 | preset_nics = preset.nics if preset else [] |
| 209 | nics = await ManualNetworkConfig(tr('Configure interfaces'), preset_nics).show() |
| 210 | |
| 211 | if nics: |
| 212 | return NetworkConfiguration(NicType.MANUAL, nics) |
| 213 | |
| 214 | return preset |
nothing calls this directly
no test coverage detected