Commit Graph

1023 Commits

Author SHA1 Message Date
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
Michael Hudson-Doyle 132440451d more reliably restart client when server restarts
Splitting subiquity into server and client means that in general
old versions of the client can still be running when the server is
updated (the client running on tty1 will be restarted by snapd/systemd
when the snap is updated but clients running via e.g. ssh will not). I
implemented a way for the client to detect this and restart itself: the
server sets a header in all responses that indicates if it has been
updated. So far so good. But the way it knows that it has been updated
is to check the presence of a file that is only created when subiquity
itself triggers the refresh, so it's not there in the case of manual
refresh, and as reported in https://bugs.launchpad.net/bugs/1921820 this
can lead to the client crashing because it cannot parse the new server's
response. This simply changes to creating the marker file in the snap
post-refresh hook, which will be executed for manual snap refreshes as
well.

While I'm at it, remove the rest of the post-install hook that restarted
subiquity clients running on the serial line as the generic machinery
will work for these too.
2021-03-31 13:15:06 +13:00
Michael Hudson-Doyle 64ac97aafe make subiquity client use new API for guided disk usage 2021-03-30 14:22:28 +13:00
Michael Hudson-Doyle e3361aa51c do not set installer user password if it has password or authorized keys
dearie me making a nice UI can involve a lot of typing.
2021-03-25 14:26:49 +13:00
Michael Hudson-Doyle 6fa1d9bbd0 fix crash on refresh: change ids are strings in the snapd api
for https://bugs.launchpad.net/subiquity/+bug/1913417
2021-02-10 11:43:58 +13:00
Michael Hudson-Doyle fac0eeed43 fix crash when trying to view nic info
fixes half of https://bugs.launchpad.net/subiquity/+bug/1912955
2021-01-27 09:35:09 +13:00
Michael Hudson-Doyle 53d06961cc append, do not overwrite logs
The log file names have pids in now, but when subiquity re-execs itself
to fake a snap refresh the pid doesn't change. Having the pre "refresh"
logs get overwritten does not help anything and is sometimes very
annoying.
2020-12-18 12:18:40 +13:00
Michael Hudson-Doyle 007dd3e5ef tidy up answers handling a bit and fix a race 2020-12-16 10:21:32 +13:00
Michael Hudson-Doyle aad036d925 split subiquity.core into subiquity.client.client and subiquity.server.server 2020-11-04 10:57:22 +13:00
Michael Hudson-Doyle 93b8998af6 split NetworkController into non-ui and ui-focused classes 2020-10-12 12:05:56 +13:00
Michael Hudson-Doyle d6f3f83622 run network answers in run_answers 2020-10-12 11:58:08 +13:00
Michael Hudson-Doyle 287b4492e8 start to factor out bits of networkcontroller that touch the view 2020-10-12 11:47:48 +13:00
Michael Hudson-Doyle 798a9da563 have answers code wait for nic creation/deletion to take effect
the UI will not be quite so synchronous in the client/server world
2020-10-12 11:25:50 +13:00
Michael Hudson-Doyle 8dc31a3c6b change network answers processing to not reference model directly 2020-10-12 11:22:08 +13:00
Michael Hudson-Doyle f89b9e692a asyncioify "fine grained action" handling a bit 2020-10-12 11:16:38 +13:00
Michael Hudson-Doyle 673ade7f2a make core interface a little simpler 2020-10-09 13:12:09 +13:00
Michael Hudson-Doyle c03f6580fd move more code that should never have been so generic 2020-10-09 13:08:15 +13:00
Michael Hudson-Doyle 2bf981ebb8 move "last-screen" handling out of generic code 2020-10-09 13:07:04 +13:00
Michael Hudson-Doyle 15ae0bf234 make NetDevInfo.is_connected a bool, as it is supposed to be 2020-09-25 14:33:53 +12:00
Michael Hudson-Doyle edc43ff811 add a minimal server process
run it automatically in dry-run mode
2020-09-22 14:43:26 +12:00
Michael Hudson-Doyle 7d02ee17f6 make zdev view/controller interface more client/server friendly 2020-09-21 21:04:14 +12:00
Michael Hudson-Doyle bc6c66efbb give contexts an id and have progressview track them by id not identity 2020-09-21 14:01:40 +12:00
Michael Hudson-Doyle 219360d12d fixes for how install failures are presented
some of these have been around for a while :/
2020-09-21 14:01:23 +12:00
Michael Hudson-Doyle 56441c6f97 small tidies 2020-09-18 22:01:36 +12:00
Michael Hudson-Doyle 9b414df0eb add a helper to wait and show a dialog if needed
use this in snaplist view. cancellation with asyncio is mindbending!
2020-09-18 21:51:14 +12:00
Michael Hudson-Doyle a7bcc7faf0 add a way to wait for something with notification after 0.1s
use this for moving between screens, removing some crummy code from subquity/core.py
2020-09-18 21:18:27 +12:00
Michael Hudson-Doyle 6c258d6da4 allow make_ui to be a coroutine 2020-09-18 11:52:19 +12:00
Michael Hudson-Doyle f0082c2068 change controller api to return a view, rather than setting it 2020-09-18 11:44:00 +12:00
Michael Hudson-Doyle eb5dba579e handle answers in a separate method 2020-09-18 11:18:08 +12:00
Michael Hudson-Doyle aa3bce4414 do not run the urwid loop at all when not interactive 2020-09-18 09:54:50 +12:00
Michael Hudson-Doyle 45009e3a12 refactor startup a little
the point of this is to have the event loop running while loading
autoinstall commands, which means we do not have to start and stop the
event loop inside load_autoinstall_config if there are early-commands to
run.
2020-09-18 09:54:50 +12:00
Michael Hudson-Doyle 88821f745c
Merge pull request #822 from mwhudson/network-simpler-types
make network view use a plain-old-data view of a nic
2020-09-18 09:54:13 +12:00
Michael Hudson-Doyle 85b35c9e87 steal contextlib from Python 3.8
Python 3.6's does not have asynccontextmanager.
2020-09-11 16:55:26 +12:00
Michael Hudson-Doyle 01e9c04ab5
Merge pull request #817 from mwhudson/tuiapplication
remove all UI code from "core" application object, add tuiapplication
2020-09-10 11:31:30 +12:00
Michael Hudson-Doyle f4066d97d7 convert controller api methods to take strings and trigger updates for affected nics
this is going to work better in the client/server world
2020-09-03 22:52:31 +12:00
Michael Hudson-Doyle f32c74c86d address review comments 2020-09-03 12:31:25 +12:00
Michael Hudson-Doyle 04426cec15 make network view use a plain-old-data view of a nic
The network view code used to crawl all over the network model object,
which isn't really going to work with the upcoming client/server split.
So this adds a much better defined interface between the view and
controller.
2020-09-03 11:12:38 +12:00
Michael Hudson-Doyle e367226f47 fix crash on renaming bond 2020-08-25 13:55:20 +12:00
Michael Hudson-Doyle edc65dbbfb make the base controller have no ui, add subclass for one that has ui 2020-08-23 23:18:28 +12:00
Michael Hudson-Doyle f6757af8d1 fix restarting after refresh 2020-08-23 23:18:28 +12:00
Michael Hudson-Doyle f5f8a8a75c import the controllers module explicitly 2020-08-23 23:18:28 +12:00
Michael Hudson-Doyle ccd8c2382e split urwid-using bits out of subiquitycore.core.Application 2020-08-23 23:18:26 +12:00
Michael Hudson-Doyle bc1060eefa make ControllerSet more re-usable 2020-08-23 22:59:39 +12:00
Michael Hudson-Doyle 63f5f57f30
Merge pull request #804 from mwhudson/screen-refactor
Move the code for setting up the screen to its own file
2020-08-23 22:43:42 +12:00
Tsunghan Liu (Robert Liu) e798451c27 Ignore CAN and unknown interfaces (LP: #1890397)
Add CAN and unknown interfaces to NETDEV_IGNORED_IFACE_TYPES, otherwise rander_config() will throw a KeyError exception when a unsupported interface shows up.
2020-08-07 21:04:05 +08:00
Michael Hudson-Doyle 210cdcb51b Move the code for setting up the screen to its own file
Looking at this code thinking about the coming client / server split
made me realise that we could start by at least moving this
functionality to a more encapsulated place.
2020-07-27 23:40:17 +12:00
Michael Hudson-Doyle 6b26b668be fix formatting of error message 2020-07-22 12:27:04 +12:00
Michael Hudson-Doyle 9271f17dd2 move subiquity.snapd to subiquitycore.snapd 2020-07-02 12:56:49 +12:00
Michael Hudson-Doyle 97b5c64805 do not crash in NetworkController._data_ready if ui.body is not a widgetwrap
for https://bugs.launchpad.net/subiquity/+bug/1881887
2020-06-12 15:01:58 +12:00
Michael Hudson-Doyle a9dd3757f1
Merge pull request #761 from mwhudson/still-better-i18n
more work towards being able to provide good translations
2020-05-21 12:38:51 +12:00
Michael Hudson-Doyle 3e881df107
Merge pull request #778 from mwhudson/ascii-toggle
start in a super basic mode on serial, offer upgrade immediately
2020-05-21 12:05:47 +12:00
Dimitri John Ledkov e2fe2a0693
Merge pull request #773 from xnox/snap-create-user-error
console_conf: fix showing error messages, when snap create-user fails
2020-05-21 01:02:31 +01:00
Michael Hudson-Doyle 0d267b320e only allow downgrading color/ascii experience on serial
and collapse ascii/color choice to a single 'rich' toggle
2020-05-21 11:41:16 +12:00
Michael Hudson-Doyle 7bcfcba99b Merge branch 'master' into still-better-i18n 2020-05-21 11:15:32 +12:00
Michael Hudson-Doyle b85f8118b7 update the network view when wlan dialod is saved 2020-05-19 11:53:03 +12:00
Michael Hudson-Doyle c523e21c34 update wlan dialog when scan results come in 2020-05-19 11:53:03 +12:00
Michael Hudson-Doyle 7236771d2f correctly enable dhcp4 when configuring a ssid for a wlan interface 2020-05-19 11:53:03 +12:00
Michael Hudson-Doyle acd6ee0032
Merge pull request #775 from mwhudson/logged-passwords-lp-1879381
do not log wifi passwords from existing configs
2020-05-19 11:25:44 +12:00
Michael Hudson-Doyle e588d6475f do not log wifi passwords from existing configs 2020-05-19 07:47:33 +12:00
Dimitri John Ledkov debc34cb3c Fix typo 2020-05-18 19:59:47 +01:00
Dimitri John Ledkov 6de8970560 console_conf: fix showing error messages, when snap create-user fails 2020-05-18 12:42:14 +01:00
Dimitri John Ledkov da1477ba01 network: fix wifi screen
WiFi screen was broken since NetDev refactor. Unbreak it.
2020-05-18 12:00:42 +01:00
Michael Hudson-Doyle 812f33cab6 default to setting up LVM in guided storage screen 2020-05-13 16:34:35 +12:00
Michael Hudson-Doyle 24abf5dd4e fix some lint found by new version of flake8 2020-05-12 10:41:54 +12:00
Michael Hudson-Doyle a05b030085 fix lint 2020-05-08 15:44:07 +12:00
Michael Hudson-Doyle 21ed91d7d3 add comments, contexts for some translatable strings
from scanning though about one third of subiquity.pot
2020-05-08 15:40:59 +12:00
Michael Hudson-Doyle 59c47254e7 use pgettext in one place, add support for extracting it 2020-05-08 15:13:15 +12:00
Michael Hudson-Doyle 33bdc90780 copy gettext.py from python 3.8 and use it 2020-05-08 15:09:46 +12:00
Michael Hudson-Doyle 3060a03bd6 make some things slightly better 2020-05-08 15:06:24 +12:00
Michael Hudson-Doyle 2d65fe4f16 attempt to make providing a good translation easier
* annotate a few missed string literals with _()
 * try to consistently use named placeholders when formatting strings
   for display (i.e. _("frob the {thing}") not _("frob the {}")
 * run selector values, form captions and form help through _() before
   display
 * use ngettext in one place. not sure if there need to be more...
 * reduce cuteness about how strings are constructed in a few places
2020-05-06 21:16:24 +12:00
Michael Hudson-Doyle 4e3996f3f8 improve with_context helper a bit, use it more
the decorated function must now be called with keyword arguments
2020-05-05 16:20:03 +12:00
Michael Hudson-Doyle 4891d76aca actually write the netplan from the autoinstall config to the target system
I got lost in a forest of similarly named methods :(
2020-05-04 19:37:43 +12:00
Michael Hudson-Doyle bc37b2c628 add a helper to make it easier to next contexts appropriately
i want this to help debug another branch i am working on!
2020-05-04 18:44:47 +12:00
Michael Hudson-Doyle d15e5f25fa remove mistakenly added backup files 2020-05-01 13:45:59 +12:00
Michael Hudson-Doyle 5dc2895481 add the ability to remove a particular overlay, not just the top one 2020-05-01 12:46:45 +12:00
Michael Hudson-Doyle 7e9c1412b9 introduce and use a state_path helper for finding things in /run 2020-05-01 09:58:06 +12:00
Michael Hudson-Doyle 37a62f21aa fix travis some more 2020-04-30 20:56:09 +12:00
Michael Hudson-Doyle b66ad552f8 make default_netplan valid, for some reason this causes issues sometimes on travis 2020-04-30 20:25:14 +12:00
Michael Hudson-Doyle 6007b4dc41 do not crash in a terminal < 76 columns wide
for https://bugs.launchpad.net/ubuntu-z-systems/+bug/1874314
2020-04-28 21:32:46 +12:00
Michael Hudson-Doyle 88165ce5fd use a cleaner way of attaching controllers to contexts 2020-04-24 14:45:20 +12:00
Michael Hudson-Doyle 9ff059eae7 put zdev rows directly in a listbox, not in a pile in a listbox
this required adding TableListRow.set_contents.

it fixes (partly by accident) a crash when a row becomes unselectable
after a refresh (https://bugs.launchpad.net/subiquity/+bug/1874114), it
also makes the home and end keys do something sane.

really this view should not rebuild every row on any change, but that's
something for another day.
2020-04-22 15:36:06 +12:00
Dimitri John Ledkov 760fbaa22f Review comments 2020-04-16 00:22:52 +01:00
Dimitri John Ledkov a70d309f6a Use common palette.
Fixes header frindge colors in console-conf.
2020-04-09 12:20:16 +01:00
Dimitri John Ledkov f3b1a70822
Merge pull request #692 from bboozzoo/bboozzoo/chooser-tweaks
console_conf: various recover chooser tweaks
2020-04-09 10:59:39 +01:00
Maciej Borzecki a33a477324 subiquitycore/core: fix typo in comments
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-04-07 15:35:47 +02:00
Michael Hudson-Doyle 9a11e90719 attach a controller to most contexts 2020-04-07 21:51:11 +12:00
Michael Hudson-Doyle 246570314a pass the context object to report_start_event / report_finish_event 2020-04-07 21:51:11 +12:00
Michael Hudson-Doyle 81b6f8a90a if netplan apply fails show an error rather than crashing the ui 2020-04-07 12:16:53 +12:00
Michael Hudson-Doyle 00e33ae0e1 include ssh host key details in ssh help 2020-04-06 14:10:26 +12:00
Michael Hudson-Doyle 4101440814 a bigger hammer 2020-04-03 13:47:29 +13:00
Michael Hudson-Doyle fa476d54cc treat virtual network devices a bit more like physical ones
in particular: have subiquitycore.netplan understand them. The goal of
all this is to make the recent change to not delete virtual interfaces
if their configuration has not changed actually work.
2020-04-03 10:12:42 +13:00
Maciej Borzecki 9bcf507b7c subiquitycore: do not assume that stdin is /proc/self/fd/0
The KeyCodesFilter assumed that /proc/self/fd/0 is actual stdin and proceeded to
toy with that fd. This broke the recovery mode chooser where console-conf is fed
a list of recovery systems over stdin. The `sys.stdin` is already correctly
updated to use the real tty and that should be used elsewhere instead of
hardcoding the fd number.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-04-02 13:08:16 +02:00
Michael Hudson-Doyle a03a336bd7 translate concurrent.futures.CancelledError to asyncio.CancelledError
apparently cancelling something that is running in a thread leads to a different
exception class being raised...
2020-04-02 12:15:06 +13:00
Dimitri John Ledkov 590b4b8f23
Merge pull request #655 from bboozzoo/bboozzoo/uc20-recovery-chooser
console_conf: implement UC20 recovery chooser
2020-04-01 22:05:30 +01:00
Michael Hudson-Doyle cab565304a write netplan directly to the target
rather than via curtin and then cloud-init
2020-04-01 19:37:02 +13:00
Maciej Borzecki 93ac6b94a3 Merge remote-tracking branch 'upstream/master' into bboozzoo/uc20-recovery-chooser 2020-03-31 17:14:28 +02:00
Michael Hudson-Doyle d717375d9c apply network autoinstall config 2020-03-31 15:58:18 +13:00
Dimitri John Ledkov d97bf081ea Only delete virtual devices when config has changed 2020-03-26 21:26:34 +00:00
Maciej Borzecki 5d77d71499 subiquitycore: allow overriding input/output when creating screens
The interaction with snap-recovery-chooser happens over stdin/stdout. The early
setup code in console-conf will attempt to restore sys.stdin/sys.stdout and hook
them up to the current tty.

The patch allows passing input/output streams explicitly as parameters to the
constructors.

Also, default to sys.stdin/sys.stdout and pass both streams explicitly when
constructing urwid.raw_display.Screen(), to workaround the bug in their
constructor. THe constructor is defined as follows:

    class Screen(BaseScreen, RealTerminal):
        def __init__(self, input=sys.stdin, output=sys.stdout):

What means, that even if we override sys.stdout/sys.stdin globally in our setup
code, this will have no effect as `input` and `output` already got their values.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-03-24 13:32:52 +01:00
Michael Hudson-Doyle 3856a11186 fix deleting virtual network devices 2020-03-20 09:18:25 +13:00
Michael Hudson-Doyle cc52bb62a5 fix enabling dhcp on a virtual interface 2020-03-20 09:17:29 +13:00
Michael Hudson-Doyle 7596e63a9f pass **kw args to arun_command in run_command_in_foreground
this makes the debug shell run in / rather than /snap/subiquity/whatever
2020-03-17 12:23:06 +13:00
Michael Hudson-Doyle b4ab4d8f1b Only mark definitively seen screens as configured.
Mark a screen as configured if:
 - last-screen is present
 - the screen was before the screen last-screen indicates
2020-03-16 16:37:25 +13:00
Michael Hudson-Doyle 94611c58e2 remove last-screen file before restarting or exiting
unless we are restarting because of a snap refresh.

ths lead to all kinds of confusion after e.g. a ui crash after a snap refresh
2020-03-16 16:37:16 +13:00
Michael Hudson-Doyle 99218fbeb4 support early and late commands 2020-02-04 14:03:59 +13:00
Michael Hudson-Doyle 963cbaaafe refactor how subiquity is exited after install
if we want to do things after install has completed (e.g.: run late
commands), we can't have the code that runs the install invoking
/sbin/reboot directly.
2019-12-20 13:54:34 +13:00
Michael Hudson-Doyle f925c3fa2a
Merge pull request #622 from mwhudson/make_screen-method
make screen behaviour more configurable
2019-12-20 13:09:57 +13:00
Michael Hudson-Doyle a40082a29b
Merge pull request #621 from mwhudson/controller-set-tweaks
tweak ControllerSet
2019-12-20 13:01:04 +13:00
Michael Hudson-Doyle 78d59de8c6 only call setraw if the screen is talking to a tty 2019-12-20 12:48:27 +13:00
Michael Hudson-Doyle 039b5313c4 move make_screen into a method 2019-12-20 12:47:37 +13:00
Michael Hudson-Doyle ab6fdeb1b5 tweak ControllerSet
* add a way to load just one controller
 * fetch the RepeatedController class from a projet specific location

neither used yet, but soon
2019-12-20 12:43:42 +13:00
Michael Hudson-Doyle cb52ab75a2 use the asyncio loop object rather than the urwid loop almost everywhere 2019-12-20 12:04:38 +13:00
Michael Hudson-Doyle cfc38e1c1b make all subiquity controllers used inherit from SubiquityController
There is going to be a chunk of subiquity specific functionality coming
for autoinstalls, this gives us somewhere to put it.
2019-12-20 11:41:12 +13:00
Michael Hudson-Doyle 570472315d Add SingleInstanceTask.wait
this can be called without having to worry about the task being
cancelled out from under you
2019-12-20 11:00:46 +13:00
Michael Hudson-Doyle 45478b68a4 add a way to change the default level of a context's children 2019-12-20 09:47:38 +13:00
Michael Hudson-Doyle a91dff2b14 add a way to log a dialog open/close, use it for network dialogs 2019-12-20 09:47:38 +13:00
Michael Hudson-Doyle 4be25fc78f log applying network config via context 2019-12-20 09:47:36 +13:00
Michael Hudson-Doyle 1f1937b03f report progress through screens via context 2019-12-20 09:46:26 +13:00
Michael Hudson-Doyle fa39f10651 fix answers 2019-12-20 09:46:26 +13:00
Michael Hudson-Doyle 5961b68b7d introduce a Context object for logging start/stop events 2019-12-20 09:46:26 +13:00
Michael Hudson-Doyle 0c268f6c22 fix case where NIC does not get DHCP address 2019-12-19 16:06:56 +13:00
Dimitri John Ledkov 904c0e3179
Merge pull request #613 from mwhudson/model-events
stop using urwid signals to coordinate installation
2019-12-17 02:11:32 +00:00
Michael Hudson-Doyle ca1635a1f9 a bit of refactoring 2019-12-17 15:05:17 +13:00
Dimitri John Ledkov dce0f10c10 Merge guided method & disk selection into one screen. (#588)
Merge guided method & disk selection into one screen.
2019-12-17 12:59:03 +13:00
Michael Hudson-Doyle 29c9f0878b indent a "raise" properly 2019-12-17 11:28:42 +13:00
Dimitri John Ledkov 4bcb0e5fd1
Merge pull request #609 from mwhudson/less-signalling
stop some pointless use of urwid signals
2019-12-16 19:38:45 +00:00
Dimitri John Ledkov 42343d665f
Merge pull request #601 from mwhudson/more-async-refresh
make the refresh view code use asyncio apis
2019-12-16 12:33:22 +00:00
Dimitri John Ledkov c067e5e741
Merge pull request #606 from mwhudson/prober-fail-lower
push debug_flag block probe crashing into Prober
2019-12-16 12:27:16 +00:00
Michael Hudson-Doyle 33af65bde1 make --screen command line option do something again 2019-12-16 23:17:21 +13:00
Michael Hudson-Doyle 324dddac94 push debug_flag block probe crashing into Prober 2019-12-16 23:15:48 +13:00
Michael Hudson-Doyle 01e5261b3f kill off other top level signals 2019-12-16 23:09:17 +13:00
Michael Hudson-Doyle 2765e6a773 replace next-screen/prev-screen signals with method calls 2019-12-16 23:02:03 +13:00
Michael Hudson-Doyle 7e7ca080f6
Merge pull request #604 from mwhudson/tab-cycling-oddity
fix tab-cycling between header and body
2019-12-16 21:37:20 +13:00
Michael Hudson-Doyle 7b697a1978
Merge pull request #602 from mwhudson/selector-non-text
allow Selector to have non-text entries
2019-12-16 21:36:45 +13:00
Michael Hudson-Doyle b41560fc4c fix tab-cycling between header and body 2019-12-16 21:32:25 +13:00
Michael Hudson-Doyle 9736825e32 simplify SubForm stuff a bit 2019-12-16 21:21:57 +13:00
Michael Hudson-Doyle 6913294de6 EXTREMELY OBSCURE fix
without this, selectors get skipped over when selecting the first element in a
pile if the label is some kind of container.
2019-12-16 21:15:46 +13:00
Michael Hudson-Doyle 9759957f36 allow Selector to have non-text entries 2019-12-16 13:28:42 +13:00
Michael Hudson-Doyle de18cc977f make SingleInstanceTask.start_sync set self.task synchronously 2019-12-16 12:33:19 +13:00
Michael Hudson-Doyle 5173e46b33
Merge pull request #600 from mwhudson/fix-probing-failures
stop block probing failures from crashing the process
2019-12-15 09:53:47 +13:00
Michael Hudson-Doyle fe08311c19 stop block probing failures from crashing the process
There is a common problem in concurrent / asynchronous code of what to
do with unhandled exceptions. If a (conceptual) thread of execution
fails, there's no guarantee (and no way of telling) if there's anything
listening.  By default, I chose to have a failing task propagate the
exception up to the run loop for two reasons:

 1) Unhandled exceptions are generally bad
 2) urwid.ExitMainLoop needs to be propagated to the run loop to have
    any effect

But this means that tasks that are expected to fail (and have this
failure handled) like block probing crash the process, which is
obviously a Bad Thing. This branch adds a way to turn off exception
propagation per-task, which is a bit hackish but works ok it seems.
2019-12-15 09:45:14 +13:00
Michael Hudson-Doyle bd3ede4c21
Merge pull request #595 from mwhudson/remove-run_in_bg
remove run_in_bg

the asyncioification is complete (apart from bug fixes)
2019-12-15 09:44:09 +13:00
Michael Hudson-Doyle 6d4ea2bf34
Merge pull request #596 from xnox/uc20
Unbreak console-conf in UC20 images
2019-12-15 09:04:03 +13:00
Michael Hudson-Doyle ae5cd6268a kill off run_in_bg and some related hacks 2019-12-15 08:53:37 +13:00
Michael Hudson-Doyle a92b88ed9d asyncioify run_command_in_foreground 2019-12-15 08:53:36 +13:00
Dimitri John Ledkov d6689d9200
Merge pull request #594 from mwhudson/asyncio-ssh
asyncioify ssh
2019-12-14 16:48:55 +00:00
Dimitri John Ledkov b4ff1bde70
Merge pull request #599 from mwhudson/radiobuttonfield
add a RadioButtonField for forms
2019-12-14 16:47:29 +00:00
Michael Hudson-Doyle a2fc6da694 add a RadioButtonField for forms 2019-12-14 22:35:19 +13:00
Michael Hudson-Doyle 285eeee0ed
Merge pull request #598 from mwhudson/repeatedcontroller-index
fix RepeatedController
2019-12-14 22:16:07 +13:00
Michael Hudson-Doyle 0090aec3be fix RepeatedController
a snap update was offered the second time even if it had been
offered already
2019-12-14 21:44:10 +13:00
Michael Hudson-Doyle 5571e1fab3 add a class for controllers with no ui
there will be a bunch of these coming for autoinstall
2019-12-14 21:27:39 +13:00
Dimitri John Ledkov d19e405666 Unbreak console-conf in UC20 images 2019-12-14 03:00:17 +00:00
Michael Hudson-Doyle 05a61544fb asyncio.create_subprocess_exec defaults stdin to None 2019-12-13 11:44:12 +13:00
Michael Hudson-Doyle 992e131b5f squash all exceptions when cancelling the task in SingleInstanceTask
otherwise restarting a failed task just raises the exception from the previous
failure
2019-12-13 10:05:23 +13:00
Michael Hudson-Doyle 4e1afd60a4 do not always stop networkd 2019-12-13 10:04:57 +13:00
Michael Hudson-Doyle b155d3eff0 have apply_config task exit as soon as all dhcp NICs have an address 2019-12-13 10:04:31 +13:00
Michael Hudson-Doyle 08e081415d move async_helpers to subiquitycore 2019-12-13 10:04:02 +13:00