settings: add "dispvm_netvm" property in advanced tab

This commit is contained in:
Marek Marczykowski-Górecki 2015-04-06 00:59:15 +02:00
parent 4e5f63be24
commit dd93b1237f
2 changed files with 226 additions and 145 deletions

View File

@ -567,6 +567,36 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.drive_path.setText(drv_path)
self.drive_domain.setCurrentIndex(self.drive_domain_idx)
if not hasattr(self.vm, "dispvm_netvm"):
self.other_groupbox.setVisible(False)
else:
self.other_groupbox.setVisible(True)
netvm_list = [vm for vm in self.qvm_collection.values() if not vm.internal and vm.is_netvm() and vm.qid != 0]
self.dispvm_netvm_idx = -1
text = "default (same as VM own NetVM)"
if self.vm.uses_default_dispvm_netvm:
text += " (current)"
self.dispvm_netvm_idx = 0
self.dispvm_netvm.insertItem(0, text)
for (i, vm) in enumerate(netvm_list):
text = vm.name
if self.vm.dispvm_netvm is not None and vm.qid == \
self.vm.dispvm_netvm.qid and not \
self.vm.uses_default_dispvm_netvm:
self.dispvm_netvm_idx = i+1
text += " (current)"
self.dispvm_netvm.insertItem(i+1, text)
none_text = "none"
if self.vm.dispvm_netvm is None:
none_text += " (current)"
self.dispvm_netvm_idx = len(netvm_list)+1
self.dispvm_netvm.insertItem(len(netvm_list)+1, none_text)
self.dispvm_netvm.setCurrentIndex(self.dispvm_netvm_idx)
def __apply_advanced_tab__(self):
msg = []
@ -631,6 +661,35 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
except Exception as ex:
msg.append(str(ex))
#vm dispvm_netvm changed
try:
print self.dispvm_netvm.currentIndex()
if self.dispvm_netvm.currentIndex() != self.dispvm_netvm_idx:
new_dispvm_netvm_name = str(self.dispvm_netvm.currentText())
new_dispvm_netvm_name = new_dispvm_netvm_name.split(' ')[0]
uses_default_dispvm_netvm = False
if new_dispvm_netvm_name == "default":
uses_default_dispvm_netvm = True
if new_dispvm_netvm_name == "none":
dispvm_netvm = None
else:
dispvm_netvm = self.qvm_collection.get_vm_by_name(
new_dispvm_netvm_name)
assert (dispvm_netvm is None or (dispvm_netvm.qid in
self.qvm_collection and dispvm_netvm.is_netvm()))
if uses_default_dispvm_netvm:
self.vm.uses_default_dispvm_netvm = True
else:
self.vm.uses_default_dispvm_netvm = False
self.vm.dispvm_netvm = dispvm_netvm
self.anything_changed = True
except Exception as ex:
msg.append(str(ex))
return msg
def drive_path_button_pressed(self):

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>704</width>
<height>483</height>
<height>485</height>
</rect>
</property>
<property name="windowTitle">
@ -373,150 +373,6 @@
<string>Advanced</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="1" rowspan="2" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="kernel_groupbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Kernel</string>
</property>
<layout class="QFormLayout" name="formLayout_9">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Kernel:</string>
</property>
<property name="buddy">
<cstring>kernel</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="kernel"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Kernel opts:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="kernel_opts">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>[]</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="drive_groupbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Additional drive</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_18">
<item row="5" column="1">
<widget class="QLineEdit" name="drive_path"/>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="drive_domain"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_52">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="drive_type"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_53">
<property name="text">
<string>Backend domain:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_51">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QToolButton" name="drive_path_button">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="drive_running_warning">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 0, 0);</string>
</property>
<property name="text">
<string>New drive will be used only at next VM startup</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="enabled">
@ -782,6 +638,172 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="other_groupbox">
<property name="title">
<string>Other</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>NetVM for DispVM:</string>
</property>
<property name="buddy">
<cstring>dispvm_netvm</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="dispvm_netvm"/>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" rowspan="3" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="kernel_groupbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Kernel</string>
</property>
<layout class="QFormLayout" name="formLayout_9">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Kernel:</string>
</property>
<property name="buddy">
<cstring>kernel</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="kernel"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Kernel opts:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="kernel_opts">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>[]</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="drive_groupbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Additional drive</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_18">
<item row="5" column="1">
<widget class="QLineEdit" name="drive_path"/>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="drive_domain"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_52">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="drive_type"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_53">
<property name="text">
<string>Backend domain:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_51">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QToolButton" name="drive_path_button">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="drive_running_warning">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 0, 0);</string>
</property>
<property name="text">
<string>New drive will be used only at next VM startup</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="firewall_tab">