Commit Graph

1022 Commits

Author SHA1 Message Date
Olivier Gayot d4a51027d9 Merge pull request #1944 from ogayot/noble-ui-rework
Fix UI so it runs properly with modern urwid
2024-05-02 14:25:11 +02:00
Olivier Gayot 144a2adf49 spinner: pass the app to the spinners, to make the screen redraw 2024-05-02 14:07:35 +02:00
Olivier Gayot 592714279c spinner: don't restart the spinner when .start() is called
Previously, when we called spinner.start(), we would automatically call
.stop() first to reset it.

Unfortunately, after calling stop(), the spinner mutates its visual
representation to become invisible using .set_text("").

This is a problem because after disappearing, the spinner does not
reappear instantly, which causes visual glitches depending on how often
we redraw the screen.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-05-02 14:07:35 +02:00
Olivier Gayot 0987dc5a7a spinner: add the ability to redraw after spinning
Every time a spinner "spins", it changes its visual representation. In
order for the user to see a smooth animation, we need to redraw the
spinner after each iteration. Hopefully this is not too much when
multiple spinners are visible at the same time.

For that, we give the option to pass the application to the spinner, so
that we can request a screen redraw after each iteration.

Alternatively, the user can decide not to pass the application to the
spinner, and to manage the animation themselves using calls to .spin()

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-05-02 14:07:35 +02:00
Olivier Gayot a81caf7f65 spinner: add a debug mode with extra logging
Spinners run very quickly and generate a lot of events. If we forget to
stop() a spinner, it will continue running forever until the event loop
is closed.

We now add an optional debug parameter that will cause spinner events to
be logged. It is very useful to find out if we forgot to stop spinners.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-05-02 14:07:35 +02:00
Olivier Gayot 76815d6fa1 views: redraw screen after receiving event
Views that are dynamically updated using asynchronous events that are
handled by urwid need to be redrawn.

Ensure that such events trigger a redraw.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-05-02 14:07:35 +02:00
Olivier Gayot e129c13590 view: add way to redraw screen if the view is visible
Views can now redraw themselves using the request_redraw_if_visible()
method. Behind the scenes, it will look if the view is the currently
visible view and skip the redraw otherwise.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-05-02 14:07:35 +02:00
Michael Hudson-Doyle e1ca8731c7
Merge pull request #1986 from mwhudson/begin-relicensing
relicense code outside of subiquity to GPLv3-only
2024-04-30 09:58:40 +12:00
Michael Hudson-Doyle 34afb5b40c update license headers outside of subiquity package 2024-04-29 09:28:40 +12:00
Olivier Gayot c18d434439 file-util: replace use of deprecate datetime.datetime.utcnow()
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-04-25 17:51:14 +02:00
Olivier Gayot 020dcc0b88 ui: redraw screens after moving from one screen to another
Wieh urwid > 2.1.2, the screen is only redrawn after urwid handles an
event (e.g., keypress, resize, ...) or an urwid alarm (it is like a
timer).

All other changes made to the UI do not trigger a screen redraw. We now
redraw the screen properly after moving from one screen to another.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-03-28 10:04:11 +01:00
Chris Peterson f307b87426 context: also send events to log 2024-03-25 20:18:00 -07:00
Chris Peterson 980411a670 reporting: add new logging type events
Adds new reporting type events "INFO", "WARNING", and "ERROR" to be
used for context logging. These can be invoked with the new `.info`,
`.warning`, and `.error` methods on the context object accordingly.
Useful for things like warning/errors on autoinstall configuartions.
2024-03-20 16:14:28 -07:00
Dan Bungert 1b00eb5616 utils: extract write_named_tempfile 2024-02-27 15:14:34 -07:00
Chris Peterson efd5138853 network: fix typo in BondConfig to_config method
A mismatch between the key names in BondConfig's to_config method
and NetworkDev's netdev_info function was causing subiquity to
crash when creating a bond with a valid transmit hash policy and
then later trying to edit it (LP: #2051586).

The correct key name set by the to_config method should be
"transmit-hash-policy" since this later gets passed to netplan
and neither "xmit-hash-policy" nor "xmit_hash_policy" is a valid
key name in pure netplan config.
2024-02-21 08:48:34 -08:00
Olivier Gayot 4e6bae198b network: fix detection of netplan on recent Ubuntu releases
Subiquity has a mechanism to detect the presence of netplan. It does so
by checking the existence of the file /lib/netplan/generate. This
mechanism is used in the network screen to validate the YAML
configuration.

However, since netplan 0.107 (present in mantic and noble), the file
/lib/netplan/generate is no longer present. It used to be provided as an
alias for /usr/libexec/netplan/generate ; starting in jammy.

This made Subiquity unable to detect that netplan is running ; and
therefore skip the YAML validation against netplan.

Since we support focal in Subiquity, let's change the detection code so
that we look for both locations. When we stop supporting Focal in the
future, we can drop the reference to /lib/netplan/generate.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-02-19 13:03:30 +01:00
Olivier Gayot c8501d81db
Merge pull request #1910 from ogayot/pro-dynamic-eol
Do not use hard-coded EOL year for ESM updates on the ubuntu-pro screen
2024-02-16 09:46:08 +01:00
Olivier Gayot ce938e6d03
Merge pull request #1895 from ogayot/pr/ssh-dissociate-form-submission
Dissociate SSH key import from form submission
2024-02-13 19:20:34 +01:00
Olivier Gayot 8e3751f647 lsb-release: split the function so it can be tested with more ease
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-02-13 11:56:31 +01:00
Olivier Gayot 5861968e80 view-helpers: add function waiting for an overlay to be displayed
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-02-12 14:08:59 +01:00
Maciej Borzecki ea86499691 subiquitycore/snapd: add response set serving objects from memory
Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-02-08 07:34:48 +01:00
Maciej Borzecki 8cfb2406b0 subiquitycore: allow to register callbacks for POST for fake snapd connections
Allow registration of handlers for POST.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-02-08 07:34:48 +01:00
Dan Bungert 47256905a4 ssh: fix unclosed file 2024-02-07 22:45:06 -07:00
Maciej Borzecki 66e8222a09 subiquitycore: use a premade host key fingerprints info if present
It is possible that the platform integration glue may have already prepared a
summary of host key fingerprints at the state directory. If so, use it
otherwise, try to build the summary directly.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-02-07 11:44:05 +01:00
Ondrej Kubik 082c59a9a9 console_conf: identity: move strict confinement handling to ssh
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
2024-02-07 11:30:39 +01:00
Maciej Borzecki b4708b0a51 subiquitycore: helpers for probing for snap execution environment
Add helpers for probing if the process is executing inside a snap.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-02-06 16:02:08 +01:00
Chris Peterson 48e5f9c616
Merge pull request #1897 from Chris-Peterson444/autoinstall-exception-FR-6293
AutoinstallError exception
2024-02-05 16:19:15 -08:00
Chris Peterson 24de248cec AutoinstallError: Disable apport reporting
Autoinstall related failures are more likely than not going to be
user caused, so we shouldn't immediately generate a crash report
for these types of failures. This should hopefully allow the user
to debug their autoinstall data much faster and reduce the number
of autoinstall-related bugs reported.
2024-02-05 09:37:42 -08:00
Maciej Borzecki 5c266cc38c subiquitycore/log: use 'root' as group for strictly confined snaps
When setting up the logging in a strictly confined snap, use the 'root' group,
rather than 'adm'. This will not interfere with the sandbox's policy but also
does not result in providing wider access to the logs.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-02-05 16:18:03 +01:00
Chris Peterson e3a0f6d215
Merge pull request #1882 from Chris-Peterson444/link2doc-ai-user-data-FR-5802 2024-01-05 07:35:54 -08:00
Chris Peterson 5350d01715 ai: include link to docs in post-install user data
We write out the autoinstall data to make the install repeatable
but this should also include a reference to the autoinstall
documentation to increase usability.
2024-01-03 16:02:30 -08:00
Olivier Gayot 0b7a4d16af network: ensure we pass tasks to asyncio.wait
In Python < 3.11, when passing a coroutine to asyncio.wait, it would
automatically be scheduled as a task. This isn't the case anymore with
Python 3.11. Now passing coroutines to asyncio.wait fails with:

 TypeError: Passing coroutines is forbidden, use tasks explicitly.

Let's ensure we schedule the coroutines as tasks before passing them on
to asyncio.wait.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-12-08 14:27:00 +01:00
Robert Krátký 4e81b0d81d Unify UI screen titles and minor lang. fixes 2023-11-21 14:05:59 +01:00
Chris Peterson 6c27d656f2 tests: add shared mocks and remove bad import
This commit re-adds some of the shared mock fields for testing
and removes a bad import from test_snaplist. These are changes
that shouldn't have been part of the previously reverted patch:
0a70a969d4
2023-10-25 15:34:23 -07:00
Chris Peterson 0a70a969d4 Revert "autoinstall: Don't use snap env when invoking early and late commands"
This reverts commit 39f1ea9cb6. The fix proposed
in this patch caused more issues than it fixed. We will have to revisit this in
a more nuanced way in the future. In the meantime users can make use of env
directly to strip/modify the subcommand environment.
2023-10-25 15:13:26 -07:00
Dan Bungert 84bcd5f7c8 log: move /var/log/installer back to 0770 root:adm 2023-10-10 13:25:26 +01:00
Dan Bungert c9cfdafe0c log: create /var/log/installer root only 2023-10-05 18:03:32 -06:00
Dan Bungert 80b144f220 file_util: just make written files root only 2023-10-05 17:22:18 -06:00
Dan Bungert a2b63dae13 util: ensure log file is root owned 2023-10-04 14:06:09 -06:00
Dan Bungert 8ab052c200 util: set_log_perms tests 2023-10-03 19:02:16 -06:00
Dan Bungert 4a4e8ba886 util: explicit isdir arg from set_log_perms
target already exists, we should just inspect target and find if it is a
directory or not.
2023-10-03 18:56:07 -06:00
Dan Bungert ddc11d8687 util: more control on file writer mode and group 2023-10-03 17:09:05 -06:00
Dan Bungert ddc3345eb6 util: standardize on term 'mode' 2023-10-03 17:09:01 -06:00
Chris Peterson 39f1ea9cb6 autoinstall: Don't use snap env when invoking early and late commands 2023-10-03 10:09:26 -07:00
Olivier Gayot c9f3e252af
Merge pull request #1802 from ogayot/rich-mode-s390x
ui: have a distinct state file for rich mode over serial
2023-09-25 09:06:58 +02:00
Dan Bungert 5a573f2cef snapd api: wait longer
While these changes are not supposed to take nearly this long,
per LP: #2034715 we know that they are, and that some systems will
correctly perform the finish_install() step if just given more time.
2023-09-22 15:05:01 -06:00
Olivier Gayot c95261e0de ui: have a distinct state file for rich mode over serial
We recently made sure that after doing a snap refresh, the rich mode
(i.e., either rich or basic) is preserved. This was implemented by
storing the rich mode in a state file. When the client starts, it loads
the rich mode from said state file if it exists.

Unfortunately, on s390x, it causes installs to default to basic mode.
This happens because on this architecture, a subiquity install consists
of:

 * a first client (over serial) showing the SSH password
 * a second client (logging over SSH) actually going through the
   installation UI.

Since the first client uses a serial connection, the state file is
created with rich-mode set to basic. Upon connecting using SSH, the
state file is read and the rich-mode is set to basic as well.

Fixed by storing the rich-mode in two separate files, one for clients
over serial and one for other clients.

LP: #2036096

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-09-22 09:27:13 +02:00
Dan Bungert d84c445612 network: fix import during snap build
Adding this import means a dependency on probert, which also means
anybody importing subiquity.common.types also has that requirement.

The make-kbd-info script imports types, and that steps was causing
snapcraft build failures due to not finding probert.
2023-09-11 09:45:28 -06:00
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