From 952c5713c829d94cf5c291a6f9b3ba4ee1096e2a Mon Sep 17 00:00:00 2001 From: Idan Hefetz Date: Sun, 11 Feb 2018 14:22:36 +0000 Subject: [PATCH] graph mock changes vertices changed to be more realistic with proper ids and names Depends-On: I8b35d1a9fe92c8a2cdd371aa7f83f173620f476e Change-Id: I7da3d6d306fb0d887e50584b1a6e2462d9fbb792 --- vitrage/tests/mocks/graph_generator.py | 19 ++++++++++++------- .../vertices/cinder.volume.json | 2 +- .../vertices/neutron.network.json | 2 +- .../vertices/neutron.port.json | 2 +- .../vertices/nova.host.json | 1 + .../vertices/nova.instance.json | 2 +- .../vertices/nova.zone.json | 1 + .../vertices/openstack-cluster.json | 1 + .../vertices/tripleo.controller.json | 4 +++- .../vertices/vitrage.alarm.json | 1 + .../mock_configurations/vertices/zabbix.json | 4 +++- 11 files changed, 26 insertions(+), 13 deletions(-) diff --git a/vitrage/tests/mocks/graph_generator.py b/vitrage/tests/mocks/graph_generator.py index 363a85e59..abdb38c03 100644 --- a/vitrage/tests/mocks/graph_generator.py +++ b/vitrage/tests/mocks/graph_generator.py @@ -13,7 +13,10 @@ # under the License. import itertools +from oslo_utils import uuidutils + from vitrage.common.constants import EdgeProperties +from vitrage.common.constants import VertexProperties as VProps from vitrage.graph import Direction from vitrage.graph.driver.networkx_graph import NXGraph from vitrage.graph import Edge @@ -35,7 +38,6 @@ class GraphGenerator(object): num_of_vitrage_alarms_per_instance=2, num_of_tripleo_controllers=2, num_of_zabbix_alarms_per_controller=2): - self.id_counter = 0 self._num_of_networks = num_of_networks self._num_of_zones_per_cluster = num_of_zones_per_cluster self._num_of_hosts_per_zone = num_of_hosts_per_zone @@ -116,7 +118,7 @@ class GraphGenerator(object): def _create_n_vertices(self, g, n, props_file): created_vertices = [] for i in range(n): - v = self._file_to_vertex(props_file) + v = self._file_to_vertex(props_file, i) created_vertices.append(v) g.add_vertex(v) return created_vertices @@ -127,7 +129,8 @@ class GraphGenerator(object): created_vertices = [] for source_v in source_v_list: for i in range(n): - v = self._file_to_vertex(neighbor_props_file) + v = self._file_to_vertex(neighbor_props_file, i) + v[VProps.NAME] = source_v[VProps.NAME] + "-" + v[VProps.NAME] created_vertices.append(v) g.add_vertex(v) if direction == Direction.OUT: @@ -153,12 +156,14 @@ class GraphGenerator(object): source_v.vertex_id, v.vertex_id)) - def _file_to_vertex(self, relative_path): + def _file_to_vertex(self, relative_path, index=0): full_path = RESOURCES_PATH + "/vertices/" props = utils.load_specs(relative_path, full_path) - v = Vertex(str(self.id_counter), props) - self.id_counter += 1 - return v + if props.get(VProps.ID): + props[VProps.ID] = uuidutils.generate_uuid() + props[VProps.NAME] = "%s-%s" % (props[VProps.VITRAGE_TYPE], str(index)) + props[VProps.VITRAGE_ID] = uuidutils.generate_uuid() + return Vertex(props[VProps.VITRAGE_ID], props) @staticmethod def _file_to_edge(relative_path, source_id, target_id): diff --git a/vitrage/tests/resources/mock_configurations/vertices/cinder.volume.json b/vitrage/tests/resources/mock_configurations/vertices/cinder.volume.json index c18821102..0cfe89a1a 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/cinder.volume.json +++ b/vitrage/tests/resources/mock_configurations/vertices/cinder.volume.json @@ -1,5 +1,6 @@ { "vitrage_id": "12b49b03-e754-4728-8214-4ad20ae5b187", + "id": "111", "vitrage_is_deleted": false, "update_timestamp": "2017-11-09T11:18:44.000000", "size": 1, @@ -11,7 +12,6 @@ "vitrage_sample_timestamp": "2017-12-25 09:43:49.905125+00:00", "vitrage_aggregated_state": "IN-USE", "vitrage_is_placeholder": false, - "project_id": "7ff7bcc9c23d48b9afe7de8029981c22", "is_real_vitrage_id": true, "attachments": [ "f96f3054-41fc-4110-a182-336fbb2168fc" diff --git a/vitrage/tests/resources/mock_configurations/vertices/neutron.network.json b/vitrage/tests/resources/mock_configurations/vertices/neutron.network.json index f70edeb35..948dbba94 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/neutron.network.json +++ b/vitrage/tests/resources/mock_configurations/vertices/neutron.network.json @@ -1,5 +1,6 @@ { "vitrage_id": "b951c60e-8815-45b7-900a-052816cc2515", + "id": "111", "name": "private", "update_timestamp": "2017-11-20T13:49:13Z", "vitrage_category": "RESOURCE", @@ -9,7 +10,6 @@ "vitrage_sample_timestamp": "2017-12-25 06:30:24.928811+00:00", "vitrage_aggregated_state": "ACTIVE", "vitrage_is_placeholder": false, - "project_id": "c0879e8fe5084cd89af29514ec4fddfe", "is_real_vitrage_id": true, "vitrage_is_deleted": false } diff --git a/vitrage/tests/resources/mock_configurations/vertices/neutron.port.json b/vitrage/tests/resources/mock_configurations/vertices/neutron.port.json index f7df72a69..832ee1d71 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/neutron.port.json +++ b/vitrage/tests/resources/mock_configurations/vertices/neutron.port.json @@ -1,5 +1,6 @@ { "vitrage_id": "27432eb2-3e09-4e50-b3bf-818075b376ea", + "id": "111", "vitrage_is_deleted": false, "update_timestamp": "2017-11-20T13:49:43Z", "ip_addresses": [ @@ -13,6 +14,5 @@ "host_id": "compute-0-0", "vitrage_aggregated_state": "ACTIVE", "vitrage_is_placeholder": false, - "project_id": "c0879e8fe5084cd89af29514ec4fddfe", "is_real_vitrage_id": true } \ No newline at end of file diff --git a/vitrage/tests/resources/mock_configurations/vertices/nova.host.json b/vitrage/tests/resources/mock_configurations/vertices/nova.host.json index f86b9b891..e6f3bab3f 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/nova.host.json +++ b/vitrage/tests/resources/mock_configurations/vertices/nova.host.json @@ -1,5 +1,6 @@ { "vitrage_id": "e2e5054e-f3bd-49e7-b584-04fb1fbc0e3f", + "id": "111", "vitrage_is_deleted": false, "vitrage_category": "RESOURCE", "vitrage_operational_state": "N/A", diff --git a/vitrage/tests/resources/mock_configurations/vertices/nova.instance.json b/vitrage/tests/resources/mock_configurations/vertices/nova.instance.json index 2da5d2bfb..99349ea55 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/nova.instance.json +++ b/vitrage/tests/resources/mock_configurations/vertices/nova.instance.json @@ -1,5 +1,6 @@ { "vitrage_id": "29f18c8b-1fce-4abb-8e96-4b478e124c59", + "id": "111", "vitrage_state": "SUBOPTIMAL", "vitrage_is_deleted": false, "update_timestamp": "2017-12-25 09:43:49.711469+00:00", @@ -11,7 +12,6 @@ "host_id": "compute-0-0", "vitrage_aggregated_state": "SUBOPTIMAL", "vitrage_is_placeholder": false, - "project_id": "7ff7bcc9c23d48b9afe7de8029981c22", "is_real_vitrage_id": true, "name": "App_2-server_1-esi2oaogigfp" } \ No newline at end of file diff --git a/vitrage/tests/resources/mock_configurations/vertices/nova.zone.json b/vitrage/tests/resources/mock_configurations/vertices/nova.zone.json index 37fe892e6..04780da38 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/nova.zone.json +++ b/vitrage/tests/resources/mock_configurations/vertices/nova.zone.json @@ -1,5 +1,6 @@ { "vitrage_id": "1572855d-1551-4507-b60c-3a16ddc012bf", + "id": "111", "name": "nova", "update_timestamp": "2017-12-24 10:32:41.941967+00:00", "vitrage_category": "RESOURCE", diff --git a/vitrage/tests/resources/mock_configurations/vertices/openstack-cluster.json b/vitrage/tests/resources/mock_configurations/vertices/openstack-cluster.json index e4e8d94b6..40201670f 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/openstack-cluster.json +++ b/vitrage/tests/resources/mock_configurations/vertices/openstack-cluster.json @@ -1,5 +1,6 @@ { "vitrage_id": "4bfbde3a-bb30-4c0a-b1e4-83ebfb2ec2ff", + "id": "111", "vitrage_is_deleted": false, "vitrage_category": "RESOURCE", "vitrage_operational_state": "OK", diff --git a/vitrage/tests/resources/mock_configurations/vertices/tripleo.controller.json b/vitrage/tests/resources/mock_configurations/vertices/tripleo.controller.json index 6a8bbd1a6..b8de4956f 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/tripleo.controller.json +++ b/vitrage/tests/resources/mock_configurations/vertices/tripleo.controller.json @@ -1,5 +1,6 @@ { "vitrage_id": "2396b5bb-b00b-4d6d-b842-6debb3ba8091", + "id": "111", "name": "overcloud-controller-0.localdomain", "update_timestamp": "2017-12-25 09:33:05.073194+00:00", "vitrage_category": "RESOURCE", @@ -9,5 +10,6 @@ "vitrage_sample_timestamp": "2017-12-25 09:33:05.073194+00:00", "vitrage_aggregated_state": "ACTIVE", "vitrage_is_placeholder": false, - "vitrage_is_deleted": false + "vitrage_is_deleted": false, + "is_real_vitrage_id": true } \ No newline at end of file diff --git a/vitrage/tests/resources/mock_configurations/vertices/vitrage.alarm.json b/vitrage/tests/resources/mock_configurations/vertices/vitrage.alarm.json index 59bb7c971..11301f356 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/vitrage.alarm.json +++ b/vitrage/tests/resources/mock_configurations/vertices/vitrage.alarm.json @@ -1,5 +1,6 @@ { "vitrage_id": "98fab0f9-72b7-4362-a16c-1b19d72505c4", + "id": "111", "vitrage_is_deleted": false, "update_timestamp": "2017-12-24T10:32:49Z", "resource_id": "2507553d-1738-4711-938f-19a47181bfc1", diff --git a/vitrage/tests/resources/mock_configurations/vertices/zabbix.json b/vitrage/tests/resources/mock_configurations/vertices/zabbix.json index 19e6b7d8b..7605d4970 100644 --- a/vitrage/tests/resources/mock_configurations/vertices/zabbix.json +++ b/vitrage/tests/resources/mock_configurations/vertices/zabbix.json @@ -1,6 +1,7 @@ { "rawtext": "Component etcd-1 is not in Healthy state", "vitrage_id": "a508142a-b0c6-4880-8b05-38d252b0d840", + "id": "111", "name": "Component etcd-1 is not in Healthy state", "update_timestamp": "2017-12-24T10:32:43Z", "resource_id": "k8s", @@ -14,5 +15,6 @@ "vitrage_aggregated_severity": "WARNING", "vitrage_resource_id": "932d6f9a-dfc4-4a32-9e7a-1fb16a68d3af", "vitrage_resource_type": "kubernetes_cluster", - "severity": "WARNING" + "severity": "WARNING", + "is_real_vitrage_id": true } \ No newline at end of file