__init__.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # -*- encoding: utf8 -*-
  2. #
  3. # The Qubes OS Project, http://www.qubes-os.org
  4. #
  5. # Copyright (C) 2017 Marek Marczykowski-Górecki
  6. # <marmarek@invisiblethingslab.com>
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU Lesser General Public License as published by
  10. # the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Lesser General Public License along
  19. # with this program; if not, see <http://www.gnu.org/licenses/>.
  20. '''Qubes backup'''
  21. import collections
  22. class BackupApp(object):
  23. '''Interface for backup collection'''
  24. # pylint: disable=too-few-public-methods
  25. def __init__(self, qubes_xml):
  26. '''Initialize BackupApp object and load qubes.xml into it'''
  27. self.store = qubes_xml
  28. self.domains = {}
  29. self.globals = {}
  30. self.load()
  31. def load(self):
  32. '''Load qubes.xml'''
  33. raise NotImplementedError
  34. class BackupVM(object):
  35. '''Interface for a single VM in the backup'''
  36. # pylint: disable=too-few-public-methods
  37. def __init__(self):
  38. '''Initialize empty BackupVM object'''
  39. #: VM class
  40. self.klass = 'AppVM'
  41. #: VM name
  42. self.name = None
  43. #: VM template
  44. self.template = None
  45. #: VM label
  46. self.label = None
  47. #: VM properties
  48. self.properties = {}
  49. #: VM features (key/value), aka services in core2
  50. self.features = {}
  51. #: VM tags
  52. self.tags = set()
  53. #: VM devices - dict with key=devtype, value=dict of devices (
  54. # key=ident, value=options)
  55. self.devices = collections.defaultdict(dict)
  56. #: VM path in the backup
  57. self.backup_path = None
  58. #: size of the VM
  59. self.size = 0
  60. @property
  61. def included_in_backup(self):
  62. '''Report whether a VM is included in the backup'''
  63. return False
  64. def handle_firewall_xml(self, vm, stream):
  65. '''Import appropriate format of firewall.xml'''
  66. raise NotImplementedError