Ensure image is absent on the computenode

    name : string
        uuid of image

    .. note::

        computenode.image_absent will only remove the image if it is not used
        by a vm.

def image_absent(name):
    '''
    Ensure image is absent on the computenode

    name : string
        uuid of image

    .. note::

        computenode.image_absent will only remove the image if it is not used
        by a vm.
    '''
    ret = {'name': name,
           'changes': {},
           'result': None,
           'comment': ''}

    uuid = None
    if _is_uuid(name):
        uuid = name
    if _is_docker_uuid(name):
        uuid = __salt__['imgadm.docker_to_uuid'](name)

    if not uuid or uuid not in __salt__['imgadm.list']():
        # image not imported
        ret['result'] = True
        ret['comment'] = 'image {0} is absent'.format(name)
    else:
        # check if image in use by vm
        if uuid in __salt__['vmadm.list'](order='image_uuid'):
            ret['result'] = False
            ret['comment'] = 'image {0} currently in use by a vm'.format(name)
        else:
            # delete image
            if __opts__['test']:
                ret['result'] = True
            else:
                image = __salt__['imgadm.get'](uuid)
                image_count = 0
                if image['manifest']['name'] == 'docker-layer':
                    # NOTE: docker images are made of multiple layers, loop over them
                    while image:
                        image_count += 1
                        __salt__['imgadm.delete'](image['manifest']['uuid'])
                        if 'origin' in image['manifest']:
                            image = __salt__['imgadm.get'](image['manifest']['origin'])
                        else:
                            image = None
                else:
                    # NOTE: normal images can just be delete
                    __salt__['imgadm.delete'](uuid)

            ret['result'] = uuid not in __salt__['imgadm.list']()
            if image_count:
                ret['comment'] = 'image {0} and {1} children deleted'.format(name, image_count)
            else:
                ret['comment'] = 'image {0} deleted'.format(name)
            ret['changes'][name] = None

    return ret