# Copyright (c) 2015 iXsystems, Inc.
# All rights reserved.
# This file is a part of TrueNAS
# and may not be copied and/or distributed
# without the express permission of iXsystems.

import logging

log = logging.getLogger('freenasUI.truenas.mixins')


class AlertPlugins(object):

    def run(self):
        from freenasUI.middleware.notifier import notifier
        rvs = super(AlertPlugins, self).run()
        current = 'OK'
        for alert in rvs:
            if alert.getDismiss():
                continue
            if alert.getLevel() in (alert.CRIT, alert.WARN):
                current = 'CRIT'
                break
        notifier().set_global_alarm(current)
        return rvs
