def get_resource_ref_from_model(model):
    """
    Return a ResourceReference given db_model.

    :param model: DB model that contains name and pack.
    :type model: ``object``

    :return: ResourceReference.
    """
    try:
        name = model.name
        pack = model.pack
    except AttributeError:
        raise Exception(
            "Cannot build ResourceReference for model: %s. Name or pack missing."
            % model
        )
    return ResourceReference(name=name, pack=pack)

    Return a ResourceReference given db_model.

    :param model: DB model that contains name and pack.
    :type model: ``object``

    :return: ResourceReference.
    
st2common/st2common/util/reference.py