Added proper error handling and Check netvm_name is not None
This commit is contained in:
parent
f90ab86a73
commit
0cb89e611a
@ -820,8 +820,20 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
|
||||
QMessageBox.Yes | QMessageBox.Cancel)
|
||||
|
||||
if reply == QMessageBox.Yes:
|
||||
failed = []
|
||||
for info in selected_vms:
|
||||
info.vm.template = template
|
||||
try:
|
||||
info.vm.template = template
|
||||
except:
|
||||
failed.append(info.name)
|
||||
|
||||
if failed:
|
||||
info_dialog = QMessageBox(self)
|
||||
info_dialog.setWindowTitle(self.tr("Warning!"))
|
||||
info_dialog.setText(
|
||||
self.tr("Some template change failed: {0} "
|
||||
).format(", ".join(failed)))
|
||||
info_dialog.show()
|
||||
|
||||
def change_network(self, netvm_name):
|
||||
selected_vms = self.get_selected_vms()
|
||||
@ -836,25 +848,39 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
|
||||
return
|
||||
|
||||
try:
|
||||
check_power = any(info.state['power'] == 'Running' for info
|
||||
in self.get_selected_vms())
|
||||
netvm = self.qubes_cache.get_vm(name=netvm_name)
|
||||
if check_power and netvm.state['power'] != 'Running':
|
||||
reply = QMessageBox.question(
|
||||
self, self.tr("Qube Start Confirmation"),
|
||||
self.tr("<br>Can not change netvm to a halted Qube.<br>"
|
||||
"Do you want to start the Qube <b>'{0}'</b>?").format(
|
||||
netvm_name),
|
||||
QMessageBox.Yes | QMessageBox.Cancel)
|
||||
if netvm_name is not None:
|
||||
check_power = any(info.state['power'] == 'Running' for info
|
||||
in self.get_selected_vms())
|
||||
netvm = self.qubes_cache.get_vm(name=netvm_name)
|
||||
if check_power and netvm.state['power'] != 'Running':
|
||||
reply = QMessageBox.question(
|
||||
self, self.tr("Qube Start Confirmation"),
|
||||
self.tr("<br>Can not change netvm to a halted Qube.<br>"
|
||||
"Do you want to start the Qube <b>'{0}'</b>?").format(
|
||||
netvm_name),
|
||||
QMessageBox.Yes | QMessageBox.Cancel)
|
||||
|
||||
if reply == QMessageBox.Yes:
|
||||
with common_threads.busy_cursor():
|
||||
netvm.vm.start()
|
||||
else:
|
||||
return
|
||||
if reply == QMessageBox.Yes:
|
||||
with common_threads.busy_cursor():
|
||||
netvm.vm.start()
|
||||
else:
|
||||
return
|
||||
|
||||
failed = []
|
||||
for info in self.get_selected_vms():
|
||||
info.vm.netvm = netvm_name
|
||||
try:
|
||||
info.vm.netvm = netvm_name
|
||||
except:
|
||||
failed.append(info.name)
|
||||
|
||||
if failed:
|
||||
info_dialog = QMessageBox(self)
|
||||
info_dialog.setWindowTitle(self.tr("Warning!"))
|
||||
info_dialog.setText(
|
||||
self.tr("Some network change failed: {0} "
|
||||
).format(", ".join(failed)))
|
||||
info_dialog.show()
|
||||
|
||||
except exc.QubesValueError as ex:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
|
Loading…
Reference in New Issue
Block a user