def image_vacuum(name):
 name = name.lower()
 ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''}
 images = []
 for state in __salt__['state.show_lowstate']():
  if ('state' not in state):
   continue
  if (state['state'] != __virtualname__):
   continue
  if (state['fun'] not in ['image_present']):
   continue
  if ('name' in state):
   images.append(state['name'])
 for image_uuid in __salt__['vmadm.list'](order='image_uuid'):
  if (image_uuid in images):
   continue
  images.append(image_uuid)
 ret['result'] = True
 for image_uuid in __salt__['imgadm.list']():
  if (image_uuid in images):
   continue
  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 (len(ret['changes']) == 0)):
  ret['comment'] = 'no images deleted'
 elif (ret['result'] and (len(ret['changes']) > 0)):
  ret['comment'] = 'images deleted'
 return ret

def image_vacuum ( name ) : name = name . lower ( ) ret = { 'name' : name , 'changes' : { } , 'result' : None , 'comment' : '' } images = [ ] for state in __salt__ [ 'state.show_lowstate' ] ( ) : if ( 'state' not in state ) : continue if ( state [ 'state' ] != __virtualname__ ) : continue if ( state [ 'fun' ] not in [ 'image_present' ] ) : continue if ( 'name' in state ) : images . append ( state [ 'name' ] ) for image_uuid in __salt__ [ 'vmadm.list' ] ( order = 'image_uuid' ) : if ( image_uuid in images ) : continue images . append ( image_uuid ) ret [ 'result' ] = True for image_uuid in __salt__ [ 'imgadm.list' ] ( ) : if ( image_uuid in images ) : continue 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 ( len ( ret [ 'changes' ] ) == 0 ) ) : ret [ 'comment' ] = 'no images deleted' elif ( ret [ 'result' ] and ( len ( ret [ 'changes' ] ) > 0 ) ) : ret [ 'comment' ] = 'images deleted' return ret
delete images not in use or installed via image_present .