Пример #1
0
    def test_can_vertex_be_deleted(self):
        entity_graph = entity_g.EntityGraph("Entity Graph")

        # create vertex properties
        instance_vertex = self._update_vertex_to_graph(entity_graph,
                                                       'RESOURCE', 'INSTANCE',
                                                       '123', False, True, {})

        # check is placeholder vertex
        is_placeholder_vertex = \
            entity_graph.can_vertex_be_deleted(instance_vertex)
        self.assertTrue(is_placeholder_vertex)

        # add host vertex
        host_vertex = self._update_vertex_to_graph(entity_graph, 'RESOURCE',
                                                   'HOST', '321',
                                                   False, True, {})
        edge = self._update_edge_to_graph(entity_graph, host_vertex.vertex_id,
                                          instance_vertex.vertex_id,
                                          'contains')

        # check is placeholder vertex
        is_placeholder_vertex = \
            entity_graph.can_vertex_be_deleted(instance_vertex)
        self.assertFalse(is_placeholder_vertex)

        # change host to is_deleted
        entity_graph.mark_vertex_as_deleted(host_vertex)
        entity_graph.mark_edge_as_deleted(edge)

        # check is placeholder vertex
        is_placeholder_vertex = \
            entity_graph.can_vertex_be_deleted(instance_vertex)
        self.assertTrue(is_placeholder_vertex)
Пример #2
0
 def __init__(self, conf, initialization_status, e_graph=None):
     super(Processor, self).__init__()
     self.conf = conf
     self.transformer_manager = TransformerManager(self.conf)
     self.state_manager = DatasourceInfoMapper(self.conf)
     self._initialize_events_actions()
     self.initialization_status = initialization_status
     self.entity_graph = entity_graph.EntityGraph("Entity Graph") if \
         e_graph is None else e_graph
     self._notifier = DeducedAlarmNotifier(conf)
Пример #3
0
def init():
    conf = service.prepare_service()
    event_queue = multiprocessing.Queue()
    e_graph = entity_graph.EntityGraph(
        'Entity Graph', '%s:%s' % (EntityCategory.RESOURCE, OPENSTACK_CLUSTER))
    scenario_repo = ScenarioRepository(conf)
    evaluator = ScenarioEvaluator(conf, e_graph, scenario_repo, event_queue)
    initialization_status = InitializationStatus()

    return conf, event_queue, evaluator, e_graph, initialization_status
Пример #4
0
def init(conf):
    mp_queue = multiprocessing.Queue()
    evaluator_q = queue.Queue()
    e_graph = entity_graph.EntityGraph(
        'Entity Graph', '%s:%s' % (EntityCategory.RESOURCE, OPENSTACK_CLUSTER))
    scenario_repo = ScenarioRepository(conf)

    evaluator = ScenarioEvaluator(conf, e_graph, scenario_repo, evaluator_q)

    return mp_queue, evaluator_q, evaluator, e_graph
Пример #5
0
    def test_mark_vertex_as_deleted(self):
        entity_graph = entity_g.EntityGraph("Entity Graph")

        # create vertex properties
        vertex = self._update_vertex_to_graph(entity_graph, 'RESOURCE',
                                              'INSTANCE', '12345',
                                              False, True, {})

        # check vitrage deleted
        self.assertFalse(entity_graph.is_vertex_deleted(vertex))
        entity_graph.mark_vertex_as_deleted(vertex)
        self.assertTrue(entity_graph.is_vertex_deleted(vertex))
Пример #6
0
    def test_is_not_can_vertex_be_deleted(self):
        entity_graph = entity_g.EntityGraph("Entity Graph")

        # create vertex properties
        prop = {VertexProperties.STATE: 'ACTIVE'}
        vertex = self._update_vertex_to_graph(entity_graph, 'RESOURCE',
                                              'INSTANCE', '12345',
                                              False, False, prop)

        # check is not placeholder vertex
        is_placeholder_vertex = entity_graph.can_vertex_be_deleted(vertex)
        self.assertFalse(is_placeholder_vertex)
Пример #7
0
    def test_delete_placeholder_vertex(self):
        entity_graph = entity_g.EntityGraph("Entity Graph")

        # create vertex properties
        vertex = self._update_vertex_to_graph(entity_graph, 'RESOURCE',
                                              'INSTANCE', '12345',
                                              False, True, {})

        # check is placeholder vertex
        is_placeholder_vertex = entity_graph.can_vertex_be_deleted(vertex)
        self.assertTrue(is_placeholder_vertex)

        # deal with placeholder vertex - mark it as deleted
        entity_graph.delete_placeholder_vertex(vertex)
        vertex = entity_graph.get_vertex(vertex.vertex_id)
        self.assertTrue(not vertex)
Пример #8
0
    def test_mark_edge_as_deleted(self):
        entity_graph = entity_g.EntityGraph("Entity Graph")

        # create vertex properties
        vertex1 = self._update_vertex_to_graph(entity_graph, 'RESOURCE',
                                               'INSTANCE', '12345',
                                               False, True, {})
        vertex2 = self._update_vertex_to_graph(entity_graph, 'RESOURCE',
                                               'HOST', '54321',
                                               False, True, {})
        edge = self._update_edge_to_graph(entity_graph, vertex1.vertex_id,
                                          vertex2.vertex_id, 'contains')

        # check vitrage deleted
        self.assertFalse(entity_graph.is_edge_deleted(edge))
        entity_graph.mark_edge_as_deleted(edge)
        self.assertTrue(entity_graph.is_edge_deleted(edge))
Пример #9
0
    def test_find_neighbor_types(self):
        neighbors = []
        entity_graph = entity_g.EntityGraph("Entity Graph")
        entities_details = [('RESOURCE', 'HOST', '1', False, True),
                            ('RESOURCE', 'STORAGE', '2', False, True),
                            ('RESOURCE', 'APPLICATION', '3', False, True),
                            ('RESOURCE', 'STORAGE', '4', False, True),
                            ('ALARM', 'INSTANCE_AT_RISK', '5', False, True)]

        # add neighbors
        for details in entities_details:
            # neighbor
            vertex = self._update_vertex_to_graph(entity_graph, details[0],
                                                  details[1], details[2],
                                                  details[3], details[4], {})
            neighbors.append((vertex, None))

        # get neighbors types
        types = entity_graph.find_neighbor_types(neighbors)
        self.assertEqual(4, len(types))