예제 #1
0
def operator_health(name):
    try:
        op = search_operator(name)
        if not op:
            raise NotExistError("operator %s not exist" % name, "")
        return health(op)
    except Exception as e:
        logger.error(e)
        return e
예제 #2
0
def operator_detail(name):
    try:
        op = search_operator(name)
        if not op:
            raise NotExistError("operator %s not exist" % name, "")
        return new_operator(name=op.name, backend=op.backend,
                            type=op.type,
                            input=op.input,
                            output=op.output,
                            endpoint=op.endpoint,
                            dimension=op.dimension,
                            metric_type=op.metric_type)
    except Exception as e:
        logger.error(e)
        raise e
예제 #3
0
def operator_detail(name):
    try:
        op = search_operator(name)
        if not op:
            raise NotExistError("operator %s not exist" % name, "")
        return new_operator(name=op.name,
                            type=op.type,
                            addr=op.addr,
                            author=op.author,
                            version=op.version,
                            description=op.description)

    except Exception as e:
        logger.error(e)
        raise e
예제 #4
0
def all_operators():
    res = []
    try:
        operators = search_operator()
        for x in operators:
            res.append(new_operator(name=x.Operator.name,
                                    type=x.Operator.type,
                                    addr=x.Operator.addr,
                                    author=x.Operator.author,
                                    version=x.Operator.version,
                                    description=x.Operator.description))
        return res
    except Exception as e:
        logger.error(e)
        raise e
예제 #5
0
def all_operators():
    res = []
    try:
        operators = search_operator()
        for x in operators:
            res.append(new_operator(name=x.Operator.name,
                                    backend=x.Operator.backend,
                                    type=x.Operator.type,
                                    input=x.Operator.input,
                                    output=x.Operator.output,
                                    endpoint=x.Operator.endpoint,
                                    dimension=x.Operator.dimension,
                                    metric_type=x.Operator.metric_type))
    except Exception as e:
        logger.error(e)
        return e
    return res
예제 #6
0
def register_operators(**args):
    op = DB(name=args['name'],
            type=args['type'],
            addr=args['addr'],
            author=args['author'],
            version=args['version'],
            description=args['description'])
    try:
        if search_operator(args['name']):
            raise ExistError(f"operator {args['name']} had exist", "")
        insert_operator(op)
        return new_operator(name=args['name'],
                            type=args['type'],
                            addr=args['addr'],
                            author=args['author'],
                            version=args['version'],
                            description=args['description'])
    except Exception as e:
        raise e
예제 #7
0
def register_operators(**args):
    op = DB(name=args['name'],
            type=args['type'],
            addr=args['addr'],
            author=args['author'],
            version=args['version'],
            description=args['description'])
    try:
        if search_operator(args['name']):
            raise ExistError(f"operator {args['name']} had exist", "")
        insert_operator(op)
        return new_operator(name=args['name'],
                            type=args['type'],
                            addr=args['addr'],
                            author=args['author'],
                            version=args['version'],
                            description=args['description'])
    except Exception as e:
        logger.error(f"Unexpected error happen during register operator, {str(e)}", exc_info=True)
        raise e