Improved communication on Remove VM in Qube Manager
When a user tries to remove a VM that's used by other VMs or Global Settings from Qube Manager, they get information about where the VM is used. Depends on https://github.com/QubesOS/qubes-core-admin-client/pull/73
This commit is contained in:
parent
b8c1ec8dac
commit
d46bf2aa8e
@ -35,6 +35,7 @@ from pydbus import SessionBus
|
||||
|
||||
from qubesadmin import Qubes
|
||||
from qubesadmin import exc
|
||||
from qubesadmin import utils
|
||||
|
||||
from PyQt4 import QtGui # pylint: disable=import-error
|
||||
from PyQt4 import QtCore # pylint: disable=import-error
|
||||
@ -685,21 +686,31 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
|
||||
|
||||
vm = self.get_selected_vm()
|
||||
|
||||
if vm.klass == 'TemplateVM':
|
||||
dependent_vms = 0
|
||||
for single_vm in self.qubes_app.domains:
|
||||
if getattr(single_vm, 'template', None) == vm:
|
||||
dependent_vms += 1
|
||||
if dependent_vms > 0:
|
||||
QtGui.QMessageBox.warning(
|
||||
None, self.tr("Warning!"),
|
||||
self.tr("This Template Qube cannot be removed, "
|
||||
"because there is at least one Qube that is based "
|
||||
"on it.<br><small>If you want to remove this "
|
||||
"Template Qube and all the Qubes based on it, you "
|
||||
"should first remove each individual Qube that "
|
||||
"uses this template.</small>"))
|
||||
return
|
||||
dependencies = utils.vm_usage(self.qubes_app, vm)
|
||||
|
||||
if dependencies:
|
||||
list_text = "<br>"
|
||||
for (holder, prop) in dependencies:
|
||||
if holder is None:
|
||||
list_text += "- Global property <b>{}</b> <br>".format(prop)
|
||||
else:
|
||||
list_text += "- <b>{}</b> for qube <b>{}</b> <br>".format(
|
||||
prop, holder.name)
|
||||
list_text += "<br>"
|
||||
|
||||
info_dialog = QtGui.QMessageBox(self)
|
||||
info_dialog.setWindowTitle(self.tr("Warning!"))
|
||||
info_dialog.setText(
|
||||
self.tr("This qube cannot be removed. It is used as:"
|
||||
" <br>" + list_text + "<small>If you want to "
|
||||
" remove this qube, you should remove or change "
|
||||
" settings of each qube or setting that uses"
|
||||
" it.</small>"))
|
||||
info_dialog.setModal(False)
|
||||
info_dialog.show()
|
||||
self.qt_app.processEvents()
|
||||
|
||||
return
|
||||
|
||||
(requested_name, ok) = QtGui.QInputDialog.getText(
|
||||
None, self.tr("Qube Removal Confirmation"),
|
||||
|
Loading…
Reference in New Issue
Block a user