templatevm.py 1.1 KB

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