def present(name):
    ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}

    vhost_exists = __salt__['rabbitmq.vhost_exists'](name)

    if vhost_exists:
        ret['comment'] = 'Virtual Host \'{0}\' already exists.'.format(name)
        return ret

    if not __opts__['test']:
        result = __salt__['rabbitmq.add_vhost'](name)
        if 'Error' in result:
            ret['result'] = False
            ret['comment'] = result['Error']
            return ret
        elif 'Added' in result:
            ret['comment'] = result['Added']

    # If we've reached this far before returning, we have changes.
    ret['changes'] = {'old': '', 'new': name}

    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = 'Virtual Host \'{0}\' will be created.'.format(name)

    return ret
Ensure the RabbitMQ VHost exists.
dataset/ETHPy150Open saltstack/salt/salt/states/rabbitmq_vhost.py/present