ADConnectionInfo to be the model data submited by clients
ADValidationResult models the enum returned from a POST request.
(input must be validated in the server)
During TUI launch, turn systemd ShowStatus off. We don't want to do that
earlier, if we did then the easier path would be quiet boot or something
similar. This is done here so that service completion messages don't
overwrite the console.
In the following patches, we detached the disabled components and the
primary section from the config object in the mirror model.
c13edb07f mirror: detach disabled-components from config
8c29f3475 mirror: detach primary section from config object
However, the patches introduced a regression. The disable_components &
primary autoinstall section are not included in the
autoinstall-user-data file anymore.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
From subiquity, we sometimes execute entry point python scripts such as:
* usr/bin/ubuntu-advantage
* usr/bin/ssh-import-id
Those scripts require pkg_resources on core20 to run properly:
from pkg_resources import load_entry_point
On core22, the scripts will be a bit more flexible but for now, we need
python3-pkg-resources in the snap.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
With autoinstall, a controller that was not interactive would decline
outright to provide the response to GET queries, with the notion that
the controller needed to be skipped. Limit this behavior to only when
`x-make-view-request: yes` is set, which let's the client be able to get
the real response, or the skip info, depending on need.
calling asyncio.create_task(...) without storing a reference to the
result can lead to the task being garbage collected before it actually
executed.
https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task
The documentation gives an example of a reliable way to run
fire-and-forget background tasks.
This patch adds an helper to do exactly that.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Many views provide a different display based on whether the network is
available. Up to now, it was up to the controller corresponding to the
view to return the value of has_network.
We now have a dedicated /network/has_network endpoint that clients can
lean on.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
For autoinstalls, we now perform mirror testing as well. Unlike in
interactive mode, if the mirror check fails, we wait 10 seconds and try
again. Only if the second check fails, we give up.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
For answers-based runs, we now wait for the mirror check to be complete
before submitting the form. This ensures that we don't get a
confirmation dialog if the check is successful.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
From the mirror view, we used to call /mirror/check_mirror/progress
every second, we can now check more often according to the value of
SUBIQUITY_REPLAY_TIMESCALE.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
For dialogs asking the user if they want to continue anyway (e.g., the
mirror check is still running or has failed), we now lean on
BaseView.ask_confirmation.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
In dry-run mode, we can now define rules to control if the mirror check
should:
* succeed (the output of APT is faked)
* fail (the output of APT is faked)
* randomly succeed or fail (the output of APT is faked)
* run on the host (this will effectively bypass the apt parameters
supplied)
The default rules are as follows:
* https://archive.ubuntu.com/ubuntu will succeed
* https://<country-code>.archive.ubuntu.com/ubuntu will succeed
* any URL that ends in /success will succeed
* any URL that ends in /fail or /failed will fail
* any URL that ends in /rand or /random will randomly succeed or fail
* any URL that ends in /host will run on the host (bypassing the URL
configured)
* anything else with run on the host
Different rules can be provided by supplying a --dry-run-config YAML
file.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Before, doing a POST request to /mirror/check_mirror/start when a mirror
test was already running resulted in an exception on the server side.
We now have a parameter to control whether any ongoing check should be
cancelled first.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
The /mirror/check_mirror/progress endpoint now returns the URL of the
mirror being tested. This helps in the client side tofigure out if we
already have a check running for a given URL.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
On slow connections, running a full apt-get update for the sole purpose
of mirror testing ; and discarding the result is a bad thing to do.
This can take minutes and consume over 50 MiB.
Instead, we use mwhudson's approach and only download the index files.
Instructing apt to do so is a bit clunky but it seems to be worth the
effort.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
With the previous implementation, the box containing the APT output was
only shown when the test was in progress or failed. It seems simpler to
just display it at all times, so that warnings from APT can be noticed.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
The POST handler for /mirror applies the URL passed but also marks the
model configured. That said, we want the ability to:
1. supply a mirror URL
2. run the mirror test
3. mark the model configured if the test is successful
This patches creates a new endpoint: /mirror/candidate that does the
same as /mirror except that it does not mark the model configured.
It is therefore suitable for step 1.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Since Python 3.3, log.warn has been deprecated in favor of log.warning.
Running the unit tests raises the following warning:
subiquity/server/tests/test_geoip.py::TestGeoIPBadData::test_lookup_error
/home/olivier/dev/canonical/subiquity/subiquity/server/geoip.py:112:
DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
log.warn("geoip lookup failed: %r", le)
I replaced all the calls to log.warn by calls to log.warning
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
apt-get complains if the var/lib/apt/lists/partial directory does not
exist or is not owned by the _apt user. Make sure that it is.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
When running the apt config check, we can now pass a stream that will be
populated with the output of apt-get update (stdout + stderr combined).
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
The AptConfigurer object now has a method that runs apt-get update on
the applied configuration and returns the result Strictly speaking, it
does more than just checking if the mirror is in a good shape, thus the
naming shows "apt config" rather than "apt mirror".
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Going forward, we need the mirror model to keep the data that it can
handle separately from what goes straight to curtin. This patch
separates the primary section from the config blob.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Going forward, we need the mirror model to the data that it can handle
separately from what goes straight to curtin. This patch separates the
disabled-components from the config blob.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Instead of transforming on the fly the archive URL into the country mirror URL
using string substitutions, we can now use the countrify_uri function that does
the job and has unit tests.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>