Added bootfromdevice dialog to create_new_vm (instead subprocess.call)
This commit is contained in:
parent
70ea6e2591
commit
cbae4f5868
@ -28,13 +28,14 @@ from qubesadmin import exc
|
|||||||
|
|
||||||
class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
|
class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
|
||||||
QtWidgets.QDialog):
|
QtWidgets.QDialog):
|
||||||
def __init__(self, vm, qapp, qubesapp=None, parent=None):
|
def __init__(self, vm, qapp, qubesapp=None, parent=None, new_vm = False):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
self.qapp = qapp
|
self.qapp = qapp
|
||||||
self.qubesapp = qubesapp
|
self.qubesapp = qubesapp
|
||||||
self.cdrom_location = None
|
self.cdrom_location = None
|
||||||
|
self.new_vm = new_vm
|
||||||
|
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.setWindowTitle(
|
self.setWindowTitle(
|
||||||
@ -69,6 +70,9 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
|
|||||||
self.accept()
|
self.accept()
|
||||||
|
|
||||||
def __warn_if_running__(self):
|
def __warn_if_running__(self):
|
||||||
|
if self.new_vm:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.qubesapp.domains[self.vm].is_running():
|
if self.qubesapp.domains[self.vm].is_running():
|
||||||
QtWidgets.QMessageBox.warning(
|
QtWidgets.QMessageBox.warning(
|
||||||
|
@ -32,6 +32,7 @@ import qubesadmin.tools
|
|||||||
import qubesadmin.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
|
from . import bootfromdevice
|
||||||
|
|
||||||
from .ui_newappvmdlg import Ui_NewVMDlg # pylint: disable=import-error
|
from .ui_newappvmdlg import Ui_NewVMDlg # pylint: disable=import-error
|
||||||
|
|
||||||
@ -102,6 +103,7 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
|
|||||||
|
|
||||||
self.thread = None
|
self.thread = None
|
||||||
self.progress = None
|
self.progress = None
|
||||||
|
self.boot_dialog = None
|
||||||
|
|
||||||
utils.initialize_widget_with_labels(
|
utils.initialize_widget_with_labels(
|
||||||
widget=self.label,
|
widget=self.label,
|
||||||
@ -175,9 +177,14 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
|
|||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
vmclass = self.vm_type.currentData()
|
vmclass = self.vm_type.currentData()
|
||||||
|
|
||||||
name = str(self.name.text())
|
name = str(self.name.text())
|
||||||
|
|
||||||
|
if self.install_system.isChecked():
|
||||||
|
self.boot_dialog = bootfromdevice.VMBootFromDeviceWindow(
|
||||||
|
name, self.qtapp, self.app, self, True)
|
||||||
|
if not self.boot_dialog.exec_():
|
||||||
|
return
|
||||||
|
|
||||||
if name in self.app.domains:
|
if name in self.app.domains:
|
||||||
QtWidgets.QMessageBox.warning(
|
QtWidgets.QMessageBox.warning(
|
||||||
self,
|
self,
|
||||||
@ -227,6 +234,7 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
|
|||||||
|
|
||||||
def create_finished(self):
|
def create_finished(self):
|
||||||
self.progress.hide()
|
self.progress.hide()
|
||||||
|
self.done(0)
|
||||||
|
|
||||||
if self.thread.msg:
|
if self.thread.msg:
|
||||||
QtWidgets.QMessageBox.warning(
|
QtWidgets.QMessageBox.warning(
|
||||||
@ -234,15 +242,15 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
|
|||||||
self.tr("Error creating the qube!"),
|
self.tr("Error creating the qube!"),
|
||||||
self.tr("ERROR: {0}").format(self.thread.msg))
|
self.tr("ERROR: {0}").format(self.thread.msg))
|
||||||
|
|
||||||
self.done(0)
|
else:
|
||||||
|
|
||||||
if not self.thread.msg:
|
|
||||||
if self.launch_settings.isChecked():
|
if self.launch_settings.isChecked():
|
||||||
subprocess.check_call(['qubes-vm-settings',
|
subprocess.check_call(['qubes-vm-settings',
|
||||||
str(self.name.text())])
|
str(self.name.text())])
|
||||||
if self.install_system.isChecked():
|
if self.install_system.isChecked():
|
||||||
subprocess.check_call(
|
qubesadmin.tools.qvm_start.main(
|
||||||
['qubes-vm-boot-from-device', str(self.name.text())])
|
['--cdrom', self.boot_dialog.cdrom_location,
|
||||||
|
self.name.text()])
|
||||||
|
|
||||||
|
|
||||||
def type_change(self):
|
def type_change(self):
|
||||||
template = self.template_vm.currentData()
|
template = self.template_vm.currentData()
|
||||||
|
Loading…
Reference in New Issue
Block a user