def _lookup_nexus_bindings(query_type, session=None, **bfilter):
if session is None:<EOL><INDENT>session = bc.get_reader_session()<EOL><DEDENT>query_method = getattr(session.query(<EOL>nexus_models_v2.NexusPortBinding).filter_by(**bfilter), query_type)<EOL>try:<EOL><INDENT>bindings = query_method()<EOL>if bindings:<EOL><INDENT>return bindings<EOL><DEDENT><DEDENT>except sa_exc.NoResultFound:<EOL><INDENT>pass<EOL><DEDENT>raise c_exc.NexusPortBindingNotFound(**bfilter)<EOL>
Look up 'query_type' Nexus bindings matching the filter.

    :param query_type: 'all', 'one' or 'first'
    :param session: db session
    :param bfilter: filter for bindings query
    :returns: bindings if query gave a result, else
             raise NexusPortBindingNotFound.