templatevm.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/python2 -O
  2. # vim: fileencoding=utf-8
  3. import qubes
  4. import qubes.config
  5. import qubes.vm.qubesvm
  6. class TemplateVM(qubes.vm.qubesvm.QubesVM):
  7. '''Template for AppVM'''
  8. dir_path_prefix = qubes.config.system_path['qubes_templates_dir']
  9. @property
  10. def rootcow_img(self):
  11. '''COW image'''
  12. return self.storage.rootcow_img
  13. def __init__(self, *args, **kwargs):
  14. super(TemplateVM, self).__init__(*args, **kwargs)
  15. # Some additional checks for template based VM
  16. # TODO find better way
  17. # assert self.root_img is not None, "Missing root_img for standalone VM!"
  18. def clone_disk_files(self, src):
  19. super(TemplateVM, self).clone_disk_files(src)
  20. # Create root-cow.img
  21. self.commit_changes()
  22. def commit_changes(self):
  23. '''Commit changes to template'''
  24. self.log.debug('commit_changes()')
  25. if not self.app.vmm.offline_mode:
  26. assert not self.is_running(), \
  27. 'Attempt to commit changes on running Template VM!'
  28. self.log.info(
  29. 'Commiting template update; COW: {}'.format(self.rootcow_img))
  30. self.storage.commit_template_changes()