Beispiel #1
0
def check_function(func_str):
    try:
        parts = func_str.split('.')
        if parts[0] != 'checker':
            raise Exception()
        dm.load_module(func_str)
    except:
        raise Exception("Invalid check function: %s" % func_str)
Beispiel #2
0
def input_class(class_str):
    try:
        parts = class_str.split('.')
        if parts[0] != 'polling':
            raise Exception()
        if 'PollInput' not in parts[-1]:
            raise Exception()
        dm.load_module(class_str)
    except Exception as e:
        raise e
        raise Exception("Invalid PollInput: %s" % class_str)
Beispiel #3
0
def poller(poller_str):
    try:
        parts = poller_str.split('.')
        if parts[0] != 'polling':
            raise Exception()
        if 'Poller' not in parts[-1]:
            raise Exception()
        dm.load_module(poller_str)
    except Exception as e:
        raise e
        raise Exception("Invalid poller: %s" % poller_str)
Beispiel #4
0
def parse_poll_inputs(contents):
    poll_inputs = {}
    portion = get_portion(contents, '[PollInputs]')
    lines = parse_portion(portion)
    for id, args in lines:
        input_class_str = 'polling.' + args[0]
        args = ','.join(args[1:])

        validate.input_class(input_class_str)
        validate.jsondata(args)

        input_class = load_module(input_class_str)
        args = json.loads(args)
        input = input_class(*args)

        poll_inputs[id] = pickle.dumps(input)
    return poll_inputs