Fix VM creation with default template

Fixes QubesOS/qubes-issues#2866
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-06 14:17:15 +02:00
parent 9036103102
commit e6149b09ce
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 14 additions and 1 deletions

View File

@ -248,7 +248,9 @@ class QubesBase(qubesadmin.base.PropertyHolder):
if not isinstance(cls, str):
cls = cls.__name__
if template is not None:
if template is qubesadmin.DEFAULT:
template = None
elif template is not None:
template = str(template)
if pool and pools:

View File

@ -148,6 +148,17 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase):
self.assertEqual(vm.__class__.__name__, 'AppVM')
self.assertAllCalled()
def test_016_new_template_based_default(self):
self.app.expected_calls[('dom0', 'admin.vm.Create.AppVM',
None, b'name=new-vm label=red')] = b'0\x00'
self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \
b'0\x00new-vm class=AppVM state=Running\n'
vm = self.app.add_new_vm('AppVM', 'new-vm', 'red',
template=qubesadmin.DEFAULT)
self.assertEqual(vm.name, 'new-vm')
self.assertEqual(vm.__class__.__name__, 'AppVM')
self.assertAllCalled()
def test_020_get_label(self):
self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \
b'0\x00red\nblue\n'