reset_vm_configs.py 715 B

123456789101112131415161718192021222324
  1. #!/usr/bin/python2.6
  2. from qubes.qubes import QubesVmCollection
  3. import sys
  4. def main():
  5. if len(sys.argv) != 2:
  6. print 'Usage: fixconf templatename'
  7. sys.exit(1)
  8. qvm_collection = QubesVmCollection()
  9. qvm_collection.lock_db_for_reading()
  10. qvm_collection.load()
  11. qvm_collection.unlock_db()
  12. templ = sys.argv[1]
  13. tvm = qvm_collection.get_vm_by_name(templ)
  14. if tvm is None:
  15. print 'Template', templ, 'does not exist'
  16. sys.exit(1)
  17. if not tvm.is_templete():
  18. print templ, 'is not a template'
  19. sys.exit(1)
  20. for vm in qvm_collection.values():
  21. if vm.is_appvm() and vm.template_vm.qid == tvm.qid:
  22. vm.create_config_file()
  23. main()