Updated Clone VM tool to use new better helper functions

This commit is contained in:
Marta Marczykowska-Górecka 2020-07-30 22:52:05 +02:00
parent bdc11582f1
commit 8461a307f2
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
2 changed files with 23 additions and 29 deletions

3
debian/install vendored
View File

@ -7,6 +7,7 @@
/usr/bin/qubes-qube-manager /usr/bin/qubes-qube-manager
/usr/bin/qubes-log-viewer /usr/bin/qubes-log-viewer
/usr/bin/qubes-template-manager /usr/bin/qubes-template-manager
/usr/bin/qubes-vm-clone
/usr/libexec/qubes-manager/mount_for_backup.sh /usr/libexec/qubes-manager/mount_for_backup.sh
/usr/libexec/qubes-manager/qvm_about.sh /usr/libexec/qubes-manager/qvm_about.sh
/usr/libexec/qubes-manager/dsa-4371-update /usr/libexec/qubes-manager/dsa-4371-update
@ -33,6 +34,7 @@
/usr/lib/*/dist-packages/qubesmanager/bootfromdevice.py /usr/lib/*/dist-packages/qubesmanager/bootfromdevice.py
/usr/lib/*/dist-packages/qubesmanager/device_list.py /usr/lib/*/dist-packages/qubesmanager/device_list.py
/usr/lib/*/dist-packages/qubesmanager/template_manager.py /usr/lib/*/dist-packages/qubesmanager/template_manager.py
/usr/lib/*/dist-packages/qubesmanager/clone_vm.py
/usr/lib/*/dist-packages/qubesmanager/resources_rc.py /usr/lib/*/dist-packages/qubesmanager/resources_rc.py
@ -51,6 +53,7 @@
/usr/lib/*/dist-packages/qubesmanager/ui_qubemanager.py /usr/lib/*/dist-packages/qubesmanager/ui_qubemanager.py
/usr/lib/*/dist-packages/qubesmanager/ui_devicelist.py /usr/lib/*/dist-packages/qubesmanager/ui_devicelist.py
/usr/lib/*/dist-packages/qubesmanager/ui_templatemanager.py /usr/lib/*/dist-packages/qubesmanager/ui_templatemanager.py
/usr/lib/*/dist-packages/qubesmanager/ui_clonevmdlg.py
/usr/lib/*/dist-packages/qubesmanager/i18n/qubesmanager_*.qm /usr/lib/*/dist-packages/qubesmanager/i18n/qubesmanager_*.qm
/usr/lib/*/dist-packages/qubesmanager/i18n/qubesmanager_*.ts /usr/lib/*/dist-packages/qubesmanager/i18n/qubesmanager_*.ts

View File

@ -47,35 +47,25 @@ class CloneVMDlg(QtWidgets.QDialog, Ui_CloneVMDlg):
self.thread = None self.thread = None
self.progress = None self.progress = None
self.vm_list, self.vm_idx = utils.prepare_vm_choice( utils.initialize_widget_with_vms(
self.src_vm, widget=self.src_vm,
self.app, None, qubes_app=self.app,
None, filter_function=(lambda vm: vm.klass != 'AdminVM'))
(lambda vm: vm.klass != 'AdminVM'),
allow_internal=False
)
if src_vm and self.src_vm.findText(src_vm.name) > -1: if src_vm and self.src_vm.findText(src_vm.name) > -1:
self.src_vm.setCurrentIndex(self.src_vm.findText(src_vm.name)) self.src_vm.setCurrentIndex(self.src_vm.findText(src_vm.name))
self.label_list, self.label_idx = utils.prepare_label_choice( utils.initialize_widget_with_labels(widget=self.label,
self.label, qubes_app=self.app)
self.app, None,
None,
allow_default=False
)
self.update_label() self.update_label()
self.pool_list, self.pool_idx = utils.prepare_choice( utils.initialize_widget_with_default(
widget=self.storage_pool, widget=self.storage_pool,
holder=None, choices=[(str(pool), pool) for pool in self.app.pools.values()],
propname=None, add_qubes_default=True,
choice=self.app.pools.values(), mark_existing_as_default=True,
default=self.app.default_pool, default_value=self.app.default_pool)
allow_default=True,
allow_none=False
)
self.set_clone_name() self.set_clone_name()
@ -104,15 +94,13 @@ class CloneVMDlg(QtWidgets.QDialog, Ui_CloneVMDlg):
'system!').format(self.name.text())) 'system!').format(self.name.text()))
return return
label = self.label_list[self.label.currentIndex()] label = self.label.currentData()
if self.pool_list[self.storage_pool.currentIndex()] is not \ pool = self.storage_pool.currentData()
qubesadmin.DEFAULT: if pool is qubesadmin.DEFAULT:
pool = self.pool_list[self.storage_pool.currentIndex()]
else:
pool = None pool = None
src_vm = self.vm_list[self.src_vm.currentIndex()] src_vm = self.src_vm.currentData()
self.thread = common_threads.CloneVMThread( self.thread = common_threads.CloneVMThread(
src_vm, name, pool=pool, label=label) src_vm, name, pool=pool, label=label)
@ -134,14 +122,13 @@ class CloneVMDlg(QtWidgets.QDialog, Ui_CloneVMDlg):
self.name.setText(name_format % name_number) self.name.setText(name_format % name_number)
def update_label(self): def update_label(self):
vm_label = self.vm_list[self.src_vm.currentIndex()].label vm_label = self.src_vm.currentData().label
label_idx = self.label.findText(str(vm_label)) label_idx = self.label.findText(str(vm_label))
if label_idx > -1: if label_idx > -1:
self.label.setCurrentIndex(label_idx) self.label.setCurrentIndex(label_idx)
def clone_finished(self): def clone_finished(self):
self.progress.hide() self.progress.hide()
@ -150,6 +137,10 @@ class CloneVMDlg(QtWidgets.QDialog, Ui_CloneVMDlg):
self, self,
self.tr("Error cloning the qube!"), self.tr("Error cloning the qube!"),
self.tr("ERROR: {0}").format(self.thread.msg)) self.tr("ERROR: {0}").format(self.thread.msg))
else:
QtWidgets.QMessageBox.information(
self,
*self.thread.msg)
self.done(0) self.done(0)