Skip to content

Commit

Permalink
Merge pull request #1713 from mwhudson/organize-examples
Browse files Browse the repository at this point in the history
tidy up examples/ directory
  • Loading branch information
mwhudson authored Jul 11, 2023
2 parents 560247e + 2c75df0 commit 07cc844
Show file tree
Hide file tree
Showing 59 changed files with 125 additions and 113 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ PYTHONSRC=$(NAME)
PYTHONPATH=$(shell pwd):$(shell pwd)/probert:$(shell pwd)/curtin
PROBERTDIR=./probert
PROBERT_REPO=https://github.com/canonical/probert
DRYRUN?=--dry-run --bootloader uefi --machine-config examples/simple.json \
--source-catalog examples/install-sources.yaml \
DRYRUN?=--dry-run --bootloader uefi --machine-config examples/machines/simple.json \
--source-catalog examples/sources/install.yaml \
--postinst-hooks-dir examples/postinst.d/
SYSTEM_SETUP_DRYRUN?=--dry-run
export PYTHONPATH
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ backend configuration files to /tmp/subiquity-config-\* but it won't attempt to
run any installer commands (which would fail without root privileges). Further,
subiquity can load other machine profiles in case you want to test out the
installer without having access to the machine. A few sample machine
profiles are available in the repository at ./examples/ and
profiles are available in the repository at ./examples/machines and
can be loaded via the MACHINE make variable:

`make dryrun MACHINE=examples/simple.json`
`make dryrun MACHINE=examples/machines/simple.json`

# Generating machine profiles
Machine profiles are generated from the probert tool. To collect a machine profile:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/answers-imsm.yaml → examples/answers/imsm.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#machine-config: examples/imsm.json
#machine-config: examples/machines/imsm.json
Source:
source: ubuntu-server
Welcome:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#machine-config: examples/existing-partitions.json
#machine-config: examples/machines/existing-partitions.json
Source:
source: ubuntu-server
Welcome:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/answers-tpm.yaml → examples/answers/tpm.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#source-catalog: examples/tpm-sources.yaml
#dr-config: examples/tpm-dr-config.yaml
#source-catalog: examples/sources/tpm.yaml
#dr-config: examples/dry-run-configs/tpm.yaml
Source:
source: src-prefer-encrypted
Serial:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 14 additions & 14 deletions scripts/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,16 @@ tty=$(tty) || tty=/dev/console

export SUBIQUITY_REPLAY_TIMESCALE=100

for answers in examples/answers*.yaml; do
for answers in examples/answers/*.yaml; do
if echo $answers|grep -vq system-setup; then
config=$(sed -n 's/^#machine-config: \(.*\)/\1/p' $answers || true)
catalog=$(sed -n 's/^#source-catalog: \(.*\)/\1/p' $answers || true)
dr_config=$(sed -n 's/^#dr-config: \(.*\)/\1/p' "$answers" || true)
if [ -z "$config" ]; then
config=examples/simple.json
config=examples/machines/simple.json
fi
if [ -z "$catalog" ]; then
catalog=examples/install-sources.yaml
catalog=examples/sources/install.yaml
fi
serial=$(sed -n 's/^#serial/x/p' $answers || true)
opts=()
Expand Down Expand Up @@ -220,12 +220,12 @@ LANG=C.UTF-8 timeout --foreground 60 \
python3 -m subiquity.cmd.tui \
--dry-run \
--output-base "$tmpdir" \
--machine-config examples/existing-partitions.json \
--machine-config examples/machines/existing-partitions.json \
--bootloader bios \
--autoinstall examples/autoinstall.yaml \
--dry-run-config examples/dr-config-apt-local-mirror.yaml \
--autoinstall examples/autoinstall/most-options.yaml \
--dry-run-config examples/dry-run-configs/apt-local-mirror.yaml \
--kernel-cmdline autoinstall \
--source-catalog examples/install-sources.yaml
--source-catalog examples/sources/install.yaml
validate
python3 scripts/check-yaml-fields.py $tmpdir/var/log/installer/subiquity-curtin-apt.conf \
apt.disable_components='[non-free, restricted]' \
Expand Down Expand Up @@ -254,10 +254,10 @@ LANG=C.UTF-8 timeout --foreground 60 \
python3 -m subiquity.cmd.tui \
--dry-run \
--output-base "$tmpdir" \
--machine-config examples/simple.json \
--autoinstall examples/autoinstall-user-data.yaml \
--machine-config examples/machines/simple.json \
--autoinstall examples/autoinstall/user-data.yaml \
--kernel-cmdline autoinstall \
--source-catalog examples/install-sources.yaml
--source-catalog examples/sources/install.yaml
validate
python3 scripts/check-yaml-fields.py "$tmpdir"/var/log/installer/autoinstall-user-data \
'autoinstall.source.id="ubuntu-server-minimal"'
Expand All @@ -268,10 +268,10 @@ LANG=C.UTF-8 timeout --foreground 60 \
python3 -m subiquity.cmd.tui \
--dry-run \
--output-base "$tmpdir" \
--machine-config examples/simple.json \
--autoinstall examples/autoinstall-reset-only.yaml \
--machine-config examples/machines/simple.json \
--autoinstall examples/autoinstall/reset-only.yaml \
--kernel-cmdline autoinstall \
--source-catalog examples/install-sources.yaml
--source-catalog examples/sources/install.yaml
validate install reset-only

# The OOBE doesn't exist in WSL < 20.04
Expand Down Expand Up @@ -299,7 +299,7 @@ if [ "${RELEASE%.*}" -ge 20 ]; then
python3 -m system_setup.cmd.tui \
--dry-run \
--output-base "$tmpdir" \
--autoinstall "examples/autoinstall-system-setup${mode}.yaml"
--autoinstall "examples/autoinstall/system-setup${mode}.yaml"
validate "system_setup" "autoinstall${mode}"
done

Expand Down
2 changes: 1 addition & 1 deletion subiquity/models/tests/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_render(self):
self.assertEqual(model.render(), {})

def test_canary(self):
with open('examples/install-sources-canary.yaml') as fp:
with open('examples/sources/install-canary.yaml') as fp:
model = SourceModel()
model.load_from_file(fp)
self.assertEqual(2, len(model.sources))
Expand Down
15 changes: 8 additions & 7 deletions subiquity/server/curtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ async def run(self, context):
class _DryRunCurtinCommand(_CurtinCommand):

stages_mapping = {
tuple(): "examples/curtin-events-initial.json", # no stage
("partitioning",): "examples/curtin-events-partitioning.json",
("extract",): "examples/curtin-events-extract.json",
("curthooks",): "examples/curtin-events-curthooks.json",
("swap",): "examples/curtin-events-curthooks.json", # hack
tuple(): "initial.json", # no stage
("partitioning",): "partitioning.json",
("extract",): "extract.json",
("curthooks",): "curthooks.json",
("swap",): "curthooks.json", # hack
}

def make_command(self, command, *args, config=None):
Expand All @@ -161,9 +161,10 @@ def make_command(self, command, *args, config=None):
]
if config:
cmd.extend(['--config', config])
event_log_filename = self.stages_mapping[tuple(stages)]
cmd.extend([
"--",
self.stages_mapping[tuple(stages)],
f"examples/curtin-events/{event_log_filename}",
])
return cmd
else:
Expand All @@ -174,7 +175,7 @@ class _FailingDryRunCurtinCommand(_DryRunCurtinCommand):

stages_mapping = {
**_DryRunCurtinCommand.stages_mapping,
**{("extract",): "examples/curtin-events-fail.json"}
**{("extract",): "curtin-events-fail.json"}
}


Expand Down
4 changes: 2 additions & 2 deletions subiquity/server/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def asyncSetUp(self):
opts = Mock()
opts.dry_run = True
opts.output_base = self.tempdir
opts.machine_config = 'examples/simple.json'
opts.machine_config = 'examples/machines/simple.json'
opts.kernel_cmdline = {}
opts.autoinstall = None
self.server = SubiquityServer(opts, None)
Expand Down Expand Up @@ -164,7 +164,7 @@ async def test_no_default_user(self):
opts = Mock()
opts.dry_run = True
opts.output_base = self.tmp_dir()
opts.machine_config = 'examples/simple.json'
opts.machine_config = 'examples/machines/simple.json'
server = SubiquityServer(opts, None)
server.cloud = Mock()
server._user_has_password = Mock(
Expand Down
Loading

0 comments on commit 07cc844

Please sign in to comment.