qvm_remove.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env python2
  2. # -*- encoding: utf8 -*-
  3. #
  4. # The Qubes OS Project, http://www.qubes-os.org
  5. #
  6. # Copyright (C) 2016 Bahtiar `kalkin-` Gadimov <bahtiar@gadimov.de>
  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. ''' Remove domains from the system '''
  23. from __future__ import print_function
  24. import sys
  25. from qubes.tools import QubesArgumentParser
  26. parser = QubesArgumentParser(description=__doc__,
  27. want_app=True,
  28. want_force_root=True,
  29. vmname_nargs='+')
  30. parser.add_argument('--just-db',
  31. action='store_true',
  32. help='Remove only from db, don\'t remove files')
  33. def main(args=None): # pylint: disable=missing-docstring
  34. args = parser.parse_args(args)
  35. for vm in args.domains:
  36. del args.app.domains[vm.qid]
  37. args.app.save()
  38. if not args.just_db:
  39. vm.remove_from_disk()
  40. return 0
  41. if __name__ == '__main__':
  42. sys.exit(main())