docs: def image_vacuum(name):
      '''
      Delete images not in use or installed via image_present
  
      .. warning::
  
          Only image_present states that are included via the
          top file will be detected.
      '''
      name = name.lower()
      ret = {'name': name,
             'changes': {},
             'result': None,
             'comment': ''}
  
      # list of images to keep
      images = []
  
      # retrieve image_present state data for host
      for state in __salt__['state.show_lowstate']():
          # don't throw exceptions when not highstate run
          if 'state' not in state:
              continue
  
          # skip if not from this state module
          if state['state'] != __virtualname__:
              continue
          # skip if not image_present
          if state['fun'] not in ['image_present']:
              continue
          # keep images installed via image_present
          if 'name' in state:
              if _is_uuid(state['name']):
                  images.append(state['name'])
              elif _is_docker_uuid(state['name']):
                  state['name'] = __salt__['imgadm.docker_to_uuid'](state['name'])
                  if not state['name']:
                      continue
                  images.append(state['name'])
  
      # retrieve images in use by vms
      for image_uuid in __salt__['vmadm.list'](order='image_uuid'):
          if image_uuid not in images:
              images.append(image_uuid)
  
      # purge unused images
      ret['result'] = True
      for image_uuid in __salt__['imgadm.list']():
          if image_uuid in images:
              continue
  
          image = __salt__['imgadm.get'](image_uuid)
          if image['manifest']['name'] == 'docker-layer':
              # NOTE: docker images are made of multiple layers, loop over them
              while image:
                  image_uuid = image['manifest']['uuid']
                  if image_uuid in __salt__['imgadm.delete'](image_uuid):
                      ret['changes'][image_uuid] = None
                  else:
                      ret['result'] = False
                      ret['comment'] = 'failed to delete images'
                  if 'origin' in image['manifest']:
                      image = __salt__['imgadm.get'](image['manifest']['origin'])
                  else:
                      image = None
          else:
              # NOTE: normal images can just be delete
              if image_uuid in __salt__['imgadm.delete'](image_uuid):
                  ret['changes'][image_uuid] = None
              else:
                  ret['result'] = False
                  ret['comment'] = 'failed to delete images'
  
      if ret['result'] and not ret['changes']:
          ret['comment'] = 'no images deleted'
      elif ret['result'] and ret['changes']:
          ret['comment'] = 'images deleted'
  
      return ret