network: initialize bond, vlan & wlan to None to avoid changing type
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
2cd1cf2659
commit
f0ea1d16c2
|
@ -208,6 +208,7 @@ class NetworkDev(object):
|
||||||
if self.name in dev2.config.get('interfaces', []):
|
if self.name in dev2.config.get('interfaces', []):
|
||||||
bond_master = dev2.name
|
bond_master = dev2.name
|
||||||
break
|
break
|
||||||
|
bond: Optional[BondConfig] = None
|
||||||
if self.type == 'bond' and self.config is not None:
|
if self.type == 'bond' and self.config is not None:
|
||||||
params = self.config['parameters']
|
params = self.config['parameters']
|
||||||
bond = BondConfig(
|
bond = BondConfig(
|
||||||
|
@ -215,20 +216,16 @@ class NetworkDev(object):
|
||||||
mode=params['mode'],
|
mode=params['mode'],
|
||||||
xmit_hash_policy=params.get('xmit-hash-policy'),
|
xmit_hash_policy=params.get('xmit-hash-policy'),
|
||||||
lacp_rate=params.get('lacp-rate'))
|
lacp_rate=params.get('lacp-rate'))
|
||||||
else:
|
vlan: Optional[VLANConfig] = None
|
||||||
bond = None
|
|
||||||
if self.type == 'vlan' and self.config is not None:
|
if self.type == 'vlan' and self.config is not None:
|
||||||
vlan = VLANConfig(id=self.config['id'], link=self.config['link'])
|
vlan = VLANConfig(id=self.config['id'], link=self.config['link'])
|
||||||
else:
|
wlan: Optional[WLANStatus] = None
|
||||||
vlan = None
|
|
||||||
if self.type == 'wlan':
|
if self.type == 'wlan':
|
||||||
ssid, psk = self.configured_ssid
|
ssid, psk = self.configured_ssid
|
||||||
wlan = WLANStatus(
|
wlan = WLANStatus(
|
||||||
config=WLANConfig(ssid=ssid, psk=psk),
|
config=WLANConfig(ssid=ssid, psk=psk),
|
||||||
scan_state=self.info.wlan['scan_state'],
|
scan_state=self.info.wlan['scan_state'],
|
||||||
visible_ssids=self.info.wlan['visible_ssids'])
|
visible_ssids=self.info.wlan['visible_ssids'])
|
||||||
else:
|
|
||||||
wlan = None
|
|
||||||
|
|
||||||
dhcp_addresses = self.dhcp_addresses()
|
dhcp_addresses = self.dhcp_addresses()
|
||||||
configured_addresses: Dict[int, List[str]] = {4: [], 6: []}
|
configured_addresses: Dict[int, List[str]] = {4: [], 6: []}
|
||||||
|
|
Loading…
Reference in New Issue