Cosmetic changes

Change-Id: If8f1b2da42ccd7851be92c418191bd4a920c2412
This commit is contained in:
Alexey Weyl 2016-04-12 11:45:58 +03:00
parent 4ba74f4689
commit 03fc7d1fe7
28 changed files with 93 additions and 92 deletions

View File

@ -102,7 +102,7 @@ Response Examples
Get topology Get topology
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
Get the topology for the node. Get the topology for the cluster.
Its possible to filter the edges vertices and depth of the Its possible to filter the edges vertices and depth of the
graph graph
@ -463,10 +463,10 @@ Response Examples
"category": "RESOURCE", "category": "RESOURCE",
"is_placeholder": false, "is_placeholder": false,
"is_deleted": false, "is_deleted": false,
"name": "openstack.node", "name": "openstack.cluster",
"type": "openstack.node", "type": "openstack.cluster",
"id": "openstack.node", "id": "openstack.cluster",
"vitrage_id": "RESOURCE:openstack.node" "vitrage_id": "RESOURCE:openstack.cluster"
} }
], ],
"links": [ "links": [

View File

@ -273,10 +273,10 @@
"category": "RESOURCE", "category": "RESOURCE",
"is_placeholder": false, "is_placeholder": false,
"is_deleted": false, "is_deleted": false,
"name": "openstack.node", "name": "openstack.cluster",
"type": "openstack.node", "type": "openstack.cluster",
"id": "openstack.node", "id": "openstack.cluster",
"vitrage_id": "RESOURCE:openstack.node", "vitrage_id": "RESOURCE:openstack.cluster",
"state": "available", "state": "available",
"aggregated_state": "RUNNING" "aggregated_state": "RUNNING"
} }

View File

@ -20,7 +20,7 @@ import pecan as pecan
from pecan import abort from pecan import abort
from pecan import rest from pecan import rest
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_CLUSTER
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -28,7 +28,7 @@ LOG = log.getLogger(__name__)
class RootRestController(rest.RestController): class RootRestController(rest.RestController):
@staticmethod @staticmethod
def as_tree(graph, root=OPENSTACK_NODE, reverse=False): def as_tree(graph, root=OPENSTACK_CLUSTER, reverse=False):
linked_graph = json_graph.node_link_graph(graph) linked_graph = json_graph.node_link_graph(graph)
if reverse: if reverse:
linked_graph = linked_graph.reverse() linked_graph = linked_graph.reverse()

View File

@ -20,7 +20,7 @@ from oslo_service import service as os_service
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.datasources import launcher as datasource_launcher from vitrage.datasources import launcher as datasource_launcher
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_CLUSTER
from vitrage.entity_graph.api_handler import service as api_handler_svc from vitrage.entity_graph.api_handler import service as api_handler_svc
from vitrage.entity_graph.consistency import service as consistency_svc from vitrage.entity_graph.consistency import service as consistency_svc
from vitrage.entity_graph.initialization_status import InitializationStatus from vitrage.entity_graph.initialization_status import InitializationStatus
@ -65,7 +65,7 @@ def init():
event_queue = multiprocessing.Queue() event_queue = multiprocessing.Queue()
e_graph = entity_graph.EntityGraph( e_graph = entity_graph.EntityGraph(
'Entity Graph', 'Entity Graph',
'%s:%s' % (EntityCategory.RESOURCE, OPENSTACK_NODE)) '%s:%s' % (EntityCategory.RESOURCE, OPENSTACK_CLUSTER))
scenario_repo = ScenarioRepository(conf) scenario_repo = ScenarioRepository(conf)
evaluator = ScenarioEvaluator(conf, e_graph, scenario_repo, event_queue) evaluator = ScenarioEvaluator(conf, e_graph, scenario_repo, event_queue)
initialization_status = InitializationStatus() initialization_status = InitializationStatus()

View File

@ -23,7 +23,7 @@ from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
OPENSTACK_NODE = 'openstack.node' OPENSTACK_CLUSTER = 'openstack.cluster'
# Register options for the service # Register options for the service
OPTS = [ OPTS = [

View File

@ -76,7 +76,7 @@ class ZoneTransformer(ResourceTransformerBase):
def _create_neighbors(self, entity_event): def _create_neighbors(self, entity_event):
zone_vertex_id = self._create_entity_key(entity_event) zone_vertex_id = self._create_entity_key(entity_event)
neighbors = [self._create_node_neighbor(zone_vertex_id)] neighbors = [self._create_cluster_neighbor(zone_vertex_id)]
hosts = extract_field_value(entity_event, 'hosts') hosts = extract_field_value(entity_event, 'hosts')
host_transformer = self.transformers[NOVA_HOST_DATASOURCE] host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
@ -107,15 +107,15 @@ class ZoneTransformer(ResourceTransformerBase):
return neighbors return neighbors
@staticmethod @staticmethod
def _create_node_neighbor(zone_vertex_id): def _create_cluster_neighbor(zone_vertex_id):
node_vertex = tbase.create_node_placeholder_vertex() cluster_vertex = tbase.create_cluster_placeholder_vertex()
relation_edge = graph_utils.create_edge( relation_edge = graph_utils.create_edge(
source_id=node_vertex.vertex_id, source_id=cluster_vertex.vertex_id,
target_id=zone_vertex_id, target_id=zone_vertex_id,
relationship_type=EdgeLabels.CONTAINS) relationship_type=EdgeLabels.CONTAINS)
return tbase.Neighbor(node_vertex, relation_edge) return tbase.Neighbor(cluster_vertex, relation_edge)
def _create_host_neighbor(self, zone_id, host_name, def _create_host_neighbor(self, zone_id, host_name,
host_state, sample_timestamp): host_state, sample_timestamp):

View File

@ -25,7 +25,7 @@ from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode from vitrage.common.constants import SyncMode
from vitrage.common.exception import VitrageTransformerError from vitrage.common.exception import VitrageTransformerError
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_CLUSTER
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -55,19 +55,19 @@ def build_key(key_values):
return TransformerBase.KEY_SEPARATOR.join(map(str, key_values)) return TransformerBase.KEY_SEPARATOR.join(map(str, key_values))
def create_node_placeholder_vertex(): def create_cluster_placeholder_vertex():
key = build_key([cons.EntityCategory.RESOURCE, key = build_key([cons.EntityCategory.RESOURCE,
OPENSTACK_NODE]) OPENSTACK_CLUSTER])
metadata = { metadata = {
cons.VertexProperties.NAME: OPENSTACK_NODE cons.VertexProperties.NAME: OPENSTACK_CLUSTER
} }
return graph_utils.create_vertex( return graph_utils.create_vertex(
key, key,
entity_id=OPENSTACK_NODE, entity_id=OPENSTACK_CLUSTER,
entity_category=cons.EntityCategory.RESOURCE, entity_category=cons.EntityCategory.RESOURCE,
entity_type=OPENSTACK_NODE, entity_type=OPENSTACK_CLUSTER,
entity_state=AVAILABLE, entity_state=AVAILABLE,
metadata=metadata metadata=metadata
) )

View File

@ -22,7 +22,7 @@ from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_CLUSTER
from vitrage.graph import create_algorithm from vitrage.graph import create_algorithm
from vitrage.graph import Direction from vitrage.graph import Direction
@ -36,7 +36,7 @@ TREE_TOPOLOGY_QUERY = {
{'==': {VProps.IS_PLACEHOLDER: False}}, {'==': {VProps.IS_PLACEHOLDER: False}},
{ {
'or': [ 'or': [
{'==': {VProps.TYPE: OPENSTACK_NODE}}, {'==': {VProps.TYPE: OPENSTACK_CLUSTER}},
{'==': {VProps.TYPE: NOVA_INSTANCE_DATASOURCE}}, {'==': {VProps.TYPE: NOVA_INSTANCE_DATASOURCE}},
{'==': {VProps.TYPE: NOVA_HOST_DATASOURCE}}, {'==': {VProps.TYPE: NOVA_HOST_DATASOURCE}},
{'==': {VProps.TYPE: NOVA_ZONE_DATASOURCE}} {'==': {VProps.TYPE: NOVA_ZONE_DATASOURCE}}

View File

@ -20,7 +20,7 @@ from oslo_log import log
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common.datetime_utils import utcnow from vitrage.common.datetime_utils import utcnow
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_CLUSTER
from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -152,7 +152,7 @@ class ConsistencyEnforcer(object):
return filter( return filter(
lambda ver: lambda ver:
not (ver[VProps.CATEGORY] == EntityCategory.RESOURCE and not (ver[VProps.CATEGORY] == EntityCategory.RESOURCE and
ver[VProps.TYPE] == OPENSTACK_NODE), vertices) ver[VProps.TYPE] == OPENSTACK_CLUSTER), vertices)
def _wait_for_action(self, function): def _wait_for_action(self, function):
count_retries = 0 count_retries = 0

View File

@ -116,7 +116,8 @@ def simple_zone_generators(zone_num, snapshot_events=0, snap_vals=None):
:return: generators for vm_num vms as specified :return: generators for vm_num vms as specified
""" """
mapping = [('zone-{0}'.format(ind), 'node-0') for ind in range(zone_num)] mapping = [('zone-{0}'.format(ind), 'cluster-0')
for ind in range(zone_num)]
test_entity_spec_list = [ test_entity_spec_list = [
{tg.DYNAMIC_INFO_FKEY: tg.TRANS_ZONE_SNAPSHOT_D, {tg.DYNAMIC_INFO_FKEY: tg.TRANS_ZONE_SNAPSHOT_D,

View File

@ -450,12 +450,12 @@ def _get_trans_zone_snapshot_values(spec):
:rtype: list :rtype: list
""" """
zone_node_mapping = spec[MAPPING_KEY] zone_cluster_mapping = spec[MAPPING_KEY]
static_info_re = None static_info_re = None
if spec[STATIC_INFO_FKEY] is not None: if spec[STATIC_INFO_FKEY] is not None:
static_info_re = utils.load_specs(spec[STATIC_INFO_FKEY]) static_info_re = utils.load_specs(spec[STATIC_INFO_FKEY])
static_values = [] static_values = []
for zone_name, node_name in zone_node_mapping: for zone_name, cluster_name in zone_cluster_mapping:
mapping = {'name': zone_name, mapping = {'name': zone_name,
'id': zone_name} 'id': zone_name}
static_values.append(combine_data( static_values.append(combine_data(

View File

@ -24,7 +24,7 @@ from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.host.transformer import HostTransformer from vitrage.datasources.nova.host.transformer import HostTransformer
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
from vitrage.datasources.nova.zone.transformer import ZoneTransformer from vitrage.datasources.nova.zone.transformer import ZoneTransformer
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_CLUSTER
from vitrage.datasources import transformer_base as tbase from vitrage.datasources import transformer_base as tbase
from vitrage.datasources.transformer_base import TransformerBase from vitrage.datasources.transformer_base import TransformerBase
from vitrage.tests import base from vitrage.tests import base
@ -130,14 +130,14 @@ class NovaZoneTransformerTest(base.BaseTest):
def _validate_neighbors(self, neighbors, zone_vertex_id, event): def _validate_neighbors(self, neighbors, zone_vertex_id, event):
node_neighbors_counter = 0 cluster_neighbors_counter = 0
for neighbor in neighbors: for neighbor in neighbors:
vertex_type = neighbor.vertex.get(VertexProperties.TYPE) vertex_type = neighbor.vertex.get(VertexProperties.TYPE)
if OPENSTACK_NODE == vertex_type: if OPENSTACK_CLUSTER == vertex_type:
node_neighbors_counter += 1 cluster_neighbors_counter += 1
self._validate_node_neighbor(neighbor, zone_vertex_id) self._validate_cluster_neighbor(neighbor, zone_vertex_id)
else: else:
hosts = tbase.extract_field_value(event, 'hosts') hosts = tbase.extract_field_value(event, 'hosts')
self._validate_host_neighbor(neighbor, self._validate_host_neighbor(neighbor,
@ -146,8 +146,8 @@ class NovaZoneTransformerTest(base.BaseTest):
event[DSProps.SYNC_MODE]) event[DSProps.SYNC_MODE])
self.assertEqual(1, self.assertEqual(1,
node_neighbors_counter, cluster_neighbors_counter,
'Zone can belongs to only one Node') 'Zone can belongs to only one Cluster')
def _validate_host_neighbor(self, def _validate_host_neighbor(self,
host_neighbor, host_neighbor,
@ -191,14 +191,14 @@ class NovaZoneTransformerTest(base.BaseTest):
self.assertEqual(edge.source_id, zone_vertex_id) self.assertEqual(edge.source_id, zone_vertex_id)
self.assertEqual(edge.label, EdgeLabels.CONTAINS) self.assertEqual(edge.label, EdgeLabels.CONTAINS)
def _validate_node_neighbor(self, node_neighbor, zone_vertex_id): def _validate_cluster_neighbor(self, cluster_neighbor, zone_vertex_id):
expected_node_neighbor = tbase.create_node_placeholder_vertex() expected_cluster_neighbor = tbase.create_cluster_placeholder_vertex()
self.assertEqual(expected_node_neighbor, node_neighbor.vertex) self.assertEqual(expected_cluster_neighbor, cluster_neighbor.vertex)
# Validate neighbor edge # Validate neighbor edge
edge = node_neighbor.edge edge = cluster_neighbor.edge
self.assertEqual(edge.source_id, node_neighbor.vertex.vertex_id) self.assertEqual(edge.source_id, cluster_neighbor.vertex.vertex_id)
self.assertEqual(edge.target_id, zone_vertex_id) self.assertEqual(edge.target_id, zone_vertex_id)
self.assertEqual(edge.label, EdgeLabels.CONTAINS) self.assertEqual(edge.label, EdgeLabels.CONTAINS)

View File

@ -144,7 +144,7 @@ class TestStaticPhysicalTransformer(base.BaseTest):
self.assertEqual(5, self.assertEqual(5,
host_counter, host_counter,
'Zone can belongs to only one Node') 'Zone can belongs to only one Cluster')
def _validate_host_neighbor(self, def _validate_host_neighbor(self,
host_neighbor, host_neighbor,

View File

@ -55,7 +55,7 @@ class TestEntityGraphUnitBase(base.BaseTest):
min=1) min=1)
] ]
NUM_NODES = 1 NUM_CLUSTERS = 1
NUM_ZONES = 2 NUM_ZONES = 2
NUM_HOSTS = 4 NUM_HOSTS = 4
NUM_INSTANCES = 16 NUM_INSTANCES = 16
@ -147,9 +147,9 @@ class TestEntityGraphUnitBase(base.BaseTest):
) )
def _num_total_expected_vertices(self): def _num_total_expected_vertices(self):
return self.NUM_NODES + self.NUM_ZONES + self.NUM_HOSTS + \ return self.NUM_CLUSTERS + self.NUM_ZONES + self.NUM_HOSTS + \
self.NUM_INSTANCES self.NUM_INSTANCES
def _num_total_expected_edges(self): def _num_total_expected_edges(self):
return self.NUM_NODES + self.NUM_ZONES + self.NUM_HOSTS + \ return self.NUM_CLUSTERS + self.NUM_ZONES + self.NUM_HOSTS + \
self.NUM_INSTANCES - 1 self.NUM_INSTANCES - 1

View File

@ -28,7 +28,7 @@ from vitrage.common.constants import EdgeLabels as ELabel
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_CLUSTER
from vitrage.datasources.static_physical import SWITCH from vitrage.datasources.static_physical import SWITCH
from vitrage.graph import create_graph from vitrage.graph import create_graph
from vitrage.graph import utils as graph_utils from vitrage.graph import utils as graph_utils
@ -36,7 +36,7 @@ from vitrage.tests import base
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
ENTITY_GRAPH_HOSTS_PER_NODE = 8 ENTITY_GRAPH_HOSTS_PER_CLUSTER = 8
ENTITY_GRAPH_VMS_PER_HOST = 8 ENTITY_GRAPH_VMS_PER_HOST = 8
ENTITY_GRAPH_ALARMS_PER_HOST = 8 ENTITY_GRAPH_ALARMS_PER_HOST = 8
ENTITY_GRAPH_TESTS_PER_HOST = 20 ENTITY_GRAPH_TESTS_PER_HOST = 20
@ -51,9 +51,9 @@ ALARM_ON_HOST = 'ALARM_ON_HOST'
TEST_ON_HOST = 'TEST_ON_HOST' TEST_ON_HOST = 'TEST_ON_HOST'
v_node = graph_utils.create_vertex( v_node = graph_utils.create_vertex(
vitrage_id=EntityCategory.RESOURCE + ':' + OPENSTACK_NODE, vitrage_id=EntityCategory.RESOURCE + ':' + OPENSTACK_CLUSTER,
entity_id='111111111111', entity_id='111111111111',
entity_type=OPENSTACK_NODE, entity_type=OPENSTACK_CLUSTER,
entity_category=RESOURCE) entity_category=RESOURCE)
v_host = graph_utils.create_vertex( v_host = graph_utils.create_vertex(
vitrage_id=NOVA_HOST_DATASOURCE + '222222222222', vitrage_id=NOVA_HOST_DATASOURCE + '222222222222',
@ -123,7 +123,7 @@ class GraphTestBase(base.BaseTest):
self.host_test_id = 40000000 self.host_test_id = 40000000
self.entity_graph = self._create_entity_graph( self.entity_graph = self._create_entity_graph(
'entity_graph', 'entity_graph',
num_of_hosts_per_node=ENTITY_GRAPH_HOSTS_PER_NODE, num_of_hosts_per_node=ENTITY_GRAPH_HOSTS_PER_CLUSTER,
num_of_vms_per_host=ENTITY_GRAPH_VMS_PER_HOST, num_of_vms_per_host=ENTITY_GRAPH_VMS_PER_HOST,
num_of_alarms_per_host=ENTITY_GRAPH_ALARMS_PER_HOST, num_of_alarms_per_host=ENTITY_GRAPH_ALARMS_PER_HOST,
num_of_alarms_per_vm=ENTITY_GRAPH_ALARMS_PER_VM, num_of_alarms_per_vm=ENTITY_GRAPH_ALARMS_PER_VM,
@ -141,7 +141,7 @@ class GraphTestBase(base.BaseTest):
start = time.time() start = time.time()
g = create_graph(name, EntityCategory.RESOURCE + ':' + g = create_graph(name, EntityCategory.RESOURCE + ':' +
OPENSTACK_NODE) OPENSTACK_CLUSTER)
g.add_vertex(v_node) g.add_vertex(v_node)
g.add_vertex(v_switch) g.add_vertex(v_switch)
g.add_edge(e_node_to_switch) g.add_edge(e_node_to_switch)

View File

@ -372,20 +372,20 @@ class GraphTest(GraphTestBase):
'get_vertices __len__ all vertices') 'get_vertices __len__ all vertices')
node_vertices = g.get_vertices( node_vertices = g.get_vertices(
vertex_attr_filter={VProps.TYPE: OPENSTACK_NODE}) vertex_attr_filter={VProps.TYPE: OPENSTACK_CLUSTER})
self.assertEqual(1, len(node_vertices), self.assertEqual(1, len(node_vertices),
'get_vertices __len__ node vertices') 'get_vertices __len__ node vertices')
found_vertex = node_vertices.pop() found_vertex = node_vertices.pop()
self.assertEqual(OPENSTACK_NODE, found_vertex[VProps.TYPE], self.assertEqual(OPENSTACK_CLUSTER, found_vertex[VProps.TYPE],
'get_vertices check node vertex') 'get_vertices check node vertex')
node_vertices = g.get_vertices( node_vertices = g.get_vertices(
vertex_attr_filter={VProps.TYPE: OPENSTACK_NODE, vertex_attr_filter={VProps.TYPE: OPENSTACK_CLUSTER,
VProps.CATEGORY: RESOURCE}) VProps.CATEGORY: RESOURCE})
self.assertEqual(1, len(node_vertices), self.assertEqual(1, len(node_vertices),
'get_vertices __len__ node vertices') 'get_vertices __len__ node vertices')
found_vertex = node_vertices.pop() found_vertex = node_vertices.pop()
self.assertEqual(OPENSTACK_NODE, found_vertex[VProps.TYPE], self.assertEqual(OPENSTACK_CLUSTER, found_vertex[VProps.TYPE],
'get_vertices check node vertex') 'get_vertices check node vertex')
def _check_callback_result(self, result, msg, exp_prev, exp_curr): def _check_callback_result(self, result, msg, exp_prev, exp_curr):

View File

@ -28,22 +28,22 @@ class GraphAlgorithmTest(GraphTestBase):
def test_graph_query_vertices(self): def test_graph_query_vertices(self):
ga = create_algorithm(self.entity_graph) ga = create_algorithm(self.entity_graph)
query = {'==': {VProps.TYPE: OPENSTACK_NODE}} query = {'==': {VProps.TYPE: OPENSTACK_CLUSTER}}
subgraph = ga.graph_query_vertices(query) subgraph = ga.graph_query_vertices(query)
self.assertEqual( self.assertEqual(
1, # For NODE 1, # For Cluster
subgraph.num_vertices(), 'num of vertex node') subgraph.num_vertices(), 'num of vertex node')
query = { query = {
'or': [ 'or': [
{'==': {VProps.TYPE: NOVA_HOST_DATASOURCE}}, {'==': {VProps.TYPE: NOVA_HOST_DATASOURCE}},
{'==': {VProps.TYPE: OPENSTACK_NODE}} {'==': {VProps.TYPE: OPENSTACK_CLUSTER}}
] ]
} }
subgraph = ga.graph_query_vertices(query) subgraph = ga.graph_query_vertices(query)
self.assertEqual( self.assertEqual(
ENTITY_GRAPH_HOSTS_PER_NODE, ENTITY_GRAPH_HOSTS_PER_CLUSTER,
subgraph.num_edges(), 'num of edges Host <-- NODE') subgraph.num_edges(), 'num of edges Host <-- NODE')
query = { query = {
@ -51,15 +51,15 @@ class GraphAlgorithmTest(GraphTestBase):
{'==': {VProps.TYPE: NOVA_INSTANCE_DATASOURCE}}, {'==': {VProps.TYPE: NOVA_INSTANCE_DATASOURCE}},
{'==': {VProps.CATEGORY: ALARM}}, {'==': {VProps.CATEGORY: ALARM}},
{'==': {VProps.TYPE: NOVA_HOST_DATASOURCE}}, {'==': {VProps.TYPE: NOVA_HOST_DATASOURCE}},
{'==': {VProps.TYPE: OPENSTACK_NODE}} {'==': {VProps.TYPE: OPENSTACK_CLUSTER}}
] ]
} }
subgraph = ga.graph_query_vertices(query) subgraph = ga.graph_query_vertices(query)
self.assertEqual( self.assertEqual(
ENTITY_GRAPH_HOSTS_PER_NODE + ENTITY_GRAPH_HOSTS_PER_CLUSTER +
ENTITY_GRAPH_HOSTS_PER_NODE * ENTITY_GRAPH_ALARMS_PER_HOST + ENTITY_GRAPH_HOSTS_PER_CLUSTER * ENTITY_GRAPH_ALARMS_PER_HOST +
ENTITY_GRAPH_HOSTS_PER_NODE * ENTITY_GRAPH_VMS_PER_HOST + ENTITY_GRAPH_HOSTS_PER_CLUSTER * ENTITY_GRAPH_VMS_PER_HOST +
ENTITY_GRAPH_HOSTS_PER_NODE * ENTITY_GRAPH_VMS_PER_HOST * ENTITY_GRAPH_HOSTS_PER_CLUSTER * ENTITY_GRAPH_VMS_PER_HOST *
ENTITY_GRAPH_ALARMS_PER_VM, ENTITY_GRAPH_ALARMS_PER_VM,
subgraph.num_edges(), 'num of BOTH edges Host (depth 1)') subgraph.num_edges(), 'num of BOTH edges Host (depth 1)')
@ -73,7 +73,7 @@ class GraphAlgorithmTest(GraphTestBase):
query_dict=query, root_id=first_host_id, depth=1) query_dict=query, root_id=first_host_id, depth=1)
self.assertEqual( self.assertEqual(
1 + # For tye host 1 + # For tye host
1 + # For NODE 1 + # For Cluster
1 + # For SWITCH 1 + # For SWITCH
ENTITY_GRAPH_ALARMS_PER_HOST + ENTITY_GRAPH_ALARMS_PER_HOST +
ENTITY_GRAPH_TESTS_PER_HOST + ENTITY_GRAPH_TESTS_PER_HOST +
@ -94,8 +94,8 @@ class GraphAlgorithmTest(GraphTestBase):
subgraph = ga.graph_query_vertices(root_id=first_host_id, depth=2) subgraph = ga.graph_query_vertices(root_id=first_host_id, depth=2)
self.assertEqual( self.assertEqual(
1 + # Node to switch 1 + # Cluster to switch
ENTITY_GRAPH_HOSTS_PER_NODE * 2 + ENTITY_GRAPH_HOSTS_PER_CLUSTER * 2 +
ENTITY_GRAPH_ALARMS_PER_HOST + ENTITY_GRAPH_ALARMS_PER_HOST +
ENTITY_GRAPH_TESTS_PER_HOST + ENTITY_GRAPH_TESTS_PER_HOST +
ENTITY_GRAPH_VMS_PER_HOST + ENTITY_GRAPH_VMS_PER_HOST +
@ -118,15 +118,15 @@ class GraphAlgorithmTest(GraphTestBase):
} }
subgraph = ga.graph_query_vertices(query_dict=query, depth=3) subgraph = ga.graph_query_vertices(query_dict=query, depth=3)
self.assertEqual( self.assertEqual(
1 + # Node to switch 1 + # Cluster to switch
ENTITY_GRAPH_HOSTS_PER_NODE * 2 + ENTITY_GRAPH_HOSTS_PER_CLUSTER * 2 +
ENTITY_GRAPH_HOSTS_PER_NODE * ENTITY_GRAPH_TESTS_PER_HOST + ENTITY_GRAPH_HOSTS_PER_CLUSTER * ENTITY_GRAPH_TESTS_PER_HOST +
ENTITY_GRAPH_HOSTS_PER_NODE * ENTITY_GRAPH_VMS_PER_HOST, ENTITY_GRAPH_HOSTS_PER_CLUSTER * ENTITY_GRAPH_VMS_PER_HOST,
subgraph.num_edges(), 'num of edges Node (depth 3)') subgraph.num_edges(), 'num of edges Node (depth 3)')
query = { query = {
'or': [ 'or': [
{'==': {VProps.TYPE: OPENSTACK_NODE}}, {'==': {VProps.TYPE: OPENSTACK_CLUSTER}},
{'==': {VProps.CATEGORY: ALARM}}, {'==': {VProps.CATEGORY: ALARM}},
] ]
} }
@ -171,10 +171,10 @@ class GraphAlgorithmTest(GraphTestBase):
t_v_node = graph_utils.create_vertex( t_v_node = graph_utils.create_vertex(
vitrage_id='6', vitrage_id='6',
entity_category=RESOURCE, entity_category=RESOURCE,
entity_type=OPENSTACK_NODE) entity_type=OPENSTACK_CLUSTER)
t_v_node_not_in_graph = graph_utils.create_vertex( t_v_node_not_in_graph = graph_utils.create_vertex(
vitrage_id='7', entity_category=RESOURCE, vitrage_id='7', entity_category=RESOURCE,
entity_type=OPENSTACK_NODE + ' not in graph') entity_type=OPENSTACK_CLUSTER + ' not in graph')
e_alarm_on_host = graph_utils.create_edge( e_alarm_on_host = graph_utils.create_edge(
t_v_host_alarm.vertex_id, t_v_host.vertex_id, ELabel.ON) t_v_host_alarm.vertex_id, t_v_host.vertex_id, ELabel.ON)

View File

@ -27,7 +27,7 @@ from vitrage.datasources import CINDER_VOLUME_DATASOURCE
from vitrage.datasources import NOVA_HOST_DATASOURCE from vitrage.datasources import NOVA_HOST_DATASOURCE
from vitrage.datasources import NOVA_INSTANCE_DATASOURCE from vitrage.datasources import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources import NOVA_ZONE_DATASOURCE from vitrage.datasources import NOVA_ZONE_DATASOURCE
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_CLUSTER
from vitrage.datasources.static_physical import SWITCH from vitrage.datasources.static_physical import SWITCH
from vitrage.graph import Edge from vitrage.graph import Edge
from vitrage.graph import NXGraph from vitrage.graph import NXGraph
@ -112,16 +112,16 @@ class BaseTopologyTest(test.BaseTestCase):
if os.path.exists(path): if os.path.exists(path):
os.remove(path) os.remove(path)
def _entities_validation_data(self, node_entities=1, node_edges=1, def _entities_validation_data(self, cluster_entities=1, cluster_edges=1,
zone_entities=1, zone_edges=2, zone_entities=1, zone_edges=2,
host_entities=1, host_edges=1, host_entities=1, host_edges=1,
instance_entities=0, instance_edges=0, instance_entities=0, instance_edges=0,
volume_entities=0, volume_edges=0, volume_entities=0, volume_edges=0,
switch_entities=0, switch_edges=0): switch_entities=0, switch_edges=0):
return [ return [
{VProps.TYPE: OPENSTACK_NODE, {VProps.TYPE: OPENSTACK_CLUSTER,
self.NUM_ENTITIES_PER_TYPE: node_entities, self.NUM_ENTITIES_PER_TYPE: cluster_entities,
self.NUM_EDGES_PER_TYPE: node_edges}, self.NUM_EDGES_PER_TYPE: cluster_edges},
{VProps.TYPE: NOVA_ZONE_DATASOURCE, {VProps.TYPE: NOVA_ZONE_DATASOURCE,
self.NUM_ENTITIES_PER_TYPE: zone_entities, self.NUM_ENTITIES_PER_TYPE: zone_entities,
self.NUM_EDGES_PER_TYPE: zone_edges}, self.NUM_EDGES_PER_TYPE: zone_edges},
@ -284,7 +284,7 @@ class BaseTopologyTest(test.BaseTestCase):
return '{"and": [{"==": {"category": "RESOURCE"}},' \ return '{"and": [{"==": {"category": "RESOURCE"}},' \
'{"==": {"is_deleted": false}},' \ '{"==": {"is_deleted": false}},' \
'{"==": {"is_placeholder": false}},' \ '{"==": {"is_placeholder": false}},' \
'{"or": [{"==": {"type": "openstack.node"}},' \ '{"or": [{"==": {"type": "openstack.cluster"}},' \
'{"==": {"type": "nova.instance"}},' \ '{"==": {"type": "nova.instance"}},' \
'{"==": {"type": "nova.host"}},' \ '{"==": {"type": "nova.host"}},' \
'{"==": {"type": "nova.zone"}}]}]}' '{"==": {"type": "nova.zone"}}]}]}'
@ -294,6 +294,6 @@ class BaseTopologyTest(test.BaseTestCase):
return '{"and": [{"==": {"category": "RESOURCE"}},' \ return '{"and": [{"==": {"category": "RESOURCE"}},' \
'{"==": {"is_deleted": false}},' \ '{"==": {"is_deleted": false}},' \
'{"==": {"is_placeholder": false}},' \ '{"==": {"is_placeholder": false}},' \
'{"or": [{"==": {"type": "openstack.node"}},' \ '{"or": [{"==": {"type": "openstack.cluster"}},' \
'{"==": {"type": "nova.host"}},' \ '{"==": {"type": "nova.host"}},' \
'{"==": {"type": "nova.zone"}}]}]}' '{"==": {"type": "nova.zone"}}]}]}'

View File

@ -23,7 +23,7 @@ from vitrage.datasources import CINDER_VOLUME_DATASOURCE
from vitrage.datasources import NOVA_HOST_DATASOURCE from vitrage.datasources import NOVA_HOST_DATASOURCE
from vitrage.datasources import NOVA_INSTANCE_DATASOURCE from vitrage.datasources import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources import NOVA_ZONE_DATASOURCE from vitrage.datasources import NOVA_ZONE_DATASOURCE
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_CLUSTER
from vitrage.graph import Edge from vitrage.graph import Edge
from vitrage.graph import NXGraph from vitrage.graph import NXGraph
from vitrage.graph import Vertex from vitrage.graph import Vertex
@ -148,15 +148,15 @@ class TestTopology(BaseTopologyTest):
# entity graph processor # entity graph processor
time.sleep(5) time.sleep(5)
def _entities_validation_data(self, node_entities=1, node_edges=1, def _entities_validation_data(self, cluster_entities=1, cluster_edges=1,
zone_entities=1, zone_edges=2, zone_entities=1, zone_edges=2,
host_entities=1, host_edges=1, host_entities=1, host_edges=1,
instance_entities=0, instance_edges=0, instance_entities=0, instance_edges=0,
volume_entities=0, volume_edges=0): volume_entities=0, volume_edges=0):
return [ return [
{VProps.TYPE: OPENSTACK_NODE, {VProps.TYPE: OPENSTACK_CLUSTER,
self.NUM_ENTITIES_PER_TYPE: node_entities, self.NUM_ENTITIES_PER_TYPE: cluster_entities,
self.NUM_EDGES_PER_TYPE: node_edges}, self.NUM_EDGES_PER_TYPE: cluster_edges},
{VProps.TYPE: NOVA_ZONE_DATASOURCE, {VProps.TYPE: NOVA_ZONE_DATASOURCE,
self.NUM_ENTITIES_PER_TYPE: zone_entities, self.NUM_ENTITIES_PER_TYPE: zone_entities,
self.NUM_EDGES_PER_TYPE: zone_edges}, self.NUM_EDGES_PER_TYPE: zone_edges},
@ -316,7 +316,7 @@ class TestTopology(BaseTopologyTest):
return '{"and": [{"==": {"category": "RESOURCE"}},' \ return '{"and": [{"==": {"category": "RESOURCE"}},' \
'{"==": {"is_deleted": false}},' \ '{"==": {"is_deleted": false}},' \
'{"==": {"is_placeholder": false}},' \ '{"==": {"is_placeholder": false}},' \
'{"or": [{"==": {"type": "openstack.node"}},' \ '{"or": [{"==": {"type": "openstack.cluster"}},' \
'{"==": {"type": "nova.instance"}},' \ '{"==": {"type": "nova.instance"}},' \
'{"==": {"type": "nova.host"}},' \ '{"==": {"type": "nova.host"}},' \
'{"==": {"type": "nova.zone"}}]}]}' '{"==": {"type": "nova.zone"}}]}]}'
@ -326,6 +326,6 @@ class TestTopology(BaseTopologyTest):
return '{"and": [{"==": {"category": "RESOURCE"}},' \ return '{"and": [{"==": {"category": "RESOURCE"}},' \
'{"==": {"is_deleted": false}},' \ '{"==": {"is_deleted": false}},' \
'{"==": {"is_placeholder": false}},' \ '{"==": {"is_placeholder": false}},' \
'{"or": [{"==": {"type": "openstack.node"}},' \ '{"or": [{"==": {"type": "openstack.cluster"}},' \
'{"==": {"type": "nova.host"}},' \ '{"==": {"type": "nova.host"}},' \
'{"==": {"type": "nova.zone"}}]}]}' '{"==": {"type": "nova.zone"}}]}]}'