Commit Graph

5649 Commits

Author SHA1 Message Date
Dan Bungert 8d9ad23ca6
Merge pull request #1566 from dbungert/lp-2007554-async-parameterized
tests: patch parameterized to handle async
2023-02-18 18:48:06 -07:00
Carlos Nihelton bf603d3b3e
Merge pull request #1568 from CarlosNihelton/ad-enhancements-deeng-596
Active Directory API UX Enhancements
2023-02-18 00:12:16 -03:00
Carlos Nihelton b60305edb2
Replaces raw asyncio.create_task
`run_bg_task` is the default recommendation instead.
2023-02-17 23:19:01 -03:00
Carlos Nihelton 9b50c8db07
Auto discover the domain at start
`realm discover` without a domain name attempts to find one from DHCP.
This attempts to run it from the controller start method.
Only creates the discover task if there is support
Avoids exception on controller start.
2023-02-17 14:27:05 -03:00
Carlos Nihelton a37b5e3870
Check for the needed programs in the live system
Currently only the realm program is executed by the ad controller.
Thus we only check if its accessible.

Clients should call this endpoint prior to showing the AD screen.
2023-02-17 14:21:31 -03:00
Carlos Nihelton 4266a5e642
Merge pull request #1563 from CarlosNihelton/ad-ping-deeng-586
Active Directory API Part 3 - Pinging the Domain Controller
2023-02-17 14:09:19 -03:00
Dan Bungert f9ce25f15f tests: patch parameterized to handle async
parameterized async tests run into cpython bug gh-101486

We use parameterized.expand, which works by creating new functions and
inserting those into the list of tests.  It's a wonder this worked at
all before for the async tests.

Update the function generation to create a coroutine function, if
appropriate.

LP: #2007554
2023-02-16 19:17:37 -07:00
Olivier Gayot 9ed734b48b
Merge pull request #1564 from ogayot/fallback-offline
Optionally fallback to offline install if no usable mirror provided
2023-02-16 18:45:05 +01:00
Carlos Nihelton b1f29c897f
Pinging the DC in the domain check endpoint
added one more error value to the enum
"ping" relies on realmd, which is part of the minimal layer.
For now not considering it coming from the snap.
The package is not staged at this point.
2023-02-16 09:19:32 -03:00
Carlos Nihelton 27e85717df
Merge pull request #1553 from CarlosNihelton/ad-validations-deeng-585
Active Directory API Part 2 - Validations on POST  🎉
2023-02-16 09:17:26 -03:00
Carlos Nihelton 80e395129d
Updates POST comment. 2023-02-16 08:42:16 -03:00
Carlos Nihelton a706b99478
re.escape at the regex compile call site. 2023-02-16 08:42:16 -03:00
Olivier Gayot 6c3ae3c6dd mirror: add support for falling back to an offline install
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-15 18:09:39 +01:00
Olivier Gayot 10a2e6ac22 mirror: allow to combine different filters for the candidates
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-15 14:14:20 +01:00
Olivier Gayot 1350ef8d1b mirror: do not raise from POST /mirror if no usable mirror
Raising from the POST /mirror handler makes it difficult for the client
to distinguish an internal error from the lack of usable mirror.

We now return an enumeration with the following possible values:
 * ok
 * no-usable-mirror

It is up to the client to either:
 1. adjust the network settings and retry
 2. give up on the install

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-15 11:35:31 +01: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
Olivier Gayot 58e524ae6e
Merge pull request #1552 from ogayot/fallback-mirror
Support of multiple candidates mirrors with automatic selection in autoinstall & desktop installs
2023-02-15 09:04:11 +01:00
Dan Bungert 25aaf00792
Merge pull request #1541 from dbungert/more-fde-strings
More fde strings
2023-02-14 15:51:47 -07:00
Olivier Gayot 12fbea7321 doc: update autoinstall reference & schema for mirror selection
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-14 22:18:13 +01:00
Olivier Gayot ff46c48d60 mirror: use apt->mirror-selection instead of relying on version
We used to rely on a version key under apt autoinstall section to
specify if we want the old implementation (i.e., a single candidate
primary mirror) or the new implementation (i.e., multiple primary mirror
candidates).

Instead, we now introduce the apt->mirror-selection autoinstall section,
and move the primary section under it.

If the primary section if under apt, we want the old implementation.
If the primary section is under apt->mirror-selection, we want the new
implementation.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-14 19:44:57 +01:00
Dan Bungert c2ce50f809
Merge pull request #1562 from dbungert/use-run-bg-task
many: s/create_task/run_bg_task/
2023-02-14 07:18:17 -07:00
Olivier Gayot 7848ccee46
Merge pull request #1559 from ogayot/ssh-import-mock
Stop calling ssh-import-id as part of the CI - use mock responses instead
2023-02-14 11:23:56 +01:00
Olivier Gayot 538a802118
Merge pull request #1560 from ogayot/fix-unittest-schroot
Fix unittest using timedatectl failing in chroot
2023-02-14 10:43:41 +01:00
Dan Bungert 9d12871f15 many: s/create_task/run_bg_task/
create_task has the following note:
  Important: Save a reference to the result of this function, to avoid a
  task disappearing mid-execution.

Convert existing usage of create_task to run_bg_task, if that
create_task is not actually storing the result.
2023-02-13 14:56:07 -07:00
Olivier Gayot fe8ab8a1e8 ssh: don't run ssh-import-id as part of the CI
Running ssh-import-id as part of the CI has limitations. First it
requires that we have access to the Internet. Second, it is affected by
github and launchpad service disruptions and or rate limiting policies.

Make sure we don't call ssh-import-id as part of the CI. Instead use a
username that is configured to produce fake successful key imports.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-13 16:41:47 +01:00
Carlos Nihelton 5be95d09b2
Breaks too long line in apidef 2023-02-13 10:01:18 -03:00
Carlos Nihelton 1a40860437
More sensible error enum values 2023-02-13 09:59:33 -03:00
Carlos Nihelton 8225b4e5ca
Validation calls data as Payload
Makes the logs look less silly :D
2023-02-13 09:53:01 -03:00
Carlos Nihelton f0297d8f5c
Redesigns the admin name validation
Thanks to the feedback in Launchpad:
https://bugs.launchpad.net/ubuntu-mate/+bug/1985971

See also the conversation on GitHub:
https://github.com/canonical/subiquity/pull/1553#discussion_r1103063195

Adn MS Docs:
https://learn.microsoft.com/en-us/windows/win32/adschema/a-samaccountname
2023-02-13 09:31:08 -03:00
Olivier Gayot 2120054887 ssh: implement different dry-run strategies for ssh keys imports
We now have 3 different dry-run strategies for ssh key imports:

 * success: fake a successful key import
 * failure: fake a failed key import
 * run-on-host: actually run ssh-import-id

Through a dry-run-config file, we can choose which strategy applies
based on the username.

By default, the policy is as follows:
 * username 'heracles' uses the fake successful key import
 * username 'sisyphus' uses the fake failed key import
 * any other username runs ssh-import-id

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-13 12:31:10 +01:00
Olivier Gayot 093019b4ca mirror: log the the autoinstall repr. of a mirror when iterating
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-13 10:16:37 +01:00
Dan Bungert ffa29c4fcb
Merge pull request #1557 from dbungert/api-cleanup-match
test/api: match cleanup
2023-02-12 19:40:31 -07:00
Olivier Gayot 64d77470b0 tests: fix test using timedatectl failing in chroot
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-11 12:38:33 +01:00
Dan Bungert bd4e463177 ui/guided: tweak wording for ENCRYPTED + AVAILABLE 2023-02-10 15:48:30 -07:00
Dan Bungert 3c3e467966 server/fs: FDE string improvements 2023-02-10 15:32:24 -07:00
Dan Bungert b8ca9c54e8 ui/guided: FDE string improvements
Remove references to the "model", which isn't a concept we expect the
user to know about.  General text tweaks on top of that.
2023-02-10 15:32:24 -07:00
Dan Bungert 4855fd316d
Merge pull request #1554 from jpnurmi/netplan-generate
network: reset SNAP when calling netplan in dry-run mode
2023-02-10 13:45:40 -07:00
Carlos Nihelton 4ff20dd135
Addresses the feedback about regex.match 2023-02-10 15:57:33 -03:00
Carlos Nihelton 6be551d728
Better styling if clauses
+ plus fixes a typo
2023-02-10 15:55:07 -03:00
Olivier Gayot 51b82e7897 mirror: document model and use more relevant wording
* LegacyPrimarySection => LegacyPrimaryEntry
* PrimaryElement => BasePrimaryEntry
* PrimaryEntry => PrimaryEntry

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot 915aeb6058 mirror: make sure we can get final configuration when offline
When offline, it is possible when requesting the final configuration
that the mirror model does not have an elected primary mirror.

This happens every time in an automated offline install.

Make sure that we return something sensible instead of raising an
exception.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot 8533ed1bbe apt: be implementation agnostic when requesting a model's apt config
Models that participate in building the apt configuration (i.e.,
currently proxy & mirror) now have the same method signature
get_apt_config having "final" as a parameter.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot eb255c6996 apt: use wording final instead of elected to reduce coupling with mirror
The mirror model has the notion of primary candidates, staged primary
candidate and elected primary candidate. This is purely specific to the
mirror model and does not necessarily make sense from the outside.

In code that does not specifically need to know implmentation details of
the mirror model, we now prefer the wording "final configuration" over
"elected configuration".

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
Olivier Gayot c5a0b567b4 mirror: add unit tests for find_and_elect_candidate_mirror
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-10 15:43:05 +01:00
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