qvm_pause.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # encoding=utf-8
  2. #
  3. # The Qubes OS Project, https://www.qubes-os.org/
  4. #
  5. # Copyright (C) 2010-2015 Joanna Rutkowska <joanna@invisiblethingslab.com>
  6. # Copyright (C) 2015 Wojtek Porczyk <woju@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. '''qvm-pause - Pause a domain'''
  21. import sys
  22. import qubesadmin
  23. parser = qubesadmin.tools.QubesArgumentParser(vmname_nargs='+',
  24. description='pause a domain')
  25. def main(args=None, app=None):
  26. '''Main routine of :program:`qvm-pause`.
  27. :param list args: Optional arguments to override those delivered from \
  28. command line.
  29. '''
  30. args = parser.parse_args(args, app=app)
  31. exit_code = 0
  32. for domain in args.domains:
  33. try:
  34. domain.pause()
  35. except (IOError, OSError, qubesadmin.exc.QubesException) as e:
  36. exit_code = 1
  37. parser.print_error(str(e))
  38. return exit_code
  39. if __name__ == '__main__':
  40. sys.exit(main())