__init__.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # pylint: disable=protected-access,pointless-statement
  2. #
  3. # The Qubes OS Project, https://www.qubes-os.org/
  4. #
  5. # Copyright (C) 2015 Joanna Rutkowska <joanna@invisiblethingslab.com>
  6. # Copyright (C) 2015 Wojtek Porczyk <woju@invisiblethingslab.com>
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License along
  19. # with this program; if not, write to the Free Software Foundation, Inc.,
  20. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. #
  22. import jinja2
  23. import qubes.tests
  24. class TestVMM(object):
  25. # pylint: disable=too-few-public-methods
  26. def __init__(self, offline_mode=False):
  27. self.offline_mode = offline_mode
  28. @property
  29. def libvirt_conn(self):
  30. import libvirt
  31. raise libvirt.libvirtError('phony error')
  32. class TestHost(object):
  33. # pylint: disable=too-few-public-methods
  34. def __init__(self):
  35. self.memory_total = 1000 * 1024
  36. self.no_cpus = 4
  37. class TestApp(qubes.tests.TestEmitter):
  38. labels = {1: qubes.Label(1, '0xcc0000', 'red')}
  39. check_updates_vm = False
  40. def get_label(self, label):
  41. # pylint: disable=unused-argument
  42. if label in self.labels:
  43. return self.labels[label]
  44. for l in self.labels.values():
  45. if l.name == label:
  46. return l
  47. raise KeyError(label)
  48. def get_pool(self, pool):
  49. return self.pools[pool]
  50. def __init__(self):
  51. super(TestApp, self).__init__()
  52. self.vmm = TestVMM()
  53. self.host = TestHost()
  54. self.pools = {}
  55. self.default_pool_volatile = 'default'
  56. self.default_pool_root = 'default'
  57. self.default_pool_private = 'default'
  58. self.default_pool_kernel = 'linux-kernel'
  59. self.domains = {}
  60. #: jinja2 environment for libvirt XML templates
  61. self.env = jinja2.Environment(
  62. loader=jinja2.FileSystemLoader([
  63. 'templates',
  64. '/etc/qubes/templates',
  65. '/usr/share/qubes/templates',
  66. ]),
  67. undefined=jinja2.StrictUndefined)