Added default option for network change

This commit is contained in:
donoban 2021-01-09 00:42:47 +01:00
parent 3bd7c218e5
commit 9f44f7413d
No known key found for this signature in database
GPG Key ID: 141310D8E3ED08A5

View File

@ -843,7 +843,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
if reply != QMessageBox.Yes:
return
if netvm_name is not None:
if netvm_name not in [None, 'default']:
check_power = any(info.state['power'] == 'Running' for info
in self.get_selected_vms())
netvm = self.qubes_cache.get_vm(name=netvm_name)
@ -863,6 +863,9 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
errors = []
for info in self.get_selected_vms():
try:
if netvm_name == 'default':
delattr(info.vm, 'netvm')
else:
info.vm.netvm = netvm_name
except exc.QubesValueError as ex:
errors.append((info.name, str(ex)))
@ -945,10 +948,19 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
action.setData(vm.name)
action.triggered.connect(partial(self.change_template, vm.name))
def _get_default_netvm(self):
for vm in self.qubes_app.domains:
if vm.klass == 'AppVM':
return vm.property_get_default('netvm')
def init_network_menu(self):
default = self._get_default_netvm().name
self.network_menu.clear()
action = self.network_menu.addAction("None")
action.triggered.connect(partial(self.change_network, None))
action = self.network_menu.addAction("default ({0})".format(default))
action.triggered.connect(partial(self.change_network, 'default'))
for vm in self.qubes_app.domains:
if vm.qid != 0 and vm.provides_network:
action = self.network_menu.addAction(vm.name)