]> git.ipfire.org Git - oddments/fireinfo.git/blame - fireinfo/hypervisor.py
Add detection of bios vendor.
[oddments/fireinfo.git] / fireinfo / hypervisor.py
CommitLineData
715ba5ac
MT
1#!/usr/bin/python
2
3import _fireinfo
4
5class Hypervisor(object):
6 def __init__(self):
7 self.__info = _fireinfo.get_hypervisor()
8
9 @property
10 def vendor(self):
11 """
12 Returns the name of the hypervisor vendor.
13 """
14 if not self.virtual:
15 return None
16
17 # If the script already returned a hypervisor, we return the name.
18 if self.__info["hypervisor"]:
19 return self.__info["hypervisor"]
20
21 # XXX fill in some code to detect hypervisors, that do
22 # not say their name.
23
24 return "unknown"
25
26 @property
27 def type(self):
28 """
29 Returns if the host is running in full virt mode or
30 if it is running in a paravirtualized environment.
31 """
32 if not self.virtual:
33 return None
34
35 return self.__info["virtype"]
36
37 @property
38 def virtual(self):
39 """
40 Returns true if the host is running in a virtual environment.
41 Otherwise: false.
42 """
43 return _fireinfo.is_virtualized()
44
45
46if __name__ == "__main__":
47 h = Hypervisor()
48
49 print "Vendor:", h.vendor
50 print "Type:", h.type
51 print "Virtual:", h.virtual