2013-03-16 02:39:30 +01:00
|
|
|
#!/usr/bin/python2
|
2014-05-18 21:01:21 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-03-16 02:39:30 +01:00
|
|
|
#
|
|
|
|
# The Qubes OS Project, http://www.qubes-os.org
|
|
|
|
#
|
|
|
|
# Copyright (C) 2010 Joanna Rutkowska <joanna@invisiblethingslab.com>
|
|
|
|
# Copyright (C) 2013 Marek Marczykowski <marmarek@invisiblethingslab.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2013-05-04 04:45:55 +02:00
|
|
|
from qubes.qubes import QubesNetVm,register_qubes_vm_class
|
2013-03-16 02:39:30 +01:00
|
|
|
from qubes.qubes import defaults
|
2013-05-17 04:06:29 +02:00
|
|
|
from qubes.qubes import QubesException,dry_run,vmm
|
2013-05-10 05:39:46 +02:00
|
|
|
import psutil
|
2013-03-16 02:39:30 +01:00
|
|
|
|
2013-11-29 03:42:56 +01:00
|
|
|
class QubesAdminVm(QubesNetVm):
|
2013-11-24 23:50:39 +01:00
|
|
|
|
|
|
|
# In which order load this VM type from qubes.xml
|
|
|
|
load_order = 10
|
|
|
|
|
2013-03-16 02:39:30 +01:00
|
|
|
def __init__(self, **kwargs):
|
2013-11-29 03:42:56 +01:00
|
|
|
super(QubesAdminVm, self).__init__(qid=0, name="dom0", netid=0,
|
2013-03-16 02:39:30 +01:00
|
|
|
dir_path=None,
|
|
|
|
private_img = None,
|
|
|
|
template = None,
|
|
|
|
label = defaults["template_label"],
|
|
|
|
**kwargs)
|
2013-05-10 05:35:22 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def xid(self):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
@property
|
|
|
|
def libvirt_domain(self):
|
|
|
|
return None
|
2013-03-16 02:39:30 +01:00
|
|
|
|
2013-11-24 23:50:39 +01:00
|
|
|
@property
|
|
|
|
def type(self):
|
2013-11-29 03:42:56 +01:00
|
|
|
return "AdminVM"
|
2013-11-24 23:50:39 +01:00
|
|
|
|
2013-03-16 02:39:30 +01:00
|
|
|
def is_running(self):
|
|
|
|
return True
|
|
|
|
|
|
|
|
def get_power_state(self):
|
|
|
|
return "Running"
|
|
|
|
|
2013-05-10 05:39:46 +02:00
|
|
|
def get_mem(self):
|
|
|
|
return psutil.virtual_memory().total/1024
|
|
|
|
|
|
|
|
def get_mem_static_max(self):
|
2013-05-17 04:06:29 +02:00
|
|
|
return vmm.libvirt_conn.getInfo()[1]
|
2013-05-10 05:39:46 +02:00
|
|
|
|
|
|
|
def get_disk_usage(self, file_or_dir):
|
|
|
|
return 0
|
|
|
|
|
2013-03-16 02:39:30 +01:00
|
|
|
def get_disk_utilization(self):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def get_disk_utilization_private_img(self):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def get_private_img_sz(self):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
@property
|
|
|
|
def ip(self):
|
|
|
|
return "10.137.0.2"
|
|
|
|
|
|
|
|
def start(self, **kwargs):
|
|
|
|
raise QubesException ("Cannot start Dom0 fake domain!")
|
|
|
|
|
2013-10-23 21:56:50 +02:00
|
|
|
def suspend(self):
|
|
|
|
return
|
|
|
|
|
2013-05-04 04:45:55 +02:00
|
|
|
def create_xml_element(self):
|
2013-03-16 02:39:30 +01:00
|
|
|
return None
|
|
|
|
|
|
|
|
def verify_files(self):
|
|
|
|
return True
|
|
|
|
|
2013-11-29 03:42:56 +01:00
|
|
|
register_qubes_vm_class(QubesAdminVm)
|