Skip to content

Commit

Permalink
Merge pull request #55739 from asomers/sysctl_n
Browse files Browse the repository at this point in the history
Microoptimize the command to set FreeBSD's virtual grain
  • Loading branch information
dwoz authored Dec 28, 2019
2 parents 5f9b611 + 334c872 commit 4e862c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,17 +1016,17 @@ def _virtual(osdata):
if maker.startswith('Bochs'):
grains['virtual'] = 'kvm'
if sysctl:
hv_vendor = __salt__['cmd.run']('{0} hw.hv_vendor'.format(sysctl))
model = __salt__['cmd.run']('{0} hw.model'.format(sysctl))
hv_vendor = __salt__['cmd.run']('{0} -n hw.hv_vendor'.format(sysctl))
model = __salt__['cmd.run']('{0} -n hw.model'.format(sysctl))
jail = __salt__['cmd.run'](
'{0} -n security.jail.jailed'.format(sysctl)
)
if 'bhyve' in hv_vendor:
grains['virtual'] = 'bhyve'
elif 'QEMU Virtual CPU' in model:
grains['virtual'] = 'kvm'
if jail == '1':
grains['virtual_subtype'] = 'jail'
if 'QEMU Virtual CPU' in model:
grains['virtual'] = 'kvm'
elif osdata['kernel'] == 'OpenBSD':
if 'manufacturer' in osdata:
if osdata['manufacturer'] in ['QEMU', 'Red Hat', 'Joyent']:
Expand Down

0 comments on commit 4e862c4

Please sign in to comment.