add XEN support to virt.py

This commit is contained in:
David Bishop 2012-03-06 01:32:33 -05:00
parent 7ad3728290
commit 09860b447c

View File

@ -501,7 +501,7 @@ def virt_type():
def is_kvm_hyper():
'''
Returns a bool whether or not this node is a hypervisor
Returns a bool whether or not this node is a KVM hypervisor
CLI Example::
@ -512,3 +512,27 @@ def is_kvm_hyper():
if 'kvm_' not in open('/proc/modules').read():
return False
return 'libvirtd' in __salt__['cmd.run'](__grains__['ps'])
def is_xen_hyper():
'''
Returns a bool whether or not this node is a XEN hypervisor
CLI Example::
salt '*' virt.is_xen_hyper
'''
if __grains__['virtual_subtype'] != 'Xen Dom0':
return False
if 'xen_' not in open('/proc/modules').read():
return False
return 'libvirtd' in __salt__['cmd.run'](__grains__['ps'])
def is_hyper():
'''
Returns a bool whether or not this nos is a hypervisor of any kind
CLI Example::
salt '*' virt.is_hyper
'''
return is_xen_hyper() or is_kvm_hyper()