Commit Graph

879 Commits

Author SHA1 Message Date
Olivier Gayot 87c249d5d0 Add type annotations for command execution methods
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-02-28 14:05:56 +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
Dan Bungert 42db747a0d file_util: remove omode / copy_mode
omode used to be in use, but has been standardized to 'w'.
copy_mode was unused.  Remove both.
2022-02-14 11:23:39 -07:00
Dan Bungert f4a9836143 file_util generate_config -> generate_config_yaml
The two usages of generate_config were both for yaml, so make that
simpler.
2022-02-14 11:21:56 -07:00
Dan Bungert b7349241a9 standardize on useage of file_util methods 2022-02-14 11:14:10 -07:00
Dan Bungert fae24f3247 logging: log files 0640 root:adm 2022-02-14 11:14:10 -07:00
Dan Bungert 9b5513f311 file_util: add open_perms and generate_config
Create open_perms context manager for custom or multiple writes.
Create generate_config for a small removal of redundancy.
0640 root:adm the resulting files.
2022-02-14 11:14:10 -07: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
Olivier Gayot de19b3abee Add type hinting for controller base class attributes
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-14 13:02:44 +01:00
Olivier Gayot 475d71e166 Allow to pass dry_run boolean to lsb_release
So that we consistently return the same value from lsb_release() across
all calls that use dry-run, the function now accepts a dry_run argument
(defaulting to False). This way, in dry-run mode, the caller does not
need to supply the path to a specific example file anymore.

  lsb_release(dry_run=True) -> will load examples/lsb-release-focal

Having said that, the caller is still left with the possibility to
specify the example file by using the path argument:

  lsb_release(path="example/lsb-release-impish")

The path and dry_run arguments are mutually exclusive: providing both
will result in a ValueError.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-17 16:00:52 +01:00
Olivier Gayot 68b9c42fac Fix exception messages not interpolated properly
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2021-12-16 11:35:40 +01:00
Dan Bungert 0308fa49b1 core test_view: don't prefix local class w/ Test
Fix warning:
  subiquitycore/tests/test_view.py:24
    subiquity/subiquitycore/tests/test_view.py:24:
    PytestCollectionWarning: cannot collect test class 'TestStretchy'
    because it has a __init__ constructor
2021-10-15 16:12:44 -06:00
Michael Hudson-Doyle 744269d074 remove stdlib backports from Python 3.8 2021-10-12 18:55:09 -06:00
Michael Hudson-Doyle 7cfc7d1215 close the session object after each request to the snapd API
As reported in https://bugs.launchpad.net/snapd/+bug/1946656,
not-quite idle connections between subiquity and snapd are piling up and
causing issues when trying to restart subiquity. I don't really
understand why, but using a fresh session for each API access makes the
problem go away.
2021-10-12 22:22:12 +13:00
Michael Hudson-Doyle b144f234ac install packages listed by check-language-support when locale_support == "langpack" 2021-09-30 12:09:57 +13:00
Dan Bungert af8dcfe6c3 pubsub: remove subscribe args, more broadcast args
Remove the subscribe time args, as they weren't used.
With that flexibility we can add many args at broadcast time.
2021-09-24 13:11:55 -06:00
Dan Bungert 350ce11dd9 pubsub: optional argument at broadcast time 2021-09-24 13:10:04 -06: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
Michael Hudson-Doyle 7f6af23694 set wider permissions on log directory 2021-09-23 21:24:44 +12:00
Patrick Wu 1aac580dfd system_setup: update the detection logic 2021-09-20 21:58:16 +08:00
Michael Hudson-Doyle 1519c49d8e
Merge pull request #1030 from mwhudson/source-selection-3
install source selection
2021-09-14 15:10:58 +12:00
Michael Hudson-Doyle a6270cbaa1 server side implementation of source selection 2021-09-13 13:23:09 +12:00
Dan Bungert a005418cde pubsub: split channels into two classes 2021-09-08 18:33:57 -06:00
Dan Bungert bc8fda47f6 EventCallback: remove 2021-09-08 18:33:57 -06:00
Dan Bungert 3a69683128 geoip: switch to MessageHub 2021-09-08 18:33:57 -06:00
Dan Bungert fc95c72f35 pubsub: Add unit test for MessageHub
Also minor cleanup on the soon-to-be-removed EventCallback test to help
demonostrate that some of this code isn't needed.
2021-09-08 18:33:57 -06:00
Dan Bungert 0ea8139f32 MessageHub: Switch to using enum constants 2021-09-08 18:33:57 -06:00
Michael Hudson-Doyle 7f1beb1d64 add a mode argument to shutdown to allow reboot or power off 2021-08-22 09:36:41 +12:00
Dan Bungert c79aa602dc Proper fix for setting timezone inappropriately in dryrun
Reenable integration test for set of timezone.
Don't set it while in dryrun.
2021-07-15 10:49:32 -06:00
Dan Bungert ada889328d Verify that machine-config arg is a file
If machine-config is pointed to a non-existant file, dryrun can kind of
unhelpfully hang without much indication that anything is happening.
2021-07-14 16:40:22 -06:00
Dan Bungert 40945f1823
TimeZone: autoinstall and API (FR-1184) (#986)
* TimeZone: autoinstall and API

Add support for Get/Set timezone methods.  Get means that we inquire
with GeoIP as to which timezone is suggested.  Non-availability of
GeoIP, or a previous explicit Set, means that we return the system
timezone.  Set of timezone by Post results in set of the live system
timzeone, and queuing a set of the target system by way of cloud-init.

* Add clarifying comment about _request.
2021-07-13 06:25:03 -06:00
Dan Bungert 6a189dd598
Add EventCallback, and move mirror task things to GeoIP (#983)
Move mock_app to common location.
Move run_coro to subiquitycore so that subiquitycore doesn't have to
reference things in subiquity, even for test.
Move task tracking things from mirror to geoip.
Server app owns the geoip instance.
Create EventCallback as an alternative to MessageHub that should
hopefully express clearer intermodule dependencies.
2021-06-14 16:05:27 -06:00
Michael Hudson-Doyle 83d076975d
Merge pull request #979 from mwhudson/install-wpasupplicant-on-demand
install wpasupplicant when a wifi nic is seen
2021-06-10 12:54:09 +12:00
Michael Hudson-Doyle ef008f4aea address review comments 2021-06-10 12:32:29 +12:00
Michael Hudson-Doyle 7b3bb0278b fix some more assorted small wlan problems 2021-06-09 15:28:06 +12:00
Michael Hudson-Doyle fa9628f34c remove support from network model for filtering out wlan devices 2021-06-09 13:00:43 +12:00
Michael Hudson-Doyle 907e7dd7b0 implement UI for tracking wpasupplicant install state
this should perhaps be in the subiquity package vs subiquitycore somehow
but that seems hard.
2021-06-09 13:00:43 +12:00
Michael Hudson-Doyle 47b2836aee pretend virtual wlan (i.e. mac80211_hwsim) devices are real
this allows their use for testing
2021-06-02 12:40:57 +12:00
Michael Hudson-Doyle d14fd35330 move "enabling wifi turns on dhcp4" behaviour to controller from view 2021-06-02 12:40:50 +12:00
Michael Hudson-Doyle 902c57f7f7 move start_scan error handling into controller
report errors via scan_state field
2021-06-02 12:28:44 +12:00
Michael Hudson-Doyle b84fa27752 call apply_config in controller set_wlan method 2021-06-02 12:28:44 +12:00
Michael Hudson-Doyle b046608a78 fix type annotations in network model types 2021-06-02 12:28:44 +12:00
Michael Hudson-Doyle 4850cee5ce NetworkConfigureWLANStretchy.update_link should only care about updates for its nic
this was very confusing to debug!
2021-06-02 12:28:44 +12:00
Michael Hudson-Doyle c325e76e9e fix the wlan view calls to controller methods to pass just the nic name 2021-06-02 12:28:42 +12:00
Dan Bungert 2719c57c1b
locale - let it check interactive-sections again (#937)
* locale - let it check interactive-sections again

* Turn Serial into a whole new screen

When in serial, first offer the rich/basic choice (or SSH button),
and only show the current welcome screen if we choose rich mode.
Add a back button on Welcome if we are on serial.

LP: #1919251
2021-04-21 10:11:27 -06:00
Michael Hudson-Doyle bc2ae6199a asyncify pubsub a bit 2021-04-13 09:41:43 +12:00
Michael Hudson-Doyle dab04bcb3a simple replacement for urwid signals wrapper as used in server
I think this removes all use of urwid from the server code.
2021-04-13 09:41:43 +12:00
Michael Hudson-Doyle b0af11ad02 kill any foreground subprocess before restarting
This fixes a problem where you drop to a shell and refresh subiquity
from that shell -- the client tries to restart but it is running in the
background and so crashes trying to modify the terminal settings. So
this kills the subprocess before restarting. This required the extremely
angry PR I sent before: forcefully killing the subprocess also crashes
the client before restart in a similar way.
2021-04-01 17:24:49 +13:00
Michael Hudson-Doyle 939c81920c do not crash when subshell exits via signal
Here is something you can try with a live server installer today: drop
into a subshell and type "kill -9 $$". The installer will crash with an
'Input/output error' from tcsetattr.

What's going on is some deep unix arcana: when the subshell exits via
signal somehow the shell's process group is still in the foreground
(even though there are no processes in it?) and calling tcsetattr() from
a background process is not allowed. So the fix for this is reasonably
simple (or at least: short): call tcsetpgrp() to put our process group
back into the foreground. A background process doing this gets sent
SIGTTOU, but if we ignore that, all is well.

Frankly this is all very strange and I would like a lie down now.
2021-04-01 16:27:05 +13:00
Michael Hudson-Doyle 26593f4c16
Merge pull request #924 from mwhudson/lp-1921820-2
more reliably restart client when server restarts
2021-03-31 13:30:56 +13:00