Example #1
0
    def _create_cluster_neighbor(zone_vertex_id):

        cluster_vertex = tbase.create_cluster_placeholder_vertex()

        relation_edge = graph_utils.create_edge(
            source_id=cluster_vertex.vertex_id,
            target_id=zone_vertex_id,
            relationship_type=EdgeLabel.CONTAINS)
        return tbase.Neighbor(cluster_vertex, relation_edge)
Example #2
0
    def _create_cluster_neighbor(zone_vertex_id):

        cluster_vertex = tbase.create_cluster_placeholder_vertex()

        relation_edge = graph_utils.create_edge(
            source_id=cluster_vertex.vertex_id,
            target_id=zone_vertex_id,
            relationship_type=EdgeLabel.CONTAINS)
        return tbase.Neighbor(cluster_vertex, relation_edge)
    def _validate_cluster_neighbor(self, cluster_neighbor, zone_vertex_id):

        expected_cluster_neighbor = tbase.create_cluster_placeholder_vertex()
        self.assertEqual(expected_cluster_neighbor, cluster_neighbor.vertex)

        # Validate neighbor edge
        edge = cluster_neighbor.edge
        self.assertEqual(edge.source_id, cluster_neighbor.vertex.vertex_id)
        self.assertEqual(edge.target_id, zone_vertex_id)
        self.assertEqual(edge.label, EdgeLabel.CONTAINS)
Example #4
0
    def _validate_cluster_neighbor(self, cluster_neighbor, zone_vertex_id):

        expected_cluster_neighbor = tbase.create_cluster_placeholder_vertex()
        self.assertEqual(expected_cluster_neighbor, cluster_neighbor.vertex)

        # Validate neighbor edge
        edge = cluster_neighbor.edge
        self.assertEqual(edge.source_id, cluster_neighbor.vertex.vertex_id)
        self.assertEqual(edge.target_id, zone_vertex_id)
        self.assertEqual(edge.label, EdgeLabels.CONTAINS)
Example #5
0
    def _topology_for_unrooted_graph(self, ga, subgraph, root):
        """Finds topology for unrooted subgraph

        1. Finds all the connected component subgraphs in subgraph.
        2. For each component, finds the path from one of the VMs (if exists)
           to the root entity.
        3. Unify all the entities found and return them

        :type ga: NXAlgorithm
        :type subgraph: networkx graph
        :type root: string
        :rtype: list
        """

        entities = []

        if root:
            root_vertex = \
                self.entity_graph.get_vertex(root)
        else:
            key_values_hash = processor_utils.get_defining_properties(
                create_cluster_placeholder_vertex())
            tmp_vertices = self.entity_graph.get_vertices_by_key(
                key_values_hash)
            if not tmp_vertices:
                LOG.debug("No root vertex found")
                return set(entities)
            root_vertex = tmp_vertices[0]

        local_connected_component_subgraphs = \
            ga.connected_component_subgraphs(subgraph)

        for component_subgraph in local_connected_component_subgraphs:
            entities += component_subgraph.nodes()
            instance_in_component_subgraph = \
                self._find_instance_in_graph(component_subgraph)
            if instance_in_component_subgraph:
                paths = ga.all_simple_paths(root_vertex.vertex_id,
                                            instance_in_component_subgraph)
                for path in paths:
                    entities += path

        return set(entities)
Example #6
0
    def _create_graph(self):
        graph = NXGraph('Multi tenancy graph')
        self._add_alarm_persistency_subscription(graph)

        # create vertices
        cluster_vertex = create_cluster_placeholder_vertex()
        zone_vertex = self._create_resource('zone_1', NOVA_ZONE_DATASOURCE)
        host_vertex = self._create_resource('host_1', NOVA_HOST_DATASOURCE)
        instance_1_vertex = self._create_resource('instance_1',
                                                  NOVA_INSTANCE_DATASOURCE,
                                                  project_id='project_1')
        instance_2_vertex = self._create_resource('instance_2',
                                                  NOVA_INSTANCE_DATASOURCE,
                                                  project_id='project_1')
        instance_3_vertex = self._create_resource('instance_3',
                                                  NOVA_INSTANCE_DATASOURCE,
                                                  project_id='project_2')
        instance_4_vertex = self._create_resource('instance_4',
                                                  NOVA_INSTANCE_DATASOURCE,
                                                  project_id='project_2')
        alarm_on_host_vertex = self._create_alarm(
            'alarm_on_host',
            'alarm_on_host',
            metadata={
                VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE,
                VProps.NAME: 'host_1',
                VProps.RESOURCE_ID: 'host_1',
                VProps.VITRAGE_OPERATIONAL_SEVERITY:
                OperationalAlarmSeverity.SEVERE,
                VProps.VITRAGE_AGGREGATED_SEVERITY:
                OperationalAlarmSeverity.SEVERE
            })
        alarm_on_instance_1_vertex = self._create_alarm(
            'alarm_on_instance_1',
            'deduced_alarm',
            project_id='project_1',
            vitrage_resource_project_id='project_1',
            metadata={
                VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
                VProps.NAME: 'instance_1',
                VProps.RESOURCE_ID: 'sdg7849ythksjdg',
                VProps.VITRAGE_OPERATIONAL_SEVERITY:
                OperationalAlarmSeverity.SEVERE,
                VProps.VITRAGE_AGGREGATED_SEVERITY:
                OperationalAlarmSeverity.SEVERE
            })
        alarm_on_instance_2_vertex = self._create_alarm(
            'alarm_on_instance_2',
            'deduced_alarm',
            vitrage_resource_project_id='project_1',
            metadata={
                VProps.VITRAGE_TYPE:
                NOVA_INSTANCE_DATASOURCE,
                VProps.NAME:
                'instance_2',
                VProps.RESOURCE_ID:
                'nbfhsdugf',
                VProps.VITRAGE_OPERATIONAL_SEVERITY:
                OperationalAlarmSeverity.WARNING,
                VProps.VITRAGE_AGGREGATED_SEVERITY:
                OperationalAlarmSeverity.WARNING
            })
        alarm_on_instance_3_vertex = self._create_alarm(
            'alarm_on_instance_3',
            'deduced_alarm',
            project_id='project_2',
            vitrage_resource_project_id='project_2',
            metadata={
                VProps.VITRAGE_TYPE:
                NOVA_INSTANCE_DATASOURCE,
                VProps.NAME:
                'instance_3',
                VProps.RESOURCE_ID:
                'nbffhsdasdugf',
                VProps.VITRAGE_OPERATIONAL_SEVERITY:
                OperationalAlarmSeverity.CRITICAL,
                VProps.VITRAGE_AGGREGATED_SEVERITY:
                OperationalAlarmSeverity.CRITICAL
            })
        alarm_on_instance_4_vertex = self._create_alarm(
            'alarm_on_instance_4',
            'deduced_alarm',
            vitrage_resource_project_id='project_2',
            metadata={
                VProps.VITRAGE_TYPE:
                NOVA_INSTANCE_DATASOURCE,
                VProps.NAME:
                'instance_4',
                VProps.RESOURCE_ID:
                'ngsuy76hgd87f',
                VProps.VITRAGE_OPERATIONAL_SEVERITY:
                OperationalAlarmSeverity.WARNING,
                VProps.VITRAGE_AGGREGATED_SEVERITY:
                OperationalAlarmSeverity.WARNING
            })

        # create links
        edges = list()
        edges.append(
            graph_utils.create_edge(cluster_vertex.vertex_id,
                                    zone_vertex.vertex_id,
                                    EdgeLabel.CONTAINS,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(zone_vertex.vertex_id,
                                    host_vertex.vertex_id,
                                    EdgeLabel.CONTAINS,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(host_vertex.vertex_id,
                                    instance_1_vertex.vertex_id,
                                    EdgeLabel.CONTAINS,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(host_vertex.vertex_id,
                                    instance_2_vertex.vertex_id,
                                    EdgeLabel.CONTAINS,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(host_vertex.vertex_id,
                                    instance_3_vertex.vertex_id,
                                    EdgeLabel.CONTAINS,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(host_vertex.vertex_id,
                                    instance_4_vertex.vertex_id,
                                    EdgeLabel.CONTAINS,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(alarm_on_host_vertex.vertex_id,
                                    host_vertex.vertex_id,
                                    EdgeLabel.ON,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(alarm_on_instance_1_vertex.vertex_id,
                                    instance_1_vertex.vertex_id,
                                    EdgeLabel.ON,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(alarm_on_instance_2_vertex.vertex_id,
                                    instance_2_vertex.vertex_id,
                                    EdgeLabel.ON,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(alarm_on_instance_3_vertex.vertex_id,
                                    instance_3_vertex.vertex_id,
                                    EdgeLabel.ON,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(alarm_on_instance_4_vertex.vertex_id,
                                    instance_4_vertex.vertex_id,
                                    EdgeLabel.ON,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(alarm_on_host_vertex.vertex_id,
                                    alarm_on_instance_1_vertex.vertex_id,
                                    EdgeLabel.CAUSES,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(alarm_on_host_vertex.vertex_id,
                                    alarm_on_instance_2_vertex.vertex_id,
                                    EdgeLabel.CAUSES,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(alarm_on_host_vertex.vertex_id,
                                    alarm_on_instance_3_vertex.vertex_id,
                                    EdgeLabel.CAUSES,
                                    update_timestamp=str(utcnow())))
        edges.append(
            graph_utils.create_edge(alarm_on_host_vertex.vertex_id,
                                    alarm_on_instance_4_vertex.vertex_id,
                                    EdgeLabel.CAUSES,
                                    update_timestamp=str(utcnow())))

        # add vertices to graph
        graph.add_vertex(cluster_vertex)
        graph.add_vertex(zone_vertex)
        graph.add_vertex(host_vertex)
        graph.add_vertex(instance_1_vertex)
        graph.add_vertex(instance_2_vertex)
        graph.add_vertex(instance_3_vertex)
        graph.add_vertex(instance_4_vertex)
        graph.add_vertex(alarm_on_host_vertex)
        graph.add_vertex(alarm_on_instance_1_vertex)
        graph.add_vertex(alarm_on_instance_2_vertex)
        graph.add_vertex(alarm_on_instance_3_vertex)
        graph.add_vertex(alarm_on_instance_4_vertex)

        # add links to graph
        for edge in edges:
            graph.add_edge(edge)

        return graph
Example #7
0
    def _create_graph(self):
        graph = NXGraph('Multi tenancy graph', uuid=True)

        # create vertices
        cluster_vertex = create_cluster_placeholder_vertex()
        zone_vertex = self._create_resource('zone_1',
                                            NOVA_ZONE_DATASOURCE)
        host_vertex = self._create_resource('host_1',
                                            NOVA_HOST_DATASOURCE)
        instance_1_vertex = self._create_resource('instance_1',
                                                  NOVA_INSTANCE_DATASOURCE,
                                                  project_id='project_1')
        instance_2_vertex = self._create_resource('instance_2',
                                                  NOVA_INSTANCE_DATASOURCE,
                                                  project_id='project_1')
        instance_3_vertex = self._create_resource('instance_3',
                                                  NOVA_INSTANCE_DATASOURCE,
                                                  project_id='project_2')
        instance_4_vertex = self._create_resource('instance_4',
                                                  NOVA_INSTANCE_DATASOURCE,
                                                  project_id='project_2')
        alarm_on_host_vertex = self._create_alarm(
            'alarm_on_host',
            'alarm_on_host',
            metadata={'type': 'nova.host',
                      'name': 'host_1',
                      'resource_id': 'host_1'})
        alarm_on_instance_1_vertex = self._create_alarm(
            'alarm_on_instance_1',
            'deduced_alarm',
            project_id='project_1',
            metadata={'type': 'nova.instance',
                      'name': 'instance_1',
                      'resource_id': 'sdg7849ythksjdg'})
        alarm_on_instance_2_vertex = self._create_alarm(
            'alarm_on_instance_2',
            'deduced_alarm',
            metadata={'type': 'nova.instance',
                      'name': 'instance_2',
                      'resource_id': 'nbfhsdugf'})
        alarm_on_instance_3_vertex = self._create_alarm(
            'alarm_on_instance_3',
            'deduced_alarm',
            project_id='project_2',
            metadata={'type': 'nova.instance',
                      'name': 'instance_3',
                      'resource_id': 'nbffhsdasdugf'})
        alarm_on_instance_4_vertex = self._create_alarm(
            'alarm_on_instance_4',
            'deduced_alarm',
            metadata={'type': 'nova.instance',
                      'name': 'instance_4',
                      'resource_id': 'ngsuy76hgd87f'})

        # create links
        edges = list()
        edges.append(graph_utils.create_edge(
            cluster_vertex.vertex_id,
            zone_vertex.vertex_id,
            'contains'))
        edges.append(graph_utils.create_edge(
            zone_vertex.vertex_id,
            host_vertex.vertex_id,
            'contains'))
        edges.append(graph_utils.create_edge(
            host_vertex.vertex_id,
            instance_1_vertex.vertex_id,
            'contains'))
        edges.append(graph_utils.create_edge(
            host_vertex.vertex_id,
            instance_2_vertex.vertex_id,
            'contains'))
        edges.append(graph_utils.create_edge(
            host_vertex.vertex_id,
            instance_3_vertex.vertex_id,
            'contains'))
        edges.append(graph_utils.create_edge(
            host_vertex.vertex_id,
            instance_4_vertex.vertex_id,
            'contains'))
        edges.append(graph_utils.create_edge(
            alarm_on_host_vertex.vertex_id,
            host_vertex.vertex_id,
            'on'))
        edges.append(graph_utils.create_edge(
            alarm_on_instance_1_vertex.vertex_id,
            instance_1_vertex.vertex_id,
            'on'))
        edges.append(graph_utils.create_edge(
            alarm_on_instance_2_vertex.vertex_id,
            instance_2_vertex.vertex_id,
            'on'))
        edges.append(graph_utils.create_edge(
            alarm_on_instance_3_vertex.vertex_id,
            instance_3_vertex.vertex_id,
            'on'))
        edges.append(graph_utils.create_edge(
            alarm_on_instance_4_vertex.vertex_id,
            instance_4_vertex.vertex_id,
            'on'))
        edges.append(graph_utils.create_edge(
            alarm_on_host_vertex.vertex_id,
            alarm_on_instance_1_vertex.vertex_id,
            'causes'))
        edges.append(graph_utils.create_edge(
            alarm_on_host_vertex.vertex_id,
            alarm_on_instance_2_vertex.vertex_id,
            'causes'))
        edges.append(graph_utils.create_edge(
            alarm_on_host_vertex.vertex_id,
            alarm_on_instance_3_vertex.vertex_id,
            'causes'))
        edges.append(graph_utils.create_edge(
            alarm_on_host_vertex.vertex_id,
            alarm_on_instance_4_vertex.vertex_id,
            'causes'))

        # add vertices to graph
        graph.add_vertex(cluster_vertex)
        graph.add_vertex(zone_vertex)
        graph.add_vertex(host_vertex)
        graph.add_vertex(instance_1_vertex)
        graph.add_vertex(instance_2_vertex)
        graph.add_vertex(instance_3_vertex)
        graph.add_vertex(instance_4_vertex)
        graph.add_vertex(alarm_on_host_vertex)
        graph.add_vertex(alarm_on_instance_1_vertex)
        graph.add_vertex(alarm_on_instance_2_vertex)
        graph.add_vertex(alarm_on_instance_3_vertex)
        graph.add_vertex(alarm_on_instance_4_vertex)

        # add links to graph
        for edge in edges:
            graph.add_edge(edge)

        return graph