コード例 #1
0
def do_downtime():
    # Getting lists of informations for the commands
    action = request.forms.get('action', 'add')
    time_stamp = request.forms.get('time_stamp', int(time.time()))
    host_name = request.forms.get('host_name', '')
    service_description = request.forms.get('service_description', '')
    start_time = request.forms.get('start_time', int(time.time()))
    end_time = request.forms.get('end_time', int(time.time()))
    # Fixed is 1 for a period between start and end time
    fixed = request.forms.get('fixed', '1')
    # Fixed is 0 (flexible) for a period of duration seconds from start time
    duration = request.forms.get('duration', int('86400'))
    trigger_id = request.forms.get('trigger_id', '0')
    author = request.forms.get('author', 'anonymous')
    comment = request.forms.get('comment', 'No comment')
    logger.debug(
        "[WS_Arbiter] Downtime %s - host: '%s', service: '%s', comment: '%s'" %
        (action, host_name, service_description, comment))

    if not host_name:
        abort(400, 'Missing parameter host_name')

    if action == 'add':
        if service_description:
            # SCHEDULE_SVC_DOWNTIME;<host_name>;<service_description>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
            command = '[%s] SCHEDULE_SVC_DOWNTIME;%s;%s;%s;%s;%s;%s;%s;%s;%s\n' % (
                time_stamp, host_name, service_description, start_time,
                end_time, fixed, trigger_id, duration, author, comment)
        else:
            # SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
            command = '[%s] SCHEDULE_HOST_DOWNTIME;%s;%s;%s;%s;%s;%s;%s;%s\n' % (
                time_stamp, host_name, start_time, end_time, fixed, trigger_id,
                duration, author, comment)

    if action == 'delete':
        if service_description:
            # DEL_ALL_SVC_DOWNTIMES;<host_name>;<service_description>
            command = '[%s] DEL_ALL_SVC_DOWNTIMES;%s;%s\n' % (
                time_stamp, host_name, service_description)
        else:
            # DEL_ALL_SVC_DOWNTIMES;<host_name>
            command = '[%s] DEL_ALL_HOST_DOWNTIMES;%s\n' % (time_stamp,
                                                            host_name)

    # We check for auth if it's not anonymously allowed
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')

    # Adding commands to the main queue()
    logger.debug("[WS_Arbiter] command =  %s" % command)
    ext = ExternalCommand(command)
    app.from_q.put(ext)
コード例 #2
0
def check_auth():
    """Check for auth if it's not anonymously allowed"""
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')
コード例 #3
0
ファイル: module.py プロジェクト: geektophe/mod-ws-arbiter
def check_auth():
    """Check for auth if it's not anonymously allowed"""
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')
コード例 #4
0
ファイル: module.py プロジェクト: dgilm/mod-ws-arbiter
def do_acknowledge():
    # Getting lists of informations for the commands
    action = request.forms.get('action', 'add')
    time_stamp = request.forms.get('time_stamp', int(time.time()))
    host_name = request.forms.get('host_name', '')
    service_description = request.forms.get('service_description', '')
    sticky = request.forms.get('sticky', '1')
    notify = request.forms.get('notify', '0')
    persistent = request.forms.get('persistent', '1')
    author = request.forms.get('author', 'anonymous')
    comment = request.forms.get('comment', 'No comment')
    logger.debug(
        "[WS_Arbiter] Acknowledge %s - host: '%s', service: '%s', comment: '%s'"
        % (action, host_name, service_description, comment))

    if not host_name:
        abort(400, 'Missing parameter host_name')

    if action == 'add':
        if service_description:
            command = '[%s] ACKNOWLEDGE_SVC_PROBLEM;%s;%s;%s;%s;%s;%s;%s\n' % (
                time_stamp, host_name, service_description, sticky, notify,
                persistent, author, comment)
        else:
            command = '[%s] ACKNOWLEDGE_HOST_PROBLEM;%s;%s;%s;%s;%s;%s\n' % (
                time_stamp, host_name, sticky, notify, persistent, author,
                comment)

    if action == 'delete':
        if service_description:
            # REMOVE_SVC_ACKNOWLEDGEMENT;<host_name>;<service_description>
            command = '[%s] REMOVE_SVC_ACKNOWLEDGEMENT;%s;%s\n' % (
                time_stamp, host_name, service_description)
        else:
            # REMOVE_HOST_ACKNOWLEDGEMENT;<host_name>
            command = '[%s] REMOVE_HOST_ACKNOWLEDGEMENT;%s\n' % (time_stamp,
                                                                 host_name)

    # logger.warning("[WS_Arbiter] command: %s" % (command))
    # We check for auth if it's not anonymously allowed
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')

    # Adding commands to the main queue()
    logger.debug("[WS_Arbiter] command: %s" % str(command))
    ext = ExternalCommand(command)
    app.from_q.put(ext)
コード例 #5
0
ファイル: module.py プロジェクト: aviau/mod-ws-arbiter
def do_reload():
    # Getting lists of informations for the commands
    time_stamp = request.forms.get('time_stamp', int(time.time()))
    command = '[%s] RELOAD_CONFIG\n' % time_stamp

    # We check for auth if it's not anonymously allowed
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')

    # Adding commands to the main queue()
    logger.warning("[WS_Arbiter] command: %s" % str(command))
    ext = ExternalCommand(command)
    app.from_q.put(ext)
コード例 #6
0
ファイル: module.py プロジェクト: dgilm/mod-ws-arbiter
def do_reload():
    # Getting lists of informations for the commands
    time_stamp = request.forms.get('time_stamp', int(time.time()))
    command = '[%s] RELOAD_CONFIG\n' % time_stamp

    # We check for auth if it's not anonymously allowed
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')

    # Adding commands to the main queue()
    logger.warning("[WS_Arbiter] command: %s" % str(command))
    ext = ExternalCommand(command)
    app.from_q.put(ext)
コード例 #7
0
ファイル: module.py プロジェクト: geektophe/mod-ws-arbiter
def do_downtime():
    # Getting lists of informations for the commands
    action              = request.forms.get('action', 'add')
    time_stamp          = request.forms.get('time_stamp', int(time.time()))
    host_name           = request.forms.get('host_name', '')
    service_description = request.forms.get('service_description', '')
    start_time          = request.forms.get('start_time', int(time.time()))
    end_time            = request.forms.get('end_time', int(time.time()))
    # Fixed is 1 for a period between start and end time
    fixed               = request.forms.get('fixed', '1')
    # Fixed is 0 (flexible) for a period of duration seconds from start time
    duration            = request.forms.get('duration', int('86400'))
    trigger_id          = request.forms.get('trigger_id', '0')
    author              = request.forms.get('author', 'anonymous')
    comment             = request.forms.get('comment', 'No comment')
    logger.debug("[WS_Arbiter] Downtime %s - host: '%s', service: '%s', comment: '%s'" % (action, host_name, service_description, comment))

    if not host_name:
        abort(400, 'Missing parameter host_name')

    if action == 'add':
        if service_description:
            # SCHEDULE_SVC_DOWNTIME;<host_name>;<service_description>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
            command = '[%s] SCHEDULE_SVC_DOWNTIME;%s;%s;%s;%s;%s;%s;%s;%s;%s\n' % ( time_stamp,
                                                                                    host_name,
                                                                                    service_description,
                                                                                    start_time,
                                                                                    end_time,
                                                                                    fixed,
                                                                                    trigger_id,
                                                                                    duration,
                                                                                    author,
                                                                                    comment
                                                                                   )
        else:
            # SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
            command = '[%s] SCHEDULE_HOST_DOWNTIME;%s;%s;%s;%s;%s;%s;%s;%s\n' % (   time_stamp,
                                                                                    host_name,
                                                                                    start_time,
                                                                                    end_time,
                                                                                    fixed,
                                                                                    trigger_id,
                                                                                    duration,
                                                                                    author,
                                                                                    comment
                                                                                )

    if action == 'delete':
        if service_description:
            # DEL_ALL_SVC_DOWNTIMES;<host_name>;<service_description>
            command = '[%s] DEL_ALL_SVC_DOWNTIMES;%s;%s\n' % ( time_stamp,
                                                               host_name,
                                                               service_description)
        else:
            # DEL_ALL_SVC_DOWNTIMES;<host_name>
            command = '[%s] DEL_ALL_HOST_DOWNTIMES;%s\n' % ( time_stamp,
                                                             host_name)


    # We check for auth if it's not anonymously allowed
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')

    # Adding commands to the main queue()
    logger.debug("[WS_Arbiter] command =  %s" % command)
    ext = ExternalCommand(command)
    app.from_q.put(ext)
コード例 #8
0
ファイル: module.py プロジェクト: axadil/mod-ws-arbiter
def do_downtime():
    # Getting lists of informations for the commands
    action = request.forms.get("action", "add")
    time_stamp = request.forms.get("time_stamp", int(time.time()))
    host_name = request.forms.get("host_name", "")
    service_description = request.forms.get("service_description", "")
    start_time = request.forms.get("start_time", int(time.time()))
    end_time = request.forms.get("end_time", int(time.time()))
    # Fixed is 1 for a period between start and end time
    fixed = request.forms.get("fixed", "1")
    # Fixed is 0 (flexible) for a period of duration seconds from start time
    duration = request.forms.get("duration", int("86400"))
    trigger_id = request.forms.get("trigger_id", "0")
    author = request.forms.get("author", "anonymous")
    comment = request.forms.get("comment", "No comment")
    logger.debug(
        "[WS_Arbiter] Downtime %s - host: '%s', service: '%s', comment: '%s'"
        % (action, host_name, service_description, comment)
    )

    if not host_name:
        abort(400, "Missing parameter host_name")

    if action == "add":
        if service_description:
            # SCHEDULE_SVC_DOWNTIME;<host_name>;<service_description>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
            command = "[%s] SCHEDULE_SVC_DOWNTIME;%s;%s;%s;%s;%s;%s;%s;%s;%s\n" % (
                time_stamp,
                host_name,
                service_description,
                start_time,
                end_time,
                fixed,
                trigger_id,
                duration,
                author,
                comment,
            )
        else:
            # SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
            command = "[%s] SCHEDULE_HOST_DOWNTIME;%s;%s;%s;%s;%s;%s;%s;%s\n" % (
                time_stamp,
                host_name,
                start_time,
                end_time,
                fixed,
                trigger_id,
                duration,
                author,
                comment,
            )

    if action == "delete":
        if service_description:
            # DEL_ALL_SVC_DOWNTIMES;<host_name>;<service_description>
            command = "[%s] DEL_ALL_SVC_DOWNTIMES;%s;%s\n" % (time_stamp, host_name, service_description)
        else:
            # DEL_ALL_SVC_DOWNTIMES;<host_name>
            command = "[%s] DEL_ALL_HOST_DOWNTIMES;%s\n" % (time_stamp, host_name)

    # We check for auth if it's not anonymously allowed
    if app.username != "anonymous":
        basic = parse_auth(request.environ.get("HTTP_AUTHORIZATION", ""))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, "Authentication required")
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, "Authentication denied")

    # Adding commands to the main queue()
    logger.debug("[WS_Arbiter] command =  %s" % command)
    ext = ExternalCommand(command)
    app.from_q.put(ext)
コード例 #9
0
ファイル: module.py プロジェクト: aviau/mod-ws-arbiter
def do_acknowledge():
    # Getting lists of informations for the commands
    action              = request.forms.get('action', 'add')
    time_stamp          = request.forms.get('time_stamp', int(time.time()))
    host_name           = request.forms.get('host_name', '')
    service_description = request.forms.get('service_description', '')
    sticky              = request.forms.get('sticky', '1')
    notify              = request.forms.get('notify', '0')
    persistent          = request.forms.get('persistent', '1')
    author              = request.forms.get('author', 'anonymous')
    comment             = request.forms.get('comment', 'No comment')
    logger.debug("[WS_Arbiter] Acknowledge %s - host: '%s', service: '%s', comment: '%s'" % (action, host_name, service_description, comment))
 
    if not host_name:
        abort(400, 'Missing parameter host_name')
        
    if action == 'add':
        if service_description:
            command = '[%s] ACKNOWLEDGE_SVC_PROBLEM;%s;%s;%s;%s;%s;%s;%s\n' % ( time_stamp,
                                                                                host_name,
                                                                                service_description,
                                                                                sticky,
                                                                                notify,
                                                                                persistent,
                                                                                author,
                                                                                comment
                                                                                )
        else:
            command = '[%s] ACKNOWLEDGE_HOST_PROBLEM;%s;%s;%s;%s;%s;%s\n' % (   time_stamp,
                                                                                host_name,
                                                                                sticky,
                                                                                notify,
                                                                                persistent,
                                                                                author,
                                                                                comment
                                                                                )
        
    if action == 'delete':
        if service_description:
            # REMOVE_SVC_ACKNOWLEDGEMENT;<host_name>;<service_description>
            command = '[%s] REMOVE_SVC_ACKNOWLEDGEMENT;%s;%s\n' % ( time_stamp,
                                                                    host_name,
                                                                    service_description)
        else:
            # REMOVE_HOST_ACKNOWLEDGEMENT;<host_name>
            command = '[%s] REMOVE_HOST_ACKNOWLEDGEMENT;%s\n' % ( time_stamp,
                                                                  host_name)
                                                                                

    # logger.warning("[WS_Arbiter] command: %s" % (command))
    # We check for auth if it's not anonymously allowed
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')

    # Adding commands to the main queue()
    logger.debug("[WS_Arbiter] command: %s" % str(command))
    ext = ExternalCommand(command)
    app.from_q.put(ext)
コード例 #10
0
ファイル: module.py プロジェクト: aviau/mod-ws-arbiter
        host_name_list = request.forms.getall(key='host_name')
        logger.debug("[WS_Arbiter] host_name_list: %s" % (host_name_list))
        service_description_list = request.forms.getall(key='service_description')
        logger.debug("[WS_Arbiter] service_description_list: %s" % (service_description_list))
        return_code_list = request.forms.getall(key='return_code')
        logger.debug("[WS_Arbiter] return_code_list: %s" % (return_code_list))
        output_list = request.forms.getall(key='output')
        logger.debug("[WS_Arbiter] output_list: %s" % (output_list))
        commands_list = get_commands(time_stamp_list, host_name_list, service_description_list, return_code_list, output_list)
    except Exception, e:
        logger.error("[WS_Arbiter] failed to get the lists: %s" % str(e))
        commands_list = []

    # We check for auth if it's not anonymously allowed
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')

    # Adding commands to the main queue()
    logger.debug("[WS_Arbiter] commands: %s" % str(sorted(commands_list)))
    for c in sorted(commands_list):
        ext = ExternalCommand(c)
        app.from_q.put(ext)

    # OK here it's ok, it will return a 200 code
コード例 #11
0
ファイル: module.py プロジェクト: dgilm/mod-ws-arbiter
        logger.debug("[WS_Arbiter] service_description_list: %s" %
                     (service_description_list))
        return_code_list = request.forms.getall(key='return_code')
        logger.debug("[WS_Arbiter] return_code_list: %s" % (return_code_list))
        output_list = request.forms.getall(key='output')
        logger.debug("[WS_Arbiter] output_list: %s" % (output_list))
        commands_list = get_commands(time_stamp_list, host_name_list,
                                     service_description_list,
                                     return_code_list, output_list)
    except Exception, e:
        logger.error("[WS_Arbiter] failed to get the lists: %s" % str(e))
        commands_list = []

    # We check for auth if it's not anonymously allowed
    if app.username != 'anonymous':
        basic = parse_auth(request.environ.get('HTTP_AUTHORIZATION', ''))
        # Maybe the user not even ask for user/pass. If so, bail out
        if not basic:
            abort(401, 'Authentication required')
        # Maybe he do not give the good credential?
        if basic[0] != app.username or basic[1] != app.password:
            abort(403, 'Authentication denied')

    # Adding commands to the main queue()
    logger.debug("[WS_Arbiter] commands: %s" % str(sorted(commands_list)))
    for c in sorted(commands_list):
        ext = ExternalCommand(c)
        app.from_q.put(ext)

    # OK here it's ok, it will return a 200 code