Add "HVM Template" VM type to create VM dialog (#758)

This commit is contained in:
Marek Marczykowski-Górecki 2014-03-06 01:46:45 +01:00
parent 95c3f822ab
commit 538b358df0
2 changed files with 44 additions and 16 deletions

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>500</width> <width>496</width>
<height>200</height> <height>215</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -98,9 +98,17 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="3" column="3">
<widget class="QRadioButton" name="hvmtpl_radio">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>HVM template</string>
</property>
</widget>
</item> </item>
<item> <item row="3" column="0">
<widget class="QCheckBox" name="allow_networking"> <widget class="QCheckBox" name="allow_networking">
<property name="text"> <property name="text">
<string>Allow networking</string> <string>Allow networking</string>
@ -110,6 +118,8 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item> <item>
<widget class="QFrame" name="hvmtemplatewarningbox"> <widget class="QFrame" name="hvmtemplatewarningbox">
<property name="frameShape"> <property name="frameShape">
@ -127,7 +137,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>482</width> <width>482</width>
<height>30</height> <height>51</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">

View File

@ -59,6 +59,7 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
pass pass
else: else:
self.hvm_radio.setEnabled(True) self.hvm_radio.setEnabled(True)
self.hvmtpl_radio.setEnabled(True)
self.qvm_collection.lock_db_for_reading() self.qvm_collection.lock_db_for_reading()
self.qvm_collection.load() self.qvm_collection.load()
@ -86,6 +87,8 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
return False return False
if self.hvm_radio.isChecked(): if self.hvm_radio.isChecked():
return QubesHVm.is_template_compatible(vm) return QubesHVm.is_template_compatible(vm)
elif self.hvmtpl_radio.isChecked():
return False
else: else:
return QubesVm.is_template_compatible(vm) return QubesVm.is_template_compatible(vm)
self.template_vm_list = filter(filter_template, self.qvm_collection.values()) self.template_vm_list = filter(filter_template, self.qvm_collection.values())
@ -108,19 +111,28 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
if checked: if checked:
self.template_name.setEnabled(True) self.template_name.setEnabled(True)
self.allow_networking.setEnabled(False) self.allow_networking.setEnabled(False)
def on_proxyvm_radio_toggled(self, checked): def on_proxyvm_radio_toggled(self, checked):
if checked: if checked:
self.template_name.setEnabled(True) self.template_name.setEnabled(True)
self.allow_networking.setEnabled(True) self.allow_networking.setEnabled(True)
def on_hvm_radio_toggled(self, checked): def on_hvm_radio_toggled(self, checked):
if checked: if self.hvm_radio.isChecked() or self.hvmtpl_radio.isChecked():
self.standalone.setChecked(True) self.standalone.setChecked(True)
self.allow_networking.setEnabled(True) self.allow_networking.setEnabled(True)
self.standalone.setEnabled(self.hvm_radio.isChecked())
else: else:
self.standalone.setChecked(False) self.standalone.setChecked(False)
self.standalone.setEnabled(True)
self.fill_template_list() self.fill_template_list()
def on_hvmtpl_radio_toggled(self, checked):
return self.on_hvm_radio_toggled(checked)
def on_standalone_toggled(self, checked): def on_standalone_toggled(self, checked):
if checked and self.hvm_radio.isChecked(): if checked and (self.hvm_radio.isChecked() or
self.hvmtpl_radio.isChecked()):
self.template_name.setEnabled(False) self.template_name.setEnabled(False)
else: else:
self.template_name.setEnabled(True) self.template_name.setEnabled(True)
@ -157,8 +169,14 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
vmtype = "NetVM" vmtype = "NetVM"
elif self.proxyvm_radio.isChecked(): elif self.proxyvm_radio.isChecked():
vmtype = "ProxyVM" vmtype = "ProxyVM"
else: #hvm_radio.isChecked() elif self.hvm_radio.isChecked():
vmtype = "HVM" vmtype = "HVM"
elif self.hvmtpl_radio.isChecked():
vmtype = "TemplateHVM"
else:
QErrorMessage.showMessage(None, "Error creating AppVM!", "Unknown "
"VM type, this is error in Qubes Manager")
self.done(0)
vmclass = "Qubes" + vmtype.replace("VM", "Vm") vmclass = "Qubes" + vmtype.replace("VM", "Vm")