Commit Graph

5805 Commits

Author SHA1 Message Date
Olivier Gayot 6fd4559763 mirror: make resolved country mirror entries distinguishable
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot 5d1d761dd3 mirror: drop assign_elected and replace_candidate functions
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot a385e55197 mirror: improve /mirror API
* GET /mirror now returns:
  * the URL of all the candidates
  * the URL of the candidate staged for testing (if any - otherwise null)
  * the URL of the elected candidate (if any - otherwise null)

* POST /mirror can now be invoked in different ways:
  * Make fr.archive.ubuntu.com be the elected mirror ; and mark the
    mirror model configured:
  {"elected": "http://fr.archive.ubuntu.com/ubuntu"}

  * Mark us.archive.ubuntu.com as staged for testing.
    This replaces POST /mirror/candidate that was recently introduced
    (except it does not override model.candidates)
  {"staged": "http://us.archive.ubuntu.com/ubuntu"}

  * Replace the list of candidates with the new values. Not used on
    practice, but can be used for testing / debugging.
  {"candidates": ["http://us.archive.ubuntu.com/ubuntu"]}

  * Explicit way to trigger the election of a mirror automatically.
    If a mirror is elected, the model will be marked configured ;
    otherwise an exception is raised.  This would be the recommended
    option for the desktop installer NOTE: maybe something like
  null

A combination of multiple key can also be used.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot 188a457792 mirror: produce usable autoinstall data in apt/mirror version 2
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot 7dbd0177e4 mirror: add autoinstall tests for apt/mirror version 2
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot 38bb82f43f mirror: skip unresolved mirrors on GET /mirror and autoinstalls
Country mirrors start with no URI. Make sure we skip those if we don't
receive a geoip query response.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot 5711660d5d mirror: run check automatically if mirror is marked configured
Although it is not recommended, a client can mark the mirror model
configured by way of meta/mark_configured. If this happens, we will now
automatically run mirror testing to find the right candidate.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot 378e6bd6ce mirror: extend endpoint for clients without a mirror screen
Clients that do not have a mirror screen can now rely on mirror testing
in a way similar to autoinstall. They can do so by sending a POST
request to /mirror with null in the body.

The call will block and will only return after Subiquity has either:
 * found a suitable mirror and elected it (mirror gets marked
   configured)
 * failed to find a suitable mirror ; a NoUsableMirrorError extception
   gets raised.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:03 +01:00
Olivier Gayot 272697201d mirror: handle the architectures properly
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:41:16 +01:00
Olivier Gayot 5c466e5765 mirror: start supporting both primary sections formats
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:41:16 +01:00
Olivier Gayot 037a5ac8ed mirror: add functions to make a section as staged or elected
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:41:16 +01:00
Olivier Gayot f7cd813254 mirror: introduce new primary entry format but do not use yet
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:41:16 +01:00
Olivier Gayot 23db4b597b mirror: use properties to get and set mirror uri
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:41:16 +01:00
Olivier Gayot 927df0b845 mirror: do not assign an elected mirror automatically
When Subiquity starts, we no longer assign the elected mirror. This
means that marking the mirror model configured without selecting a
mirror is possible, and will cause trouble during install.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:41:16 +01:00
Olivier Gayot 6541ea055c mirror: use PrimarySection objects for candidates and elected
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:41:16 +01:00
Olivier Gayot f8f6ca1fc2 mirror: add PrimarySection class with tests
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:41:16 +01:00
Olivier Gayot 54a06c6e5d mirror: try all candidates in autoinstall
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:41:16 +01:00
Carlos Nihelton 5ee8e58312
Fix linter warninig 2023-02-09 13:24:03 -03:00
Carlos Nihelton 367cae78ae
Better comment styling 2023-02-09 12:55:37 -03:00
Carlos Nihelton 9c6962b67e
Split validation in different endpoints
Allows clients to call specific endpoint on demand
as the user inputs data, looking for a smoother UX.

Better wording check_admin_user_name docstring:
 - "all the possible errors" is too strong.
2023-02-09 12:55:37 -03:00
Olivier Gayot 099db0bfdd mirror: call relevant version of apt_config
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-09 11:43:01 +01:00
Dan Bungert 312e010d81 test/api: refactor out a few match usages 2023-02-08 19:56:45 -07:00
Dan Bungert e86d152a69 test/api: remove first / find 2023-02-08 19:56:45 -07:00
Carlos Nihelton 6bf71db29a
Better styling 2023-02-08 17:55:08 -03:00
Dan Bungert c2f23f9cf2
Merge pull request #1556 from dbungert/format-blank
storage/v2: allow unformatted partition creation
2023-02-08 13:33:12 -07:00
Dan Bungert 0749f69c9b storage/v2: allow unformatted partition creation
Previously unformatted partition creation was blocked, but supplying
None does seem to do the right thing, and we want to support creation of
unformatted partitions.  Allow it and add a API test to help document it
as an intended feature.
2023-02-08 13:09:16 -07:00
Dan Bungert fa7220512d
Merge pull request #1555 from dbungert/api-test-timeouts
test/api: mark all with timeout
2023-02-08 12:59:26 -07:00
Dan Bungert 17b42fe797 test/api: mark all with timeout 2023-02-08 12:33:34 -07:00
J-P Nurmi 10833a848f network: reset SNAP when calling netplan in dry-run mode 2023-02-08 17:49:57 +01:00
Carlos Nihelton 8d744004fe
Implements the validation on POST
Regexes following the Ubuquity approach.
API tests demonstrate the validation.
2023-02-08 11:55:42 -03:00
Carlos Nihelton a8c0a17828
Added one more item to the validation result enum
ADMIN_NAME_EMPTY

Since there is no validation at time of creating the data.
2023-02-08 11:55:08 -03:00
Olivier Gayot 5bfd6fda03 mirror: add theoretical support multiple primary sections
This patchs makes Subiquity internally support multiple primary
sections. Emphasis on "internally" because we only accept a single
section for autoinstalls. This is a first step into making it possible
to use multiple candidates mirrors.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-08 15:26:08 +01:00
Carlos Nihelton 7e2ceb9f94
Merge pull request #1550 from CarlosNihelton/ad-api-deeng-576
Active Directory API Part 1
2023-02-08 09:25:17 -03:00
Carlos Nihelton 7962bdcc9f
Shorter if clause 2023-02-08 09:05:00 -03:00
Olivier Gayot daeae3b004
Merge pull request #1547 from ogayot/apt-translated
Make sure mirror test output is translated if translation is available
2023-02-07 19:00:35 +01:00
Olivier Gayot d522487313 locale: generate the locale definition in the background
When the user selects a language, we now attempt to generate the
relevant locale definition. The generation can fail for multiple reasons
(including running as non-root) so a failure is not considered fatal.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-07 18:18:16 +01:00
Olivier Gayot 7bb5742685 apt: request translation when executing the mirror check
By setting the LANG variable and passing clean_locale=False, the apt-get
command will be translated if the locale definition exists on the
system.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-07 18:18:16 +01:00
Olivier Gayot f284d25757 utils: add parameter to avoid clearing the LC_* variables
We used to set LC_ALL=C unconditionally when executing a command. This
is a problem if we want the output of a specific command to be
translated (provided a locale definition and an actual translation exist
for the requested language).

This patch adds the clean_locale parameter, which can be used to specify
if we want the locale variable to be cleaned, to most of the helpers
that execute commands.

The value defaults to True so the default behavior is preserved.
If one wants a command to be translated, they have to  explicitly pass
clean_locale=False.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-07 18:18:16 +01:00
Carlos Nihelton f77971238f
Clearer logic on ADModel.target_packages method. 2023-02-07 14:17:49 -03:00
Carlos Nihelton fe25d07eca
Explains the return value of active_directory.POST
Returning a list of errors seems uncommon.
2023-02-06 22:52:49 -03:00
Carlos Nihelton 0ea977a6cc
Test enhancements:
- timeout
- assert equals because the success case wil return a very specific list
  of a single value: 'OK'
2023-02-06 22:37:16 -03:00
Carlos Nihelton 70819367de
Implements AD Model and Server Controller
Plus the first lines of test.

**Notice that the AD Controller is not required.**

POST'ing still incomplete: just a placeholder method to enable cycling
between testing and writing code.

Now testing the API is possible.
2023-02-06 22:31:06 -03:00
Carlos Nihelton ceda86031f
Defines the first API endpoint
/active_directory

Clients GET the current model or POST a new one.
Not implemented yet.
2023-02-06 22:31:05 -03:00
Carlos Nihelton bb5f6362c5
Adds vocabulary type for Active Directory support
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)
2023-02-06 22:31:03 -03:00
Dan Bungert d410022340
Merge pull request #1551 from dbungert/antirequirementism
requirements: remove
2023-02-06 17:53:23 -07:00
Dan Bungert cb9c2263e7 runtests: allow longer socket wakeup 2023-02-06 16:39:06 -07:00
Dan Bungert 6f6178c601 requirements: remove
Get em from apt
2023-02-06 16:13:22 -07:00
Dan Bungert f47874bdc9
Merge pull request #1545 from dbungert/lp-2004040
tui: turn off systemd ShowStatus
2023-02-02 07:05:53 -07:00
Dan Bungert 8dd14957c2 tui: turn off systemd ShowStatus
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.
2023-02-01 14:45:23 -07:00
Olivier Gayot e5f0e302c3
Merge pull request #1544 from ogayot/fixes-mirror-testing
Fixes and more tests for mirror testing
2023-02-01 17:58:05 +01:00