# along with Canopsis. If not, see <http://www.gnu.org/licenses/>. # --------------------------------- from canopsis.migration.manager import MigrationModule from canopsis.configuration.configurable.decorator import conf_paths from canopsis.configuration.configurable.decorator import add_category from canopsis.configuration.model import Parameter from canopsis.old.account import Account from canopsis.old.storage import Storage CONF_PATH = 'migration/purge.conf' CATEGORY = 'PURGE' CONTENT = [ Parameter('collections', parser=Parameter.array()) ] @conf_paths(CONF_PATH) @add_category(CATEGORY, content=CONTENT) class PurgeModule(MigrationModule): @property def collections(self): if not hasattr(self, '_collections'): self.collections = None return self._collections @collections.setter
from signal import SIGTERM, SIGINT import importlib import sys import os config = { 'server': ( Parameter('debug', parser=Parameter.bool), Parameter('enable_crossdomain_send_events', parser=Parameter.bool), Parameter('root_directory', parser=Parameter.path) ), 'auth': ( Parameter('providers', parser=Parameter.array(), critical=True) ), 'session': ( Parameter('cookie_expires', parser=int), Parameter('secret'), Parameter('data_dir', parser=Parameter.path) ), 'webservices': ParamList(parser=Parameter.bool) } class EnsureAuthenticated(object): name = 'EnsureAuthenticated' handle_logout = False def __init__(self, ws, *args, **kwargs):
from canopsis.timeserie.timewindow import get_offset_timewindow from canopsis.common.utils import ensure_iterable from canopsis.task.core import get_task from canopsis.event.manager import Event from canopsis.check import Check from canopsis.alerts.status import get_last_state, get_last_status, OFF from time import time CONF_PATH = 'alerts/manager.conf' CATEGORY = 'ALERTS' CONTENT = [ Parameter('extra_fields', Parameter.array()) ] @conf_paths(CONF_PATH) @add_category(CATEGORY, content=CONTENT) class Alerts(MiddlewareRegistry): """ Alarm cycle managment. Used to archive events related to alarms in a TimedStorage. """ CONFIG_STORAGE = 'config_storage' ALARM_STORAGE = 'alarm_storage' CONTEXT_MANAGER = 'context'
class InvalidState(Exception): """Handle CheckManager errors.""" def __init__(self, state, states): self.state = state self.states = states def __str__(self): return 'Invalid state: got value {}, expected one of {}'.format( self.state, self.states ) @add_category(CATEGORY, content=Parameter('types', parser=Parameter.array())) @conf_paths(CONF_PATH) class CheckManager(MiddlewareRegistry): """Manage entity checking state. A state is bound to an entity. Therefore, an entity id is a document state id. """ CHECK_STORAGE = 'check_storage' #: storage name. ID = '_id' #: state id field name. STATE = Check.STATE #: state field name. LAST_STATE = 'last' #: last state field name if criticity != HARD. COUNT = 'count' #: last state count if criticity != 0.
from canopsis.configuration.configurable.decorator import conf_paths from canopsis.configuration.configurable.decorator import add_category from canopsis.configuration.model import Parameter from canopsis.common.utils import lookup from logging import StreamHandler import signal import json import os CONF_PATH = 'migration/manager.conf' CATEGORY = 'MIGRATION' CONTENT = [ Parameter('modules', parser=Parameter.array()) ] @conf_paths(CONF_PATH) @add_category(CATEGORY, content=CONTENT) class MigrationTool(Configurable): @property def modules(self): if not hasattr(self, '_modules'): self.modules = None return self._modules @modules.setter
from canopsis.configuration.configurable.decorator import ( conf_paths, add_category ) from canopsis.configuration.model import Parameter from canopsis.middleware.registry import MiddlewareRegistry from canopsis.event import Event, forger from canopsis.storage.composite import CompositeStorage from urllib import unquote_plus CONF_RESOURCE = 'context/context.conf' #: last context conf resource CATEGORY = 'CONTEXT' #: context category CONTENT = [Parameter('accept_event_types', Parameter.array())] @add_category(CATEGORY, content=CONTENT) @conf_paths(CONF_RESOURCE) class Context(MiddlewareRegistry): """ Manage access to a context (connector, component, resource) elements and context data (metric, downtime, etc.) It uses a composite storage in order to modelise composite data. For example, let a resource ``R`` in the component ``C`` and connector ``K``. ``R`` is identified through the context [``K``, ``C``], the name ``R`` and the type ``resource``.