Commit Graph

206 Commits

Author SHA1 Message Date
Carlos Nihelton d3e2544875
Ensures snap_dir='/' if not better specified.
UDI sets the SNAP env var to '.' for development purposes.

See: https://github.com/canonical/ubuntu-desktop-installer/commit/9eb6f04

It is unlikely that under test or production that env var will
ever by just '.'. On the other hand in dry-run we want this controller
to interpret it as '/' if not properly set, thus discarding the '.'.
2022-04-06 13:25:35 -03:00
Carlos Nihelton c2b6be3cd3
Enables passing the autoinstall CLI to the server.
The server was prepared to receive this CLI option.
TUI was not. When not in dry-run that option had no effect.
2022-04-05 18:12:47 -03:00
Carlos Nihelton ef18564eca
Cleans comments and adresses test.
- Under dry-run apt is run with --simulate.
- That can still fail if a package does not exist, for instance.
- If so, a file will not be written.
2022-03-22 19:41:37 -03:00
Carlos Nihelton c9f90dffb3
Fix stylistic flake8 warnings. 2022-03-22 18:04:37 -03:00
Carlos Nihelton f4a2b916a7
Removes dependency on apt python lib.
It seemed far too much complicated find the proper way to deal with
apt Python library under the snap environment.

Opted for running the system apt command without the LD_*
customisations, similar to what an installer does when chroot into the
taget system.
2022-03-22 17:50:54 -03:00
Carlos Nihelton a950d9e98f
Removes __recomended_language_packs() env argument
That function will not require a custom environment.
Also simplified snap_dir variable assignment.
2022-03-22 17:47:53 -03:00
Carlos Nihelton a36120e0bb
apply_locale() and create_user() accept custom env
This allows for running subprocess outside of the snap environment.
Both functions now receive a custom env without the LD_ related vars.
Renamed _create_user() to create_user() to make explicit that it has the
same semantic level as apply_locale().
2022-03-22 17:46:25 -03:00
Dan Bungert e59078c74e system-setup: inform server proc of output_base 2022-03-21 10:50:59 -06:00
Didier Roche 09c7210406 System-Setup: fix typos
Co-authored-by: Jean-Baptiste Lallement <jean-baptiste@ubuntu.com>
2022-03-16 12:24:46 +01:00
Didier Roche 208d8778c9 System-Setup: Clean up load data API
We don’t need to pass an empty dict as parameter.

Co-authored-by: Jean-Baptiste Lallement <jean-baptiste@ubuntu.com>
2022-03-16 12:24:46 +01:00
Didier Roche d17cd6fc38 System-Setup: Add systemd experimental support to WSL
Grow a new API for enabling/disabling systemd experimental support. We
do this by chaining a specific command= in the boot section.
We preserve the user customized command= content when systemd
experimental support is not enabled.

Co-authored-by: Jean-Baptiste Lallement <jean-baptiste@ubuntu.com>
2022-03-16 12:24:18 +01:00
Didier Roche 5695da5699 system-setup: Remove ubuntu-wsl-integration from API and TUI.
This project is no longer supported under WSL. Remove integration in the TUI
and API for it. Adapted tests and schema.
2022-03-14 15:58:03 +01:00
Olivier Gayot 9856b79f36 Redirect stdout and stderr from server into two distinct files
Instead of having interleaved stdout and stderr in server-output, we now
have respectively:

* stdout redirected to server-stdout
* stderr redirected to server-stderr

This will allow us to monitor for warnings / errors more efficiently.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-03-08 12:12:07 +01:00
Olivier Gayot 812bba1de1 Use logger names consistent with directory structure
Refreshed name of loggers to make them consistent with the directory
structure.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-02-25 17:35:45 +01:00
Carlos Nihelton e79e4ea9a9
Removes unnecessary check `sourceDirs is None` 2022-02-17 07:07:19 -03:00
Carlos Nihelton a7fd83a384
Fixes missing dir on system_setup integration test
By providing alternative directories to find LC_* locale definitions.
2022-02-16 22:59:05 -03:00
Dan Bungert 0f9c9eef3f options: add output_base for dryrun use
To enable parallel API testing, add an output_base argument to replace
the default '.subiquity' that is sprinkled everywhere.
2022-01-26 10:39:23 -07:00
Didier Roche 34b621ee66
Merge pull request #1165 from CarlosNihelton/fix-wsl-snap-env
[SystemSetup] Fix L-S-C behavior under WSL snap environment
2022-01-21 15:56:42 +01:00
Carlos Nihelton 0d30deac7f
Promotes the "--no-checks" to outside of dry-run
Tests in real WSL2 environment revealed that update-locale checks fails but with the "--no-checks" option it updates the locale files accordingly and when the image restarts the locale is correctly set.
2022-01-18 10:18:45 -03:00
Carlos Nihelton a14a143d55 Fix l-s-c behavior under SNAP environment.
- By passing the datadir command line option.
2022-01-17 11:57:04 -03:00
Carlos Nihelton 957d56a52f FIx unbound variable in live run 2022-01-17 10:48:58 -03:00
Olivier Gayot 3d3994f3f3 Fix return type of __recommended_languages_pack
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-14 13:02:25 +01:00
Carlos Nihelton e429babb03 Fixes potential false positive UID findings
Also, splits part of the configure() method:
-  `__query_uid()` finds the username UID
- `_create_user()` creates the user set in IdentityModel
- Both methods accept a fake root path under dryrun.
2021-12-17 10:35:38 -03:00
Carlos Nihelton b17c3d3db9 Cleanup complete.
- No user setup in wsl.conf
- Shutdown controller creates the launcher-command file
2021-12-14 12:13:00 -03:00
Carlos Nihelton bad945f5d7 Remove username from wsl.conf
- This is a cleanup for SystemSetup per DEENG-134 and DEENG-139
- Default user should be set by the WSL launcher.
- Shutdown/reboot actions also.
- Added a structured form of communication between OOBE and launcher.
- /run/launcher-command
2021-12-14 12:04:38 -03:00
Carlos Nihelton 22a8219cb3 Dryrun won't stop configure controller due C-L-S
- Also noticed a possible unbound var in IOError handler.
2021-11-24 11:35:31 -03:00
Carlos Nihelton a88fcdb8b3 Explicit case for c-l-s failure by returning None 2021-11-22 13:42:45 -03:00
Carlos Nihelton 37758047f2 Improved control over lang packs on integration
- Dryrun should never return empty packages list unless under failure.
- runtests check if the mimic-installed files match the proper language.
2021-11-22 12:16:01 -03:00
Carlos Nihelton 1e6c4472a5 Complementary to 1127 on integration side 2021-11-17 13:26:41 -03:00
Dan Bungert 1eefb7a9e5 check-language-support: fix empty pkg list
The check-language-support on my machine was providing a single empty
newline as output, and the length check isn't catching that as the
resulting packages array has a value of [''].
Drop empty values from the list to avoid a "KeyError: ''" exception.
2021-11-17 07:23:16 -07:00
Didier Roche dde0a6d53c
Merge pull request #1116 from CarlosNihelton/ft-wsl-locale-deeng-31
System locale manipulation wired into Subiquity.
2021-11-16 08:43:51 +01:00
Didier Roche 072d2b233a
Merge pull request #1124 from CarlosNihelton/fix-systemsetup-reconfig-post
SystemSetupModel now acks the variant at start.
2021-11-15 09:07:13 +01:00
Carlos Nihelton 377e880cb5 Style improvements. 2021-11-12 16:04:02 -03:00
Carlos Nihelton 4bb8ee3b3b SystemSetupModel now acks the variant at start.
- Without this change, wsl_configuration variant is not reckon without
  client_variant.POST.
- Issue and suggestions of fixes originally reported by jpnurmi.
2021-11-11 09:22:10 -03:00
Carlos Nihelton a1fd0615f8 Slipped on the linter. 2021-11-09 18:34:58 -03:00
Carlos Nihelton 409ac4157a From weird splits into regex 2021-11-09 18:15:59 -03:00
Carlos Nihelton 63d565b89c Write text files instead of wget 2021-11-09 18:15:20 -03:00
Carlos Nihelton 4e050ecddb Style improvements. 2021-11-09 09:36:10 -03:00
Carlos Nihelton f9d3877feb Corrected list type hint for Python 3.8.
- CI failed on Focal due Python version unable to understand list[str].
2021-11-08 19:03:10 -03:00
Carlos Nihelton eb6bd2d263 Smaller functions, early returns and funny mocking 2021-11-08 13:11:30 -03:00
Carlos Nihelton 6be4aea138 l-s-c as dep on Makefile, avoid raising exceptions
- And clear .subiquity/var/cache
2021-11-05 18:09:15 -03:00
Carlos Nihelton 5f9f2122ce System locale manipulation wired into Subiquity.
- We don't have cloud-init in WSL.
    - Subiquity must perform any actions to support the choosen locale.
    - l-s-c package added as dependency.
2021-11-05 17:29:33 -03:00
Carlos Nihelton a264fdafbc Prefill was not working outside of dry-run 2021-11-04 12:01:00 -03:00
Carlos Nihelton 887d63caf0 System locale manipulation wired into Subiquity.
- We don't have cloud-init in WSL.
- Subiquity must perform any actions to support the choosen locale.
2021-11-03 18:22:42 -03:00
Carlos Nihelton 106b8c758e Temporary fix for integration tests chroot'ing
useradd -R does chroot.
useradd -P doesn't.
2021-11-03 15:53:02 -03:00
Didier Roche 3d2be8f66f
Merge pull request #1113 from canonical/fix_server_state_rerun
Fix reruning in production system_setup on WSL
2021-11-03 12:54:06 +01:00
Didier Roche 244aa7de81 Fix reruning in production system_setup on WSL
On system_setup, we always run the subiquity server. On WSL, ensure we
wipe the server-state file (no systemd fallback) before starting the
server.

Co-authored-by: Jean-Baptiste Lallement <jean-baptiste@ubuntu.com>
2021-11-03 12:48:53 +01:00
Didier Roche 277fe55599 Don’t block on running commands in configure
Those commands needs to be async to be able to still answer GET/POST
request while configure is running.
This allows showing up the summary page immediately.

Co-authored-by: Jean-Baptiste Lallement <jean-baptiste@ubuntu.com>
2021-11-03 12:35:25 +01:00
Didier Roche f8e90c894d Summary page to show immediately and update once the setup is done
Shows immediately the summary page. Before, this one was making a GET
request to the server, which was stuck on any long running command in
the controller.
Now, affect correctly the identity in memory and reuse it if needed.

Show a progress message while the configuration is happening and replace
it with a "completed" text on success.

Co-authored-by: Jean-Baptiste Lallement <jean-baptiste@ubuntu.com>
2021-11-03 10:48:03 +01:00
Didier Roche fa5721ce0a Allow waiting on summary page
We previously only went on this page when DONE or in ERROR state. Allow
now to be in any state as we switch to it as soon as possible.

Co-authored-by: Jean-Baptiste Lallement <jean-baptiste@ubuntu.com>
2021-11-03 10:33:38 +01:00
Didier Roche f762f41a5b Don’t override syslog dir to prevent printing on TUI.
Co-authored-by: Jean-Baptiste Lallement <jean-baptiste@ubuntu.com>
2021-11-03 10:32:57 +01:00
Didier Roche 7cd65267e9 Fix server socket path in dry-run mode
Co-authored-by: Jean-Baptiste Lallement <jean-baptiste@ubuntu.com>
2021-11-03 10:32:11 +01:00
Carlos Nihelton 1a0c3a1ef0 Prefill file checks summarized by os.path.isfile. 2021-11-01 16:20:24 -03:00
Carlos Nihelton af91bb0a6f Removing dead code.
- My bad.
2021-10-29 20:23:16 -03:00
Carlos Nihelton 4c0ad44738 Moving logic form SystemSetupModel to controllers.
- In order to stay confined into system_setup,
WSLLocaleController had to be recriated.
2021-10-29 12:53:06 -03:00
Carlos Nihelton 10f209ad81 Linting issues fixed. 2021-10-28 15:54:07 -03:00
Carlos Nihelton 2125acffe6 WSL Locale controller is not needed anymore.
- With 'prefill' working, calling Powershell to find Windows locale
is not required anymore.
- Since `f21986be` subiquity's default locale controller respects
  mode.selected_language initialization.
2021-10-28 15:52:24 -03:00
Carlos Nihelton 168a5c13a0 SystemSetupModel handles 'prefill' data
- Init method changed to accept that data, which could be None.
- If valid, user Identity and Locale are prepopulated.
- Server parses the YAML and send valid info (or None) to the Model.
2021-10-28 15:52:24 -03:00
Carlos Nihelton 41a2a554ef Server CLI option '--prefill' added.
- TUI logs the args in consistency to what's been done to Flutter UI.
- Server starting code checks if prefill file exists.
2021-10-28 15:51:41 -03:00
Patrick Wu a3fce9f9c2
system_setup: add useradd tests 2021-10-20 00:27:10 +08:00
Patrick Wu ec04a6833a
system_setup: shutdown/reboot tests 2021-10-18 17:15:45 +08:00
Didier Roche 31fa83e79e
Merge pull request #1078 from canonical/wsl_oobe_deeng_83
DEENG-83 - Implement a reboot in shutdown to restart WSL instances to take new configuration in effect.
2021-10-12 18:13:07 +02:00
Patrick Wu 1d19dfb772
system_setup: implement shutdown/reboot action 2021-10-12 23:20:05 +08:00
Patrick Wu 8559d7fe7d modulizing the usergroup retriving 2021-10-12 10:07:45 +08:00
Patrick Wu 271b72b41a
system_setup: setup user with wsl.conf 2021-10-11 15:33:46 +08:00
Patrick Wu 7ae8e108a6
system_setup: include full autoinstall system 2021-10-11 10:20:18 +08:00
Patrick Wu 07b0407815
system_setup: refactor the testing system
1. updating testing system with the proper autoinstall schema
2. reconf mode testing included
2021-10-08 20:49:06 +08:00
Patrick Wu 5879b41e48
system_setup: several fixes that should be merge before DEENG-82
1. fix a wrong type information
2. fix some configuration error when updating information
2021-10-08 16:41:28 +08:00
Patrick Wu 1c111c764c
system_setup: write files to .subiquity when dryrun 2021-10-07 16:25:07 +08:00
Patrick Wu c934268813 system_setup: changes and fixes
1. rebase with main and update autoinstall-system-setup.yml
2. provide a more unified indent style
3. update get_userandgroups() to the dropped one
4. fix the problematic os action
5. simply asignments
6. assign default_loader a default value
7. provide a type-to-file dict in wsl_conf
8. provide stderr info when providing error in creating user
9. update schema and example files
2021-10-06 22:13:15 +08:00
Patrick Wu 1a7274dbba system_setup: unify api names and simply WSLconfig class into function 2021-10-06 22:13:15 +08:00
Patrick Wu 5c0e64e78a system_setup: address the run_command fail issue 2021-10-06 22:13:15 +08:00
Patrick Wu 9fbff87fe1 system_setup: changes to the get-usersandgroups 2021-10-06 22:13:15 +08:00
Patrick Wu 32a62748c9 system_setup: initial redesign of generic config handler
Also have to change the logic for default loader
2021-10-06 22:13:15 +08:00
Patrick Wu f31e252436 system_setup: reduce code duplication in getting default value 2021-10-06 22:13:15 +08:00
Patrick Wu 225cb1bd37 system_setup: fixes for after rebasing
1. add extra logs
2. improve the answers file
3. await the self.configured in wslconf API
2021-10-06 22:13:15 +08:00
Patrick Wu 032412a938 system_setup: provide configuration calls 2021-10-06 22:13:15 +08:00
Patrick Wu a211689e08 system_setup: update client_variant to variant 2021-10-06 22:13:15 +08:00
Patrick Wu 0a0c53a61b system_setup: move all write file actions to configure controller
This completes 5. Move all “Commits/Write to file” in the configure controller.
2021-10-06 22:13:15 +08:00
Patrick Wu 2490befbd0 system_setup: remove unnecessary params in tui.py 2021-10-05 09:33:21 +08:00
Jean-Baptiste Lallement 6cc8c6169b Fix crash with autoinstall on non-systemd env
On WSL and any system without systemd the server crashes becauses
the syslog id is always set (and never None) and systemd cat cannot
connect to the journal.
We cant set the id to None because the API expects a string, so the
check "is not None" is always true.

Co-authored-by: Didier Roche <didrocks@ubuntu.com>
2021-10-04 13:09:24 -07:00
Michael Hudson-Doyle b144f234ac install packages listed by check-language-support when locale_support == "langpack" 2021-09-30 12:09:57 +13:00
Jean-Baptiste Lallement 44b0b66531 Block shutdown controller on installation done
A race existed due to ~he shutdown controller not waiting for the
install task to be complete.

Co-authored-by: Didier Roche <didrocks@ubuntu.com>
2021-09-28 09:32:39 +02:00
Jean-Baptiste Lallement fecd1cc68c Remove empty "required" in schema
There are no required for WSLConf*, remove it instead of using empty
lists.

Co-authored-by: Didier Roche <didrocks@ubuntu.com>
2021-09-28 09:32:39 +02:00
Jean-Baptiste Lallement 4966173d6c Test system setup autoinstall
It also adds an argument --ignore-tz to the schema comparison test to
not fail on system where the schema has no TZ like WSL.

Co-authored-by: Didier Roche <didrocks@ubuntu.com>
2021-09-28 09:32:39 +02:00
Jean-Baptiste Lallement b81447c988 Added schema for system setup autoinstall
Co-authored-by: Didier Roche <didrocks@ubuntu.com>
2021-09-28 09:26:29 +02:00
Jean-Baptiste Lallement f13bb1121f Fix: use right identity controller for system setup
Co-authored-by: Didier Roche <didrocks@ubuntu.com>
2021-09-28 09:26:10 +02:00
Patrick Wu 65530cf3b3
system_setup: additional Base/Avanced changes and fixes
the fixes includes:
1. renamed helpers.py to wsl_utils.py
2. update several log strings
3. renamed LocaleController to WSLLocaleController
4. improving logic and warnings in get_windows_locale()
5. move config_ref to wsl_utils.py
5. fixes bool_converter()
6. fixes locale configured() getting stuck
2021-09-27 20:36:25 +08:00
Michael Hudson-Doyle 3b6436434c remove server-state file when starting up dry-run system_setup 2021-09-27 22:10:07 +13:00
Michael Hudson-Doyle 2f9c22961e
Merge pull request #1042 from canonical/wsl_oobe_auto_reconf_mode
DE-98/DE-99 - system_setup: Wsl oobe auto reconf mode
2021-09-24 14:26:23 +12:00
Patrick Wu ee3a3df893
sustem_setup: fixes according to Michael's feedback 2021-09-23 15:10:39 +08:00
Didier Roche fa9957d27d
Merge pull request #1055 from canonical/wsl_oobe_no_dry_mode
WSL OOBE - no dry mode
2021-09-21 11:49:38 +02:00
Jean-Baptiste Lallement 0a5b8fcf46 Do not wait on cloud-init on system without cloud-init
On systems where cloud-init cannot run (ie WSL) we where waiting forever
on cloud-init

Co-authored-by: Didier Roche <didrocks@ubuntu.com>
2021-09-20 19:30:36 +02:00
Jean-Baptiste Lallement eee1e9de6d Start server if not socket activated
On systems without socket activation enabled, the client starts the
server manually.

Co-authored-by: Didier Roche <didrocks@ubuntu.com>
2021-09-20 19:29:10 +02:00
Patrick Wu 365769c365 system_setup: update Summary code 2021-09-20 21:58:16 +08:00
Patrick Wu 1aac580dfd system_setup: update the detection logic 2021-09-20 21:58:16 +08:00
Patrick Wu ceae8e9d19 system_setup: fixes according to the feedback
1. update client_variant comment
2. remove Welcome controller
3. remove a TODO
2021-09-20 19:54:27 +08:00
Patrick Wu 6303b5d6c5
system_setup: proper wsl_configuration UI setup
This fixes In wsl_configuration mode the UI shows ”base”/”advanced” screens.
2021-09-20 19:54:14 +08:00
Patrick Wu 018185af49 system_setup: system setup API for Flutter UI part
This completes TODO "provide an API for this for the flutter UI to know
about it"

API is at /meta/client_variant with GET method, returns a string
2021-09-20 19:39:20 +08:00
Patrick Wu 78221ebf25 system setup: auto reconf mode general completion
Mostly complete the second task except the API for GUI:
Implement an API in the server to know if we are in reconfigure or setup mode based on existing UID user >= 1000. Fetch that API from the client and set the variant to wsl_setup or wsl_configuration.
2021-09-20 19:39:20 +08:00