Skip to content

Commit

Permalink
Cleaner messages on attempting to remove a Template currently in use
Browse files Browse the repository at this point in the history
  • Loading branch information
alimirjamali committed Jul 11, 2024
1 parent 1334d7a commit dd845c1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion qubesadmin/tools/qvm_template_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,22 @@ def import_template_config(args, conf_path, vm):
def pre_remove(args):
'''Handle pre-removal tasks'''
app = args.app
app.log.name = "qvm-template-postprocess"
try:
tpl = app.domains[args.name]
except KeyError:
parser.error('No Qube with this name exists')
dependant_vms = False
for appvm in tpl.appvms:
parser.error('Qube {} uses this template'.format(appvm.name))
dependant_vms = True
app.log.error(
'ERROR!!! Qube "{}" uses this template'.format(appvm.name))
if dependant_vms:
app.log.warning(
'WARNING!!! Do not use dnf to uninstall templates!')
app.log.info('Info: Use qvm-template(1) or ' \
'Qubes Template Manager GUI to uninstall templates\n')
sys.exit(1)

tpl.installed_by_rpm = False
del app.domains[args.name]
Expand Down

0 comments on commit dd845c1

Please sign in to comment.