~landscape/landscape-client/trunk

« back to all changes in this revision

Viewing changes to landscape/lib/vm_info.py

  • Committer: Landscape Builder
  • Author(s): Alberto Donato
  • Date: 2016-09-30 00:22:51 UTC
  • mfrom: (921.1.2 fix-xen-dom0-container-info)
  • Revision ID: landscape_builder-20160930002251-n8rjvba95o01sdir
Merge fix-xen-dom0-container-info [f=1601818] [r=danilo,landscape-builder,tealeg] [a=Alberto Donato]
Fix VM detection for Xen, by returning "xen" only for paravirtualized and HVM hosts, not for dom0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
    It loops through some possible configurations and return a string with
15
15
    the name of the technology being used or None if there's no match
16
16
    """
17
 
    def join_root_path(path):
18
 
        return os.path.join(root_path, path)
19
 
 
20
17
    if _is_vm_openvz(root_path):
21
18
        return "openvz"
22
19
    if _is_vm_xen(root_path):
43
40
 
44
41
def _is_vm_xen(root_path):
45
42
    """Check if the host is virtualized with Xen."""
46
 
    xen_paths = [
47
 
        os.path.join(root_path, path)
48
 
        for path in ("proc/sys/xen", "proc/xen")]
49
 
 
50
 
    if filter(os.path.exists, xen_paths):
51
 
        return True
52
 
 
53
 
    # /sys/bus/xen exists on most machines, but only virtual machines have
54
 
    # devices
55
43
    sys_xen_path = os.path.join(root_path, "sys/bus/xen/devices")
 
44
    # Paravirtualized and HVM instances have device links under the directory
56
45
    return os.path.isdir(sys_xen_path) and os.listdir(sys_xen_path)
57
46
 
58
47