Exemplo n.º 1
0
    def test_get_alarms_with_not_admin_project(self):
        # Setup
        graph = self._create_graph()
        apis = AlarmApis(graph, self.conf, self.api_lock, self._db)
        ctx = {'tenant': 'project_2', 'is_admin': False}

        # Action
        alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants=False)
        alarms = decompress_obj(alarms)['alarms']

        # Test assertions
        self.assertThat(alarms, matchers.HasLength(2))
        self._check_projects_entities(alarms, 'project_2', True)
Exemplo n.º 2
0
    def test_get_alarms_with_not_admin_project(self):
        # Setup
        graph = self._create_graph()
        apis = AlarmApis(graph, None)
        ctx = {'tenant': 'project_2', 'is_admin': False}

        # Action
        alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants=False)
        alarms = json.loads(alarms)['alarms']

        # Test assertions
        self.assertEqual(2, len(alarms))
        self._check_projects_entities(alarms, 'project_2', True)
Exemplo n.º 3
0
    def test_get_alarms_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = AlarmApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants=True)
        alarms = json.loads(alarms)['alarms']

        # Test assertions
        self.assertThat(alarms, matchers.HasLength(5))
        self._check_projects_entities(alarms, None, True)
Exemplo n.º 4
0
    def test_get_alarms_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = AlarmApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants='1')
        alarms = json.loads(alarms)['alarms']

        # Test assertions
        self.assertEqual(5, len(alarms))
        self._check_projects_entities(alarms, None, True)
Exemplo n.º 5
0
    def test_get_alarm_counts_with_not_admin_project(self):
        # Setup
        graph = self._create_graph()
        apis = AlarmApis(graph, self.conf, self.api_lock, self._db)
        ctx = {'tenant': 'project_2', 'is_admin': False}

        # Action
        counts = apis.get_alarm_counts(ctx, all_tenants=False)
        counts = json.loads(counts)

        # Test assertions
        self.assertEqual(1, counts['WARNING'])
        self.assertEqual(0, counts['SEVERE'])
        self.assertEqual(1, counts['CRITICAL'])
        self.assertEqual(0, counts['OK'])
        self.assertEqual(0, counts['N/A'])
Exemplo n.º 6
0
    def start(self):
        LOG.info("Vitrage Api Handler Service - Starting...")

        super(VitrageApiHandlerService, self).start()

        transport = messaging.get_rpc_transport(self.conf)
        rabbit_hosts = self.conf.oslo_messaging_rabbit.rabbit_hosts
        target = oslo_messaging.Target(topic=self.conf.rpc_topic,
                                       server=rabbit_hosts)

        endpoints = [
            TopologyApis(self.entity_graph, self.conf),
            AlarmApis(self.entity_graph, self.conf),
            RcaApis(self.entity_graph, self.conf),
            TemplateApis(self.scenario_repo.templates,
                         self.scenario_repo.def_templates),
            EventApis(self.conf),
            ResourceApis(self.entity_graph, self.conf)
        ]

        server = vitrage_rpc.get_server(target, endpoints, transport)

        server.start()

        LOG.info("Vitrage Api Handler Service - Started!")
Exemplo n.º 7
0
    def _init_instance(self):
        conf = self._conf
        LOG.info("Vitrage Api Handler Service - Starting...")
        notifier = messaging.VitrageNotifier(conf, "vitrage.api",
                                             [EVALUATOR_TOPIC])
        db = storage.get_connection_from_config(conf)
        transport = messaging.get_rpc_transport(conf)
        rabbit_hosts = conf.oslo_messaging_rabbit.rabbit_hosts
        target = oslo_messaging.Target(topic=conf.rpc_topic,
                                       server=rabbit_hosts)

        endpoints = [
            TopologyApis(self._entity_graph, conf),
            AlarmApis(self._entity_graph, conf, db),
            RcaApis(self._entity_graph, conf, db),
            TemplateApis(notifier, db),
            EventApis(conf),
            ResourceApis(self._entity_graph, conf),
            WebhookApis(conf)
        ]

        server = vitrage_rpc.get_server(target, endpoints, transport)

        server.start()

        LOG.info("Vitrage Api Handler Service - Started!")
Exemplo n.º 8
0
    def _start(self):
        LOG.info("Vitrage Api Handler Service - Starting...")

        transport = messaging.get_rpc_transport(self.conf)
        rabbit_hosts = self.conf.oslo_messaging_rabbit.rabbit_hosts
        target = oslo_messaging.Target(topic=self.conf.rpc_topic,
                                       server=rabbit_hosts)

        endpoints = [TopologyApis(self.entity_graph, self.conf),
                     AlarmApis(self.entity_graph, self.conf),
                     RcaApis(self.entity_graph, self.conf),
                     TemplateApis(self.notifier, self.db),
                     EventApis(self.conf),
                     ResourceApis(self.entity_graph, self.conf),
                     WebhookApis(self.conf)]

        server = vitrage_rpc.get_server(target, endpoints, transport)

        server.start()

        LOG.info("Vitrage Api Handler Service - Started!")
Exemplo n.º 9
0
    def _init_instance(self):
        notifier = messaging.VitrageNotifier("vitrage.api", [EVALUATOR_TOPIC])
        db = storage.get_connection_from_config()
        transport = messaging.get_rpc_transport()
        target = oslo_messaging.Target(topic=CONF.rpc_topic,
                                       server=uuidutils.generate_uuid())
        self.api_lock = threading.RLock()

        endpoints = [
            TopologyApis(self._entity_graph, self.api_lock),
            AlarmApis(self._entity_graph, self.api_lock, db),
            RcaApis(self._entity_graph, self.api_lock, db),
            ResourceApis(self._entity_graph, self.api_lock),
            TemplateApis(notifier, db),
            EventApis(),
            WebhookApis(db),
            OperationalApis(self._entity_graph),
        ]

        server = vitrage_rpc.get_server(target, endpoints, transport)

        server.start()