006QubesAdminVm.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/usr/bin/python2
  2. # -*- coding: utf-8 -*-
  3. #
  4. # The Qubes OS Project, http://www.qubes-os.org
  5. #
  6. # Copyright (C) 2010 Joanna Rutkowska <joanna@invisiblethingslab.com>
  7. # Copyright (C) 2013 Marek Marczykowski <marmarek@invisiblethingslab.com>
  8. #
  9. # This program is free software; you can redistribute it and/or
  10. # modify it under the terms of the GNU General Public License
  11. # as published by the Free Software Foundation; either version 2
  12. # of the License, or (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. #
  23. #
  24. from qubes.qubes import QubesNetVm,register_qubes_vm_class
  25. from qubes.qubes import defaults
  26. from qubes.qubes import QubesException,dry_run,vmm
  27. import psutil
  28. class QubesAdminVm(QubesNetVm):
  29. # In which order load this VM type from qubes.xml
  30. load_order = 10
  31. def __init__(self, **kwargs):
  32. super(QubesAdminVm, self).__init__(qid=0, name="dom0", netid=0,
  33. dir_path=None,
  34. private_img = None,
  35. template = None,
  36. maxmem = 0,
  37. vcpus = 0,
  38. label = defaults["template_label"],
  39. **kwargs)
  40. @property
  41. def xid(self):
  42. return 0
  43. @property
  44. def libvirt_domain(self):
  45. return None
  46. @property
  47. def type(self):
  48. return "AdminVM"
  49. def is_running(self):
  50. return True
  51. def get_power_state(self):
  52. return "Running"
  53. def get_mem(self):
  54. return psutil.virtual_memory().total/1024
  55. def get_mem_static_max(self):
  56. return vmm.libvirt_conn.getInfo()[1]
  57. def get_disk_usage(self, file_or_dir):
  58. return 0
  59. def get_disk_utilization(self):
  60. return 0
  61. def get_disk_utilization_private_img(self):
  62. return 0
  63. def get_private_img_sz(self):
  64. return 0
  65. @property
  66. def ip(self):
  67. return "10.137.0.2"
  68. def start(self, **kwargs):
  69. raise QubesException ("Cannot start Dom0 fake domain!")
  70. def suspend(self):
  71. return
  72. def create_xml_element(self):
  73. return None
  74. def verify_files(self):
  75. return True
  76. register_qubes_vm_class(QubesAdminVm)