Commit Graph

34 Commits

Author SHA1 Message Date
Dan Bungert c73fac697e utils: add gen_zsys_uuid
Add gen_zsys_uuid, to generate a uuid of the same form as used in the
ubiquity zsys-setup script.
2023-08-24 17:42:09 -06:00
Dan Bungert 34d40643ad format with black + isort 2023-07-25 15:27:42 -06:00
Michael Hudson-Doyle 6b35e5e4a1 tidy up examples/ directory
Move machine configs, sources, autoinstall files and dry-run configs
into their own subdirectories.
2023-07-11 12:49:22 +12:00
Olivier Gayot 60f2b506db prober: move to asyncio for probert storage
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-04-25 15:12:19 +02:00
Dan Bungert 1d9ad848fe utils: orig_environ cleans LD_LIBRARY_PATH
LD_LIBRARY_PATH is set earlier than some of the other environment
variables like PATH or PYTHONPATH, so trying to save a clean version in
snapcraft is not viable.  Remove it here.
2023-03-30 16:34:12 -06:00
Olivier Gayot 9b18f45700 snapcraft: upgrade to core22
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-03-16 12:21:44 +01:00
Dan Bungert 98a2ff8647 async_helpers: simplify task done check
Another version of the task-created-yet problem is the non-blocking
check to see if it is done or not.  Add a wrapper here to simplify
calling code.
2023-03-13 15:50:33 -06:00
Dan Bungert 075b06ce70 async_helpers: make SingleInstanceTask.wait safer
SingleInstanceTask has distinct steps for creation of the object, and
starting the task.  If a different coroutine is waiting on the
SingleInstanceTask, it isn't safe to directly call
SingleInstanceTask.wait() as the task may or may not have been created
yet.

Existing code usage of SingleInstanceTask is in 4 categories, with
reguards to SingleInstanceTask.wait():
1) using SingleInstanceTask without using SingleInstanceTask.wait().
   This is unchanged.
2) using SingleInstanceTask.wait without a check on task is not None.
   This may be safe now, but is fragile in the face of innocent-looking
   refactors around the SingleInstanceTask.
3) using SingleInstanceTask.wait after confirming that the task is not
   None.  This is fine but a leaky abstraction.
4) directly waiting on the SingleInstanceTask.task.  Another leaky
   abstraction, but it's solving a cancellation problem.  Leaving this
   alone.

By enhancing SingleInstanceTask.wait(), cases 2 and 3 are improved.  The
code not checking the task today is made safer, and the code checking
the task today can be simplified.
2023-03-13 15:50:33 -06: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 4025cbf97f ui: avoid crashing when removing overlay that does not exist
BaseView.remove_overlay() would crash with AttributeError if no overlay
was found. We now add a not_found_ok parameter (defaulting to True) that
makes the function silently return if the overlay could not be found.

Passing not_found_ok=False and catching OverlayNotFoundError can be
helpful in some scenarios to do something different if no overlay was
found.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-12-07 10:31:05 +01:00
Michael Hudson-Doyle 7618ce2af6 extend "unit" test to cover finish_install
and fix the bug it inevitably found.
2022-11-10 11:57:21 +13:00
Dan Bungert d73772258d fix some easier cases of impolite language 2022-08-29 12:30:39 -06:00
Dan Bungert dffb155203 tests: s/run_coro/IsolatedAsyncioTestCase/
Tests that use run_coro are at risk of being broken by the introduction
of another test using IsolatedAsyncioTestCase.  Switch over to only use
IsolatedAsyncioTestCase.
2022-06-23 17:43:14 -06:00
Dan Bungert 5b30732f14 debug shell: restore orig environment 2022-06-13 14:02:32 -06:00
Dan Bungert 77119a8e0b SingleInstanceTask: add cancel_restart
cancel_restart is a mode for SingleInstanceTask that changes the
behavior when starting the task - if the task is already running, do not
cancel it to start another.
2022-05-25 10:25:00 -06:00
Dan Bungert 884f1c87ae pubsub: fix test fragility 2022-05-24 13:36:02 -06:00
Dan Bungert 8ca83aa9cf file_util: genericize copy routine 2022-04-11 12:51:26 -06:00
Dan Bungert a3e1cfa6e4 probert: implement os prober arg 2022-03-29 15:09:21 -06: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
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
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 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 bc8fda47f6 EventCallback: remove 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 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 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 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
Scott Moser 3e69673501 Fix writing of netplan configs
When user configures network with subiquity, it's rendered
netplan should be wholly definitive.  So, we remove the other files
that may have config.  This fixes a bug where running in an instance
when running on a system where cloud-init had rendered a 'match' with
'macaddress'.

When writing netplan we keep 'macaddress' match in place but drop
others.  The others may just wildcard from the installer environment,
but macaddress are likely by cloud-init or otherwise intentionally
written.

Also add an atomic write in subiquitycore/file_util and move the
netplan code into subiquitycore/netplan.py, and add some unit test
helpers from cloud-init.
2018-06-07 11:46:34 -04:00
Michael Hudson-Doyle d9f596c994 Move disk and install things from subiquitycore to subiquity. 2016-07-26 16:00:36 +12:00
Mathieu Trudel-Lapierre e1970b6477 Rename subiquity to subiquitycore -- will serve as base classes for everything
Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2016-06-30 14:17:01 -04:00