def _get_users(self, sessionKey, query_params):
        logger.debug("START _get_users()")

        users = AlertManagerUsers(sessionKey=sessionKey)
        user_list = users.getUserList()

        logger.debug("user_list: %s " % json.dumps(user_list))

        return self.response(user_list, httplib.OK)
Exemple #2
0
    def _get_users(self, sessionKey, query_params):
        logger.debug("START _get_users()")

        users = AlertManagerUsers(sessionKey=sessionKey)
        user_list = users.getUserList()

        logger.debug("user_list: %s " % json.dumps(user_list))

        return self.response(user_list, httplib.OK)
Exemple #3
0
    def get_users(self, **kwargs):
        logger.info("Get users")

        user = cherrypy.session['user']['name']
        sessionKey = cherrypy.session.get('sessionKey')

        users = AlertManagerUsers(sessionKey=sessionKey)
        user_list = users.getUserList()

        logger.debug("user_list: %s " % json.dumps(user_list))

        return json.dumps(user_list)
Exemple #4
0
    args_stdout = args_stdout + "namespace:%s" % alert_app + "\n"
    log.debug("stdout args for %s: %s" % (incident_config['alert_script'], args_stdout))
    log.debug("args for %s: %s" % (incident_config['alert_script'], args))

    try:
        p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=False)
        output = p.communicate(input=args_stdout)
        log.debug("Alert script run finished. RC=%s. Output: %s" % (p.returncode, output[0]))
    except OSError, e:
        log.debug("Alert script failed. Error: %s" % str(e))


log.info("Creating incident for job_id=%s" % job_id)

users = AlertManagerUsers(sessionKey=sessionKey)
user_list = users.getUserList()
notifier = AlertManagerNotifications(sessionKey=sessionKey)

###############################
# Incident creation starts here

#####################################################################
# BEGIN CUSTOM DEVELOPMENT SWISSCOM 2015-11-02
#
# The following code has been moved to lines 422 - 426
#
# # Create unique id
# incident_id = str(uuid.uuid4())
#
# # Get results
# results = getResults(job_path, incident_id)
    # Auto assign
    owner = ''
    status = 'new'
    auto_assgined = False
    if alert_config['auto_assign'] and alert_config[
            'auto_assign_owner'] != 'unassigned':
        entry['owner'] = alert_config['auto_assign_owner']
        owner = alert_config['auto_assign_owner']
        log.info("Assigning incident to %s" %
                 alert_config['auto_assign_owner'])
        auto_assgined = True
        status = 'auto_assigned'

        # Send notification
        users = AlertManagerUsers(sessionKey=sessionKey)
        user_list = users.getUserList()
        log.debug("User list: %s" % user_list)

        user = {}
        user_found = False
        for item in user_list:
            if item["name"] == alert_config['auto_assign_owner']:
                user = item
                user_found = True

        if user_found:
            log.debug("Got user settings for user %s" %
                      alert_config['auto_assign_owner'])
            if user['notify_user'] != False or user['email'] == "":
                log.info(
                    "Auto-assign user %s configured correctly to receive notification. Proceeding..."