mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add hypervisor detection to the virt module
This commit is contained in:
parent
f0a2788309
commit
29cd89d919
1 changed files with 20 additions and 0 deletions
|
@ -207,3 +207,23 @@ def undefine(vm_):
|
|||
dom.undefine()
|
||||
return True
|
||||
|
||||
def virt_type():
|
||||
'''
|
||||
Returns the virtual machine type as a string
|
||||
|
||||
CLI Example:
|
||||
salt '*' virt.virt_type
|
||||
'''
|
||||
return __facter__['virtual']
|
||||
|
||||
def is_kvm_hyper():
|
||||
'''
|
||||
Returns a bool whether or not this node is a hypervisor
|
||||
'''
|
||||
if __facter__['virtual'] != 'physical':
|
||||
return False
|
||||
if subprocess.call('lsmod | grep kvm_', shell=True):
|
||||
return False
|
||||
if subprocess.call('ps aux | grep libvirtd | grep -v grep', shell=True):
|
||||
return False
|
||||
return True
|
||||
|
|
Loading…
Add table
Reference in a new issue