Exemple #1
0
    def _do_update_board(self, board_id, values):
        session = get_session()
        with session.begin():
            query = model_query(models.Board, session=session)
            query = add_identity_filter(query, board_id)
            try:
                ref = query.with_lockmode('update').one()
            except NoResultFound:
                raise exception.BoardNotFound(board=board_id)

            ref.update(values)
        return ref
Exemple #2
0
    def destroy_board(self, board_id):
        session = get_session()
        with session.begin():
            query = model_query(models.Board, session=session)
            query = add_identity_filter(query, board_id)
            try:
                board_ref = query.one()
            except NoResultFound:
                raise exception.BoardNotFound(board=board_id)

            # Get board ID, if an UUID was supplied. The ID is
            # required for deleting all ports, attached to the board.
            if uuidutils.is_uuid_like(board_id):
                board_id = board_ref['id']

            location_query = model_query(models.Location, session=session)
            location_query = self._add_location_filter_by_board(
                location_query, board_id)
            location_query.delete()

            query.delete()
Exemple #3
0
def get_rpc_board(board_ident):
    """Get the RPC board from the board uuid or logical name.

    :param board_ident: the UUID or logical name of a board.

    :returns: The RPC Board.
    :raises: InvalidUuidOrName if the name or uuid provided is not valid.
    :raises: BoardNotFound if the board is not found.
    """
    # Check to see if the board_ident is a valid UUID.  If it is, treat it
    # as a UUID.
    if uuidutils.is_uuid_like(board_ident):
        return objects.Board.get_by_uuid(pecan.request.context, board_ident)

    # We can refer to boards by their name, if the client supports it
    # if allow_board_logical_names():
    #    if utils.is_hostname_safe(board_ident):
    else:
        return objects.Board.get_by_name(pecan.request.context, board_ident)

    raise exception.InvalidUuidOrName(name=board_ident)

    raise exception.BoardNotFound(board=board_ident)
Exemple #4
0
 def get_board_by_code(self, board_code):
     query = model_query(models.Board).filter_by(code=board_code)
     try:
         return query.one()
     except NoResultFound:
         raise exception.BoardNotFound(board=board_code)
Exemple #5
0
 def get_board_id_by_uuid(self, board_uuid):
     query = model_query(models.Board.id).filter_by(uuid=board_uuid)
     try:
         return query.one()
     except NoResultFound:
         raise exception.BoardNotFound(board=board_uuid)