Merge pull request #1786 from ogayot/virt-netdev-help-crash

network: fix crash upon accessing Help menu after creating a bond
This commit is contained in:
Olivier Gayot 2023-09-07 09:01:35 +02:00 committed by GitHub
commit 5cc6f5df4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -255,6 +255,8 @@ class NetworkController(BaseNetworkController, SubiquityController):
async def global_addresses_GET(self) -> List[str]: async def global_addresses_GET(self) -> List[str]:
ips: List[str] = [] ips: List[str] = []
for dev in self.model.get_all_netdevs(): for dev in self.model.get_all_netdevs():
if dev.info is None:
continue
ips.extend(map(str, dev.actual_global_ip_addresses)) ips.extend(map(str, dev.actual_global_ip_addresses))
return ips return ips

View File

@ -114,6 +114,8 @@ class MetaController:
ips: List[str] = [] ips: List[str] = []
if self.app.base_model.network: if self.app.base_model.network:
for dev in self.app.base_model.network.get_all_netdevs(): for dev in self.app.base_model.network.get_all_netdevs():
if dev.info is None:
continue
ips.extend(map(str, dev.actual_global_ip_addresses)) ips.extend(map(str, dev.actual_global_ip_addresses))
if not ips: if not ips:
return None return None

View File

@ -21,6 +21,7 @@ from socket import AF_INET, AF_INET6
from typing import Dict, List, Optional from typing import Dict, List, Optional
import attr import attr
import probert.network
import yaml import yaml
from subiquitycore import netplan from subiquitycore import netplan
@ -189,13 +190,16 @@ class BondParameters:
] ]
class NetworkDev(object): class NetworkDev:
def __init__(self, model, name, typ): def __init__(self, model, name, typ):
self._model = model self._model = model
self._name = name self._name = name
self.type = typ self.type = typ
self.config = {} self.config = {}
self.info = None # Devices that have been configured in Subiquity but do not (yet) exist
# on the system have their "info" field set to None. Once they exist,
# probert should pass on the information through a call to new_link().
self.info: Optional[probert.network.Link] = None
self.disabled_reason = None self.disabled_reason = None
self.dhcp_events = {} self.dhcp_events = {}
self._dhcp_state = { self._dhcp_state = {