# Buggy code
def present(name, user=None, owner=None, conf=None, write=None, read=None, runas=None):
    """
    Ensure the RabbitMQ VHost exists.

    name
        VHost name
    user
        Initial user permission to set on the VHost, if present
        .. deprecated:: 0.17.0
    owner
        Initial owner permission to set on the VHost, if present
    conf
        Initial conf string to apply to the VHost and user. Defaults to .*
    write
        Initial write permissions to apply to the VHost and user.
        Defaults to .*
    read
        Initial read permissions to apply to the VHost and user.
        Defaults to .*
    runas
        Name of the user to run the command
    """
    ret = {"name": name, "result": True, "comment": "", "changes": {}}

    salt.utils.warn_until(
        (0, 18),
        "Please start deprecating 'runas' at this stage. Ping s0undt3ch for "
        "additional information or see #6961.",
        _dont_call_warnings=True,
    )
    if user:
        # Warn users about the deprecation
        ret.setdefault("warnings", []).append(
            "The 'user' argument is being deprecated in favor or 'owner', "
            "please update your state files."
        )
    if user is not None and owner is not None:
        # owner wins over user but let warn about the deprecation.
        ret.setdefault("warnings", []).append(
            "Passed both the 'owner' and 'user' arguments. Please don't. "
            "'user' is being ignored in favor of 'owner'."
        )
        user = None
    elif user is not None:
        # Support old runas usage
        owner = user
        user = None

    vhost_exists = __salt__["rabbitmq.vhost_exists"](name, runas=runas)

    if __opts__["test"]:
        ret["result"] = None
        if vhost_exists:
            ret["comment"] = "VHost {0} already exists".format(name)
        else:
            ret["comment"] = "Creating VHost {0}".format(name)

        if user is not None:
            ret["comment"] += " Setting permissions for {0} {1} {2} {3}".format(
                owner, conf or ".*", write or ".*", read or ".*"
            )
    elif not vhost_exists:
        result = __salt__["rabbitmq.add_vhost"](name, runas=runas)
        if "Error" in result:
            ret["result"] = False
            ret["comment"] = result["Error"]
        elif "Added" in result:
            ret["comment"] = result["Added"]
    else:
        ret["comment"] = "VHost {0} already exists".format(name)

    if owner is not None:
        conf = conf or ".*"
        write = write or ".*"
        read = read or ".*"
        result = __salt__["rabbitmq.set_permissions"](
            name, owner, conf, write, read, runas=runas
        )

        if "Error" in result:
            ret["result"] = False
            ret["comment"] = result["Error"]
        elif "Permissions Set":
            ret["comment"] += " {0}".format(result["Permissions Set"])

    return ret


# Traceback (AttributeError)
[ERROR   ] Error in function _master_opts:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/salt/master.py", line 1444, in run_func
ret = getattr(self, func)(load)
File "/usr/lib/pymodules/python2.7/salt/master.py", line 891, in _master_opts
envs = self._file_envs()
File "/usr/lib/pymodules/python2.7/salt/fileserver/__init__.py", line 153, in envs
ret.update(self.servers[fstr]())
File "/usr/lib/pymodules/python2.7/salt/fileserver/hgfs.py", line 176, in envs
tags = repo.get_tags()
AttributeError: 'hgclient' object has no attribute 'get_tags'

# Fixed code
def present(name, user=None, owner=None, conf=None, write=None, read=None, runas=None):
    """
    Ensure the RabbitMQ VHost exists.

    name
        VHost name
    user
        Initial user permission to set on the VHost, if present
        .. deprecated:: 0.17.0
    owner
        Initial owner permission to set on the VHost, if present
    conf
        Initial conf string to apply to the VHost and user. Defaults to .*
    write
        Initial write permissions to apply to the VHost and user.
        Defaults to .*
    read
        Initial read permissions to apply to the VHost and user.
        Defaults to .*
    runas
        Name of the user to run the command
    """
    ret = {"name": name, "result": True, "comment": "", "changes": {}}

    salt.utils.warn_until(
        "Hydrogen",
        "Please start deprecating 'runas' at this stage. Ping s0undt3ch for "
        "additional information or see #6961.",
        _dont_call_warnings=True,
    )
    if user:
        # Warn users about the deprecation
        ret.setdefault("warnings", []).append(
            "The 'user' argument is being deprecated in favor or 'owner', "
            "please update your state files."
        )
    if user is not None and owner is not None:
        # owner wins over user but let warn about the deprecation.
        ret.setdefault("warnings", []).append(
            "Passed both the 'owner' and 'user' arguments. Please don't. "
            "'user' is being ignored in favor of 'owner'."
        )
        user = None
    elif user is not None:
        # Support old runas usage
        owner = user
        user = None

    vhost_exists = __salt__["rabbitmq.vhost_exists"](name, runas=runas)

    if __opts__["test"]:
        ret["result"] = None
        if vhost_exists:
            ret["comment"] = "VHost {0} already exists".format(name)
        else:
            ret["comment"] = "Creating VHost {0}".format(name)

        if user is not None:
            ret["comment"] += " Setting permissions for {0} {1} {2} {3}".format(
                owner, conf or ".*", write or ".*", read or ".*"
            )
    elif not vhost_exists:
        result = __salt__["rabbitmq.add_vhost"](name, runas=runas)
        if "Error" in result:
            ret["result"] = False
            ret["comment"] = result["Error"]
        elif "Added" in result:
            ret["comment"] = result["Added"]
    else:
        ret["comment"] = "VHost {0} already exists".format(name)

    if owner is not None:
        conf = conf or ".*"
        write = write or ".*"
        read = read or ".*"
        result = __salt__["rabbitmq.set_permissions"](
            name, owner, conf, write, read, runas=runas
        )

        if "Error" in result:
            ret["result"] = False
            ret["comment"] = result["Error"]
        elif "Permissions Set":
            ret["comment"] += " {0}".format(result["Permissions Set"])

    return ret