def update_board(self, board_id, values): # NOTE(dtantsur): this can lead to very strange errors if 'uuid' in values: msg = _("Cannot overwrite UUID for an existing Board.") raise exception.InvalidParameterValue(err=msg) try: return self._do_update_board(board_id, values) except db_exc.DBDuplicateEntry as e: if 'name' in e.columns: raise exception.DuplicateName(name=values['name']) elif 'uuid' in e.columns: raise exception.BoardAlreadyExists(uuid=values['uuid']) else: raise e
def create_node(self, values): # ensure defaults are present for new nodes if 'uuid' not in values: values['uuid'] = uuidutils.generate_uuid() if 'status' not in values: values['status'] = states.OPERATIVE node = models.Node() node.update(values) try: node.save() except db_exc.DBDuplicateEntry as exc: if 'code' in exc.columns: raise exception.DuplicateCode(code=values['code']) raise exception.BoardAlreadyExists(uuid=values['uuid']) return node
def create_board(self, values): # ensure defaults are present for new boards if 'uuid' not in values: values['uuid'] = uuidutils.generate_uuid() if 'status' not in values: values['status'] = states.REGISTERED board = models.Board() board.update(values) try: board.save() except db_exc.DBDuplicateEntry as exc: if 'code' in exc.columns: raise exception.DuplicateCode(code=values['code']) raise exception.BoardAlreadyExists(uuid=values['uuid']) return board