Merge "graph mock changes"

This commit is contained in:
Zuul 2018-02-21 09:01:37 +00:00 committed by Gerrit Code Review
commit 86f825d6b7
11 changed files with 26 additions and 13 deletions

View File

@ -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):

View File

@ -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"

View File

@ -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
}

View File

@ -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
}

View File

@ -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",

View File

@ -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"
}

View File

@ -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",

View File

@ -1,5 +1,6 @@
{
"vitrage_id": "4bfbde3a-bb30-4c0a-b1e4-83ebfb2ec2ff",
"id": "111",
"vitrage_is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_operational_state": "OK",

View File

@ -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
}

View File

@ -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",

View File

@ -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
}