Skip to content

Commit

Permalink
Remove old templates after upgrade to buster templates
Browse files Browse the repository at this point in the history
Shut down and remove the following Debian Stretch templates:
* sd-svs-template
* sd-svs-disp-template
* sd-export-template
* securedrop-workstation

Adds test to ensure the templates have been properly deleted.
  • Loading branch information
emkll committed Dec 2, 2019
1 parent 92770b6 commit 35c1a20
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 2 deletions.
1 change: 0 additions & 1 deletion dom0/sd-dom0-files.sls
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ dom0-workstation-rpm-repo:
dom0-install-securedrop-workstation-template:
pkg.installed:
- pkgs:
- qubes-template-securedrop-workstation
- qubes-template-securedrop-workstation-buster
- require:
- file: dom0-workstation-rpm-repo
Expand Down
1 change: 1 addition & 0 deletions dom0/sd-export.sls
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sd-export-usb-dvm:
- tags:
- add:
- sd-workstation
- buster
- features:
- enable:
- service.paxctld
Expand Down
7 changes: 7 additions & 0 deletions dom0/sd-remove-unused-templates.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :

run-remove-upgrade-scripts:
cmd.script:
- name: salt://handle-upgrade
- args: remove
1 change: 1 addition & 0 deletions dom0/sd-svs-disp.sls
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sd-svs-disp:
- add:
- sd-workstation
- sd-svs-disp-vm
- buster
- features:
- enable:
- service.paxctld
Expand Down
1 change: 1 addition & 0 deletions dom0/sd-svs.sls
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sd-svs-template:
- tags:
- add:
- sd-workstation
- buster
- require:
- sls: sd-workstation-template
- sls: sd-upgrade-templates
Expand Down
1 change: 1 addition & 0 deletions dom0/sd-workstation-template.sls
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sd-workstation-template:
- tags:
- add:
- sd-workstation
- buster
- features:
- enable:
- service.paxctld
Expand Down
1 change: 1 addition & 0 deletions dom0/sd-workstation.top
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ base:
- sd-svs-disp
- sd-svs
- sd-whonix
- sd-remove-unused-templates
sd-export-template:
- sd-export-files
sd-gpg:
Expand Down
12 changes: 11 additions & 1 deletion scripts/handle-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ if [[ $TASK == "prepare" ]]; then
fi
fi
elif [[ $TASK == "remove" ]]; then
echo "placeholder"
# For each template, ensure the TemplateVM exists, that it is shut down
# before deleting it.
for template in sd-svs-template sd-svs-disp-template sd-export-template
do
if qvm-check "${template}" --quiet; then
if qvm-check --running "${template}"; then
qvm-shutdown --wait "${template}"
fi
qvm-remove -f "${template}"
fi
done
else
echo "Please specify prepare or remove"
exit 1
Expand Down
26 changes: 26 additions & 0 deletions tests/test_dom0_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import subprocess
import unittest

STRETCH_TEMPLATES = ["sd-svs-template",
"sd-svs-disp-template",
"sd-export-template"]


class SD_Qubes_Dom0_Templates_Tests(unittest.TestCase):

def setUp(self):
pass

def tearDown(self):
pass

def test_Templates_cleaned_up(self):
cmd = ["qvm-ls", "--raw-list"]
contents = subprocess.check_output(cmd).decode("utf-8").strip()
for template in contents.split():
self.assertTrue(template not in STRETCH_TEMPLATES)


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Qubes_Dom0_Templates_Tests)
return suite

0 comments on commit 35c1a20

Please sign in to comment.