Exemplo n.º 1
0
def find_server_byaddress(db_session, address, raise_exc=True):
    """
    Find a server by name
    """
    query = db_session.query(ServerSM)\
            .filter(ServerSM.address == address)
    try:
        server_sm = query.one()
    except NoResultFound:
        server_sm = None
    if raise_exc and not server_sm:
        raise NoServerFoundByAddress(address)
    return server_sm
Exemplo n.º 2
0
def find_server_byname(db_session, server_name, raise_exc=True):
    """
    Find a server by name
    """
    query = db_session.query(ServerSM)\
            .filter(ServerSM.name == server_name)
    try:
        server_sm = query.one()
    except NoResultFound:
        server_sm = None
    if raise_exc and not server_sm:
        raise NoServerFound(server_name)
    return server_sm