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 Qubes
|
||||||
from qubesadmin import exc
|
from qubesadmin import exc
|
||||||
|
from qubesadmin import utils
|
||||||
|
|
||||||
from PyQt4 import QtGui # pylint: disable=import-error
|
from PyQt4 import QtGui # pylint: disable=import-error
|
||||||
from PyQt4 import QtCore # 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()
|
vm = self.get_selected_vm()
|
||||||
|
|
||||||
if vm.klass == 'TemplateVM':
|
dependencies = utils.vm_usage(self.qubes_app, vm)
|
||||||
dependent_vms = 0
|
|
||||||
for single_vm in self.qubes_app.domains:
|
if dependencies:
|
||||||
if getattr(single_vm, 'template', None) == vm:
|
list_text = "<br>"
|
||||||
dependent_vms += 1
|
for (holder, prop) in dependencies:
|
||||||
if dependent_vms > 0:
|
if holder is None:
|
||||||
QtGui.QMessageBox.warning(
|
list_text += "- Global property <b>{}</b> <br>".format(prop)
|
||||||
None, self.tr("Warning!"),
|
else:
|
||||||
self.tr("This Template Qube cannot be removed, "
|
list_text += "- <b>{}</b> for qube <b>{}</b> <br>".format(
|
||||||
"because there is at least one Qube that is based "
|
prop, holder.name)
|
||||||
"on it.<br><small>If you want to remove this "
|
list_text += "<br>"
|
||||||
"Template Qube and all the Qubes based on it, you "
|
|
||||||
"should first remove each individual Qube that "
|
info_dialog = QtGui.QMessageBox(self)
|
||||||
"uses this template.</small>"))
|
info_dialog.setWindowTitle(self.tr("Warning!"))
|
||||||
return
|
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(
|
(requested_name, ok) = QtGui.QInputDialog.getText(
|
||||||
None, self.tr("Qube Removal Confirmation"),
|
None, self.tr("Qube Removal Confirmation"),
|
||||||
|
Loading…
Reference in New Issue
Block a user