Commit Graph

1011 Commits

Author SHA1 Message Date
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 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
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 c73fac697e utils: add gen_zsys_uuid
Add gen_zsys_uuid, to generate a uuid of the same form as used in the
ubiquity zsys-setup script.
2023-08-24 17:42:09 -06:00
Olivier Gayot cda6c54b87 filesystem: store the actual size in bytes alongside the human readable size
Currently, the partition form stores the size as a human readable value.
(e.g., 123456K, 1.1G, 1.876G, 100G). When we exit the size field (i.e., upon
losing focus), we convert the value to a number of bytes and then align
it up to the nearest MiB (or whatever the alignment requirement is).

Unfortunately, after computing the aligned value, we turn it back into a
human-readable string and store it as is. It is not okay because the
conversion does not ensure that the alignment requirement is still
honored.

For instance, if the user types in 1.1G, we do the following:

 * convert it to a number of bytes -> 1181116006.4 (surprise, it is not
   even an integer).

 * round it up to the nearest MiB -> 1181745152 (this is the correct
   value)

 * transform it into a human readable string and store it as is -> 1.1G
   - which actually corresponds to the original value.

This leads to an exception later when creating the partition:

    File "subiquity/models/filesystem.py", line 1841, in add_partition
      raise Exception(
   Exception: ('size %s or offset %s not aligned to %s', 1181116006, 1048576, 1048576)

Fixed by storing the actual size as a number of bytes - alongside the
human readable size.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-08-09 16:50:03 +02:00
Michael Hudson-Doyle a4c924f1f9 persist rich mode across updates 2023-08-08 14:16:36 +12:00
Michael Hudson-Doyle ce9a130f37 make initial setup of rich mode less confusing 2023-08-08 14:07:10 +12:00
Michael Hudson-Doyle 0395b6e9b0 add support for 'dd' image sources
I think only a core dd image source will work for now. Probably.
2023-08-03 09:07:06 +12:00
Dan Bungert c08fdab2f8 one-off format of long lines with black 2023-07-25 15:27:49 -06:00
Dan Bungert 34d40643ad format with black + isort 2023-07-25 15:27:42 -06:00
Michael Hudson-Doyle 6b35e5e4a1 tidy up examples/ directory
Move machine configs, sources, autoinstall files and dry-run configs
into their own subdirectories.
2023-07-11 12:49:22 +12:00
Olivier Gayot a270019387 prober: turn on parallelism for probert storage
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-04-27 11:09:23 +02:00
Olivier Gayot 60f2b506db prober: move to asyncio for probert storage
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-04-25 15:12:19 +02:00