Skip to content

Commit

Permalink
Avoid VBOX storage emulation bugs in FreeBSD disks grain
Browse files Browse the repository at this point in the history
  • Loading branch information
kev009 committed Aug 11, 2015
1 parent 41b7604 commit 2a24f8b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions salt/grains/disks.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,32 @@ class _camconsts(object):
_camconsts.__dict__ if not key.startswith('__')]


def _freebsd_vbox():
# Don't tickle VirtualBox storage emulation bugs
camcontrol = salt.utils.which('camcontrol')
devlist = __salt__['cmd.run']('{0} devlist'.format(camcontrol))
if 'VBOX' in devlist:
return True
return False


def _freebsd_disks():
ret = {'disks': {}, 'SSDs': []}
sysctl = salt.utils.which('sysctl')
devices = __salt__['cmd.run']('{0} -n kern.disks'.format(sysctl))
SSD_TOKEN = 'non-rotating'

for device in devices.split(' '):
cam = _freebsd_camcontrol(device)
ret['disks'][device] = cam
if cam.get(_clean_keys(_camconsts.MEDIA_RPM)) == SSD_TOKEN:
ret['SSDs'].append(device)
if device.startswith('cd'):
log.debug('Disk grain skipping cd')
elif _freebsd_vbox():
log.debug('Disk grain skipping CAM identify/inquirty on VBOX')
ret['disks'][device] = {}
else:
cam = _freebsd_camcontrol(device)
ret['disks'][device] = cam
if cam.get(_clean_keys(_camconsts.MEDIA_RPM)) == SSD_TOKEN:
ret['SSDs'].append(device)

return ret

Expand Down

0 comments on commit 2a24f8b

Please sign in to comment.