Commit Graph

126 Commits

Author SHA1 Message Date
Olivier Gayot 16688c56c4
Merge pull request #1789 from ogayot/netdev-deleted
network: fix crash when Wi-Fi or eth interface gets removed from the system
2023-09-07 13:47:30 +02:00
Olivier Gayot e10343b7e5 network: fix crash when Wi-Fi or eth interface gets removed from the system
When a network interface is disconnected from the system (e.g.,
physically removed if it's a USB adapter), probert asynchronously calls
the del_link() method.

Upon receiving this notification, Subiquity server wants to send an
update to the Subiquity clients. The update contains information about
the interface that disappeared - which is obtained through a call to
netdev_info.

Unfortunately, for Wi-Fi and Ethernet interfaces, netdev_info
dereferences the NetworkDev.info variable. Interfaces that no longer
exist on the system (and also interfaces that do not yet exist), have
their "info" variable set to None - so an exception is raised when
dereferencing it.

Wi-Fi interface:

    File "subiquitycore/models/network.py", line 227, in netdev_info
      scan_state=self.info.wlan['scan_state'],
  AttributeError: 'NoneType' object has no attribute 'wlan'

Ethernet interface:

    File "subiquitycore/models/network.py", line 201, in netdev_info
      is_connected = bool(self.info.is_connected)
  AttributeError: 'NoneType' object has no attribute 'is_connected'

Fixed by making sure netdev_info does not raise if the dev.info variable
is None. This is a valid use-case.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-09-07 09:56:55 +02:00
Olivier Gayot 221466aa70 network: document and add type hint for NetworkDev.info
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-09-06 14:59:51 +02:00
Dan Bungert 34d40643ad format with black + isort 2023-07-25 15:27:42 -06:00
Olivier Gayot 4247846270 network: add override mechanism to force offline install
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-15 09:05:14 +01:00
Dan Bungert 9e0a90fc22 network: use routes instead of gateway directives 2022-09-06 16:44:12 -06:00
J-P Nurmi 05ca22b320 Log NetworkModel.has_network changes 2022-08-26 15:06:15 +02:00
Chad Smith ddaf48b334 models: subiquitycore.network.rendered_config_paths to list generated files 2022-07-14 21:48:51 -06:00
Olivier Gayot f0ea1d16c2 network: initialize bond, vlan & wlan to None to avoid changing type
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-12 09:50:21 +02:00
Olivier Gayot f3634dc242 Add type hints where necessary to make mypy happy
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-06 11:23:34 +02:00
Olivier Gayot 56192938a9 network: fixed typo addressesses -> addresses
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-06 11:23:10 +02:00
Michael Hudson-Doyle 744269d074 remove stdlib backports from Python 3.8 2021-10-12 18:55:09 -06:00
Michael Hudson-Doyle fa9628f34c remove support from network model for filtering out wlan devices 2021-06-09 13:00:43 +12:00
Michael Hudson-Doyle 47b2836aee pretend virtual wlan (i.e. mac80211_hwsim) devices are real
this allows their use for testing
2021-06-02 12:40:57 +12:00
Michael Hudson-Doyle b046608a78 fix type annotations in network model types 2021-06-02 12:28:44 +12:00
Michael Hudson-Doyle 15ae0bf234 make NetDevInfo.is_connected a bool, as it is supposed to be 2020-09-25 14:33:53 +12:00
Michael Hudson-Doyle 04426cec15 make network view use a plain-old-data view of a nic
The network view code used to crawl all over the network model object,
which isn't really going to work with the upcoming client/server split.
So this adds a much better defined interface between the view and
controller.
2020-09-03 11:12:38 +12:00
Michael Hudson-Doyle e367226f47 fix crash on renaming bond 2020-08-25 13:55:20 +12:00
Tsunghan Liu (Robert Liu) e798451c27 Ignore CAN and unknown interfaces (LP: #1890397)
Add CAN and unknown interfaces to NETDEV_IGNORED_IFACE_TYPES, otherwise rander_config() will throw a KeyError exception when a unsupported interface shows up.
2020-08-07 21:04:05 +08:00
Michael Hudson-Doyle 7bcfcba99b Merge branch 'master' into still-better-i18n 2020-05-21 11:15:32 +12:00
Michael Hudson-Doyle acd6ee0032
Merge pull request #775 from mwhudson/logged-passwords-lp-1879381
do not log wifi passwords from existing configs
2020-05-19 11:25:44 +12:00
Michael Hudson-Doyle e588d6475f do not log wifi passwords from existing configs 2020-05-19 07:47:33 +12:00
Dimitri John Ledkov debc34cb3c Fix typo 2020-05-18 19:59:47 +01:00
Dimitri John Ledkov da1477ba01 network: fix wifi screen
WiFi screen was broken since NetDev refactor. Unbreak it.
2020-05-18 12:00:42 +01:00
Michael Hudson-Doyle 21ed91d7d3 add comments, contexts for some translatable strings
from scanning though about one third of subiquity.pot
2020-05-08 15:40:59 +12:00
Michael Hudson-Doyle 59c47254e7 use pgettext in one place, add support for extracting it 2020-05-08 15:13:15 +12:00
Michael Hudson-Doyle 3060a03bd6 make some things slightly better 2020-05-08 15:06:24 +12:00
Michael Hudson-Doyle fa476d54cc treat virtual network devices a bit more like physical ones
in particular: have subiquitycore.netplan understand them. The goal of
all this is to make the recent change to not delete virtual interfaces
if their configuration has not changed actually work.
2020-04-03 10:12:42 +13:00
Michael Hudson-Doyle cab565304a write netplan directly to the target
rather than via curtin and then cloud-init
2020-04-01 19:37:02 +13:00
Michael Hudson-Doyle b155d3eff0 have apply_config task exit as soon as all dhcp NICs have an address 2019-12-13 10:04:31 +13:00
Dimitri John Ledkov 962fd3ebd3 NetDev: bring back actual_global_ip_addresses used by console_conf. 2019-08-08 15:02:39 +01:00
Dimitri John Ledkov e755bf4b5f console_conf/subiquity: split identitymodel, as it is not the same at all. 2019-08-08 15:02:39 +01:00
Michael Hudson-Doyle 23488a6f2e some fixes found in testing 2019-03-26 10:59:50 +13:00
Michael Hudson-Doyle b571b3d1a9 track and display DHCP status
Mark all devices with DHCP enabled as pending when the config is
applied, and mark them as timed out ten seconds later if they have not
received any addresses.
2019-03-26 10:57:36 +13:00
Michael Hudson-Doyle eae2497d41 auto disable inactive NICs
This disables any NIC that does not have a global address by the first
time the network screen is shown
2019-03-26 10:57:36 +13:00
Michael Hudson-Doyle 3bb9268974 apply network changes immediately, rather than when the "Done" is pressed
diff makes this change look more involved than really necessary :(
2019-03-26 10:57:33 +13:00
Michael Hudson-Doyle c0f4a90179 refactor network view
The visible impact of this is that the addresses for a NIC are now
displayed underneath its name and a long "info line" (i.e. mac / model /
vendor) for a nic no longer distorts its table.

This lays the groundwork for better handling of NICs that fail to dhcp
and things like that.
2019-03-25 09:25:53 +13:00
Michael Hudson-Doyle d0c41469a7 remove login model/controller/view from subiquitycore
long ago subsumed into other code
2019-03-07 14:01:52 +13:00
Michael Hudson-Doyle c571f58dcc fix saving static network data with search domains 2019-02-21 08:35:19 +01:00
Michael Hudson-Doyle aebb0b2e2e fill identity fields if you go back to that form 2018-12-13 14:49:55 +13:00
Michael Hudson-Doyle 15b6bb1114 Major refactor of network model
The main thrust of this is to not create virtual interfaces until
applying the config.

This meant that the network model has to change a bit to be able to
represent interfaces that do not yet exist on the system. I did this
by ripping out most of the existing network device code: now a
NetworkDev is really just a wrapper for the config for a device and (if
it exists) the netlink data too. A few places had to adjust to checking
if the netlink info is available before accessing it but all in all it
was not that painful.

There are a few other refactorings in this commit that perhaps should be
split out (how the bond parameters are handled, some stuff about
resizing the table rows when interfaces are edited) but it doesn't
really seem worth it.
2018-10-31 09:58:56 +13:00
Michael Hudson-Doyle f19a453e0e mark interfaces that have dhcp enabled but did not get an address as optional 2018-07-12 14:17:20 +12:00
Michael Hudson-Doyle 46c0d598ad first cut at a bond form that handles devices too 2018-07-11 22:02:52 +12:00
Michael Hudson-Doyle 5e683dcc1f add create bond button 2018-07-11 22:02:52 +12:00
Dimitri John Ledkov 87558f0074 lint 2018-07-11 22:02:52 +12:00
Dimitri John Ledkov 88b64ca7fd Fix up bond netplan. 2018-07-11 22:02:52 +12:00
Dimitri John Ledkov 87ef3749e6 Finish bond master/slaves. 2018-07-11 22:02:52 +12:00
Dimitri John Ledkov e0d231f5d7 Create bond 2018-07-11 22:02:52 +12:00
Michael Hudson-Doyle 53a14e30ad make updates to network screen in response to netlink events more finegrained 2018-07-10 13:25:05 +12:00
Michael Hudson-Doyle b3636cfcd9 refactor how netdev action menu gets populated 2018-07-10 12:30:01 +12:00