Example #1
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!")
Example #2
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!")
Example #3
0
    def test_get_topology_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None, self.api_lock)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        graph_topology = apis.get_topology(ctx,
                                           graph_type='graph',
                                           depth=10,
                                           query=None,
                                           root=None,
                                           all_tenants=True)
        graph_topology = decompress_obj(graph_topology)

        # Test assertions
        self.assertThat(graph_topology['nodes'], matchers.HasLength(12))
Example #4
0
    def test_get_topology_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        graph_topology = apis.get_topology(ctx,
                                           graph_type='graph',
                                           depth=10,
                                           query=None,
                                           root='RESOURCE:openstack.cluster',
                                           all_tenants=1)
        graph_topology = json.loads(graph_topology)

        # Test assertions
        self.assertEqual(12, len(graph_topology['nodes']))
Example #5
0
    def test_get_topology_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        graph_topology = apis.get_topology(ctx,
                                           graph_type='graph',
                                           depth=10,
                                           query=None,
                                           root='RESOURCE:openstack.cluster',
                                           all_tenants=1)
        graph_topology = json.loads(graph_topology)

        # Test assertions
        self.assertEqual(12, len(graph_topology['nodes']))
Example #6
0
    def test_get_topology_with_not_admin_project(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None)
        ctx = {'tenant': 'project_2', 'is_admin': False}

        # Action
        graph_topology = apis.get_topology(ctx,
                                           graph_type='graph',
                                           depth=10,
                                           query=None,
                                           root=None,
                                           all_tenants=False)
        graph_topology = json.loads(graph_topology)

        # Test assertions
        self.assertThat(graph_topology['nodes'], matchers.HasLength(7))
        self._check_projects_entities(graph_topology['nodes'], 'project_2',
                                      False)
Example #7
0
    def test_get_topology_with_admin_project(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': True}

        # Action
        graph_topology = apis.get_topology(
            ctx,
            graph_type='graph',
            depth=10,
            query=None,
            root=None,
            all_tenants=False)
        graph_topology = json.loads(graph_topology)

        # Test assertions
        self.assertEqual(8, len(graph_topology['nodes']))
        self._check_projects_entities(graph_topology['nodes'],
                                      'project_1',
                                      False)
Example #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!")
Example #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()