mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Fix value of virtual
grain when using virt-what
`virt-what` might return multiple lines, depending on what it detected (e.g. `lxc` inside a `HyperV` VM), where the last line corresponds to the most likely match. Until now, Salt evaluated the whole multi-line output as a single string, which caused quite inaccurate matches. This commit changes this behavior to only evaluate the last line of the `virt-what` output. A similar issue is described in #25697, but might actually have a different root cause.
This commit is contained in:
parent
f7f8cb533f
commit
4b5421a0f5
@ -781,6 +781,7 @@ def _virtual(osdata):
|
|||||||
grains['virtual'] = 'LXC'
|
grains['virtual'] = 'LXC'
|
||||||
break
|
break
|
||||||
elif command == 'virt-what':
|
elif command == 'virt-what':
|
||||||
|
output = output.splitlines()[-1]
|
||||||
if output in ('kvm', 'qemu', 'uml', 'xen', 'lxc'):
|
if output in ('kvm', 'qemu', 'uml', 'xen', 'lxc'):
|
||||||
grains['virtual'] = output
|
grains['virtual'] = output
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user