Added an Advanced tab to Create New Qube dialog

Tab contains a warning, provides_network checkbox,
install_system_after_creation checkbox, storage pool settings
and initial RAM.

references QubesOS/qubes-issues#5127
fixes QubeSOS/qubes-issues#5198
This commit is contained in:
Marta Marczykowska-Górecka 2019-09-06 15:59:13 +02:00
parent 1ced452976
commit d85940c5a5
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
2 changed files with 264 additions and 128 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# The Qubes OS Project, http://www.qubes-os.org
#
@ -37,7 +37,8 @@ from .ui_newappvmdlg import Ui_NewVMDlg # pylint: disable=import-error
# pylint: disable=too-few-public-methods
class CreateVMThread(QtCore.QThread):
def __init__(self, app, vmclass, name, label, template, properties):
def __init__(self, app, vmclass, name, label, template, properties,
pool):
QtCore.QThread.__init__(self)
self.app = app
self.vmclass = vmclass
@ -45,6 +46,7 @@ class CreateVMThread(QtCore.QThread):
self.label = label
self.template = template
self.properties = properties
self.pool = pool
self.msg = None
def run(self):
@ -54,15 +56,29 @@ class CreateVMThread(QtCore.QThread):
src_vm = self.app.default_template
else:
src_vm = self.template
vm = self.app.clone_vm(src_vm, self.name, self.vmclass,
ignore_volumes=['private'])
args = {
'ignore_volumes': ['private']
}
if self.pool:
args['pool'] = self.pool
vm = self.app.clone_vm(src_vm, self.name, self.vmclass, **args)
vm.label = self.label
for k, v in self.properties.items():
setattr(vm, k, v)
else:
vm = self.app.add_new_vm(
self.vmclass, name=self.name,
label=self.label, template=self.template)
args = {
"name": self.name,
"label": self.label,
"template": self.template
}
if self.pool:
args['pool'] = self.pool
vm = self.app.add_new_vm(self.vmclass, **args)
for k, v in self.properties.items():
setattr(vm, k, v)
@ -107,6 +123,16 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
(lambda vm: vm.provides_network),
allow_internal=False, allow_default=True, allow_none=True)
self.pool_list, self.pool_idx = utils.prepare_choice(
widget=self.storage_pool,
holder=None,
propname=None,
choice=self.app.pools.values(),
default=self.app.default_pool,
allow_default=True,
allow_none=False
)
self.name.setValidator(QtGui.QRegExpValidator(
QtCore.QRegExp("[a-zA-Z0-9_-]*", QtCore.Qt.CaseInsensitive), None))
self.name.selectAll()
@ -163,8 +189,17 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
properties['virt_mode'] = 'hvm'
properties['kernel'] = None
if self.pool_list[self.storage_pool.currentIndex()] is not \
qubesadmin.DEFAULT:
pool = self.pool_list[self.storage_pool.currentIndex()]
else:
pool = None
if self.init_ram.value() > 0:
properties['memory'] = self.init_ram.value()
self.thread = CreateVMThread(
self.app, vmclass, name, label, template, properties)
self.app, vmclass, name, label, template, properties, pool)
self.thread.finished.connect(self.create_finished)
self.thread.start()

View File

@ -15,128 +15,231 @@
</property>
<property name="windowIcon">
<iconset theme="qubes-manager">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>450</x>
<y>260</y>
<width>160</width>
<height>27</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>10</y>
<width>611</width>
<height>241</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="template_label">
<property name="text">
<string>Template:</string>
</property>
<property name="buddy">
<cstring>template_vm</cstring>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabWidgetPage1">
<attribute name="title">
<string>Basic</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<property name="horizontalSpacing">
<number>12</number>
</property>
<property name="verticalSpacing">
<number>9</number>
</property>
<item row="6" column="0">
<widget class="QLabel" name="netvm_label">
<property name="text">
<string>Networking:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="vm_type"/>
</item>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="template_vm"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="template_label">
<property name="text">
<string>Template:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="name_label">
<property name="text">
<string>Name and label:</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="name">
<property name="text">
<string>my-new-qube</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="label">
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="QCheckBox" name="launch_settings">
<property name="text">
<string>launch settings after creation</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="3">
<widget class="QComboBox" name="netvm"/>
</item>
<item row="8" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="netvm_label">
<property name="text">
<string>Networking:</string>
</property>
<property name="buddy">
<cstring>template_vm</cstring>
</property>
</widget>
</item>
<item row="9" column="1" colspan="3">
<widget class="QCheckBox" name="install_system">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>install system from device (also available from settings)</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="3">
<widget class="QCheckBox" name="launch_settings">
<property name="text">
<string>launch settings after creation</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="template_vm"/>
</item>
<item row="7" column="1" colspan="3">
<widget class="QCheckBox" name="provides_network">
<property name="text">
<string>provides network</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="name_label">
<property name="text">
<string>Name and label:</string>
</property>
<property name="buddy">
<cstring>name</cstring>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="label">
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Advanced</string>
</property>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<property name="horizontalSpacing">
<number>12</number>
</property>
<property name="verticalSpacing">
<number>9</number>
</property>
<item row="4" column="1">
<widget class="QSpinBox" name="init_ram">
<property name="specialValueText">
<string>(default)</string>
</property>
<property name="suffix">
<string> MB</string>
</property>
<property name="maximum">
<number>90000000</number>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Caution&lt;/span&gt;: changing these settings can compromise your system or make the qube unable to boot. Use only if you know what you are doing.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="storage_pool">
<property name="currentText">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Storage pool</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Initial RAM (also available from settings)</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="install_system">
<property name="text">
<string>install system from device (also available from settings)</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="provides_network">
<property name="text">
<string>provides network to other qubes</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="6" column="1" colspan="3">
<widget class="QComboBox" name="netvm"/>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="name">
<property name="text">
<string>my-new-qube</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="vm_type"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>name</tabstop>
@ -144,9 +247,7 @@
<tabstop>vm_type</tabstop>
<tabstop>template_vm</tabstop>
<tabstop>netvm</tabstop>
<tabstop>provides_network</tabstop>
<tabstop>launch_settings</tabstop>
<tabstop>install_system</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>