2015-12-29 20:35:04 +01:00
|
|
|
# pylint: disable=protected-access,pointless-statement
|
|
|
|
|
|
|
|
#
|
|
|
|
# The Qubes OS Project, https://www.qubes-os.org/
|
|
|
|
#
|
|
|
|
# Copyright (C) 2015 Joanna Rutkowska <joanna@invisiblethingslab.com>
|
|
|
|
# Copyright (C) 2015 Wojtek Porczyk <woju@invisiblethingslab.com>
|
|
|
|
#
|
2017-10-12 00:11:50 +02:00
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
2015-12-29 20:35:04 +01:00
|
|
|
#
|
2017-10-12 00:11:50 +02:00
|
|
|
# This library is distributed in the hope that it will be useful,
|
2015-12-29 20:35:04 +01:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2017-10-12 00:11:50 +02:00
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
2015-12-29 20:35:04 +01:00
|
|
|
#
|
2017-10-12 00:11:50 +02:00
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, see <https://www.gnu.org/licenses/>.
|
2015-12-29 20:35:04 +01:00
|
|
|
#
|
2017-07-17 12:28:24 +02:00
|
|
|
import jinja2
|
2015-12-29 20:35:04 +01:00
|
|
|
|
|
|
|
import qubes.tests
|
|
|
|
|
|
|
|
class TestVMM(object):
|
|
|
|
# pylint: disable=too-few-public-methods
|
|
|
|
def __init__(self, offline_mode=False):
|
|
|
|
self.offline_mode = offline_mode
|
2016-04-20 13:41:33 +02:00
|
|
|
@property
|
|
|
|
def libvirt_conn(self):
|
|
|
|
import libvirt
|
|
|
|
raise libvirt.libvirtError('phony error')
|
2015-12-29 20:35:04 +01:00
|
|
|
|
|
|
|
class TestHost(object):
|
|
|
|
# pylint: disable=too-few-public-methods
|
|
|
|
def __init__(self):
|
2016-02-10 18:15:16 +01:00
|
|
|
self.memory_total = 1000 * 1024
|
2016-02-10 17:41:05 +01:00
|
|
|
self.no_cpus = 4
|
2015-12-29 20:35:04 +01:00
|
|
|
|
|
|
|
class TestApp(qubes.tests.TestEmitter):
|
2016-02-10 17:41:05 +01:00
|
|
|
labels = {1: qubes.Label(1, '0xcc0000', 'red')}
|
|
|
|
check_updates_vm = False
|
|
|
|
|
2016-05-05 16:58:43 +02:00
|
|
|
def get_label(self, label):
|
|
|
|
# pylint: disable=unused-argument
|
2016-05-21 03:46:17 +02:00
|
|
|
if label in self.labels:
|
|
|
|
return self.labels[label]
|
|
|
|
for l in self.labels.values():
|
|
|
|
if l.name == label:
|
|
|
|
return l
|
|
|
|
raise KeyError(label)
|
2016-05-05 16:58:43 +02:00
|
|
|
|
2017-06-04 01:13:57 +02:00
|
|
|
def get_pool(self, pool):
|
|
|
|
return self.pools[pool]
|
|
|
|
|
2015-12-29 20:35:04 +01:00
|
|
|
def __init__(self):
|
|
|
|
super(TestApp, self).__init__()
|
|
|
|
self.vmm = TestVMM()
|
|
|
|
self.host = TestHost()
|
2016-06-02 13:35:52 +02:00
|
|
|
self.pools = {}
|
2017-07-25 05:23:17 +02:00
|
|
|
self.default_pool_volatile = 'default'
|
|
|
|
self.default_pool_root = 'default'
|
|
|
|
self.default_pool_private = 'default'
|
|
|
|
self.default_pool_kernel = 'linux-kernel'
|
2017-06-04 01:13:57 +02:00
|
|
|
self.domains = {}
|
2017-07-17 12:28:24 +02:00
|
|
|
#: jinja2 environment for libvirt XML templates
|
|
|
|
self.env = jinja2.Environment(
|
|
|
|
loader=jinja2.FileSystemLoader([
|
|
|
|
'templates',
|
|
|
|
'/etc/qubes/templates',
|
|
|
|
'/usr/share/qubes/templates',
|
|
|
|
]),
|
|
|
|
undefined=jinja2.StrictUndefined)
|