Vertex Properties refactoring

Rename vitrage properties to start with the vitrage prefix
so it will be easier work with and to recognize.

Change-Id: Ia8afaa1a13897927984a9c8d8d9b85343ef69c01
This commit is contained in:
Alexey Weyl 2017-06-06 07:12:57 +00:00
parent 0af2b7ceb5
commit 3b1de001ec
117 changed files with 1790 additions and 1556 deletions

View File

@ -20,7 +20,7 @@ In order to add a new datasource to Vitrage do the following steps:
a. Driver and transformer with the path to your driver and transformer
classes respectively.
b. ``update_method`` property that describes the type of update mechanism for
b. ``update_method`` property that describes the vitrage_type of update mechanism for
this datasource. The options are (string): push, pull or none.
c. In addition to those three, you may add any other configuration options
you may need for your datasource.

View File

@ -16,7 +16,7 @@ Since each data-source might represent severity differently, for each
data-source we can supply it's own mapping to the aggregated severity supported
in Vitrage. This way we can know which severity is more important.
In addition we also normalize the severities for the horizon UI (called
``operational_severity``) in order for the UI to know what color to show in
``vitrage_operational_severity``) in order for the UI to know what color to show in
Horizon.
This page explains how to handle this mapping for a given

View File

@ -16,7 +16,7 @@ Since each data-source might represent state differently, for each
data-source we can supply it's own mapping to the aggregated state supported
in Vitrage. This way we can know which state is more important.
In addition we also normalize the states for the horizon UI (called
operational_state) in order for the UI to know what color to show in Horizon.
vitrage_operational_state) in order for the UI to know what color to show in Horizon.
This page explains how to handle this mapping for a given
data-source.

View File

@ -34,8 +34,8 @@ The following describes all the possible status code and their messages:
+------------------+---------------------------------------------------------+-------------------------------+
| 43 | At least one entity must be defined | syntax |
+------------------+---------------------------------------------------------+-------------------------------+
| 45 | Invalid entity category. Category must be from types: | syntax |
| | [entities_categories] | |
| 45 | Invalid entity category. Category must be from | syntax |
| | types: [entities_categories] | |
+------------------+---------------------------------------------------------+-------------------------------+
| 46 | Entity field is required | syntax |
+------------------+---------------------------------------------------------+-------------------------------+

View File

@ -60,13 +60,13 @@ Let's take a basic template as example
expected_entities = {
'alarm': Vertex(vertex_id='alarm',
properties={'category': 'ALARM',
'type': 'nagios',
'name': 'HOST_HIGH_CPU_LOAD'
properties={'vitrage_category': 'ALARM',
'vitrage_type': 'nagios',
'name': 'HOST_HIGH_CPU_LOAD',
}),
'resource': Vertex(vertex_id='resource',
properties={'category': 'RESOURCE',
'type': 'nova.host'
properties={'vitrage_category': 'RESOURCE',
'vitrage_type': 'nova.host',
})
}

View File

@ -167,19 +167,19 @@ Query example
[
"=":
{
"type":"host"
"vitrage_type":"host"
},
"=":
{
"type":"instance"
"vitrage_type":"instance"
},
"=":
{
"type":"zone"
"vitrage_type":"zone"
},
"=":
{
"type":"node"
"vitrage_type":"node"
}
]
}
@ -215,257 +215,257 @@ Response Examples
"graph": {},
"nodes": [
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-8",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "20d12a8a-ea9a-89c6-5947-83bea959362e",
"vitrage_id": "RESOURCE:nova.instance:20d12a8a-ea9a-89c6-5947-83bea959362e"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-2",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "dc35fa2f-4515-1653-ef6b-03b471bb395b",
"vitrage_id": "RESOURCE:nova.instance:dc35fa2f-4515-1653-ef6b-03b471bb395b"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-13",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "9879cf5a-bdcf-3651-3017-961ed887ec86",
"vitrage_id": "RESOURCE:nova.instance:9879cf5a-bdcf-3651-3017-961ed887ec86"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-10",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "fe124f4b-9ed7-4591-fcd1-803cf5c33cb1",
"vitrage_id": "RESOURCE:nova.instance:fe124f4b-9ed7-4591-fcd1-803cf5c33cb1"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-11",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "f2e48a97-7350-061e-12d3-84c6dc3e67c0",
"vitrage_id": "RESOURCE:nova.instance:f2e48a97-7350-061e-12d3-84c6dc3e67c0"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "host-2",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "available",
"type": "nova.host",
"vitrage_type": "nova.host",
"id": "host-2",
"vitrage_id": "RESOURCE:nova.host:host-2"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "host-3",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "available",
"type": "nova.host",
"vitrage_type": "nova.host",
"id": "host-3",
"vitrage_id": "RESOURCE:nova.host:host-3"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "host-0",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "available",
"type": "nova.host",
"vitrage_type": "nova.host",
"id": "host-0",
"vitrage_id": "RESOURCE:nova.host:host-0"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "host-1",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "available",
"type": "nova.host",
"vitrage_type": "nova.host",
"id": "host-1",
"vitrage_id": "RESOURCE:nova.host:host-1"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-9",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "275097cf-954e-8e24-b185-9514e24b8591",
"vitrage_id": "RESOURCE:nova.instance:275097cf-954e-8e24-b185-9514e24b8591"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-1",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "a0f0805f-c804-cffe-c25a-1b38f555ed68",
"vitrage_id": "RESOURCE:nova.instance:a0f0805f-c804-cffe-c25a-1b38f555ed68"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-14",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "56af57d2-34a4-19b1-5106-b613637a11a7",
"vitrage_id": "RESOURCE:nova.instance:56af57d2-34a4-19b1-5106-b613637a11a7"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "zone-1",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "available",
"type": "nova.zone",
"vitrage_type": "nova.zone",
"id": "zone-1",
"vitrage_id": "RESOURCE:nova.zone:zone-1"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-3",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "16e14c58-d254-2bec-53e4-c766e48810aa",
"vitrage_id": "RESOURCE:nova.instance:16e14c58-d254-2bec-53e4-c766e48810aa"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-7",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "f35a1e10-74ff-7332-8edf-83cd6ffcb2de",
"vitrage_id": "RESOURCE:nova.instance:f35a1e10-74ff-7332-8edf-83cd6ffcb2de"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-4",
"update_timestamp": "2015-12-01T12:46:41Z?vitrage_id=all",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "ea8a450e-cab1-2272-f431-494b40c5c378",
"vitrage_id": "RESOURCE:nova.instance:ea8a450e-cab1-2272-f431-494b40c5c378"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-6",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "6e42bdc3-b776-1b2c-2c7d-b7a8bb98f721",
"vitrage_id": "RESOURCE:nova.instance:6e42bdc3-b776-1b2c-2c7d-b7a8bb98f721"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-5",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "8c951613-c660-87c0-c18b-0fa3293ce8d8",
"vitrage_id": "RESOURCE:nova.instance:8c951613-c660-87c0-c18b-0fa3293ce8d8"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "zone-0",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "available",
"type": "nova.zone",
"vitrage_type": "nova.zone",
"id": "zone-0",
"vitrage_id": "RESOURCE:nova.zone:zone-0"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-0",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "78353ce4-2710-49b5-1341-b8cbb6000ebc",
"vitrage_id": "RESOURCE:nova.instance:78353ce4-2710-49b5-1341-b8cbb6000ebc"
},TODO
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-12",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "35bf479a-75d9-80a9-874e-d3b50fb2dd2e",
"vitrage_id": "RESOURCE:nova.instance:35bf479a-75d9-80a9-874e-d3b50fb2dd2e"
},
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "openstack.cluster",
"type": "openstack.cluster",
"vitrage_type": "openstack.cluster",
"id": "openstack.cluster",
"vitrage_id": "RESOURCE:openstack.cluster"
}
@ -473,147 +473,147 @@ Response Examples
"links": [
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 3,
"key": "contains",
"source": 5
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 1,
"key": "contains",
"source": 5
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 16,
"key": "contains",
"source": 5
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 11,
"key": "contains",
"source": 5
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 13,
"key": "contains",
"source": 6
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 4,
"key": "contains",
"source": 6
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 14,
"key": "contains",
"source": 6
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 20,
"key": "contains",
"source": 7
},?vitrage_id=all
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 0,
"key": "contains",
"source": 7
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 19,
"key": "contains",
"source": 7
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 15,
"key": "contains",
"source": 7
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 9,
"key": "contains",
"source": 8
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 10,
"key": "contains",
"source": 8
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 2,
"key": "contains",
"source": 8
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 17,
"key": "contains",
"source": 8
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 6,
"key": "contains",
"source": 12
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 8,
"key": "contains",
"source": 12
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 5,
"key": "contains",
"source": 18
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 7,
"key": "contains",
"source": 18
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 18,
"key": "contains",
"source": 21
},
{
"relationship_name": "contains",
"is_deleted": false,
"vitrage_is_deleted": false,
"target": 12,
"key": "contains",
"source": 21
@ -685,8 +685,8 @@ Response Examples
},
"nodes": [
{
"category": "ALARM",
"type": "nagios",
"vitrage_category": "ALARM",
"vitrage_type": "nagios",
"name": "CPU load",
"state": "Active",
"severity": "WARNING",
@ -699,8 +699,8 @@ Response Examples
"vitrage_id": "ALARM:nagios:host0:CPU load"
},
{
"category": "ALARM",
"type": "vitrage",
"vitrage_category": "ALARM",
"vitrage_type": "vitrage",
"name": "Machine Suboptimal",
"state": "Active",
"severity": "WARNING",
@ -712,8 +712,8 @@ Response Examples
"vitrage_id": "ALARM:vitrage:vm0:Machine Suboptimal"
},
{
"category": "ALARM",
"type": "vitrage",
"vitrage_category": "ALARM",
"vitrage_type": "vitrage",
"name": "Machine Suboptimal",
"state": "Active",
"severity": "WARNING",
@ -799,8 +799,8 @@ Response Examples
[
{
"category": "ALARM",
"type": "nagios",
"vitrage_category": "ALARM",
"vitrage_type": "nagios",
"name": "CPU load",
"state": "Active",
"severity": "WARNING",
@ -814,8 +814,8 @@ Response Examples
"normalized_severity": "WARNING"
},
{
"category": "ALARM",
"type": "vitrage",
"vitrage_category": "ALARM",
"vitrage_type": "vitrage",
"name": "Machine Suboptimal",
"state": "Active",
"severity": "CRITICAL",
@ -828,8 +828,8 @@ Response Examples
"normalized_severity": "CRITICAL"
},
{
"category": "ALARM",
"type": "vitrage",
"vitrage_category": "ALARM",
"vitrage_type": "vitrage",
"name": "Machine Suboptimal",
"state": "Active",
"severity": "CRITICAL",
@ -842,8 +842,8 @@ Response Examples
"normalized_severity": "CRITICAL"
},
{
"category": "ALARM",
"type": "aodh",
"vitrage_category": "ALARM",
"vitrage_type": "aodh",
"name": "Memory overload",
"state": "Active",
"severity": "WARNING",
@ -1130,30 +1130,30 @@ Response Examples
"entities": [
{
"entity": {
"category": "ALARM",
"type": "nagios",
"vitrage_category": "ALARM",
"vitrage_type": "nagios",
"name": "check_libvirtd",
"template_id": "alarm_1"
}
},
{
"entity": {
"category": "RESOURCE",
"type": "nova.host",
"vitrage_category": "RESOURCE",
"vitrage_type": "nova.host",
"template_id": "host"
}
},
{
"entity": {
"category": "RESOURCE",
"type": "nova.instance",
"vitrage_category": "RESOURCE",
"vitrage_type": "nova.instance",
"template_id": "instance"
}
},
{
"entity": {
"category": "ALARM",
"type": "vitrage",
"vitrage_category": "ALARM",
"vitrage_type": "vitrage",
"name": "exploding_world",
"template_id": "alarm_2"
}
@ -1317,9 +1317,9 @@ Response Examples
[
{
"vitrage_id": "RESOURCE:nova.host:cloud",
"aggregated_state": "AVAILABLE",
"vitrage_aggregated_state": "AVAILABLE",
"state": "available",
"type": "nova.host",
"vitrage_type": "nova.host",
"id": "cloud",
"metadata": {
"name": "cloud",
@ -1387,14 +1387,14 @@ Response Examples
::
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "vm-1",
"update_timestamp": "2015-12-01T12:46:41Z",
"state": "ACTIVE",
"project_id": "0683517e1e354d2ba25cba6937f44e79",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "dc35fa2f-4515-1653-ef6b-03b471bb395b",
"vitrage_id": "RESOURCE:nova.instance:dc35fa2f-4515-1653-ef6b-03b471bb395b"
}

View File

@ -294,26 +294,26 @@ Adding/removing a template
Common parameters and their acceptable values - for writing templates
---------------------------------------------------------------------
+-------------------+---------------+-------------------------+------------------------------------+
| block | key | supported values | comments |
+===================+===============+=========================+====================================+
| entity | category | ALARM | |
| | | RESOURCE | |
+-------------------+---------------+-------------------------+------------------------------------+
| entity (ALARM) | type | any string | |
+-------------------+---------------+-------------------------+------------------------------------+
| entity (RESOURCE) | type | openstack.cluster, | These are for the datasources that |
| | | nova.zone, | come with vitrage by default. |
| | | nova.host, | Adding datasources will add more |
| | | nova.instance, | supported types, as defined in the |
| | | cinder.volume, | datasource transformer |
| | | switch | |
+-------------------+---------------+-------------------------+------------------------------------+
| action | action_type | raise_alarm, | |
| | | set_state, | |
| | | add_causal_relationship | |
| | | mark_down | |
+-------------------+---------------+-------------------------+------------------------------------+
+-------------------+-----------------------+-------------------------+------------------------------------+
| block | key | supported values | comments |
+===================+=======================+=========================+====================================+
| entity | category | ALARM | |
| | | RESOURCE | |
+-------------------+-----------------------+-------------------------+------------------------------------+
| entity (ALARM) | type | any string | |
+-------------------+-----------------------+-------------------------+------------------------------------+
| entity (RESOURCE) | type | openstack.cluster, | These are for the datasources that |
| | | nova.zone, | come with vitrage by default. |
| | | nova.host, | Adding datasources will add more |
| | | nova.instance, | supported types, as defined in the |
| | | cinder.volume, | datasource transformer |
| | | switch | |
+-------------------+-----------------------+-------------------------+------------------------------------+
| action | action_type | raise_alarm, | |
| | | set_state, | |
| | | add_causal_relationship | |
| | | mark_down | |
+-------------------+-----------------------+-------------------------+------------------------------------+
Supported Actions

View File

@ -104,8 +104,8 @@ Vitrage configuration
zabbix:
- zabbix_host: Zabbix server
type: nova.host
name: Zabbix server
type: nova.host
name: Zabbix server
4. Restart vitrage service in devstack/openstack

View File

@ -48,10 +48,10 @@ class AlarmApis(EntityGraphApisBase):
is_admin_project)
alarms = set(alarms)
else:
alarms = self.entity_graph.neighbors(
vitrage_id,
vertex_attr_filter={VProps.CATEGORY: EntityCategory.ALARM,
VProps.IS_DELETED: False})
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_IS_DELETED: False}
alarms = self.entity_graph.neighbors(vitrage_id,
vertex_attr_filter=query)
return json.dumps({'alarms': [v.properties for v in alarms]})

View File

@ -30,15 +30,15 @@ LOG = log.getLogger(__name__)
# Used for Sunburst to show only specific resources
TREE_TOPOLOGY_QUERY = {
'and': [
{'==': {VProps.CATEGORY: EntityCategory.RESOURCE}},
{'==': {VProps.IS_DELETED: False}},
{'==': {VProps.IS_PLACEHOLDER: False}},
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}},
{'==': {VProps.VITRAGE_IS_DELETED: False}},
{'==': {VProps.VITRAGE_IS_PLACEHOLDER: False}},
{
'or': [
{'==': {VProps.TYPE: OPENSTACK_CLUSTER}},
{'==': {VProps.TYPE: NOVA_INSTANCE_DATASOURCE}},
{'==': {VProps.TYPE: NOVA_HOST_DATASOURCE}},
{'==': {VProps.TYPE: NOVA_ZONE_DATASOURCE}}
{'==': {VProps.VITRAGE_TYPE: OPENSTACK_CLUSTER}},
{'==': {VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE}},
{'==': {VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE}},
{'==': {VProps.VITRAGE_TYPE: NOVA_ZONE_DATASOURCE}}
]
}
]
@ -46,12 +46,12 @@ TREE_TOPOLOGY_QUERY = {
TOPOLOGY_AND_ALARMS_QUERY = {
'and': [
{'==': {VProps.IS_DELETED: False}},
{'==': {VProps.IS_PLACEHOLDER: False}},
{'==': {VProps.VITRAGE_IS_DELETED: False}},
{'==': {VProps.VITRAGE_IS_PLACEHOLDER: False}},
{
'or': [
{'==': {VProps.CATEGORY: EntityCategory.ALARM}},
{'==': {VProps.CATEGORY: EntityCategory.RESOURCE}}
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}},
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}}
]
}
]
@ -59,31 +59,31 @@ TOPOLOGY_AND_ALARMS_QUERY = {
RCA_QUERY = {
'and': [
{'==': {VProps.CATEGORY: EntityCategory.ALARM}},
{'==': {VProps.IS_DELETED: False}}
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}},
{'==': {VProps.VITRAGE_IS_DELETED: False}}
]
}
ALARMS_ALL_QUERY = {
'and': [
{'==': {VProps.CATEGORY: EntityCategory.ALARM}},
{'==': {VProps.IS_DELETED: False}}
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}},
{'==': {VProps.VITRAGE_IS_DELETED: False}}
]
}
ALARM_QUERY = {
VProps.CATEGORY: EntityCategory.ALARM,
VProps.IS_DELETED: False,
VProps.IS_PLACEHOLDER: False
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_IS_DELETED: False,
VProps.VITRAGE_IS_PLACEHOLDER: False
}
EDGE_QUERY = {'==': {EProps.IS_DELETED: False}}
EDGE_QUERY = {'==': {EProps.VITRAGE_IS_DELETED: False}}
RESOURCES_ALL_QUERY = {
'and': [
{'==': {VProps.CATEGORY: EntityCategory.RESOURCE}},
{'==': {VProps.IS_DELETED: False}},
{'==': {VProps.IS_PLACEHOLDER: False}}
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}},
{'==': {VProps.VITRAGE_IS_DELETED: False}},
{'==': {VProps.VITRAGE_IS_PLACEHOLDER: False}}
]
}
@ -93,13 +93,13 @@ class EntityGraphApisBase(object):
IS_ADMIN_PROJECT_PROPERTY = 'is_admin'
@staticmethod
def _get_query_with_project(category, project_id, is_admin):
def _get_query_with_project(vitrage_category, project_id, is_admin):
"""Generate query with tenant data
Creates query for entity graph which takes into consideration the
category, project_id and if the tenant is admin
vitrage_category, project_id and if the tenant is admin
:type category: string
:type vitrage_category: string
:type project_id: string
:type is_admin: boolean
:rtype: dictionary
@ -107,9 +107,9 @@ class EntityGraphApisBase(object):
query = {
'and': [
{'==': {VProps.IS_DELETED: False}},
{'==': {VProps.IS_PLACEHOLDER: False}},
{'==': {VProps.CATEGORY: category}}
{'==': {VProps.VITRAGE_IS_DELETED: False}},
{'==': {VProps.VITRAGE_IS_PLACEHOLDER: False}},
{'==': {VProps.VITRAGE_CATEGORY: vitrage_category}}
]
}
@ -141,7 +141,7 @@ class EntityGraphApisBase(object):
for alarm in alarms:
alarm_project_id = alarm.get(VProps.PROJECT_ID, None)
if not alarm_project_id:
cat_filter = {VProps.CATEGORY: EntityCategory.RESOURCE}
cat_filter = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}
alarms_resource = \
self.entity_graph.neighbors(alarm.vertex_id,
vertex_attr_filter=cat_filter)
@ -183,7 +183,7 @@ class EntityGraphApisBase(object):
entities = self.entity_graph.neighbors(entity.vertex_id,
direction=Direction.OUT)
for entity in entities:
if entity[VProps.CATEGORY] == EntityCategory.RESOURCE:
if entity[VProps.VITRAGE_CATEGORY] == EntityCategory.RESOURCE:
resource_project_id = entity.get(VProps.PROJECT_ID)
if resource_project_id == project_id or \
(not resource_project_id and is_admin_project):

View File

@ -47,7 +47,7 @@ class ResourceApis(EntityGraphApisBase):
query = copy.deepcopy(resource_query)
if resource_type:
type_query = {'==': {VProps.TYPE: resource_type}}
type_query = {'==': {VProps.VITRAGE_TYPE: resource_type}}
query['and'].append(type_query)
resources = self.entity_graph.get_vertices(query_dict=query)

View File

@ -65,7 +65,7 @@ class TopologyApis(EntityGraphApisBase):
q = query if query else TOPOLOGY_AND_ALARMS_QUERY
graph = ga.create_graph_from_matching_vertices(
query_dict=q,
edge_attr_filter={VProps.IS_DELETED: False})
edge_attr_filter={VProps.VITRAGE_IS_DELETED: False})
else:
graph = self._get_topology_for_specific_project(
ga,
@ -115,7 +115,7 @@ class TopologyApis(EntityGraphApisBase):
tmp_graph = ga.create_graph_from_matching_vertices(query_dict=q)
graph = self._create_graph_of_connected_components(ga, tmp_graph, root)
edge_query = {EProps.IS_DELETED: False}
edge_query = {EProps.VITRAGE_IS_DELETED: False}
self._remove_unnecessary_elements(ga,
graph,
project_id,
@ -153,7 +153,7 @@ class TopologyApis(EntityGraphApisBase):
for alarm in graph.get_vertices(query_dict=ALARMS_ALL_QUERY):
if not alarm.get(VProps.PROJECT_ID, None):
cat_filter = {VProps.CATEGORY: EntityCategory.RESOURCE}
cat_filter = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}
resource_neighbors = \
self.entity_graph.neighbors(alarm.vertex_id,
vertex_attr_filter=cat_filter)
@ -220,7 +220,7 @@ class TopologyApis(EntityGraphApisBase):
@staticmethod
def _find_instance_in_graph(graph):
for node, node_data in graph.nodes_iter(data=True):
if node_data[VProps.CATEGORY] == EntityCategory.RESOURCE and \
node_data[VProps.TYPE] == NOVA_INSTANCE_DATASOURCE:
if node_data[VProps.VITRAGE_CATEGORY] == EntityCategory.RESOURCE and \
node_data[VProps.VITRAGE_TYPE] == NOVA_INSTANCE_DATASOURCE:
return node
return None

View File

@ -15,23 +15,24 @@
class VertexProperties(object):
CATEGORY = 'category'
TYPE = 'type'
ID = 'id'
IS_DELETED = 'is_deleted'
STATE = 'state'
VITRAGE_CATEGORY = 'vitrage_category'
VITRAGE_TYPE = 'vitrage_type'
VITRAGE_ID = 'vitrage_id'
VITRAGE_STATE = 'vitrage_state'
AGGREGATED_STATE = 'aggregated_state'
OPERATIONAL_STATE = 'operational_state'
VITRAGE_IS_DELETED = 'vitrage_is_deleted'
VITRAGE_IS_PLACEHOLDER = 'vitrage_is_placeholder'
VITRAGE_SAMPLE_TIMESTAMP = 'vitrage_sample_timestamp'
VITRAGE_AGGREGATED_STATE = 'vitrage_aggregated_state'
VITRAGE_OPERATIONAL_STATE = 'vitrage_operational_state'
VITRAGE_AGGREGATED_SEVERITY = 'vitrage_aggregated_severity'
VITRAGE_OPERATIONAL_SEVERITY = 'vitrage_operational_severity'
VITRAGE_RESOURCE_ID = 'vitrage_resource_id'
ID = 'id'
STATE = 'state'
PROJECT_ID = 'project_id'
UPDATE_TIMESTAMP = 'update_timestamp'
SAMPLE_TIMESTAMP = 'sample_timestamp'
NAME = 'name'
IS_PLACEHOLDER = 'is_placeholder'
SEVERITY = 'severity'
AGGREGATED_SEVERITY = 'aggregated_severity'
OPERATIONAL_SEVERITY = 'operational_severity'
VITRAGE_ID = 'vitrage_id'
IS_MARKED_DOWN = 'is_marked_down'
INFO = 'info'
GRAPH_INDEX = 'graph_index'
@ -45,7 +46,7 @@ class VertexProperties(object):
class EdgeProperties(object):
RELATIONSHIP_TYPE = 'relationship_type'
IS_DELETED = 'is_deleted'
VITRAGE_IS_DELETED = 'vitrage_is_deleted'
UPDATE_TIMESTAMP = 'update_timestamp'

View File

@ -27,8 +27,8 @@ class AlarmDriverBase(DriverBase):
super(DriverBase, self).__init__()
self.cache = dict()
def _entity_type(self):
"""Return the type of the datasource """
def _vitrage_type(self):
"""Return the vitrage_type of the datasource """
pass
def _alarm_key(self, alarm):
@ -74,12 +74,12 @@ class AlarmDriverBase(DriverBase):
def get_all(self, datasource_action):
return self.make_pickleable(self._get_all_alarms(),
self._entity_type(),
self._vitrage_type(),
datasource_action)
def get_changes(self, datasource_action):
return self.make_pickleable(self._get_changed_alarms(),
self._entity_type(),
self._vitrage_type(),
datasource_action)
def _get_all_alarms(self):

View File

@ -42,7 +42,7 @@ class AodhDriver(AlarmDriverBase):
self._client = os_clients.ceilometer_client(self.conf)
return self._client
def _entity_type(self):
def _vitrage_type(self):
return AODH_DATASOURCE
def _alarm_key(self, alarm):

View File

@ -24,6 +24,8 @@ from vitrage.datasources.aodh.properties import AodhProperties as AodhProps
from vitrage.datasources.aodh.properties import AodhState
from vitrage.datasources import transformer_base as tbase
from vitrage.datasources.transformer_base import Neighbor
from vitrage.evaluator.actions.evaluator_event_transformer \
import VITRAGE_DATASOURCE
import vitrage.graph.utils as graph_utils
from vitrage.utils import datetime as datetime_utils
@ -67,18 +69,18 @@ class AodhTransformer(AlarmTransformerBase):
metadata[AodhProps.STATE_TIMESTAMP] = \
entity_event[AodhProps.STATE_TIMESTAMP]
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = self._format_update_timestamp(
AodhTransformer._timestamp(entity_event), sample_timestamp)
AodhTransformer._timestamp(entity_event), vitrage_sample_timestamp)
return graph_utils.create_vertex(
self._create_entity_key(entity_event),
vitrage_category=EntityCategory.ALARM,
vitrage_type=entity_event[DSProps.ENTITY_TYPE],
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=entity_event[AodhProps.ALARM_ID],
entity_category=EntityCategory.ALARM,
entity_type=entity_event[DSProps.ENTITY_TYPE],
entity_state=self._get_alarm_state(entity_event),
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -110,16 +112,16 @@ class AodhTransformer(AlarmTransformerBase):
AodhProps.DESCRIPTION: entity_event[AodhProps.DESCRIPTION],
VProps.PROJECT_ID: entity_event[AodhProps.PROJECT_ID],
}
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = self._format_update_timestamp(
AodhTransformer._timestamp(entity_event), sample_timestamp)
AodhTransformer._timestamp(entity_event), vitrage_sample_timestamp)
return graph_utils.create_vertex(
self._create_entity_key(entity_event),
vitrage_category=EntityCategory.ALARM,
vitrage_type=VITRAGE_DATASOURCE,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=entity_event.get(AodhProps.ALARM_ID),
entity_category=EntityCategory.ALARM,
entity_type='vitrage',
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -148,7 +150,7 @@ class AodhTransformer(AlarmTransformerBase):
return None
return {VProps.ID: affected_resource_id}
def get_type(self):
def get_vitrage_type(self):
return AODH_DATASOURCE

View File

@ -112,15 +112,15 @@ class CinderVolumeTransformer(ResourceTransformerBase):
entity_key = self._create_entity_key(entity_event)
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
return graph_utils.create_vertex(
entity_key,
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=CINDER_VOLUME_DATASOURCE,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=volume_id,
entity_category=EntityCategory.RESOURCE,
entity_type=CINDER_VOLUME_DATASOURCE,
entity_state=volume_state,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -159,5 +159,5 @@ class CinderVolumeTransformer(ResourceTransformerBase):
return neighbors
def get_type(self):
def get_vitrage_type(self):
return CINDER_VOLUME_DATASOURCE

View File

@ -37,7 +37,7 @@ class CollectdDriver(AlarmDriverBase):
CollectdDriver.conf_map = \
CollectdDriver._configuration_mapping(conf)
def _entity_type(self):
def _vitrage_type(self):
return COLLECTD_DATASOURCE
def _alarm_key(self, alarm):

View File

@ -45,7 +45,7 @@ class CollectdTransformer(AlarmTransformerBase):
update_timestamp = entity_event['timestamp']
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
entity_state = AlarmProps.INACTIVE_STATE \
if self._ok_status(entity_event) else AlarmProps.ACTIVE_STATE
@ -59,10 +59,10 @@ class CollectdTransformer(AlarmTransformerBase):
return graph_utils.create_vertex(
self._create_entity_key(entity_event),
entity_category=EntityCategory.ALARM,
entity_type=entity_event[DSProps.ENTITY_TYPE],
vitrage_category=EntityCategory.ALARM,
vitrage_type=entity_event[DSProps.ENTITY_TYPE],
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_state=entity_state,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -97,7 +97,7 @@ class CollectdTransformer(AlarmTransformerBase):
resource_name,
alarm_id))
def get_type(self):
def get_vitrage_type(self):
return COLLECTD_DATASOURCE
@staticmethod

View File

@ -47,7 +47,7 @@ class ConsistencyTransformer(ResourceTransformerBase):
return graph_utils.create_vertex(
entity_event[VProps.VITRAGE_ID],
sample_timestamp=entity_event[DSProps.SAMPLE_DATE],
vitrage_sample_timestamp=entity_event[DSProps.SAMPLE_DATE],
metadata=metadata
)
@ -60,5 +60,5 @@ class ConsistencyTransformer(ResourceTransformerBase):
def _create_update_neighbors(self, entity_event):
return None
def get_type(self):
def get_vitrage_type(self):
return CONSISTENCY_DATASOURCE

View File

@ -37,7 +37,7 @@ class DoctorDriver(AlarmDriverBase):
self.conf = conf
self._client = None
def _entity_type(self):
def _vitrage_type(self):
return DOCTOR_DATASOURCE
def _alarm_key(self, alarm):

View File

@ -54,10 +54,10 @@ class DoctorTransformer(AlarmTransformerBase):
return graph_utils.create_vertex(
self._create_entity_key(entity_event),
entity_category=EntityCategory.ALARM,
entity_type=entity_event[DSProps.ENTITY_TYPE],
vitrage_category=EntityCategory.ALARM,
vitrage_type=entity_event[DSProps.ENTITY_TYPE],
vitrage_sample_timestamp=entity_event[DSProps.SAMPLE_DATE],
entity_state=self._get_alarm_state(entity_event),
sample_timestamp=entity_event[DSProps.SAMPLE_DATE],
update_timestamp=entity_event[DoctorProps.UPDATE_TIME],
metadata=details)
@ -76,7 +76,7 @@ class DoctorTransformer(AlarmTransformerBase):
entity_event[EventProps.TYPE],
get_detail(entity_event, DoctorDetails.HOSTNAME)))
def get_type(self):
def get_vitrage_type(self):
return DOCTOR_DATASOURCE
def _ok_status(self, entity_event):

View File

@ -91,15 +91,15 @@ class HeatStackTransformer(ResourceTransformerBase):
entity_key = self._create_entity_key(entity_event)
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
return graph_utils.create_vertex(
entity_key,
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=HEAT_STACK_DATASOURCE,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=stack_id,
entity_category=EntityCategory.RESOURCE,
entity_type=HEAT_STACK_DATASOURCE,
entity_state=stack_state,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -133,5 +133,5 @@ class HeatStackTransformer(ResourceTransformerBase):
return neighbors
def get_type(self):
def get_vitrage_type(self):
return HEAT_STACK_DATASOURCE

View File

@ -46,7 +46,7 @@ class NagiosConfig(object):
config[NAME])
def get_vitrage_resource(self, nagios_host):
"""Get Vitrage resource type and name for the given nagios host name
"""Get Resource type and name for the given nagios host name
Go over the configuration mappings one by one, and return the resource
by the first mapping that applies to nagios host name.

View File

@ -37,7 +37,7 @@ class NagiosDriver(AlarmDriverBase):
self.conf = conf
self.config = NagiosConfig(conf)
def _entity_type(self):
def _vitrage_type(self):
return NAGIOS_DATASOURCE
def _alarm_key(self, alarm):

View File

@ -42,9 +42,10 @@ class NagiosTransformer(AlarmTransformerBase):
entity_event[NagiosProperties.LAST_CHECK],
'%Y-%m-%d %H:%M:%S',
tbase.TIMESTAMP_FORMAT)
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = self._format_update_timestamp(update_timestamp,
sample_timestamp)
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = \
self._format_update_timestamp(update_timestamp,
vitrage_sample_timestamp)
metadata = {
VProps.NAME: entity_event[NagiosProperties.SERVICE],
@ -55,10 +56,10 @@ class NagiosTransformer(AlarmTransformerBase):
return graph_utils.create_vertex(
self._create_entity_key(entity_event),
entity_category=EntityCategory.ALARM,
entity_type=entity_event[DSProps.ENTITY_TYPE],
vitrage_category=EntityCategory.ALARM,
vitrage_type=entity_event[DSProps.ENTITY_TYPE],
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_state=self._get_alarm_state(entity_event),
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -93,5 +94,5 @@ class NagiosTransformer(AlarmTransformerBase):
resource_name,
alarm_name))
def get_type(self):
def get_vitrage_type(self):
return NAGIOS_DATASOURCE

View File

@ -87,15 +87,15 @@ class NetworkTransformer(ResourceTransformerBase):
VProps.PROJECT_ID: project_id,
}
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
return graph_utils.create_vertex(
self._create_entity_key(entity_event),
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NEUTRON_NETWORK_DATASOURCE,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=entity_id,
entity_category=EntityCategory.RESOURCE,
entity_type=NEUTRON_NETWORK_DATASOURCE,
entity_state=state,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -107,5 +107,5 @@ class NetworkTransformer(ResourceTransformerBase):
key_fields = self._key_values(NEUTRON_NETWORK_DATASOURCE, network_id)
return tbase.build_key(key_fields)
def get_type(self):
def get_vitrage_type(self):
return NEUTRON_NETWORK_DATASOURCE

View File

@ -105,15 +105,15 @@ class PortTransformer(ResourceTransformerBase):
'host_id': entity_event.get('binding:host_id'),
}
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
return graph_utils.create_vertex(
self._create_entity_key(entity_event),
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NEUTRON_PORT_DATASOURCE,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=entity_id,
entity_category=EntityCategory.RESOURCE,
entity_type=NEUTRON_PORT_DATASOURCE,
entity_state=state,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -159,5 +159,5 @@ class PortTransformer(ResourceTransformerBase):
return tbase.build_key(key_fields)
def get_type(self):
def get_vitrage_type(self):
return NEUTRON_PORT_DATASOURCE

View File

@ -48,16 +48,17 @@ class HostTransformer(ResourceTransformerBase):
metadata = {VProps.NAME: host_name}
entity_key = self._create_entity_key(entity_event)
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = self._format_update_timestamp(None,
sample_timestamp)
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = \
self._format_update_timestamp(None,
vitrage_sample_timestamp)
return graph_utils.create_vertex(
entity_key,
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NOVA_HOST_DATASOURCE,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=host_name,
entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_HOST_DATASOURCE,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -83,5 +84,5 @@ class HostTransformer(ResourceTransformerBase):
key_fields = self._key_values(NOVA_HOST_DATASOURCE, host_name)
return transformer_base.build_key(key_fields)
def get_type(self):
def get_vitrage_type(self):
return NOVA_HOST_DATASOURCE

View File

@ -62,21 +62,21 @@ class InstanceTransformer(ResourceTransformerBase):
'host_id': host
}
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
# TODO(Alexey): need to check that only the UPDATE datasource_action
# will update the UPDATE_TIMESTAMP property
update_timestamp = self._format_update_timestamp(
extract_field_value(entity_event, DSProps.SAMPLE_DATE),
sample_timestamp)
vitrage_sample_timestamp)
return graph_utils.create_vertex(
self._create_entity_key(entity_event),
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NOVA_INSTANCE_DATASOURCE,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=entity_id,
entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_INSTANCE_DATASOURCE,
entity_state=state,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -106,5 +106,5 @@ class InstanceTransformer(ResourceTransformerBase):
instance_id))
return tbase.build_key(key_fields)
def get_type(self):
def get_vitrage_type(self):
return NOVA_INSTANCE_DATASOURCE

View File

@ -61,17 +61,18 @@ class ZoneTransformer(ResourceTransformerBase):
}
entity_key = self._create_entity_key(entity_event)
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = self._format_update_timestamp(None,
sample_timestamp)
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = \
self._format_update_timestamp(None,
vitrage_sample_timestamp)
return graph_utils.create_vertex(
entity_key,
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NOVA_ZONE_DATASOURCE,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=zone_name,
entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_ZONE_DATASOURCE,
entity_state=state,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -84,7 +85,7 @@ class ZoneTransformer(ResourceTransformerBase):
def _create_zone_neighbors(self, entity_event):
neighbors = []
metadata = {
VProps.IS_PLACEHOLDER: False,
VProps.VITRAGE_IS_PLACEHOLDER: False,
VProps.STATE: 'available',
VProps.NAME: OPENSTACK_CLUSTER
}
@ -113,7 +114,7 @@ class ZoneTransformer(ResourceTransformerBase):
metadata = {
VProps.STATE: host_state,
VProps.IS_PLACEHOLDER: False
VProps.VITRAGE_IS_PLACEHOLDER: False
}
host_neighbor = self._create_neighbor(entity_event,
@ -133,5 +134,5 @@ class ZoneTransformer(ResourceTransformerBase):
key_fields = self._key_values(NOVA_ZONE_DATASOURCE, zone_name)
return tbase.build_key(key_fields)
def get_type(self):
def get_vitrage_type(self):
return NOVA_ZONE_DATASOURCE

View File

@ -28,7 +28,9 @@ LOG = log.getLogger(__name__)
class StaticDriver(DriverBase):
# base fields are required for all entities, others are treated as metadata
BASE_FIELDS = {StaticFields.STATIC_ID, StaticFields.TYPE, StaticFields.ID}
BASE_FIELDS = {StaticFields.STATIC_ID,
StaticFields.TYPE,
StaticFields.ID}
def __init__(self, conf):
super(StaticDriver, self).__init__()
@ -121,9 +123,11 @@ class StaticDriver(DriverBase):
"""Expand config id to neighbor entity
rel={'source': 's1', 'target': 'r1', 'relationship_type': 'attached'}
neighbor={'static_id': 'h1', 'type': 'host.nova', 'id': 1}
neighbor={'static_id': 'h1', 'vitrage_type': 'host.nova', 'id': 1}
result={'relationship_type': 'attached', 'source': 's1',
'target': {'static_id': 'h1', 'type': 'host.nova', 'id': 1}}
'target': {'static_id': 'h1',
'vitrage_type': 'host.nova',
'id': 1}}
"""
rel = rel.copy()

View File

@ -46,27 +46,27 @@ class StaticTransformer(ResourceTransformerBase):
def _create_entity_key(self, entity_event):
entity_id = entity_event[VProps.ID]
entity_type = entity_event[VProps.TYPE]
entity_type = entity_event[StaticFields.TYPE]
key_fields = self._key_values(entity_type, entity_id)
return transformer_base.build_key(key_fields)
@staticmethod
def get_type():
def get_vitrage_type():
return STATIC_DATASOURCE
def _create_vertex(self, entity_event):
entity_type = entity_event[VProps.TYPE]
entity_type = entity_event[StaticFields.TYPE]
entity_id = entity_event[VProps.ID]
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
if entity_type in self.transformers:
properties = {
VProps.TYPE: entity_type,
VProps.VITRAGE_TYPE: entity_type,
VProps.ID: entity_id,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: sample_timestamp,
VProps.IS_PLACEHOLDER: False
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_timestamp,
VProps.VITRAGE_IS_PLACEHOLDER: False
}
return self.create_neighbor_placeholder_vertex(**properties)
else:
@ -74,15 +74,15 @@ class StaticTransformer(ResourceTransformerBase):
state = entity_event[VProps.STATE]
update_timestamp = self._format_update_timestamp(
update_timestamp=None,
sample_timestamp=sample_timestamp)
sample_timestamp=vitrage_sample_timestamp)
metadata = entity_event.get(StaticFields.METADATA, {})
return graph_utils.create_vertex(
entity_key,
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=entity_type,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=entity_id,
entity_category=EntityCategory.RESOURCE,
entity_type=entity_type,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
entity_state=state,
metadata=metadata)
@ -103,7 +103,7 @@ class StaticTransformer(ResourceTransformerBase):
return self._create_neighbor(
entity_event,
neighbor[VProps.ID],
neighbor[VProps.TYPE],
neighbor[StaticFields.TYPE],
rel[StaticFields.RELATIONSHIP_TYPE],
is_entity_source=is_entity_source)

View File

@ -18,9 +18,9 @@ from oslo_log import log
from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import GraphAction
from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.driver_base import DriverBase
from vitrage.datasources.static.driver import StaticDriver
from vitrage.datasources.static import StaticFields
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
from vitrage.utils import file as file_utils
@ -149,8 +149,8 @@ class StaticPhysicalDriver(DriverBase):
@staticmethod
def _find_entity(new_entity, entities):
for entity in entities:
if entity[VProps.TYPE] == new_entity[VProps.TYPE] \
and entity[VProps.ID] == new_entity[VProps.ID]:
if entity[StaticFields.TYPE] == new_entity[StaticFields.TYPE] \
and entity[StaticFields.ID] == new_entity[StaticFields.ID]:
return entity
return None

View File

@ -19,6 +19,7 @@ from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.resource_transformer_base import \
ResourceTransformerBase
from vitrage.datasources.static import StaticFields
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
from vitrage.datasources.static_physical import SWITCH
from vitrage.datasources import transformer_base
@ -47,22 +48,22 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
def _create_vertex(self, entity_event):
entity_type = entity_event[VProps.TYPE]
entity_type = entity_event[StaticFields.TYPE]
entity_id = entity_event[VProps.ID]
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = self._format_update_timestamp(
update_timestamp=None,
sample_timestamp=sample_timestamp)
sample_timestamp=vitrage_sample_timestamp)
state = entity_event[VProps.STATE]
entity_key = self._create_entity_key(entity_event)
metadata = self._extract_metadata(entity_event)
return graph_utils.create_vertex(
entity_key,
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=entity_type,
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_id=entity_id,
entity_category=EntityCategory.RESOURCE,
entity_type=entity_type,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
entity_state=state,
metadata=metadata)
@ -75,14 +76,14 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
def _create_static_physical_neighbors(self, entity_event):
neighbors = []
entity_type = entity_event[VProps.TYPE]
entity_type = entity_event[StaticFields.TYPE]
for neighbor_details in entity_event.get(
self.RELATIONSHIPS_SECTION, {}):
# TODO(alexey): need to decide what to do if one of the entities
# fails
neighbor_id = neighbor_details[VProps.ID]
neighbor_type = neighbor_details[VProps.TYPE]
neighbor_type = neighbor_details[StaticFields.TYPE]
relation_type = neighbor_details[self.RELATION_TYPE]
is_entity_source = not self._find_relation_direction_source(
entity_type, neighbor_type)
@ -98,7 +99,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
def _create_entity_key(self, entity_event):
entity_id = entity_event[VProps.ID]
entity_type = entity_event[VProps.TYPE]
entity_type = entity_event[StaticFields.TYPE]
key_fields = self._key_values(entity_type, entity_id)
return transformer_base.build_key(key_fields)
@ -121,5 +122,5 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
relationship = (SWITCH, SWITCH)
self.relation_direction[relationship] = True
def get_type(self):
def get_vitrage_type(self):
return STATIC_PHYSICAL_DATASOURCE

View File

@ -74,9 +74,9 @@ def create_cluster_placeholder_vertex():
return graph_utils.create_vertex(
key,
vitrage_category=cons.EntityCategory.RESOURCE,
vitrage_type=OPENSTACK_CLUSTER,
entity_id=CLUSTER_ID,
entity_category=cons.EntityCategory.RESOURCE,
entity_type=OPENSTACK_CLUSTER,
entity_state=AVAILABLE,
metadata=metadata
)
@ -136,9 +136,11 @@ class TransformerBase(object):
def _create_entity_vertex(self, entity_event):
if is_update_event(entity_event) and \
opt_exists(self.conf, self.get_type()) and \
opt_exists(self.conf[self.get_type()], DSOpts.UPDATE_METHOD):
update_method = self.conf[self.get_type()].update_method.lower()
opt_exists(self.conf, self.get_vitrage_type()) and \
opt_exists(self.conf[self.get_vitrage_type()],
DSOpts.UPDATE_METHOD):
update_method = \
self.conf[self.get_vitrage_type()].update_method.lower()
if update_method == UpdateMethod.PUSH:
return self._create_update_entity_vertex(entity_event)
elif update_method == UpdateMethod.PULL:
@ -205,12 +207,12 @@ class TransformerBase(object):
metadata = {} if metadata is None else metadata
# create placeholder vertex
entity_vitrage_id = self._create_entity_key(entity_event)
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
properties = {
VProps.ID: neighbor_id,
VProps.TYPE: neighbor_datasource_type,
VProps.CATEGORY: neighbor_category,
VProps.SAMPLE_TIMESTAMP: sample_timestamp,
VProps.VITRAGE_TYPE: neighbor_datasource_type,
VProps.VITRAGE_CATEGORY: neighbor_category,
VProps.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_timestamp,
self.METADATA: metadata
}
neighbor_vertex = \
@ -244,7 +246,7 @@ class TransformerBase(object):
return (EntityCategory.RESOURCE,) + args
def create_neighbor_placeholder_vertex(self, **kwargs):
if VProps.TYPE not in kwargs:
if VProps.VITRAGE_TYPE not in kwargs:
LOG.error("Can't create placeholder vertex. Missing property TYPE")
raise ValueError('Missing property TYPE')
@ -256,15 +258,17 @@ class TransformerBase(object):
if self.METADATA in kwargs:
metadata = kwargs[self.METADATA]
key_fields = self._key_values(kwargs[VProps.TYPE], kwargs[VProps.ID])
key_fields = self._key_values(kwargs[VProps.VITRAGE_TYPE],
kwargs[VProps.ID])
return graph_utils.create_vertex(
build_key(key_fields),
vitrage_category=kwargs[VProps.VITRAGE_CATEGORY],
vitrage_type=kwargs[VProps.VITRAGE_TYPE],
vitrage_sample_timestamp=kwargs[VProps.VITRAGE_SAMPLE_TIMESTAMP],
vitrage_is_placeholder=kwargs.get(VProps.VITRAGE_IS_PLACEHOLDER,
True),
entity_id=kwargs[VProps.ID],
entity_category=kwargs[VProps.CATEGORY],
entity_type=kwargs[VProps.TYPE],
sample_timestamp=kwargs[VProps.SAMPLE_TIMESTAMP],
is_placeholder=kwargs.get(VProps.IS_PLACEHOLDER, True),
metadata=metadata)
def _extract_graph_action(self, entity_event):
@ -300,9 +304,8 @@ class TransformerBase(object):
@staticmethod
def _create_end_vertex(entity_event):
entity_type = entity_event[DSProps.ENTITY_TYPE]
return graph_utils.create_vertex(
'END_MESSAGE:' + entity_type,
entity_type=entity_type)
return graph_utils.create_vertex('END_MESSAGE:' + entity_type,
vitrage_type=entity_type)
@staticmethod
def _is_end_message(entity_event):
@ -325,16 +328,17 @@ class TransformerBase(object):
Example:
-------
query = {'type': 'nova.instance'}
query = {'vitrage_type': 'nova.instance'}
Before transform is called the result of running the query against
the topology graph will be updated to event[QUERY_RESULT]
To contain the list of all the vertices with type=nova.instance
To contain the list of all the vertices with
vitrage_type=nova.instance
"""
return None
@abc.abstractmethod
def get_type(self):
"""Returns the type of the datasource
def get_vitrage_type(self):
"""Returns the vitrage_type of the datasource
:return: datasource type
:rtype: String

View File

@ -64,7 +64,7 @@ class ZabbixDriver(AlarmDriverBase):
LOG.exception('pyzabbix.ZabbixAPI %s', e)
self._client = None
def _entity_type(self):
def _vitrage_type(self):
return ZABBIX_DATASOURCE
def _alarm_key(self, alarm):

View File

@ -46,10 +46,11 @@ class ZabbixTransformer(AlarmTransformerBase):
update_timestamp = entity_event[ZProps.TIMESTAMP]
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = self._format_update_timestamp(update_timestamp,
sample_timestamp)
update_timestamp = \
self._format_update_timestamp(update_timestamp,
vitrage_sample_timestamp)
zabbix_hostname = entity_event[ZProps.ZABBIX_RESOURCE_NAME]
vitrage_hostname = entity_event[ZProps.RESOURCE_NAME]
@ -70,10 +71,10 @@ class ZabbixTransformer(AlarmTransformerBase):
return graph_utils.create_vertex(
self._create_entity_key(entity_event),
entity_category=EntityCategory.ALARM,
entity_type=entity_event[DSProps.ENTITY_TYPE],
vitrage_category=EntityCategory.ALARM,
vitrage_type=entity_event[DSProps.ENTITY_TYPE],
vitrage_sample_timestamp=vitrage_sample_timestamp,
entity_state=entity_state,
sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp,
metadata=metadata)
@ -121,5 +122,5 @@ class ZabbixTransformer(AlarmTransformerBase):
ZProps.ZABBIX_TIMESTAMP_FORMAT,
tbase.TIMESTAMP_FORMAT)
def get_type(self):
def get_vitrage_type(self):
return ZABBIX_DATASOURCE

View File

@ -24,7 +24,8 @@ from vitrage.common.constants import GraphAction
from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE
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_DATASOURCE
from vitrage.utils.datetime import utcnow
LOG = log.getLogger(__name__)
@ -77,14 +78,14 @@ class ConsistencyEnforcer(object):
try:
LOG.debug('Consistency Periodic Process - Started')
# remove is_deleted=True entities
# remove vitrage_is_deleted=True entities
old_deleted_entities = self._find_old_deleted_entities()
LOG.debug('Found %s vertices to be deleted by consistency service'
': %s', len(old_deleted_entities), old_deleted_entities)
self._push_events_to_queue(old_deleted_entities,
GraphAction.REMOVE_DELETED_ENTITY)
# mark stale entities as is_deleted=True
# mark stale entities as vitrage_is_deleted=True
stale_entities = self._find_stale_entities()
LOG.debug('Found %s vertices to be marked as deleted by '
'consistency service: %s', len(stale_entities),
@ -96,12 +97,13 @@ class ConsistencyEnforcer(object):
'Error in deleting vertices from entity_graph: %s', e)
def _find_stale_entities(self):
vitrage_sample_tstmp = str(utcnow() - timedelta(
seconds=2 * self.conf.datasources.snapshots_interval))
query = {
'and': [
{'!=': {VProps.TYPE: VITRAGE_TYPE}},
{'<': {VProps.SAMPLE_TIMESTAMP: str(utcnow() - timedelta(
seconds=2 * self.conf.datasources.snapshots_interval))}},
{'==': {VProps.IS_DELETED: False}}
{'!=': {VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE}},
{'<': {VProps.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_tstmp}},
{'==': {VProps.VITRAGE_IS_DELETED: False}}
]
}
@ -110,11 +112,12 @@ class ConsistencyEnforcer(object):
return set(self._filter_vertices_to_be_deleted(vertices))
def _find_old_deleted_entities(self):
vitrage_sample_tstmp = str(utcnow() - timedelta(
seconds=self.conf.consistency.min_time_to_delete))
query = {
'and': [
{'==': {VProps.IS_DELETED: True}},
{'<': {VProps.SAMPLE_TIMESTAMP: str(utcnow() - timedelta(
seconds=self.conf.consistency.min_time_to_delete))}}
{'==': {VProps.VITRAGE_IS_DELETED: True}},
{'<': {VProps.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_tstmp}}
]
}
@ -125,9 +128,9 @@ class ConsistencyEnforcer(object):
def _find_old_deduced_alarms(self, timestamp):
query = {
'and': [
{'==': {VProps.CATEGORY: EntityCategory.ALARM}},
{'==': {VProps.TYPE: VITRAGE_TYPE}},
{'<': {VProps.SAMPLE_TIMESTAMP: timestamp}}
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}},
{'==': {VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE}},
{'<': {VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp}}
]
}
return self.graph.get_vertices(query_dict=query)
@ -159,8 +162,8 @@ class ConsistencyEnforcer(object):
DSProps.EVENT_TYPE: action,
VProps.VITRAGE_ID: vertex[VProps.VITRAGE_ID],
VProps.ID: vertex.get(VProps.ID, None),
VProps.TYPE: vertex[VProps.TYPE],
VProps.CATEGORY: vertex[VProps.CATEGORY],
VProps.VITRAGE_TYPE: vertex[VProps.VITRAGE_TYPE],
VProps.VITRAGE_CATEGORY: vertex[VProps.VITRAGE_CATEGORY],
VProps.IS_REAL_VITRAGE_ID: True
}
self.evaluator_queue.put(event)
@ -169,8 +172,8 @@ class ConsistencyEnforcer(object):
def _filter_vertices_to_be_deleted(vertices):
return list(filter(
lambda ver:
not (ver[VProps.CATEGORY] == EntityCategory.RESOURCE and
ver[VProps.TYPE] == OPENSTACK_CLUSTER), vertices))
not (ver[VProps.VITRAGE_CATEGORY] == EntityCategory.RESOURCE and
ver[VProps.VITRAGE_TYPE] == OPENSTACK_CLUSTER), vertices))
def _wait_for_action(self, function):
count_retries = 0

View File

@ -30,10 +30,10 @@ class AlarmHandler(HandlerBase):
return [VProps.SEVERITY]
def set_operational_value(self, new_vertex, operational_value):
new_vertex[VProps.OPERATIONAL_SEVERITY] = operational_value
new_vertex[VProps.VITRAGE_OPERATIONAL_SEVERITY] = operational_value
def set_aggregated_value(self, new_vertex, aggregated_value):
new_vertex[VProps.AGGREGATED_SEVERITY] = aggregated_value
new_vertex[VProps.VITRAGE_AGGREGATED_SEVERITY] = aggregated_value
def default_values(self):
return [(None, OperationalAlarmSeverity.NA, 0)]

View File

@ -39,7 +39,7 @@ class DatasourceInfoMapper(object):
self.category_normalizer = self._init_category_normalizer()
self.datasources_state_confs = self._load_state_configurations()
def operational_state(self, datasource_name, state):
def vitrage_operational_state(self, datasource_name, state):
return self._get_state_data(datasource_name,
state,
self.OPERATIONAL_VALUES)
@ -49,20 +49,20 @@ class DatasourceInfoMapper(object):
state,
self.PRIORITY_VALUES)
def aggregated_state(self, new_vertex, graph_vertex):
datasource_name = new_vertex[VProps.TYPE] if \
VProps.TYPE in new_vertex.properties else \
graph_vertex[VProps.TYPE]
def vitrage_aggregated_state(self, new_vertex, graph_vertex):
datasource_name = new_vertex[VProps.VITRAGE_TYPE] if \
VProps.VITRAGE_TYPE in new_vertex.properties else \
graph_vertex[VProps.VITRAGE_TYPE]
category = new_vertex[VProps.CATEGORY] if \
VProps.CATEGORY in new_vertex.properties else \
graph_vertex[VProps.CATEGORY]
vitrage_category = new_vertex[VProps.VITRAGE_CATEGORY] if \
VProps.VITRAGE_CATEGORY in new_vertex.properties else \
graph_vertex[VProps.VITRAGE_CATEGORY]
if datasource_name in self.datasources_state_confs or \
datasource_name not in self.conf.datasources.types:
value_properties = \
self.category_normalizer[category].value_properties()
operational_state, aggregated_state, state_priority = \
self.category_normalizer[vitrage_category].value_properties()
vitrage_operational_state, vitrage_aggregated_state, state_priority = \
self._find_operational_state_and_priority(new_vertex,
graph_vertex,
value_properties[0],
@ -76,18 +76,18 @@ class DatasourceInfoMapper(object):
property_,
datasource_name)
if t_state_priority > state_priority:
operational_state = t_operational_state
aggregated_state = t_aggregated_state
vitrage_operational_state = t_operational_state
vitrage_aggregated_state = t_aggregated_state
state_priority = t_state_priority
self.category_normalizer[category].set_aggregated_value(
new_vertex, aggregated_state)
self.category_normalizer[category].set_operational_value(
new_vertex, operational_state)
self.category_normalizer[vitrage_category].set_aggregated_value(
new_vertex, vitrage_aggregated_state)
self.category_normalizer[vitrage_category].set_operational_value(
new_vertex, vitrage_operational_state)
else:
self.category_normalizer[category].set_aggregated_value(
self.category_normalizer[vitrage_category].set_aggregated_value(
new_vertex, self.UNDEFINED_DATASOURCE)
self.category_normalizer[category].set_operational_value(
self.category_normalizer[vitrage_category].set_operational_value(
new_vertex, self.UNDEFINED_DATASOURCE)
def get_datasource_priorities(self, datasource_name=None):
@ -140,7 +140,7 @@ class DatasourceInfoMapper(object):
states = {}
priorities = {}
config = file_utils.load_yaml_file(full_path, with_exception=True)
category = config['category']
vitrage_category = config['category']
for item in config['values']:
aggregated_values = item['aggregated values']
@ -153,9 +153,9 @@ class DatasourceInfoMapper(object):
states[original_value.upper()] = operational_value
priorities[original_value.upper()] = priority_value
self._check_validity(category, states, priorities, full_path)
self._check_validity(vitrage_category, states, priorities, full_path)
self._add_default_states(states, priorities, category)
self._add_default_states(states, priorities, vitrage_category)
return states, priorities
@ -208,13 +208,13 @@ class DatasourceInfoMapper(object):
upper_state = state if not state else state.upper()
operational_state = self.operational_state(datasource_name,
upper_state)
vitrage_operational_state = self.vitrage_operational_state(
datasource_name, upper_state)
state_priority = self.state_priority(datasource_name,
upper_state)
return operational_state, upper_state, state_priority
return vitrage_operational_state, upper_state, state_priority
@staticmethod
def _get_all_local_variables_of_class(class_instance):

View File

@ -29,11 +29,12 @@ class ResourceHandler(HandlerBase):
def value_properties(self):
return [VProps.STATE, VProps.VITRAGE_STATE]
def set_operational_value(self, new_vertex, operational_value):
new_vertex[VProps.OPERATIONAL_STATE] = operational_value
def set_operational_value(self, new_vertex, vitrage_operational_value):
new_vertex[VProps.VITRAGE_OPERATIONAL_STATE] = \
vitrage_operational_value
def set_aggregated_value(self, new_vertex, aggregated_value):
new_vertex[VProps.AGGREGATED_STATE] = aggregated_value
def set_aggregated_value(self, new_vertex, vitrage_aggregated_value):
new_vertex[VProps.VITRAGE_AGGREGATED_STATE] = vitrage_aggregated_value
def default_values(self):
return [(None, OperationalResourceState.NA, 0)]

View File

@ -55,7 +55,7 @@ class GraphNotifier(object):
change that happened. None if the element was just created.
:param current: The graph element (vertex or edge) after the
change that happened. Deleted elements should arrive with the
is_deleted property set to True
vitrage_is_deleted property set to True
:param graph: The graph
"""
notification_types = _get_notification_type(before, current, is_vertex)
@ -109,8 +109,8 @@ def _get_notification_type(before, current, is_vertex):
def _is_active_deduced_alarm(vertex):
if not vertex:
return False
if vertex.get(VProps.CATEGORY) == EntityCategory.ALARM and \
vertex.get(VProps.TYPE) == evaluator.VITRAGE_TYPE:
if vertex.get(VProps.VITRAGE_CATEGORY) == EntityCategory.ALARM and \
vertex.get(VProps.VITRAGE_TYPE) == evaluator.VITRAGE_DATASOURCE:
return _is_relevant_vertex(vertex)
return False
@ -118,14 +118,14 @@ def _is_active_deduced_alarm(vertex):
def _is_marked_down(vertex):
if not vertex:
return False
if vertex.get(VProps.CATEGORY) == EntityCategory.RESOURCE and \
if vertex.get(VProps.VITRAGE_CATEGORY) == EntityCategory.RESOURCE and \
vertex.get(VProps.IS_MARKED_DOWN) is True:
return _is_relevant_vertex(vertex)
return False
def _is_relevant_vertex(vertex):
if vertex.get(VProps.IS_DELETED, False) or \
vertex.get(VProps.IS_PLACEHOLDER, False):
if vertex.get(VProps.VITRAGE_IS_DELETED, False) or \
vertex.get(VProps.VITRAGE_IS_PLACEHOLDER, False):
return False
return True

View File

@ -64,7 +64,7 @@ class Processor(processor.ProcessorBase):
self._enrich_event(event)
entity = self.transformer_manager.transform(event)
self._calculate_aggregated_state(entity.vertex, entity.action)
self._calculate_vitrage_aggregated_state(entity.vertex, entity.action)
self.actions[entity.action](entity.vertex, entity.neighbors)
def create_entity(self, new_vertex, neighbors):
@ -198,7 +198,7 @@ class Processor(processor.ProcessorBase):
def remove_deleted_entity(self, vertex, neighbors):
"""Removes the deleted vertex from the entity graph
Removes vertex that it's is_deleted value is True
Removes vertex that it's vitrage_is_deleted value is True
:param vertex: The vertex to be removed from the graph
:type vertex: Vertex
@ -218,7 +218,8 @@ class Processor(processor.ProcessorBase):
LOG.warning("Delete event arrived on invalid resource: %s", vertex)
def handle_end_message(self, vertex, neighbors):
self.initialization_status.end_messages[vertex[VProps.TYPE]] = True
self.initialization_status.end_messages[vertex[VProps.VITRAGE_TYPE]] \
= True
if len(self.initialization_status.end_messages) == \
len(self.conf.datasources.types):
@ -258,7 +259,7 @@ class Processor(processor.ProcessorBase):
if not graph_vertex or not PUtils.is_deleted(graph_vertex):
if PUtils.can_update_vertex(graph_vertex, vertex):
LOG.debug("Updates vertex: %s", vertex)
self._calculate_aggregated_state(vertex, action)
self._calculate_vitrage_aggregated_state(vertex, action)
PUtils.update_entity_graph_vertex(self.entity_graph,
graph_vertex,
vertex)
@ -336,7 +337,7 @@ class Processor(processor.ProcessorBase):
GraphAction.END_MESSAGE: self.handle_end_message
}
def _calculate_aggregated_state(self, vertex, action):
def _calculate_vitrage_aggregated_state(self, vertex, action):
LOG.debug("calculate event state")
try:
@ -359,7 +360,7 @@ class Processor(processor.ProcessorBase):
action, vertex)
return None
self.state_manager.aggregated_state(vertex, graph_vertex)
self.state_manager.vitrage_aggregated_state(vertex, graph_vertex)
except Exception as e:
LOG.exception("Calculate aggregated state failed - %s", e)
@ -408,7 +409,7 @@ class Processor(processor.ProcessorBase):
and not include_deleted):
vitrage_id = uuidutils.generate_uuid()
if vertex[VProps.TYPE] == OPENSTACK_CLUSTER:
if vertex[VProps.VITRAGE_TYPE] == OPENSTACK_CLUSTER:
self.entity_graph.root_id = vitrage_id
else:
vitrage_id = graph_vertex[VProps.VITRAGE_ID]
@ -429,9 +430,10 @@ class Processor(processor.ProcessorBase):
edge.source_id = vitrage_id
edge.target_id = neighbor_vertex.vertex_id
def _add_resource_details_to_alarm(self, vertex, neighbors):
@staticmethod
def _add_resource_details_to_alarm(vertex, neighbors):
if not vertex.get(VProps.CATEGORY) == EntityCategory.ALARM \
if not vertex.get(VProps.VITRAGE_CATEGORY) == EntityCategory.ALARM \
or not neighbors:
return
@ -441,11 +443,12 @@ class Processor(processor.ProcessorBase):
for neighbor in neighbors:
if neighbor.vertex.get(VProps.CATEGORY) == EntityCategory.RESOURCE:
if neighbor.vertex.get(VProps.VITRAGE_CATEGORY) == \
EntityCategory.RESOURCE:
vertex.properties[VProps.VITRAGE_RESOURCE_ID] = \
neighbor.vertex.vertex_id
vertex.properties[VProps.VITRAGE_RESOURCE_TYPE] = \
neighbor.vertex.get(VProps.TYPE)
neighbor.vertex.get(VProps.VITRAGE_TYPE)
def _get_single_graph_vertex_by_props(self, vertex, include_deleted=False):
"""Returns a single vertex by it's defining properties
@ -470,7 +473,7 @@ class Processor(processor.ProcessorBase):
graph_vertices.append(tmp_vertex)
else:
for tmp_vertex in received_graph_vertices:
if not tmp_vertex.get(VProps.IS_DELETED, False):
if not tmp_vertex.get(VProps.VITRAGE_IS_DELETED, False):
graph_vertices.append(tmp_vertex)
if len(graph_vertices) > 1:

View File

@ -28,12 +28,12 @@ LOG = log.getLogger(__name__)
def is_newer_vertex(prev_vertex, new_vertex):
prev_timestamp = prev_vertex.get(VProps.SAMPLE_TIMESTAMP)
prev_timestamp = prev_vertex.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
if not prev_timestamp:
return True
prev_time = parser.parse(prev_timestamp)
new_timestamp = new_vertex[VProps.SAMPLE_TIMESTAMP]
new_timestamp = new_vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP]
if not new_timestamp:
return False
new_time = parser.parse(new_timestamp)
@ -43,17 +43,19 @@ def is_newer_vertex(prev_vertex, new_vertex):
def is_deleted(item):
return item and \
(isinstance(item, Vertex) and item.get(VProps.IS_DELETED, False)) or\
(isinstance(item, Edge) and item.get(EProps.IS_DELETED, False))
(isinstance(item, Vertex) and
item.get(VProps.VITRAGE_IS_DELETED, False)) or \
(isinstance(item, Edge) and
item.get(EProps.VITRAGE_IS_DELETED, False))
def mark_deleted(g, item):
if isinstance(item, Vertex):
item[VProps.IS_DELETED] = True
item[VProps.SAMPLE_TIMESTAMP] = str(utcnow())
item[VProps.VITRAGE_IS_DELETED] = True
item[VProps.VITRAGE_SAMPLE_TIMESTAMP] = str(utcnow())
g.update_vertex(item)
elif isinstance(item, Edge):
item[EProps.IS_DELETED] = True
item[EProps.VITRAGE_IS_DELETED] = True
item[EProps.UPDATE_TIMESTAMP] = str(utcnow())
g.update_edge(item)
@ -61,7 +63,7 @@ def mark_deleted(g, item):
def delete_placeholder_vertex(g, vertex):
"""Checks if it is a placeholder vertex, and if so deletes it """
if not vertex[VProps.IS_PLACEHOLDER]:
if not vertex[VProps.VITRAGE_IS_PLACEHOLDER]:
return
if not any(True for neighbor_edge in g.get_edges(vertex.vertex_id)
if not is_deleted(neighbor_edge)):
@ -79,29 +81,31 @@ def find_neighbor_types(neighbors):
def get_vertex_types(vertex):
category = vertex[VProps.CATEGORY]
type_ = vertex[VProps.TYPE]
return category, type_
vitrage_category = vertex[VProps.VITRAGE_CATEGORY]
vitrage_type = vertex[VProps.VITRAGE_TYPE]
return vitrage_category, vitrage_type
def get_defining_properties(vertex):
if vertex.get(VProps.CATEGORY) == EntityCategory.ALARM:
dp = (vertex.get(VProps.TYPE), vertex.get(VProps.ID),
if vertex.get(VProps.VITRAGE_CATEGORY) == EntityCategory.ALARM:
dp = (vertex.get(VProps.VITRAGE_TYPE), vertex.get(VProps.ID),
vertex.get(VProps.RESOURCE_ID), vertex.get(VProps.NAME))
else:
dp = (vertex.get(VProps.TYPE), vertex.get(VProps.ID))
dp = (vertex.get(VProps.VITRAGE_TYPE), vertex.get(VProps.ID))
return hash(dp)
def can_update_vertex(graph_vertex, new_vertex):
return (not graph_vertex) or (not new_vertex[VProps.IS_PLACEHOLDER])
return (not graph_vertex) or \
(not new_vertex[VProps.VITRAGE_IS_PLACEHOLDER])
def update_entity_graph_vertex(g, graph_vertex, updated_vertex):
if updated_vertex[VProps.IS_PLACEHOLDER] and \
graph_vertex and not graph_vertex[VProps.IS_PLACEHOLDER]:
if updated_vertex[VProps.VITRAGE_IS_PLACEHOLDER] and \
graph_vertex and not graph_vertex[VProps.VITRAGE_IS_PLACEHOLDER]:
updated_vertex[VProps.IS_PLACEHOLDER] = False
updated_vertex[VProps.IS_DELETED] = graph_vertex[VProps.IS_DELETED]
updated_vertex[VProps.VITRAGE_IS_PLACEHOLDER] = False
updated_vertex[VProps.VITRAGE_IS_DELETED] = \
graph_vertex[VProps.VITRAGE_IS_DELETED]
g.update_vertex(updated_vertex)

View File

@ -22,7 +22,8 @@ from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE
from vitrage.datasources.consistency.transformer import ConsistencyTransformer
from vitrage.evaluator.actions.evaluator_event_transformer import \
EvaluatorEventTransformer
from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE
from vitrage.evaluator.actions.evaluator_event_transformer \
import VITRAGE_DATASOURCE
from vitrage.utils import opt_exists
LOG = logging.getLogger(__name__)
@ -53,7 +54,7 @@ class TransformerManager(object):
LOG.exception('Failed to register transformer %s. '
'Exception: %s', datasource_type, e)
transformers[VITRAGE_TYPE] = importutils.import_object(
transformers[VITRAGE_DATASOURCE] = importutils.import_object(
"%s.%s" % (EvaluatorEventTransformer.__module__,
EvaluatorEventTransformer.__name__), transformers, conf)

View File

@ -21,7 +21,8 @@ from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import VertexProperties as VProps
from vitrage.evaluator.actions.base import ActionMode
from vitrage.evaluator.actions.base import ActionType
from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE
from vitrage.evaluator.actions.evaluator_event_transformer \
import VITRAGE_DATASOURCE
from vitrage.evaluator.actions.recipes.action_steps import ADD_EDGE
from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX
from vitrage.evaluator.actions.recipes.action_steps import REMOVE_EDGE
@ -104,9 +105,9 @@ class ActionExecutor(object):
def _add_default_properties(event):
event[DSProps.DATASOURCE_ACTION] = AType.UPDATE
event[DSProps.ENTITY_TYPE] = VITRAGE_TYPE
event[DSProps.ENTITY_TYPE] = VITRAGE_DATASOURCE
event[VProps.UPDATE_TIMESTAMP] = str(datetime_utils.utcnow(False))
event[VProps.SAMPLE_TIMESTAMP] = str(datetime_utils.utcnow())
event[VProps.VITRAGE_SAMPLE_TIMESTAMP] = str(datetime_utils.utcnow())
@staticmethod
def _register_action_recipes():

View File

@ -36,7 +36,7 @@ from vitrage.graph import Vertex
LOG = logging.getLogger(__name__)
VITRAGE_TYPE = 'vitrage'
VITRAGE_DATASOURCE = 'vitrage'
class EvaluatorEventTransformer(transformer_base.TransformerBase):
@ -63,8 +63,9 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
if event_type == UPDATE_VERTEX:
properties = {
VProps.UPDATE_TIMESTAMP: update_timestamp,
VProps.SAMPLE_TIMESTAMP: event[VProps.SAMPLE_TIMESTAMP],
VProps.IS_PLACEHOLDER: False,
VProps.VITRAGE_SAMPLE_TIMESTAMP:
event[VProps.VITRAGE_SAMPLE_TIMESTAMP],
VProps.VITRAGE_IS_PLACEHOLDER: False,
VProps.RESOURCE_ID: event.get(TFields.TARGET)
}
if VProps.IS_REAL_VITRAGE_ID in event:
@ -89,9 +90,10 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
}
return graph_utils.create_vertex(
self._create_entity_key(event),
entity_category=EntityCategory.ALARM,
entity_type=VITRAGE_TYPE,
sample_timestamp=event[VProps.SAMPLE_TIMESTAMP],
vitrage_category=EntityCategory.ALARM,
vitrage_type=VITRAGE_DATASOURCE,
vitrage_sample_timestamp=event[
VProps.VITRAGE_SAMPLE_TIMESTAMP],
update_timestamp=update_timestamp,
metadata=metadata)
@ -104,7 +106,6 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
return self._create_vitrage_neighbors(event)
def _create_vitrage_neighbors(self, event):
event_type = event[EVALUATOR_EVENT_TYPE]
timestamp = transformer_base.convert_timestamp_format(
@ -113,6 +114,7 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
)
if event_type in [ADD_EDGE, REMOVE_EDGE]:
relation_edge = graph_utils.create_edge(
source_id=event[TFields.SOURCE],
target_id=event[TFields.TARGET],
@ -122,6 +124,7 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
return [Neighbor(None, relation_edge)]
if event_type == ADD_VERTEX:
relation_edge = graph_utils.create_edge(
source_id=self._create_entity_key(event),
target_id=event[TFields.TARGET],
@ -129,12 +132,13 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
update_timestamp=timestamp)
neighbor_props = {
VProps.IS_PLACEHOLDER: True,
VProps.VITRAGE_IS_PLACEHOLDER: True,
VProps.UPDATE_TIMESTAMP: timestamp,
VProps.SAMPLE_TIMESTAMP: event[VProps.SAMPLE_TIMESTAMP],
VProps.VITRAGE_SAMPLE_TIMESTAMP:
event[VProps.VITRAGE_SAMPLE_TIMESTAMP],
VProps.IS_REAL_VITRAGE_ID: True,
VProps.TYPE: event[VProps.VITRAGE_RESOURCE_TYPE],
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: event[VProps.VITRAGE_RESOURCE_TYPE],
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
}
neighbor = Vertex(event[TFields.TARGET], neighbor_props)
return [Neighbor(neighbor, relation_edge)]
@ -166,10 +170,10 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
return transformer_base.build_key(key_fields)
def _key_values(self, *args):
return (EntityCategory.ALARM, VITRAGE_TYPE) + args
return (EntityCategory.ALARM, VITRAGE_DATASOURCE) + args
def create_neighbor_placeholder_vertex(self, **kwargs):
LOG.info('Evaluator does not create placeholders')
def get_type(self):
return VITRAGE_TYPE
def get_vitrage_type(self):
return VITRAGE_DATASOURCE

View File

@ -53,9 +53,9 @@ class SetStateTools(object):
def get_score(self, action_info):
state = action_info.specs.properties[TemplateFields.STATE].upper()
target_resource = action_info.specs.targets[TemplateFields.TARGET]
target_type = target_resource[VProps.TYPE]
score_name = \
target_type if target_type in self.scores else DEFAULT_INFO_MAPPER
target_vitrage_type = target_resource[VProps.VITRAGE_TYPE]
score_name = target_vitrage_type \
if target_vitrage_type in self.scores else DEFAULT_INFO_MAPPER
return self.scores[score_name].get(state, 0)
@staticmethod

View File

@ -58,7 +58,7 @@ class RaiseAlarm(base.Recipe):
target_resource = action_spec.targets[TFields.TARGET]
add_vertex_params = {
TFields.TARGET: target_resource.vertex_id,
VProps.VITRAGE_RESOURCE_TYPE: target_resource[VProps.TYPE],
VProps.VITRAGE_RESOURCE_TYPE: target_resource[VProps.VITRAGE_TYPE],
}
add_vertex_params.update(action_spec.properties)

View File

@ -14,6 +14,7 @@
from vitrage.common.constants import TemplateTopologyFields
from vitrage.common.exception import VitrageError
from vitrage.evaluator.template_data import TemplateData
class Fields(TemplateTopologyFields):
@ -51,7 +52,9 @@ class EquivalenceData(object):
for entity_def in equivalent_entities:
entity_props = {(k, v)
for k, v in entity_def[Fields.ENTITY].items()}
entity_key = frozenset(entity_props)
entity_key = frozenset(
TemplateData._convert_props_with_set(entity_props))
if entity_key in equivalence:
raise VitrageError('duplicated entities found in '
'equivalence')

View File

@ -77,7 +77,7 @@ class ScenarioEvaluator(object):
change that happened. None if the element was just created.
:param current: The graph element (vertex or edge) after the
change that happened. Deleted elements should arrive with the
is_deleted property set to True
vitrage_is_deleted property set to True
"""
if not self.enabled:
@ -118,8 +118,8 @@ class ScenarioEvaluator(object):
def _get_element_scenarios(self, element, is_vertex):
if not element \
or element.get(VProps.IS_DELETED) \
or element.get(EProps.IS_DELETED):
or element.get(VProps.VITRAGE_IS_DELETED) \
or element.get(EProps.VITRAGE_IS_DELETED):
return []
elif is_vertex:
return self._scenario_repo.get_scenarios_by_vertex(element)
@ -310,8 +310,8 @@ class ScenarioEvaluator(object):
connected_component = self.get_connected_component(subgraph,
action_target)
# change the is_deleted and negative_condition props to false when
# is_switch_mode=true so that when we have an event on a
# change the vitrage_is_deleted and negative_condition props to
# false when is_switch_mode=true so that when we have an event on a
# negative_condition=true edge it will find the correct subgraph
self._switch_edge_negative_props(is_switch_mode, scenario_edge,
subgraph, False)
@ -349,7 +349,7 @@ class ScenarioEvaluator(object):
status):
if is_switch_mode:
scenario_edge.edge[NEG_CONDITION] = status
scenario_edge.edge[EProps.IS_DELETED] = status
scenario_edge.edge[EProps.VITRAGE_IS_DELETED] = status
subgraph.update_edge(scenario_edge.edge)
@staticmethod

View File

@ -52,6 +52,19 @@ def copy_edge_desc(edge_desc):
# noinspection PyAttributeOutsideInit
class TemplateData(object):
PROPS_CONVERSION = {
'category': VProps.VITRAGE_CATEGORY,
'type': VProps.VITRAGE_TYPE,
'resource_id': VProps.VITRAGE_RESOURCE_ID,
'sample_timestamp': VProps.VITRAGE_SAMPLE_TIMESTAMP,
'is_deleted': VProps.VITRAGE_IS_DELETED,
'is_placeholder': VProps.VITRAGE_IS_PLACEHOLDER,
'aggregated_state': VProps.VITRAGE_AGGREGATED_STATE,
'operational_state': VProps.VITRAGE_OPERATIONAL_STATE,
'aggregated_severity': VProps.VITRAGE_AGGREGATED_SEVERITY,
'operational_severity': VProps.VITRAGE_OPERATIONAL_SEVERITY
}
def __init__(self, template_def):
self.name = template_def[TFields.METADATA][TFields.NAME]
@ -105,7 +118,8 @@ class TemplateData(object):
entity_dict = entity_def[TFields.ENTITY]
template_id = entity_dict[TFields.TEMPLATE_ID]
properties = self._extract_properties(entity_dict)
properties = self._convert_properties_with_dictionary(
self._extract_properties(entity_dict))
entities[template_id] = Vertex(template_id, properties)
return entities
@ -143,6 +157,24 @@ class TemplateData(object):
return dict((key, var_dict[key]) for key in var_dict
if key not in ignore_ids)
@staticmethod
def _convert_props_with_set(properties):
converted_properties = set()
for key, value in properties:
new_key = TemplateData.PROPS_CONVERSION[key] if key in \
TemplateData.PROPS_CONVERSION else key
converted_properties.add((new_key, value))
return converted_properties
@staticmethod
def _convert_properties_with_dictionary(properties):
converted_properties = {}
for key, value in properties.items():
new_key = TemplateData.PROPS_CONVERSION[key] if key in \
TemplateData.PROPS_CONVERSION else key
converted_properties[new_key] = value
return converted_properties
def _build_scenarios(self, scenarios_defs):
scenarios = []
@ -347,14 +379,14 @@ class TemplateData(object):
variable, var_type = extract_var(term.symbol_name)
if var_type == ENTITY:
vertex = variable.copy()
vertex[VProps.IS_DELETED] = False
vertex[VProps.IS_PLACEHOLDER] = False
vertex[VProps.VITRAGE_IS_DELETED] = False
vertex[VProps.VITRAGE_IS_PLACEHOLDER] = False
condition_g.add_vertex(vertex)
else: # type = relationship
# prevent overwritten of NEG_CONDITION and IS_DELETED
# property when there are both "not A" and "A" in same
# template
# prevent overwritten of NEG_CONDITION and
# VITRAGE_IS_DELETED property when there are both "not A"
# and "A" in same template
edge_desc = copy_edge_desc(variable)
cls._set_edge_relationship_info(edge_desc, term.positive)
cls._add_edge_relationship(condition_g, edge_desc)
@ -366,15 +398,15 @@ class TemplateData(object):
is_positive_condition):
if not is_positive_condition:
edge_description.edge[NEG_CONDITION] = True
edge_description.edge[EProps.IS_DELETED] = True
edge_description.edge[EProps.VITRAGE_IS_DELETED] = True
else:
edge_description.edge[EProps.IS_DELETED] = False
edge_description.edge[EProps.VITRAGE_IS_DELETED] = False
edge_description.edge[NEG_CONDITION] = False
edge_description.source[VProps.IS_DELETED] = False
edge_description.source[VProps.IS_PLACEHOLDER] = False
edge_description.target[VProps.IS_DELETED] = False
edge_description.target[VProps.IS_PLACEHOLDER] = False
edge_description.source[VProps.VITRAGE_IS_DELETED] = False
edge_description.source[VProps.VITRAGE_IS_PLACEHOLDER] = False
edge_description.target[VProps.VITRAGE_IS_DELETED] = False
edge_description.target[VProps.VITRAGE_IS_PLACEHOLDER] = False
@staticmethod
def _add_edge_relationship(condition_graph, edge_description):

View File

@ -316,12 +316,12 @@ def _validate_template_id(definitions_index, id_to_check):
return get_correct_result(RESULT_DESCRIPTION)
def _validate_entity_category(entity_to_check, category):
def _validate_entity_category(entity_to_check, vitrage_category):
if TemplateFields.CATEGORY not in entity_to_check \
or entity_to_check[TemplateFields.CATEGORY] != category:
or entity_to_check[TemplateFields.CATEGORY] != vitrage_category:
msg = status_msgs[132] + ' expect %s to be %s' \
% (entity_to_check, category)
% (entity_to_check, vitrage_category)
LOG.error('%s status code: %s' % (msg, 132))
return get_fault_result(RESULT_DESCRIPTION, 132, msg)

View File

@ -191,7 +191,8 @@ class NXAlgorithm(GraphAlgorithm):
has real neighbors in the entity graph.
"""
if self.graph.neighbors(ge_v_id,
edge_attr_filter={EProps.IS_DELETED: False}):
edge_attr_filter={EProps.VITRAGE_IS_DELETED:
False}):
template_vertex = subgraph.get_vertex(sge_v_id)
graph_vertex = self.graph.get_vertex(ge_v_id)
match = Mapping(template_vertex, graph_vertex, True)

View File

@ -42,18 +42,18 @@ def create_predicate(query_dict):
--------------
query_dict = {
'and': [
{'==': {'TYPE': 'ALARM'}},
{'==': {'CATEGORY': 'ALARM'}},
{'or': [
{'>': {'TIME': 150}},
{'==': {'IS_DELETED': True}}
{'==': {'VITRAGE_IS_DELETED': True}}
]}
]
}
Example Output:
--------------
lambda item: ((item['TYPE']== 'ALARM') and
((item['TIME']> 150) or (item['IS_DELETED']== True)))
lambda item: ((item['CATEGORY']== 'ALARM') and
((item['TIME']> 150) or (item['VITRAGE_IS_DELETED']== True)))
Example Usage:
--------------

View File

@ -19,14 +19,14 @@ from vitrage.graph.driver.elements import Vertex
def create_vertex(vitrage_id,
vitrage_category=None,
vitrage_type=None,
vitrage_sample_timestamp=None,
vitrage_is_deleted=False,
vitrage_is_placeholder=False,
entity_id=None,
entity_category=None,
entity_type=None,
entity_state=None,
is_deleted=False,
sample_timestamp=None,
update_timestamp=None,
is_placeholder=False,
project_id=None,
metadata=None):
"""A builder to create a vertex
@ -35,22 +35,22 @@ def create_vertex(vitrage_id,
:type vitrage_id: str
:param entity_id:
:type entity_id: str
:param entity_category:
:type entity_category: str
:param entity_type:
:type entity_type: str
:param vitrage_category:
:type vitrage_category: str
:param vitrage_type:
:type vitrage_type: str
:param entity_state:
:type entity_state: str
:param is_deleted:
:type is_deleted: boolean
:param vitrage_is_deleted:
:type vitrage_is_deleted: boolean
:param update_timestamp:
:type update_timestamp: str
:param sample_timestamp:
:type sample_timestamp: str
:param vitrage_sample_timestamp:
:type vitrage_sample_timestamp: str
:param metadata:
:type metadata: dict
:param is_placeholder:
:type is_placeholder: boolean
:param vitrage_is_placeholder:
:type vitrage_is_placeholder: boolean
:param project_id:
:type project_id: str
:return:
@ -60,12 +60,12 @@ def create_vertex(vitrage_id,
properties = {
VConst.ID: entity_id,
VConst.STATE: entity_state,
VConst.TYPE: entity_type,
VConst.CATEGORY: entity_category,
VConst.IS_DELETED: is_deleted,
VConst.VITRAGE_TYPE: vitrage_type,
VConst.VITRAGE_CATEGORY: vitrage_category,
VConst.VITRAGE_IS_DELETED: vitrage_is_deleted,
VConst.UPDATE_TIMESTAMP: update_timestamp,
VConst.SAMPLE_TIMESTAMP: sample_timestamp,
VConst.IS_PLACEHOLDER: is_placeholder,
VConst.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_timestamp,
VConst.VITRAGE_IS_PLACEHOLDER: vitrage_is_placeholder,
VConst.VITRAGE_ID: vitrage_id,
VConst.PROJECT_ID: project_id
}
@ -80,7 +80,7 @@ def create_vertex(vitrage_id,
def create_edge(source_id,
target_id,
relationship_type,
is_deleted=False,
vitrage_is_deleted=False,
update_timestamp=None,
metadata=None):
"""A builder to create an edge
@ -92,8 +92,8 @@ def create_edge(source_id,
:type target_id: str
:param relationship_type:
:type relationship_type: str
:param is_deleted:
:type is_deleted: str
:param vitrage_is_deleted:
:type vitrage_is_deleted: str
:param metadata:
:type metadata: dict
:return:
@ -101,7 +101,7 @@ def create_edge(source_id,
"""
properties = {
EConst.UPDATE_TIMESTAMP: update_timestamp,
EConst.IS_DELETED: is_deleted,
EConst.VITRAGE_IS_DELETED: vitrage_is_deleted,
EConst.RELATIONSHIP_TYPE: relationship_type,
}
if metadata:

View File

@ -33,7 +33,7 @@ class NovaNotifier(NotifierBase):
self.client = os_clients.nova_client(conf)
def process_event(self, data, event_type):
if data and data.get(VProps.TYPE) == NOVA_HOST_DATASOURCE:
if data and data.get(VProps.VITRAGE_TYPE) == NOVA_HOST_DATASOURCE:
if event_type == NotifierEventTypes.ACTIVATE_MARK_DOWN_EVENT:
self._mark_host_down(data.get(VProps.ID), True)
elif event_type == NotifierEventTypes.DEACTIVATE_MARK_DOWN_EVENT:

View File

@ -151,7 +151,7 @@ class SnmpSender(SnmpSenderBase):
if not severity_mapping:
return None
alarm_severity = alert_values.get(VProps.OPERATIONAL_SEVERITY)
alarm_severity = alert_values.get(VProps.VITRAGE_OPERATIONAL_SEVERITY)
state = alert_values.get(VProps.STATE)
if state in severity_mapping:

View File

@ -18,6 +18,7 @@ from vitrage.api_handler.apis.alarm import AlarmApis
from vitrage.api_handler.apis.rca import RcaApis
from vitrage.api_handler.apis.resource import ResourceApis
from vitrage.api_handler.apis.topology import TopologyApis
from vitrage.common.constants import EdgeLabel
from vitrage.common.constants import EntityCategory
from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources import NOVA_HOST_DATASOURCE
@ -370,7 +371,8 @@ class TestApis(TestEntityGraphUnitBase):
tmp_project_id = alarm.get(VProps.PROJECT_ID, None)
condition = True
if check_alarm_category:
condition = alarm[VProps.CATEGORY] == EntityCategory.ALARM
condition = \
alarm[VProps.VITRAGE_CATEGORY] == EntityCategory.ALARM
if project_id:
condition = condition and \
(not tmp_project_id or
@ -381,11 +383,12 @@ class TestApis(TestEntityGraphUnitBase):
resource_type, project_id=None):
self.assertEqual(resource[VProps.VITRAGE_ID], vitrage_id)
self.assertEqual(resource[VProps.ID], vitrage_id)
self.assertEqual(resource[VProps.CATEGORY], EntityCategory.RESOURCE)
self.assertEqual(resource[VProps.TYPE], resource_type)
self.assertEqual(resource[VProps.VITRAGE_CATEGORY],
EntityCategory.RESOURCE)
self.assertEqual(resource[VProps.VITRAGE_TYPE], resource_type)
self.assertEqual(resource[VProps.STATE], 'active')
self.assertFalse(resource[VProps.IS_DELETED])
self.assertFalse(resource[VProps.IS_PLACEHOLDER])
self.assertFalse(resource[VProps.VITRAGE_IS_DELETED])
self.assertFalse(resource[VProps.VITRAGE_IS_PLACEHOLDER])
if project_id:
self.assertEqual(resource[VProps.PROJECT_ID], project_id)
@ -413,98 +416,98 @@ class TestApis(TestEntityGraphUnitBase):
alarm_on_host_vertex = self._create_alarm(
'alarm_on_host',
'alarm_on_host',
metadata={'type': 'nova.host',
'name': 'host_1',
'resource_id': 'host_1'})
metadata={VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE,
VProps.NAME: 'host_1',
VProps.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'})
metadata={VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.NAME: 'instance_1',
VProps.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'})
metadata={VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.NAME: 'instance_2',
VProps.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'})
metadata={VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.NAME: 'instance_3',
VProps.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'})
metadata={VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.NAME: 'instance_4',
VProps.RESOURCE_ID: 'ngsuy76hgd87f'})
# create links
edges = list()
edges.append(graph_utils.create_edge(
cluster_vertex.vertex_id,
zone_vertex.vertex_id,
'contains'))
EdgeLabel.CONTAINS))
edges.append(graph_utils.create_edge(
zone_vertex.vertex_id,
host_vertex.vertex_id,
'contains'))
EdgeLabel.CONTAINS))
edges.append(graph_utils.create_edge(
host_vertex.vertex_id,
instance_1_vertex.vertex_id,
'contains'))
EdgeLabel.CONTAINS))
edges.append(graph_utils.create_edge(
host_vertex.vertex_id,
instance_2_vertex.vertex_id,
'contains'))
EdgeLabel.CONTAINS))
edges.append(graph_utils.create_edge(
host_vertex.vertex_id,
instance_3_vertex.vertex_id,
'contains'))
EdgeLabel.CONTAINS))
edges.append(graph_utils.create_edge(
host_vertex.vertex_id,
instance_4_vertex.vertex_id,
'contains'))
EdgeLabel.CONTAINS))
edges.append(graph_utils.create_edge(
alarm_on_host_vertex.vertex_id,
host_vertex.vertex_id,
'on'))
EdgeLabel.ON))
edges.append(graph_utils.create_edge(
alarm_on_instance_1_vertex.vertex_id,
instance_1_vertex.vertex_id,
'on'))
EdgeLabel.ON))
edges.append(graph_utils.create_edge(
alarm_on_instance_2_vertex.vertex_id,
instance_2_vertex.vertex_id,
'on'))
EdgeLabel.ON))
edges.append(graph_utils.create_edge(
alarm_on_instance_3_vertex.vertex_id,
instance_3_vertex.vertex_id,
'on'))
EdgeLabel.ON))
edges.append(graph_utils.create_edge(
alarm_on_instance_4_vertex.vertex_id,
instance_4_vertex.vertex_id,
'on'))
EdgeLabel.ON))
edges.append(graph_utils.create_edge(
alarm_on_host_vertex.vertex_id,
alarm_on_instance_1_vertex.vertex_id,
'causes'))
EdgeLabel.CAUSES))
edges.append(graph_utils.create_edge(
alarm_on_host_vertex.vertex_id,
alarm_on_instance_2_vertex.vertex_id,
'causes'))
EdgeLabel.CAUSES))
edges.append(graph_utils.create_edge(
alarm_on_host_vertex.vertex_id,
alarm_on_instance_3_vertex.vertex_id,
'causes'))
EdgeLabel.CAUSES))
edges.append(graph_utils.create_edge(
alarm_on_host_vertex.vertex_id,
alarm_on_instance_4_vertex.vertex_id,
'causes'))
EdgeLabel.CAUSES))
# add vertices to graph
graph.add_vertex(cluster_vertex)

View File

@ -78,8 +78,8 @@ class TestAodhAlarms(TestDataSourcesBase):
aodh_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter={
VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: AODH_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: AODH_DATASOURCE
})
self.assertEqual(1, len(aodh_vertices))
@ -88,4 +88,4 @@ class TestAodhAlarms(TestDataSourcesBase):
self.assertEqual(1, len(aodh_neighbors))
self.assertEqual(NOVA_HOST_DATASOURCE,
aodh_neighbors[0][VProps.TYPE])
aodh_neighbors[0][VProps.VITRAGE_TYPE])

View File

@ -19,10 +19,10 @@ from vitrage.tests.functional.base import TestFunctionalBase
class TestDataSourcesBase(TestFunctionalBase):
def _find_entity_id_by_type(self, graph, type_):
def _find_entity_id_by_type(self, graph, vitrage_type):
entity_vertices = graph.get_vertices(vertex_attr_filter={
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: type_
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: vitrage_type
})
self.assertGreater(len(entity_vertices), 0)

View File

@ -75,8 +75,8 @@ class TestCinderVolume(TestDataSourcesBase):
cinder_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter={
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: CINDER_VOLUME_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE
})
self.assertEqual(1, len(cinder_vertices))
@ -85,4 +85,4 @@ class TestCinderVolume(TestDataSourcesBase):
self.assertEqual(1, len(cinder_neighbors))
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
cinder_neighbors[0][VProps.TYPE])
cinder_neighbors[0][VProps.VITRAGE_TYPE])

View File

@ -72,22 +72,22 @@ class TestHeatStack(TestDataSourcesBase):
stack_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter={
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: HEAT_STACK_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: HEAT_STACK_DATASOURCE
})
self.assertEqual(1, len(stack_vertices))
instance_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter={
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
})
self.assertEqual(self.NUM_INSTANCES + 1, len(instance_vertices))
cinder_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter={
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: CINDER_VOLUME_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE
})
self.assertEqual(1, len(cinder_vertices))

View File

@ -74,8 +74,8 @@ class TestNagios(TestDataSourcesBase):
nagios_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter={
VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: NAGIOS_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE
})
self.assertEqual(1, len(nagios_vertices))
@ -84,4 +84,4 @@ class TestNagios(TestDataSourcesBase):
self.assertEqual(1, len(nagios_neighbors))
self.assertEqual(NOVA_HOST_DATASOURCE,
nagios_neighbors[0][VProps.TYPE])
nagios_neighbors[0][VProps.VITRAGE_TYPE])

View File

@ -81,8 +81,8 @@ class TestStaticPhysical(TestDataSourcesBase):
static_physical_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter={
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: SWITCH
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: SWITCH
})
self.assertEqual(1, len(static_physical_vertices))
@ -91,4 +91,4 @@ class TestStaticPhysical(TestDataSourcesBase):
self.assertEqual(1, len(static_physical_neighbors))
self.assertEqual(NOVA_HOST_DATASOURCE,
static_physical_neighbors[0][VProps.TYPE])
static_physical_neighbors[0][VProps.VITRAGE_TYPE])

View File

@ -30,7 +30,8 @@ from vitrage.entity_graph.consistency.consistency_enforcer \
import ConsistencyEnforcer
from vitrage.entity_graph.initialization_status import InitializationStatus
from vitrage.entity_graph.processor.processor import Processor
from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE
from vitrage.evaluator.actions.evaluator_event_transformer \
import VITRAGE_DATASOURCE
from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
from vitrage.evaluator.scenario_repository import ScenarioRepository
import vitrage.graph.utils as graph_utils
@ -117,30 +118,30 @@ class TestConsistencyFunctional(TestFunctionalBase):
num_of_host_alarms * num_instances_per_host
num_undeleted_vertices_in_graph = \
len(self.processor.entity_graph.get_vertices(vertex_attr_filter={
VProps.IS_DELETED: False
VProps.VITRAGE_IS_DELETED: False
}))
self.assertEqual(self._num_total_expected_vertices() +
num_correct_alarms,
num_undeleted_vertices_in_graph)
alarm_vertices_in_graph = self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.ALARM,
VProps.IS_DELETED: False
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_IS_DELETED: False
})
self.assertEqual(num_correct_alarms, len(alarm_vertices_in_graph))
is_deleted_alarm_vertices_in_graph = \
self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.ALARM,
VProps.IS_DELETED: True
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_IS_DELETED: True
})
self.assertEqual(num_of_host_alarms * num_instances_per_host,
len(is_deleted_alarm_vertices_in_graph))
instance_vertices = self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: VITRAGE_TYPE,
VProps.IS_DELETED: False
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: False
})
self.assertEqual(num_of_host_alarms * num_instances_per_host,
len(instance_vertices))
@ -157,14 +158,14 @@ class TestConsistencyFunctional(TestFunctionalBase):
# Test Assertions
instance_vertices = self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
})
deleted_instance_vertices = \
self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.IS_DELETED: True
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: True
})
self.assertEqual(self.NUM_INSTANCES - 3, len(instance_vertices))
self.assertEqual(self._num_total_expected_vertices() - 3,
@ -183,8 +184,8 @@ class TestConsistencyFunctional(TestFunctionalBase):
# check number of instances in graph
instance_vertices = self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
})
self.assertEqual(self.NUM_INSTANCES, len(instance_vertices))
@ -193,13 +194,13 @@ class TestConsistencyFunctional(TestFunctionalBase):
# set part of the instances as deleted
for i in range(3, 6):
instance_vertices[i][VProps.IS_DELETED] = True
instance_vertices[i][VProps.VITRAGE_IS_DELETED] = True
self.processor.entity_graph.update_vertex(instance_vertices[i])
# set part of the instances as deleted
for i in range(6, 9):
instance_vertices[i][VProps.IS_DELETED] = True
instance_vertices[i][VProps.SAMPLE_TIMESTAMP] = str(
instance_vertices[i][VProps.VITRAGE_IS_DELETED] = True
instance_vertices[i][VProps.VITRAGE_SAMPLE_TIMESTAMP] = str(
current_time + timedelta(seconds=2 * consistency_interval + 1))
self.processor.entity_graph.update_vertex(instance_vertices[i])
@ -215,8 +216,8 @@ class TestConsistencyFunctional(TestFunctionalBase):
def _add_alarms(self):
# find hosts and instances
host_vertices = self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: NOVA_HOST_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE
})
# add host alarms + deduced alarms
@ -249,7 +250,7 @@ class TestConsistencyFunctional(TestFunctionalBase):
def _update_timestamp(self, lst, timestamp):
for vertex in lst:
vertex[VProps.SAMPLE_TIMESTAMP] = str(timestamp)
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP] = str(timestamp)
self.processor.entity_graph.update_vertex(vertex)
def _process_events(self):

View File

@ -49,9 +49,9 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
entity = processor.transformer_manager.transform(event)
processor._find_and_fix_graph_vertex(entity.vertex, [])
vertex = processor.entity_graph.get_vertex(entity.vertex.vertex_id)
self.assertEqual('ACTIVE', vertex[VProps.AGGREGATED_STATE])
self.assertEqual('ACTIVE', vertex[VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.OK,
vertex[VProps.OPERATIONAL_STATE])
vertex[VProps.VITRAGE_OPERATIONAL_STATE])
def test_state_on_neighbor_update(self):
# setup
@ -61,7 +61,7 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
self.assertEqual(2, processor.entity_graph.num_vertices())
neighbors[0].vertex[VProps.STATE] = 'available'
neighbors[0].vertex[VProps.IS_PLACEHOLDER] = False
neighbors[0].vertex[VProps.VITRAGE_IS_PLACEHOLDER] = False
# action
processor._connect_neighbors(neighbors, [], GraphAction.UPDATE_ENTITY)
@ -69,6 +69,7 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
# test assertions
neighbor_vertex = processor.entity_graph.get_vertex(
neighbors[0].vertex.vertex_id)
self.assertEqual('AVAILABLE', neighbor_vertex[VProps.AGGREGATED_STATE])
self.assertEqual('AVAILABLE',
neighbor_vertex[VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.OK,
neighbor_vertex[VProps.OPERATIONAL_STATE])
neighbor_vertex[VProps.VITRAGE_OPERATIONAL_STATE])

View File

@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from six.moves import queue
from oslo_config import cfg
from six.moves import queue
from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProp
from vitrage.common.constants import EdgeLabel
from vitrage.common.constants import EntityCategory
@ -24,13 +25,19 @@ from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
from vitrage.datasources.nagios.properties import NagiosProperties as NProps
from vitrage.datasources.nagios.properties import NagiosTestStatus
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.entity_graph.mappings.operational_alarm_severity import \
OperationalAlarmSeverity
from vitrage.entity_graph.mappings.operational_resource_state import \
OperationalResourceState
from vitrage.evaluator.actions.action_executor import ActionExecutor
from vitrage.evaluator.actions.base import ActionMode
from vitrage.evaluator.actions.base import ActionType
from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE
from vitrage.evaluator.actions.evaluator_event_transformer \
import VITRAGE_DATASOURCE
from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX
from vitrage.evaluator.actions.recipes.base import EVALUATOR_EVENT_TYPE
from vitrage.evaluator.template_data import ActionSpecs
from vitrage.evaluator.template_fields import TemplateFields as TFields
from vitrage.opts import register_opts
@ -54,7 +61,7 @@ class TestActionExecutor(TestFunctionalBase):
# Test Setup
processor = self._create_processor_with_graph(self.conf, uuid=True)
vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE}
vertex_attrs = {VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE}
host_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs)
host_vertex_before = host_vertices[0]
@ -74,12 +81,14 @@ class TestActionExecutor(TestFunctionalBase):
host_vertex_before.vertex_id)
# Test Assertions
agg_state_before = host_vertex_before.get(VProps.AGGREGATED_STATE)
agg_state_before = \
host_vertex_before.get(VProps.VITRAGE_AGGREGATED_STATE)
self.assertNotEqual(agg_state_before,
OperationalResourceState.SUBOPTIMAL)
self.assertNotIn(VProps.VITRAGE_STATE, host_vertex_before.properties)
agg_state_after = host_vertex_after.get(VProps.AGGREGATED_STATE)
agg_state_after = \
host_vertex_after.get(VProps.VITRAGE_AGGREGATED_STATE)
self.assertEqual(agg_state_after, OperationalResourceState.SUBOPTIMAL)
v_state_after = host_vertex_after.get(VProps.VITRAGE_STATE)
self.assertEqual(v_state_after, OperationalResourceState.SUBOPTIMAL)
@ -92,7 +101,8 @@ class TestActionExecutor(TestFunctionalBase):
host_vertex_before.vertex_id)
# Test Assertions
agg_state_after_undo = host_vertex_before.get(VProps.AGGREGATED_STATE)
agg_state_after_undo = \
host_vertex_before.get(VProps.VITRAGE_AGGREGATED_STATE)
self.assertEqual(agg_state_after_undo, agg_state_before)
self.assertNotIn(
VProps.VITRAGE_STATE, host_vertex_after_undo.properties)
@ -102,7 +112,7 @@ class TestActionExecutor(TestFunctionalBase):
# Test Setup
processor = self._create_processor_with_graph(self.conf, uuid=True)
vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE}
vertex_attrs = {VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE}
host_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs)
host_vertex_before = host_vertices[0]
@ -139,7 +149,7 @@ class TestActionExecutor(TestFunctionalBase):
# Test Setup
processor = self._create_processor_with_graph(self.conf, uuid=True)
vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE}
vertex_attrs = {VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE}
host_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs)
@ -153,7 +163,7 @@ class TestActionExecutor(TestFunctionalBase):
host_2.get(VProps.ID), NOVA_HOST_DATASOURCE)
processor.process_event(nagios_event2)
alarms_attrs = {VProps.TYPE: NAGIOS_DATASOURCE}
alarms_attrs = {VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE}
alarms_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=alarms_attrs)
@ -189,7 +199,7 @@ class TestActionExecutor(TestFunctionalBase):
# Test Setup
processor = self._create_processor_with_graph(self.conf, uuid=True)
vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE}
vertex_attrs = {VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE}
host_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs)
@ -207,7 +217,7 @@ class TestActionExecutor(TestFunctionalBase):
# Raise alarm action adds new vertex with type vitrage to the graph
action_spec = ActionSpecs(ActionType.RAISE_ALARM, targets, props)
alarm_vertex_attrs = {VProps.TYPE: VITRAGE_TYPE}
alarm_vertex_attrs = {VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE}
before_alarms = processor.entity_graph.get_vertices(
vertex_attr_filter=alarm_vertex_attrs)
event_queue = queue.Queue()
@ -226,13 +236,13 @@ class TestActionExecutor(TestFunctionalBase):
alarm = after_alarms[0]
self.assertEqual(alarm.properties[VProps.CATEGORY],
self.assertEqual(alarm.properties[VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(alarm.properties[VProps.TYPE],
VITRAGE_TYPE)
self.assertEqual(alarm.properties[VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(alarm.properties[VProps.SEVERITY],
props[TFields.SEVERITY])
self.assertEqual(alarm.properties[VProps.OPERATIONAL_SEVERITY],
self.assertEqual(alarm.properties[VProps.VITRAGE_OPERATIONAL_SEVERITY],
props[TFields.SEVERITY])
self.assertEqual(alarm.properties[VProps.STATE],
AlarmProps.ACTIVE_STATE)
@ -247,7 +257,7 @@ class TestActionExecutor(TestFunctionalBase):
# Test Setup
processor = self._create_processor_with_graph(self.conf, uuid=True)
vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE}
vertex_attrs = {VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE}
host_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs)
@ -269,8 +279,8 @@ class TestActionExecutor(TestFunctionalBase):
processor.process_event(add_vertex_event)
alarm_vertex_attrs = {VProps.TYPE: VITRAGE_TYPE,
VProps.IS_DELETED: False}
alarm_vertex_attrs = {VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: False}
before_alarms = processor.entity_graph.get_vertices(
vertex_attr_filter=alarm_vertex_attrs)
@ -295,10 +305,10 @@ class TestActionExecutor(TestFunctionalBase):
NProps.RESOURCE_NAME: resource_name,
NProps.RESOURCE_TYPE: resource_type,
NProps.SERVICE: 'Check_MK',
NProps.STATUS: 'CRITICAL',
NProps.STATUS: NagiosTestStatus.CRITICAL,
NProps.STATUS_INFO: 'test test test',
DSProp.DATASOURCE_ACTION: 'snapshot',
DSProp.ENTITY_TYPE: 'nagios',
DSProp.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT,
DSProp.ENTITY_TYPE: NAGIOS_DATASOURCE,
DSProp.SAMPLE_DATE: '2016-02-07 15:26:04'}
@staticmethod
@ -306,13 +316,14 @@ class TestActionExecutor(TestFunctionalBase):
return {TTFields.TARGET: target_vertex.vertex_id,
VProps.UPDATE_TIMESTAMP: '2016-03-17 11:33:32.443002',
DSProp.DATASOURCE_ACTION: 'update',
DSProp.DATASOURCE_ACTION: DatasourceAction.UPDATE,
TFields.ALARM_NAME: alarm_name,
VProps.STATE: 'Active',
VProps.TYPE: 'add_vertex',
DSProp.ENTITY_TYPE: 'vitrage',
VProps.SEVERITY: 'CRITICAL',
EVALUATOR_EVENT_TYPE: ADD_VERTEX,
DSProp.ENTITY_TYPE: VITRAGE_DATASOURCE,
VProps.SEVERITY: OperationalAlarmSeverity.CRITICAL,
VProps.VITRAGE_ID: 'mock_vitrage_id',
VProps.VITRAGE_RESOURCE_TYPE: 'nova.host',
VProps.CATEGORY: 'ALARM',
VProps.SAMPLE_TIMESTAMP: '2016-03-17 11:33:32.443002+00:00'}
VProps.VITRAGE_RESOURCE_TYPE: NOVA_HOST_DATASOURCE,
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_SAMPLE_TIMESTAMP:
'2016-03-17 11:33:32.443002+00:00'}

View File

@ -18,11 +18,13 @@ from oslo_config import cfg
from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EdgeLabel
from vitrage.common.constants import EdgeProperties as EProps
from vitrage.common.constants import EntityCategory
from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.cinder.volume.transformer import \
CINDER_VOLUME_DATASOURCE
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
from vitrage.datasources.nagios.properties import NagiosProperties
from vitrage.datasources.nagios.properties import NagiosTestStatus
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
@ -30,6 +32,8 @@ from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
from vitrage.evaluator.actions.evaluator_event_transformer \
import VITRAGE_DATASOURCE
from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
from vitrage.evaluator.scenario_repository import ScenarioRepository
from vitrage.graph import create_edge
@ -80,7 +84,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
_TARGET_HOST,
_TARGET_HOST,
processor.entity_graph)
self.assertEqual('AVAILABLE', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('AVAILABLE', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be AVAILABLE when starting')
# generate nagios alarm to trigger template scenario
@ -91,14 +95,14 @@ class TestScenarioEvaluator(TestFunctionalBase):
host_v = self.get_host_after_event(event_queue, warning_test,
processor, _TARGET_HOST)
self.assertEqual('SUBOPTIMAL', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('SUBOPTIMAL', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be SUBOPTIMAL with warning alarm')
# next disable the alarm
warning_test['status'] = 'OK'
host_v = self.get_host_after_event(event_queue, warning_test,
processor, _TARGET_HOST)
self.assertEqual('AVAILABLE', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('AVAILABLE', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be AVAILABLE when alarm disabled')
def test_overlapping_deduced_state_1(self):
@ -109,7 +113,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
_TARGET_HOST,
_TARGET_HOST,
processor.entity_graph)
self.assertEqual('AVAILABLE', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('AVAILABLE', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be AVAILABLE when starting')
# generate nagios alarm to trigger
@ -120,7 +124,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
host_v = self.get_host_after_event(event_queue, warning_test,
processor, _TARGET_HOST)
self.assertEqual('SUBOPTIMAL', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('SUBOPTIMAL', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be SUBOPTIMAL with warning alarm')
# generate CRITICAL nagios alarm to trigger
@ -131,21 +135,21 @@ class TestScenarioEvaluator(TestFunctionalBase):
host_v = self.get_host_after_event(event_queue, critical_test,
processor, _TARGET_HOST)
self.assertEqual('ERROR', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('ERROR', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be ERROR with critical alarm')
# next disable the critical alarm
critical_test['status'] = 'OK'
host_v = self.get_host_after_event(event_queue, critical_test,
processor, _TARGET_HOST)
self.assertEqual('SUBOPTIMAL', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('SUBOPTIMAL', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be SUBOPTIMAL with only warning alarm')
# next disable the alarm
warning_test['status'] = 'OK'
host_v = self.get_host_after_event(event_queue, warning_test,
processor, _TARGET_HOST)
self.assertEqual('AVAILABLE', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('AVAILABLE', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be AVAILABLE after alarm disabled')
def test_overlapping_deduced_state_2(self):
@ -156,7 +160,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
_TARGET_HOST,
_TARGET_HOST,
processor.entity_graph)
self.assertEqual('AVAILABLE', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('AVAILABLE', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be AVAILABLE when starting')
# generate CRITICAL nagios alarm to trigger
@ -167,7 +171,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
host_v = self.get_host_after_event(event_queue, critical_test,
processor, _TARGET_HOST)
self.assertEqual('ERROR', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('ERROR', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be ERROR with critical alarm')
# generate WARNING nagios alarm to trigger
@ -178,14 +182,14 @@ class TestScenarioEvaluator(TestFunctionalBase):
host_v = self.get_host_after_event(event_queue, warning_test,
processor, _TARGET_HOST)
self.assertEqual('ERROR', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('ERROR', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be ERROR with critical alarm')
# next disable the critical alarm
critical_test['status'] = 'OK'
host_v = self.get_host_after_event(event_queue, critical_test,
processor, _TARGET_HOST)
self.assertEqual('SUBOPTIMAL', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('SUBOPTIMAL', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be SUBOPTIMAL with only warning alarm')
def test_deduced_alarm(self):
@ -196,7 +200,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
_TARGET_HOST,
_TARGET_HOST,
processor.entity_graph)
self.assertEqual('AVAILABLE', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('AVAILABLE', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be AVAILABLE when starting')
# generate CRITICAL nagios alarm to trigger
@ -342,8 +346,8 @@ class TestScenarioEvaluator(TestFunctionalBase):
"""Handles a simple not operator use case
We have created the following template: if there is a neutron.port that
doesn't have a nagios alarm of type PORT_PROBLEM on it, then raise a
deduced alarm on the port called simple_port_deduced_alarm.
doesn't have a nagios alarm of vitrage_type PORT_PROBLEM on it, then
raise a deduced alarm on the port called simple_port_deduced_alarm.
The test has 5 steps in it:
1. create neutron.network and neutron.port and check that the
simple_port_deduced_alarm is raised on the neutron.port because it
@ -377,8 +381,8 @@ class TestScenarioEvaluator(TestFunctionalBase):
# find instances
query = {
VProps.CATEGORY: 'RESOURCE',
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
}
instance_ver = entity_graph.get_vertices(vertex_attr_filter=query)[0]
@ -389,9 +393,9 @@ class TestScenarioEvaluator(TestFunctionalBase):
'updated_at': '2015-12-01T12:46:41Z',
'status': 'active',
'id': '12345',
'vitrage_entity_type': 'neutron.network',
'vitrage_datasource_action': 'snapshot',
'vitrage_sample_date': '2015-12-01T12:46:41Z',
DSProps.ENTITY_TYPE: NEUTRON_NETWORK_DATASOURCE,
DSProps.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT,
DSProps.SAMPLE_DATE: '2015-12-01T12:46:41Z',
}
# update port
@ -401,9 +405,9 @@ class TestScenarioEvaluator(TestFunctionalBase):
'updated_at': '2015-12-01T12:46:41Z',
'status': 'active',
'id': '54321',
'vitrage_entity_type': 'neutron.port',
'vitrage_datasource_action': 'snapshot',
'vitrage_sample_date': '2015-12-01T12:46:41Z',
DSProps.ENTITY_TYPE: NEUTRON_PORT_DATASOURCE,
DSProps.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT,
DSProps.SAMPLE_DATE: '2015-12-01T12:46:41Z',
'network_id': '12345',
'device_id': instance_ver.get(VProps.ID),
'device_owner': 'compute:nova',
@ -413,12 +417,13 @@ class TestScenarioEvaluator(TestFunctionalBase):
processor.process_event(network_event)
processor.process_event(port_event)
port_vertex = entity_graph.get_vertices(
vertex_attr_filter={VProps.TYPE: NEUTRON_PORT_DATASOURCE})[0]
vertex_attr_filter={VProps.VITRAGE_TYPE:
NEUTRON_PORT_DATASOURCE})[0]
while not event_queue.empty():
processor.process_event(event_queue.get())
# test asserts
query = {VProps.CATEGORY: EntityCategory.ALARM}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(num_orig_vertices + num_added_vertices +
@ -426,9 +431,10 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges,
entity_graph.num_edges())
self.assertEqual(1, len(port_neighbors))
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(port_neighbors[0][VProps.NAME],
'simple_port_deduced_alarm')
@ -454,35 +460,41 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
num_nagios_alarm_edges, entity_graph.num_edges())
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'vitrage'}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE}
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(port_neighbors))
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(port_neighbors[0][VProps.NAME],
'simple_port_deduced_alarm')
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], True)
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'nagios'}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE}
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[0][VProps.TYPE], 'nagios')
self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE],
NAGIOS_DATASOURCE)
self.assertEqual(port_neighbors[0][VProps.NAME], 'PORT_PROBLEM')
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(port_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# ################### STEP 3 ###################
# disable connection between port and alarm
query = {VProps.CATEGORY: 'ALARM', VProps.TYPE: 'nagios'}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE}
nagios_vertex = \
processor.entity_graph.get_vertices(vertex_attr_filter=query)[0]
nagios_edge = [e for e in processor.entity_graph.get_edges(
nagios_vertex.vertex_id)][0]
nagios_edge[EProps.IS_DELETED] = True
nagios_edge[EProps.VITRAGE_IS_DELETED] = True
processor.entity_graph.update_edge(nagios_edge)
while not event_queue.empty():
processor.process_event(event_queue.get())
@ -498,40 +510,47 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
num_nagios_alarm_edges + 1, entity_graph.num_edges())
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'vitrage',
VProps.IS_DELETED: True}
is_deleted = True
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: True}
vitrage_is_deleted = True
for counter in range(0, 1):
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(port_neighbors))
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(port_neighbors[0][VProps.NAME],
'simple_port_deduced_alarm')
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], is_deleted)
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage', VProps.IS_DELETED: False}
is_deleted = False
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED],
vitrage_is_deleted)
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: False}
vitrage_is_deleted = False
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'nagios'}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE}
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[0][VProps.TYPE], 'nagios')
self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE],
NAGIOS_DATASOURCE)
self.assertEqual(port_neighbors[0][VProps.NAME], 'PORT_PROBLEM')
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
# ################### STEP 4 ###################
# enable connection between port and alarm
query = {VProps.CATEGORY: 'ALARM', VProps.TYPE: 'nagios'}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE}
nagios_vertex = \
processor.entity_graph.get_vertices(vertex_attr_filter=query)[0]
nagios_edge = [e for e in processor.entity_graph.get_edges(
nagios_vertex.vertex_id)][0]
nagios_edge[EProps.IS_DELETED] = False
nagios_edge[EProps.VITRAGE_IS_DELETED] = False
processor.entity_graph.update_edge(nagios_edge)
while not event_queue.empty():
processor.process_event(event_queue.get())
@ -547,35 +566,41 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
num_nagios_alarm_edges + 1, entity_graph.num_edges())
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'vitrage',
VProps.IS_DELETED: True}
is_deleted = True
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: True}
vitrage_is_deleted = True
for counter in range(0, 1):
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(2, len(port_neighbors))
for in_counter in range(0, 1):
self.assertEqual(port_neighbors[in_counter][VProps.CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[in_counter][VProps.TYPE],
'vitrage')
self.assertEqual(
port_neighbors[in_counter][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[in_counter]
[VProps.VITRAGE_TYPE], VITRAGE_DATASOURCE)
self.assertEqual(port_neighbors[in_counter][VProps.NAME],
'simple_port_deduced_alarm')
self.assertEqual(
port_neighbors[in_counter][VProps.IS_DELETED], is_deleted)
port_neighbors[in_counter][VProps.VITRAGE_IS_DELETED],
vitrage_is_deleted)
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage', VProps.IS_DELETED: False}
is_deleted = False
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: False}
vitrage_is_deleted = False
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'nagios'}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE}
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[0][VProps.TYPE], 'nagios')
self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE],
NAGIOS_DATASOURCE)
self.assertEqual(port_neighbors[0][VProps.NAME], 'PORT_PROBLEM')
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
# ################### STEP 5 ###################
# disable PORT_PROBLEM alarm
@ -591,50 +616,57 @@ class TestScenarioEvaluator(TestFunctionalBase):
# new alarm doesn't update same deleted alarm.
# Instead, it keeps the old one and creates a new one
# Since this is the second test, there are already two
# alarms of this type
# alarms of this vitrage_type
2,
entity_graph.num_vertices())
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
num_nagios_alarm_edges + 2, entity_graph.num_edges())
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage', VProps.IS_DELETED: True}
is_deleted = True
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: True}
vitrage_is_deleted = True
for counter in range(0, 1):
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(2, len(port_neighbors))
for in_counter in range(0, 1):
self.assertEqual(port_neighbors[in_counter][VProps.CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[in_counter][VProps.TYPE],
'vitrage')
self.assertEqual(
port_neighbors[in_counter][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[in_counter]
[VProps.VITRAGE_TYPE], VITRAGE_DATASOURCE)
self.assertEqual(port_neighbors[in_counter][VProps.NAME],
'simple_port_deduced_alarm')
self.assertEqual(
port_neighbors[in_counter][VProps.IS_DELETED], is_deleted)
port_neighbors[in_counter][VProps.VITRAGE_IS_DELETED],
vitrage_is_deleted)
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage', VProps.IS_DELETED: False}
is_deleted = False
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: False}
vitrage_is_deleted = False
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'nagios'}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE}
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(port_neighbors[0][VProps.TYPE], 'nagios')
self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE],
NAGIOS_DATASOURCE)
self.assertEqual(port_neighbors[0][VProps.NAME], 'PORT_PROBLEM')
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], True)
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
def test_complex_not_operator_deduced_alarm(self):
"""Handles a complex not operator use case
We have created the following template: if there is a openstack.cluster
that has a nova.zone which is connected to a neutron.network and also
there is no nagios alarm of type CLUSTER_PROBLEM on the cluster and no
nagios alarm of type NETWORK_PROBLEM on the neutron.network, then raise
a deduced alarm on the nova.zone called complex_zone_deduced_alarm.
there is no nagios alarm of vitrage_type CLUSTER_PROBLEM on the cluster
and no nagios alarm of vitrage_type NETWORK_PROBLEM on the
neutron.network, then raise a deduced alarm on the nova.zone called
complex_zone_deduced_alarm.
The test has 3 steps in it:
1. create a neutron.network and connect it to a zone, and check that
the complex_zone_deduced_alarm is raised on the nova.zone because it
@ -674,17 +706,18 @@ class TestScenarioEvaluator(TestFunctionalBase):
'updated_at': '2015-12-01T12:46:41Z',
'status': 'active',
'id': '12345',
'vitrage_entity_type': 'neutron.network',
'vitrage_datasource_action': 'snapshot',
'vitrage_sample_date': '2015-12-01T12:46:41Z',
DSProps.ENTITY_TYPE: NEUTRON_NETWORK_DATASOURCE,
DSProps.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT,
DSProps.SAMPLE_DATE: '2015-12-01T12:46:41Z',
}
# process events
processor.process_event(zone_event)
query = {VProps.TYPE: NOVA_ZONE_DATASOURCE, VProps.ID: 'zone-7'}
query = {VProps.VITRAGE_TYPE: NOVA_ZONE_DATASOURCE,
VProps.ID: 'zone-7'}
zone_vertex = entity_graph.get_vertices(vertex_attr_filter=query)[0]
processor.process_event(network_event)
query = {VProps.TYPE: NEUTRON_NETWORK_DATASOURCE}
query = {VProps.VITRAGE_TYPE: NEUTRON_NETWORK_DATASOURCE}
network_vertex = entity_graph.get_vertices(vertex_attr_filter=query)[0]
# add edge between network and zone
@ -696,7 +729,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
processor.process_event(event_queue.get())
# test asserts
query = {VProps.CATEGORY: EntityCategory.ALARM}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}
zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(num_orig_vertices + num_added_vertices +
@ -704,9 +737,10 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges,
entity_graph.num_edges())
self.assertEqual(1, len(zone_neighbors))
self.assertEqual(zone_neighbors[0][VProps.CATEGORY],
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(zone_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(zone_neighbors[0][VProps.NAME],
'complex_zone_deduced_alarm')
@ -732,26 +766,30 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
num_network_alarm_edges, entity_graph.num_edges())
query = {VProps.CATEGORY: EntityCategory.ALARM}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}
network_neighbors = entity_graph.neighbors(network_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(network_neighbors))
self.assertEqual(network_neighbors[0][VProps.CATEGORY],
self.assertEqual(network_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(network_neighbors[0][VProps.TYPE], 'nagios')
self.assertEqual(network_neighbors[0][VProps.VITRAGE_TYPE],
NAGIOS_DATASOURCE)
self.assertEqual(network_neighbors[0][VProps.NAME], 'NETWORK_PROBLEM')
self.assertEqual(network_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(network_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(network_neighbors[0][VProps.VITRAGE_IS_DELETED],
False)
self.assertEqual(network_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(zone_neighbors))
self.assertEqual(zone_neighbors[0][VProps.CATEGORY],
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(zone_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(zone_neighbors[0][VProps.NAME],
'complex_zone_deduced_alarm')
self.assertEqual(zone_neighbors[0][VProps.IS_DELETED], True)
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
# ################### STEP 3 ###################
# delete NETWORK_PROBLEM alarm
@ -770,35 +808,38 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
num_network_alarm_edges + 1, entity_graph.num_edges())
query = {VProps.CATEGORY: EntityCategory.ALARM}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}
network_neighbors = entity_graph.neighbors(network_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(network_neighbors))
self.assertEqual(network_neighbors[0][VProps.CATEGORY],
self.assertEqual(network_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(network_neighbors[0][VProps.TYPE], 'nagios')
self.assertEqual(network_neighbors[0][VProps.VITRAGE_TYPE],
NAGIOS_DATASOURCE)
self.assertEqual(network_neighbors[0][VProps.NAME], 'NETWORK_PROBLEM')
self.assertEqual(network_neighbors[0][VProps.IS_DELETED], True)
self.assertEqual(network_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.IS_DELETED: True}
is_deleted = True
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_IS_DELETED: True}
vitrage_is_deleted = True
# Alarm History is saved. We are testing the deleted alarm and
# then we are testing the live alarm
for counter in range(0, 1):
zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(zone_neighbors))
self.assertEqual(zone_neighbors[0][VProps.CATEGORY],
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(zone_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(zone_neighbors[0][VProps.NAME],
'complex_zone_deduced_alarm')
self.assertEqual(zone_neighbors[0][VProps.IS_DELETED], is_deleted)
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_IS_DELETED],
vitrage_is_deleted)
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.IS_DELETED: False}
is_deleted = False
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_IS_DELETED: False}
vitrage_is_deleted = False
def test_ha(self):
event_queue, processor, evaluator = self._init_system()
@ -806,15 +847,15 @@ class TestScenarioEvaluator(TestFunctionalBase):
# find host
query = {
VProps.CATEGORY: 'RESOURCE',
VProps.TYPE: NOVA_HOST_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE
}
hosts = entity_graph.get_vertices(vertex_attr_filter=query)
# find instances on host
query = {
VProps.CATEGORY: 'RESOURCE',
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
}
instances = entity_graph.neighbors(hosts[0].vertex_id,
vertex_attr_filter=query)
@ -847,29 +888,34 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_volumes + num_deduced_alarms,
entity_graph.num_edges())
query = {VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: CINDER_VOLUME_DATASOURCE}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE}
instance_neighbors = entity_graph.neighbors(instances[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(instance_neighbors))
self.assertEqual(instance_neighbors[0][VProps.CATEGORY],
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.RESOURCE)
self.assertEqual(instance_neighbors[0][VProps.TYPE],
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE],
CINDER_VOLUME_DATASOURCE)
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-1')
self.assertEqual(instance_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(instance_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED],
False)
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'vitrage'}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE}
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(host_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(host_neighbors[0][VProps.NAME],
'ha_warning_deduced_alarm')
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# ################### STEP 2 ###################
# Add cinder volume 2
@ -894,48 +940,54 @@ class TestScenarioEvaluator(TestFunctionalBase):
entity_graph.num_edges())
# check instance neighbors
query = {VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: CINDER_VOLUME_DATASOURCE}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE}
instance_neighbors = entity_graph.neighbors(instances[1].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(instance_neighbors))
self.assertEqual(instance_neighbors[0][VProps.CATEGORY],
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.RESOURCE)
self.assertEqual(instance_neighbors[0][VProps.TYPE],
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE],
CINDER_VOLUME_DATASOURCE)
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-2')
self.assertEqual(instance_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(instance_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED],
False)
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# check ha_error_deduced_alarm
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage',
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.NAME: 'ha_error_deduced_alarm'}
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(host_neighbors))
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(host_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(host_neighbors[0][VProps.NAME],
'ha_error_deduced_alarm')
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# check ha_warning_deduced_alarm
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage',
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.NAME: 'ha_warning_deduced_alarm'}
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(host_neighbors))
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(host_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(host_neighbors[0][VProps.NAME],
'ha_warning_deduced_alarm')
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# ################### STEP 3 ###################
# Remove Cinder Volume 2
@ -959,65 +1011,73 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_volumes + num_deduced_alarms + 1,
entity_graph.num_edges())
query = {VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: CINDER_VOLUME_DATASOURCE}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE}
instance_neighbors = entity_graph.neighbors(instances[1].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(instance_neighbors))
self.assertEqual(instance_neighbors[0][VProps.CATEGORY],
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.RESOURCE)
self.assertEqual(instance_neighbors[0][VProps.TYPE],
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE],
CINDER_VOLUME_DATASOURCE)
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-2')
self.assertEqual(instance_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(instance_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED],
False)
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# check ha_error_deduced_alarm
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage',
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.NAME: 'ha_error_deduced_alarm'}
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(host_neighbors))
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(host_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(host_neighbors[0][VProps.NAME],
'ha_error_deduced_alarm')
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# check new ha_warning_deduced_alarm
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage',
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.NAME: 'ha_warning_deduced_alarm',
VProps.IS_DELETED: False}
VProps.VITRAGE_IS_DELETED: False}
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(host_neighbors))
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(host_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(host_neighbors[0][VProps.NAME],
'ha_warning_deduced_alarm')
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# check old deleted ha_warning_deduced_alarm
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage',
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.NAME: 'ha_warning_deduced_alarm',
VProps.IS_DELETED: True}
VProps.VITRAGE_IS_DELETED: True}
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(host_neighbors))
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(host_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(host_neighbors[0][VProps.NAME],
'ha_warning_deduced_alarm')
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# ################### STEP 4 ###################
# Remove Cinder Volume 1
@ -1041,57 +1101,65 @@ class TestScenarioEvaluator(TestFunctionalBase):
self.assertEqual(num_orig_edges + num_volumes + num_deduced_alarms + 1,
entity_graph.num_edges())
query = {VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: CINDER_VOLUME_DATASOURCE}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE}
instance_neighbors = entity_graph.neighbors(instances[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(instance_neighbors))
self.assertEqual(instance_neighbors[0][VProps.CATEGORY],
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.RESOURCE)
self.assertEqual(instance_neighbors[0][VProps.TYPE],
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE],
CINDER_VOLUME_DATASOURCE)
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-1')
self.assertEqual(instance_neighbors[0][VProps.IS_DELETED], False)
self.assertEqual(instance_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED],
False)
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# check ha_error_deduced_alarm
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage',
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.NAME: 'ha_error_deduced_alarm'}
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(1, len(host_neighbors))
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(host_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(host_neighbors[0][VProps.NAME],
'ha_error_deduced_alarm')
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
# check old ha_warning_deduced_alarm
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: 'vitrage',
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.NAME: 'ha_warning_deduced_alarm'}
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
vertex_attr_filter=query)
self.assertEqual(2, len(host_neighbors))
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(host_neighbors[0][VProps.TYPE], 'vitrage')
self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(host_neighbors[0][VProps.NAME],
'ha_warning_deduced_alarm')
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
False)
self.assertEqual(host_neighbors[1][VProps.CATEGORY],
self.assertEqual(host_neighbors[1][VProps.VITRAGE_CATEGORY],
EntityCategory.ALARM)
self.assertEqual(host_neighbors[1][VProps.TYPE], 'vitrage')
self.assertEqual(host_neighbors[1][VProps.VITRAGE_TYPE],
VITRAGE_DATASOURCE)
self.assertEqual(host_neighbors[1][VProps.NAME],
'ha_warning_deduced_alarm')
self.assertEqual(host_neighbors[1][VProps.IS_DELETED], True)
self.assertEqual(host_neighbors[1][VProps.IS_PLACEHOLDER], False)
self.assertEqual(host_neighbors[1][VProps.VITRAGE_IS_DELETED], True)
self.assertEqual(host_neighbors[1][VProps.VITRAGE_IS_PLACEHOLDER],
False)
def test_simple_or_operator_deduced_alarm(self):
"""Handles a simple not operator use case
@ -1107,7 +1175,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
_TARGET_HOST,
_TARGET_HOST,
processor.entity_graph)
self.assertEqual('AVAILABLE', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('AVAILABLE', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be AVAILABLE when starting')
# generate nagios alarm1 to trigger, raise alarm3
@ -1174,7 +1242,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
_TARGET_HOST,
_TARGET_HOST,
entity_graph)
self.assertEqual('AVAILABLE', host_v[VProps.AGGREGATED_STATE],
self.assertEqual('AVAILABLE', host_v[VProps.VITRAGE_AGGREGATED_STATE],
'host should be AVAILABLE when starting')
# generate nagios alarm_a to trigger
@ -1231,14 +1299,14 @@ class TestScenarioEvaluator(TestFunctionalBase):
alarms = self._get_alarms_on_host(host_v, entity_graph)
self.assertEqual(3, len(alarms))
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.IS_DELETED: True}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_IS_DELETED: True}
deleted_alarms = entity_graph.neighbors(host_v.vertex_id,
vertex_attr_filter=query)
self.assertEqual(num_orig_vertices + len(deleted_alarms) + 3,
entity_graph.num_vertices())
query = {VProps.IS_DELETED: True}
query = {VProps.VITRAGE_IS_DELETED: True}
deleted_edges = entity_graph.neighbors(host_v.vertex_id,
edge_attr_filter=query)
self.assertEqual(num_orig_edges + len(deleted_edges) + 3,
@ -1256,14 +1324,14 @@ class TestScenarioEvaluator(TestFunctionalBase):
alarms = self._get_alarms_on_host(host_v, entity_graph)
self.assertEqual(1, len(alarms))
query = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.IS_DELETED: True}
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_IS_DELETED: True}
deleted_alarms = entity_graph.neighbors(host_v.vertex_id,
vertex_attr_filter=query)
self.assertEqual(num_orig_vertices + len(deleted_alarms) + 1,
entity_graph.num_vertices())
query = {VProps.IS_DELETED: True}
query = {VProps.VITRAGE_IS_DELETED: True}
deleted_edges = entity_graph.neighbors(host_v.vertex_id,
edge_attr_filter=query)
self.assertEqual(num_orig_edges + len(deleted_edges) + 1,
@ -1292,7 +1360,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
def _get_entity_from_graph(entity_type, entity_name,
entity_id,
entity_graph):
vertex_attrs = {VProps.TYPE: entity_type,
vertex_attrs = {VProps.VITRAGE_TYPE: entity_type,
VProps.ID: entity_id,
VProps.NAME: entity_name}
vertices = entity_graph.get_vertices(vertex_attr_filter=vertex_attrs)
@ -1303,22 +1371,22 @@ class TestScenarioEvaluator(TestFunctionalBase):
def _get_deduced_alarms_on_host(host_v, entity_graph):
v_id = host_v.vertex_id
vertex_attrs = {VProps.NAME: 'deduced_alarm',
VProps.TYPE: 'vitrage',
VProps.IS_DELETED: False, }
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
VProps.VITRAGE_IS_DELETED: False, }
return entity_graph.neighbors(v_id=v_id,
vertex_attr_filter=vertex_attrs)
@staticmethod
def _get_alarms_on_host(host_v, entity_graph):
v_id = host_v.vertex_id
vertex_attrs = {VProps.CATEGORY: EntityCategory.ALARM,
VProps.IS_DELETED: False, }
vertex_attrs = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
VProps.VITRAGE_IS_DELETED: False, }
return entity_graph.neighbors(v_id=v_id,
vertex_attr_filter=vertex_attrs)
@staticmethod
def _get_alarm_causes(alarm_v, entity_graph):
v_id = alarm_v.vertex_id
edge_attrs = {EProps.RELATIONSHIP_TYPE: "causes",
EProps.IS_DELETED: False, }
edge_attrs = {EProps.RELATIONSHIP_TYPE: EdgeLabel.CAUSES,
EProps.VITRAGE_IS_DELETED: False, }
return entity_graph.neighbors(v_id=v_id, edge_attr_filter=edge_attrs)

View File

@ -15,8 +15,9 @@
"""Methods for generating driver events
For each type of entity, need to supply configuration files that specify (a
regex of) what can be returned, which will be used to generate driver events
For each vitrage_type of entity, need to supply configuration files that
specify (a regex of) what can be returned, which will be used to generate
driver events
usage example:
test_entity_spec_list = [

View File

@ -10,7 +10,7 @@
"vitrage_entity_type": "nova.host",
"zone": "zone0",
"id": "compute-0-0.local",
"category": "RESOURCE",
"vitrage_category": "RESOURCE",
"vitrage_id": "compute-0-0.local",
"vitrage_datasource_action": "init_snapshot",
"vitrage_sample_date": "2015-12-01T12:46:41Z"

View File

@ -72,7 +72,7 @@
"key_name": null,
"OS-EXT-SRV-ATTR:hypervisor_hostname": "nyakar-devstack",
"name": "vm2",
"category": "RESOURCE",
"vitrage_category": "RESOURCE",
"created": "2015-11-25T14:18:07Z",
"tenant_id": "0683517e1e354d2ba25cba6937f44e79",
"os-extended-volumes:volumes_attached": [],

View File

@ -2,7 +2,7 @@
"name": "[switch|host|custom]-[1-9]",
"id": "[1-9]{5}",
"static_id": "[shc][1-9]",
"type": "[switch|nova.host|custom]",
"vitrage_type": "[switch|nova.host|custom]",
"state": "available",
"vitrage_datasource_action": "snapshot",
"vitrage_sample_date": "2015-12-01T12:46:41Z",

View File

@ -14,7 +14,7 @@
"zoneName": "zone0",
"id": "zone0",
"vitrage_id": "zone0",
"category": "RESOURCE",
"vitrage_category": "RESOURCE",
"zoneState": {
"available": "True"
}

View File

@ -18,18 +18,18 @@
"vitrage_sample_date": "2016-11-29T06:31:50.094836",
"graph_query_result": [
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "dwj",
"update_timestamp": "2016-12-02 07:18:05.628479+00:00",
"sample_timestamp": "2016-12-02 07:18:05.628479+00:00",
"operational_state": "OK",
"aggregated_state": "ACTIVE",
"vitrage_sample_timestamp": "2016-12-02 07:18:05.628479+00:00",
"vitrage_operational_state": "OK",
"vitrage_aggregated_state": "ACTIVE",
"state": "ACTIVE",
"graph_index": 3,
"project_id": "f0895991f44044ccba8e62b201b70360",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "3dcee183-ca42-4ccb-84af-9f0196b2e160"
}
]

View File

@ -18,18 +18,18 @@
"vitrage_sample_date": "2016-11-29T06:31:50.094836",
"graph_query_result": [
{
"category": "RESOURCE",
"is_placeholder": false,
"is_deleted": false,
"vitrage_category": "RESOURCE",
"vitrage_is_placeholder": false,
"vitrage_is_deleted": false,
"name": "test",
"update_timestamp": "2016-12-02 07:18:05.628479+00:00",
"sample_timestamp": "2016-12-02 07:18:05.628479+00:00",
"operational_state": "OK",
"aggregated_state": "ACTIVE",
"vitrage_sample_timestamp": "2016-12-02 07:18:05.628479+00:00",
"vitrage_operational_state": "OK",
"vitrage_aggregated_state": "ACTIVE",
"state": "ACTIVE",
"graph_index": 3,
"project_id": "f0895991f44044ccba8e62b201b70360",
"type": "nova.instance",
"vitrage_type": "nova.instance",
"id": "3dcee183-ca42-4ccb-84af-9f0196b2e160"
}
]

View File

@ -15,9 +15,9 @@ snmp_tree:
next:
name:
oid: 1
is_deleted:
vitrage_is_deleted:
oid: 2
operational_severity:
vitrage_operational_severity:
oid: 3
ALARM_PREFIX:
oid: 2

View File

@ -11,9 +11,9 @@ snmp_tree:
next:
name:
oid: 1
is_deleted:
vitrage_is_deleted:
oid: 2
operational_severity:
vitrage_operational_severity:
oid: 3
ALARM_PREFIX:
oid: 2

View File

@ -31,8 +31,9 @@ class AodhTransformerBaseTest(base.BaseTest):
def _validate_aodh_vertex_props(self, vertex, event):
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
self.assertEqual(EntityCategory.ALARM, vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE],
vertex[VProps.VITRAGE_TYPE])
self.assertEqual(event[AodhProps.NAME], vertex[VProps.NAME])
self.assertEqual(event[AodhProps.SEVERITY], vertex[VProps.SEVERITY])
self.assertEqual(event[AodhProps.DESCRIPTION],
@ -50,7 +51,7 @@ class AodhTransformerBaseTest(base.BaseTest):
self.assertEqual(event[AodhProps.STATE_TIMESTAMP],
vertex[AodhProps.STATE_TIMESTAMP])
self.assertEqual(event[DSProps.SAMPLE_DATE],
vertex[VProps.SAMPLE_TIMESTAMP])
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP])
event_status = event[AodhProps.STATE]
if event_status == AodhState.OK:
@ -59,8 +60,8 @@ class AodhTransformerBaseTest(base.BaseTest):
else:
self.assertEqual(AlarmProps.ACTIVE_STATE,
vertex[VProps.STATE])
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.IS_DELETED])
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
def _validate_action(self, alarm, wrapper):
if DSProps.EVENT_TYPE in alarm \
@ -94,12 +95,12 @@ class AodhTransformerBaseTest(base.BaseTest):
alarm_vertex_id):
# validate neighbor vertex
self.assertEqual(EntityCategory.RESOURCE,
alarm_neighbor.vertex[VProps.CATEGORY])
alarm_neighbor.vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
alarm_neighbor.vertex[VProps.TYPE])
alarm_neighbor.vertex[VProps.VITRAGE_TYPE])
self.assertEqual(resource_id, alarm_neighbor.vertex[VProps.ID])
self.assertFalse(alarm_neighbor.vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(alarm_neighbor.vertex[VProps.IS_DELETED])
self.assertFalse(alarm_neighbor.vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertFalse(alarm_neighbor.vertex[VProps.VITRAGE_IS_DELETED])
# Validate neighbor edge
edge = alarm_neighbor.edge
@ -108,7 +109,7 @@ class AodhTransformerBaseTest(base.BaseTest):
self.assertEqual(edge.label, EdgeLabel.ON)
def _convert_dist_to_vertex(self, neighbor):
ver_id = neighbor[VProps.CATEGORY] + \
TransformerBase.KEY_SEPARATOR + neighbor[VProps.TYPE] + \
ver_id = neighbor[VProps.VITRAGE_CATEGORY] + \
TransformerBase.KEY_SEPARATOR + neighbor[VProps.VITRAGE_TYPE] + \
TransformerBase.KEY_SEPARATOR + neighbor[VProps.ID]
return Vertex(vertex_id=ver_id, properties=neighbor)

View File

@ -65,9 +65,9 @@ class TestCinderVolumeTransformer(base.BaseTest):
timestamp = datetime.datetime.utcnow()
properties = {
VProps.ID: volume_id,
VProps.TYPE: CINDER_VOLUME_DATASOURCE,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: timestamp
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE,
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
}
transformer = self.transformers[CINDER_VOLUME_DATASOURCE]
@ -82,20 +82,20 @@ class TestCinderVolumeTransformer(base.BaseTest):
volume_id)
self.assertEqual(tuple(observed_id_values), expected_id_values)
observed_time = placeholder.get(VProps.SAMPLE_TIMESTAMP)
observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
self.assertEqual(observed_time, timestamp)
observed_type = placeholder.get(VProps.TYPE)
observed_type = placeholder.get(VProps.VITRAGE_TYPE)
self.assertEqual(observed_type, CINDER_VOLUME_DATASOURCE)
observed_entity_id = placeholder.get(VProps.ID)
self.assertEqual(observed_entity_id, volume_id)
observed_category = placeholder.get(VProps.CATEGORY)
self.assertEqual(observed_category, EntityCategory.RESOURCE)
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
self.assertEqual(is_placeholder, True)
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
self.assertEqual(vitrage_is_placeholder, True)
def test_key_values(self):
LOG.debug('Cinder Volume transformer test: get key values')
@ -164,8 +164,10 @@ class TestCinderVolumeTransformer(base.BaseTest):
is_update_event = tbase.is_update_event(event)
self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
self.assertEqual(EntityCategory.RESOURCE,
vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE],
vertex[VProps.VITRAGE_TYPE])
id_field_path = 'volume_id' if is_update_event else 'id'
self.assertEqual(
@ -173,7 +175,7 @@ class TestCinderVolumeTransformer(base.BaseTest):
vertex[VProps.ID])
self.assertEqual(event[DSProps.SAMPLE_DATE],
vertex[VProps.SAMPLE_TIMESTAMP])
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP])
name_field_path = 'display_name'
self.assertEqual(
@ -195,8 +197,8 @@ class TestCinderVolumeTransformer(base.BaseTest):
tbase.extract_field_value(event, volume_type_field_path),
vertex[CinderProps.VOLUME_TYPE])
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.IS_DELETED])
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
def _validate_neighbors(self, neighbors, volume_vertex_id, event):
instance_counter = 0
@ -220,12 +222,13 @@ class TestCinderVolumeTransformer(base.BaseTest):
volume_vertex_id):
# validate neighbor vertex
self.assertEqual(EntityCategory.RESOURCE,
instance_neighbor.vertex[VProps.CATEGORY])
instance_neighbor.vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
instance_neighbor.vertex[VProps.TYPE])
instance_neighbor.vertex[VProps.VITRAGE_TYPE])
self.assertEqual(instance_id, instance_neighbor.vertex[VProps.ID])
self.assertTrue(instance_neighbor.vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(instance_neighbor.vertex[VProps.IS_DELETED])
self.assertTrue(
instance_neighbor.vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertFalse(instance_neighbor.vertex[VProps.VITRAGE_IS_DELETED])
# Validate neighbor edge
edge = instance_neighbor.edge

View File

@ -101,5 +101,6 @@ class TestConsistencyTransformer(base.BaseTest):
vertex_id = vertex.vertex_id
self.assertIsNotNone(vertex_id)
sample_timestamp = vertex.get(VProps.SAMPLE_TIMESTAMP, None)
self.assertIsNotNone(sample_timestamp)
vitrage_sample_timestamp = \
vertex.get(VProps.VITRAGE_SAMPLE_TIMESTAMP, None)
self.assertIsNotNone(vitrage_sample_timestamp)

View File

@ -66,9 +66,9 @@ class TestHeatStackTransformer(base.BaseTest):
timestamp = datetime.datetime.utcnow()
properties = {
VProps.ID: stack_id,
VProps.TYPE: HEAT_STACK_DATASOURCE,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: timestamp
VProps.VITRAGE_TYPE: HEAT_STACK_DATASOURCE,
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
}
transformer = self.transformers[HEAT_STACK_DATASOURCE]
@ -83,20 +83,20 @@ class TestHeatStackTransformer(base.BaseTest):
stack_id)
self.assertEqual(tuple(observed_id_values), expected_id_values)
observed_time = placeholder.get(VProps.SAMPLE_TIMESTAMP)
observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
self.assertEqual(observed_time, timestamp)
observed_type = placeholder.get(VProps.TYPE)
observed_type = placeholder.get(VProps.VITRAGE_TYPE)
self.assertEqual(observed_type, HEAT_STACK_DATASOURCE)
observed_entity_id = placeholder.get(VProps.ID)
self.assertEqual(observed_entity_id, stack_id)
observed_category = placeholder.get(VProps.CATEGORY)
self.assertEqual(observed_category, EntityCategory.RESOURCE)
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
self.assertEqual(is_placeholder, True)
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
self.assertEqual(vitrage_is_placeholder, True)
def test_key_values(self):
LOG.debug('Heat Stack transformer test: get key values')
@ -165,8 +165,10 @@ class TestHeatStackTransformer(base.BaseTest):
is_update_event = tbase.is_update_event(event)
self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
self.assertEqual(EntityCategory.RESOURCE,
vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE],
vertex[VProps.VITRAGE_TYPE])
id_field_path = 'stack_identity' if is_update_event else 'id'
self.assertEqual(
@ -174,7 +176,7 @@ class TestHeatStackTransformer(base.BaseTest):
vertex[VProps.ID])
self.assertEqual(event[DSProps.SAMPLE_DATE],
vertex[VProps.SAMPLE_TIMESTAMP])
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP])
name_field_path = 'stack_name'
self.assertEqual(
@ -186,8 +188,8 @@ class TestHeatStackTransformer(base.BaseTest):
tbase.extract_field_value(event, state_field_path),
vertex[VProps.STATE])
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.IS_DELETED])
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
def _validate_neighbors(self, neighbors, stack_vertex_id, event):
self.assertEqual(2, len(neighbors))
@ -211,12 +213,13 @@ class TestHeatStackTransformer(base.BaseTest):
stack_vertex_id):
# validate neighbor vertex
self.assertEqual(EntityCategory.RESOURCE,
instance_neighbor.vertex[VProps.CATEGORY])
instance_neighbor.vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(datasource_type,
instance_neighbor.vertex[VProps.TYPE])
instance_neighbor.vertex[VProps.VITRAGE_TYPE])
self.assertEqual(instance_id, instance_neighbor.vertex[VProps.ID])
self.assertTrue(instance_neighbor.vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(instance_neighbor.vertex[VProps.IS_DELETED])
self.assertTrue(
instance_neighbor.vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertFalse(instance_neighbor.vertex[VProps.VITRAGE_IS_DELETED])
# Validate neighbor edge
edge = instance_neighbor.edge

View File

@ -100,7 +100,7 @@ class NagiosTransformerTest(base.BaseTest):
neighbor = neighbors[0]
# Right now we are support only host as a resource
if neighbor.vertex[VProps.TYPE] == NOVA_HOST_DATASOURCE:
if neighbor.vertex[VProps.VITRAGE_TYPE] == NOVA_HOST_DATASOURCE:
self._validate_host_neighbor(neighbors[0], alarm)
self._validate_action(alarm, wrapper)
@ -117,8 +117,9 @@ class NagiosTransformerTest(base.BaseTest):
def _validate_vertex(self, vertex, event):
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
self.assertEqual(EntityCategory.ALARM, vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE],
vertex[VProps.VITRAGE_TYPE])
self.assertEqual(event[NagiosProperties.SERVICE], vertex[VProps.NAME])
self.assertEqual(datetime_utils.change_to_utc_time_and_format(
event[NagiosProperties.LAST_CHECK],
@ -143,8 +144,8 @@ class NagiosTransformerTest(base.BaseTest):
self.assertEqual(event[NagiosProperties.STATUS_INFO],
vertex[VProps.INFO])
self.assertFalse(vertex[VProps.IS_DELETED])
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
def _validate_host_neighbor(self, neighbor, event):
@ -156,13 +157,15 @@ class NagiosTransformerTest(base.BaseTest):
self.assertEqual(NOVA_HOST_DATASOURCE, key_fields[1])
self.assertEqual(event[NagiosProperties.RESOURCE_NAME], key_fields[2])
self.assertFalse(host_vertex[VProps.IS_DELETED])
self.assertTrue(host_vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(host_vertex[VProps.VITRAGE_IS_DELETED])
self.assertTrue(host_vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertEqual(EntityCategory.RESOURCE, host_vertex[VProps.CATEGORY])
self.assertEqual(EntityCategory.RESOURCE,
host_vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(event[NagiosProperties.RESOURCE_NAME],
host_vertex[VProps.ID])
self.assertEqual(NOVA_HOST_DATASOURCE, host_vertex[VProps.TYPE])
self.assertEqual(NOVA_HOST_DATASOURCE,
host_vertex[VProps.VITRAGE_TYPE])
edge = neighbor.edge
self.assertEqual(EdgeLabel.ON, edge.label)

View File

@ -67,9 +67,9 @@ class NovaHostTransformerTest(base.BaseTest):
# Test action
properties = {
VProps.ID: host_name,
VProps.TYPE: NOVA_HOST_DATASOURCE,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: timestamp
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE,
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
}
placeholder = \
host_transformer.create_neighbor_placeholder_vertex(**properties)
@ -82,20 +82,20 @@ class NovaHostTransformerTest(base.BaseTest):
host_name)
self.assertEqual(tuple(observed_id_values), expected_id_values)
observed_time = placeholder.get(VProps.SAMPLE_TIMESTAMP)
observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
self.assertEqual(observed_time, timestamp)
observed_subtype = placeholder.get(VProps.TYPE)
observed_subtype = placeholder.get(VProps.VITRAGE_TYPE)
self.assertEqual(observed_subtype, NOVA_HOST_DATASOURCE)
observed_entity_id = placeholder.get(VProps.ID)
self.assertEqual(observed_entity_id, host_name)
observed_category = placeholder.get(VProps.CATEGORY)
self.assertEqual(observed_category, EntityCategory.RESOURCE)
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
self.assertEqual(is_placeholder, True)
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
self.assertEqual(vitrage_is_placeholder, True)
def test_key_values(self):
@ -149,9 +149,9 @@ class NovaHostTransformerTest(base.BaseTest):
zt = self.transformers[NOVA_ZONE_DATASOURCE]
properties = {
VProps.ID: zone_name,
VProps.TYPE: NOVA_ZONE_DATASOURCE,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: time
VProps.VITRAGE_TYPE: NOVA_ZONE_DATASOURCE,
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: time
}
expected_neighbor = \
zt.create_neighbor_placeholder_vertex(**properties)
@ -175,27 +175,27 @@ class NovaHostTransformerTest(base.BaseTest):
self.assertEqual(expected_id, observed_id)
self.assertEqual(
EntityCategory.RESOURCE,
vertex[VProps.CATEGORY]
vertex[VProps.VITRAGE_CATEGORY]
)
self.assertEqual(
NOVA_HOST_DATASOURCE,
vertex[VProps.TYPE]
vertex[VProps.VITRAGE_TYPE]
)
expected_timestamp = event[DSProps.SAMPLE_DATE]
observed_timestamp = vertex[VProps.SAMPLE_TIMESTAMP]
observed_timestamp = vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP]
self.assertEqual(expected_timestamp, observed_timestamp)
expected_name = extract_value(event, '_info', 'host_name')
observed_name = vertex[VProps.NAME]
self.assertEqual(expected_name, observed_name)
is_placeholder = vertex[VProps.IS_PLACEHOLDER]
self.assertFalse(is_placeholder)
vitrage_is_placeholder = vertex[VProps.VITRAGE_IS_PLACEHOLDER]
self.assertFalse(vitrage_is_placeholder)
is_deleted = vertex[VProps.IS_DELETED]
self.assertFalse(is_deleted)
vitrage_is_deleted = vertex[VProps.VITRAGE_IS_DELETED]
self.assertFalse(vitrage_is_deleted)
def test_extract_event_action(self):
LOG.debug('Test extract event action')

View File

@ -64,9 +64,9 @@ class NovaInstanceTransformerTest(base.BaseTest):
timestamp = datetime.datetime.utcnow()
properties = {
VProps.ID: instance_id,
VProps.TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: timestamp
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
}
transformer = self.transformers[NOVA_INSTANCE_DATASOURCE]
@ -81,20 +81,20 @@ class NovaInstanceTransformerTest(base.BaseTest):
instance_id)
self.assertEqual(tuple(observed_id_values), expected_id_values)
observed_time = placeholder.get(VProps.SAMPLE_TIMESTAMP)
observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
self.assertEqual(observed_time, timestamp)
observed_type = placeholder.get(VProps.TYPE)
observed_type = placeholder.get(VProps.VITRAGE_TYPE)
self.assertEqual(observed_type, NOVA_INSTANCE_DATASOURCE)
observed_entity_id = placeholder.get(VProps.ID)
self.assertEqual(observed_entity_id, instance_id)
observed_category = placeholder.get(VProps.CATEGORY)
self.assertEqual(observed_category, EntityCategory.RESOURCE)
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
self.assertEqual(is_placeholder, True)
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
self.assertEqual(vitrage_is_placeholder, True)
def test_snapshot_event_transform(self):
LOG.debug('Test tactual transform action for '
@ -173,10 +173,10 @@ class NovaInstanceTransformerTest(base.BaseTest):
self.assertEqual(
EntityCategory.RESOURCE,
vertex[VProps.CATEGORY]
vertex[VProps.VITRAGE_CATEGORY]
)
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
vertex[VProps.TYPE])
vertex[VProps.VITRAGE_TYPE])
expected_project = extract_value(event, 'tenant_id')
observed_project = vertex[VProps.PROJECT_ID]
@ -188,7 +188,7 @@ class NovaInstanceTransformerTest(base.BaseTest):
self.assertEqual(expected_state, observed_state)
expected_timestamp = event[DSProps.SAMPLE_DATE]
observed_timestamp = vertex[VProps.SAMPLE_TIMESTAMP]
observed_timestamp = vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP]
self.assertEqual(expected_timestamp, observed_timestamp)
name = 'hostname' if is_update_event else 'name'
@ -196,11 +196,11 @@ class NovaInstanceTransformerTest(base.BaseTest):
observed_name = vertex[VProps.NAME]
self.assertEqual(expected_name, observed_name)
is_placeholder = vertex[VProps.IS_PLACEHOLDER]
self.assertFalse(is_placeholder)
vitrage_is_placeholder = vertex[VProps.VITRAGE_IS_PLACEHOLDER]
self.assertFalse(vitrage_is_placeholder)
is_deleted = vertex[VProps.IS_DELETED]
self.assertFalse(is_deleted)
vitrage_is_deleted = vertex[VProps.VITRAGE_IS_DELETED]
self.assertFalse(vitrage_is_deleted)
def _validate_host_neighbor(self, h_neighbor, event):
@ -214,9 +214,9 @@ class NovaInstanceTransformerTest(base.BaseTest):
ht = self.transformers[NOVA_HOST_DATASOURCE]
properties = {
VProps.ID: host_name,
VProps.TYPE: NOVA_HOST_DATASOURCE,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: time
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE,
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: time
}
expected_neighbor = \
ht.create_neighbor_placeholder_vertex(**properties)
@ -313,7 +313,7 @@ class NovaInstanceTransformerTest(base.BaseTest):
self.assertEqual(host_vertex_id, neighbor.vertex.vertex_id)
self.assertEqual(
time,
neighbor.vertex.get(VProps.SAMPLE_TIMESTAMP)
neighbor.vertex.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
)
# test relation edge

View File

@ -68,9 +68,9 @@ class NovaZoneTransformerTest(base.BaseTest):
# Test action
properties = {
VProps.ID: zone_name,
VProps.TYPE: NOVA_ZONE_DATASOURCE,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: timestamp
VProps.VITRAGE_TYPE: NOVA_ZONE_DATASOURCE,
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
}
placeholder = \
zone_transformer.create_neighbor_placeholder_vertex(**properties)
@ -82,20 +82,20 @@ class NovaZoneTransformerTest(base.BaseTest):
_key_values(NOVA_ZONE_DATASOURCE, zone_name)
self.assertEqual(tuple(observed_id_values), expected_id_values)
observed_time = placeholder.get(VProps.SAMPLE_TIMESTAMP)
observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
self.assertEqual(observed_time, timestamp)
observed_subtype = placeholder.get(VProps.TYPE)
observed_subtype = placeholder.get(VProps.VITRAGE_TYPE)
self.assertEqual(observed_subtype, NOVA_ZONE_DATASOURCE)
observed_entity_id = placeholder.get(VProps.ID)
self.assertEqual(observed_entity_id, zone_name)
observed_category = placeholder.get(VProps.CATEGORY)
self.assertEqual(observed_category, EntityCategory.RESOURCE)
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
self.assertEqual(is_placeholder, True)
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
self.assertEqual(vitrage_is_placeholder, True)
def test_key_values(self):
LOG.debug('Zone transformer test: get key values')
@ -146,7 +146,7 @@ class NovaZoneTransformerTest(base.BaseTest):
cluster_neighbors_counter = 0
for neighbor in neighbors:
vertex_type = neighbor.vertex.get(VProps.TYPE)
vertex_type = neighbor.vertex.get(VProps.VITRAGE_TYPE)
if OPENSTACK_CLUSTER == vertex_type:
cluster_neighbors_counter += 1
@ -192,11 +192,11 @@ class NovaZoneTransformerTest(base.BaseTest):
host_vertex.get(VProps.STATE)
)
is_placeholder = host_vertex[VProps.IS_PLACEHOLDER]
self.assertFalse(is_placeholder)
vitrage_is_placeholder = host_vertex[VProps.VITRAGE_IS_PLACEHOLDER]
self.assertFalse(vitrage_is_placeholder)
is_deleted = host_vertex[VProps.IS_DELETED]
self.assertFalse(is_deleted)
vitrage_is_deleted = host_vertex[VProps.VITRAGE_IS_DELETED]
self.assertFalse(vitrage_is_deleted)
# Validate neighbor edge
edge = host_neighbor.edge
@ -209,15 +209,15 @@ class NovaZoneTransformerTest(base.BaseTest):
self.assertEqual(cluster_neighbor.vertex[VProps.VITRAGE_ID],
cluster_neighbor.vertex.vertex_id)
self.assertEqual(False,
cluster_neighbor.vertex[VProps.IS_DELETED])
cluster_neighbor.vertex[VProps.VITRAGE_IS_DELETED])
self.assertEqual(EntityCategory.RESOURCE,
cluster_neighbor.vertex[VProps.CATEGORY])
cluster_neighbor.vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(CLUSTER_ID,
cluster_neighbor.vertex[VProps.ID])
self.assertEqual(False,
cluster_neighbor.vertex[VProps.IS_PLACEHOLDER])
self.assertEqual(False, cluster_neighbor.vertex[
VProps.VITRAGE_IS_PLACEHOLDER])
self.assertEqual(OPENSTACK_CLUSTER,
cluster_neighbor.vertex[VProps.TYPE])
cluster_neighbor.vertex[VProps.VITRAGE_TYPE])
# Validate neighbor edge
edge = cluster_neighbor.edge
@ -236,13 +236,13 @@ class NovaZoneTransformerTest(base.BaseTest):
self.assertEqual(expected_id, observed_id)
self.assertEqual(EntityCategory.RESOURCE,
vertex[VProps.CATEGORY])
vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(NOVA_ZONE_DATASOURCE,
vertex[VProps.TYPE])
vertex[VProps.VITRAGE_TYPE])
expected_timestamp = event[DSProps.SAMPLE_DATE]
observed_timestamp = vertex[VProps.SAMPLE_TIMESTAMP]
observed_timestamp = vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP]
self.assertEqual(expected_timestamp, observed_timestamp)
expected_name = extract_value(event, 'zoneName')
@ -259,8 +259,8 @@ class NovaZoneTransformerTest(base.BaseTest):
observed_state = vertex[VProps.STATE]
self.assertEqual(expected_state, observed_state)
is_placeholder = vertex[VProps.IS_PLACEHOLDER]
self.assertFalse(is_placeholder)
vitrage_is_placeholder = vertex[VProps.VITRAGE_IS_PLACEHOLDER]
self.assertFalse(vitrage_is_placeholder)
is_deleted = vertex[VProps.IS_DELETED]
self.assertFalse(is_deleted)
vitrage_is_deleted = vertex[VProps.VITRAGE_IS_DELETED]
self.assertFalse(vitrage_is_deleted)

View File

@ -57,10 +57,10 @@ class TestStaticTransformer(base.BaseTest):
def test_create_placeholder_vertex(self):
properties = {
VProps.TYPE: self.entity_type,
VProps.VITRAGE_TYPE: self.entity_type,
VProps.ID: self.entity_id,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: self.timestamp
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: self.timestamp
}
placeholder = self.transformer.create_neighbor_placeholder_vertex(
**properties)
@ -69,20 +69,20 @@ class TestStaticTransformer(base.BaseTest):
expected_entity_id = 'RESOURCE:static:12345'
self.assertEqual(observed_entity_id, expected_entity_id)
observed_time = placeholder.get(VProps.SAMPLE_TIMESTAMP)
observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
self.assertEqual(observed_time, self.timestamp)
observed_subtype = placeholder.get(VProps.TYPE)
observed_subtype = placeholder.get(VProps.VITRAGE_TYPE)
self.assertEqual(observed_subtype, self.entity_type)
observed_entity_id = placeholder.get(VProps.ID)
self.assertEqual(observed_entity_id, self.entity_id)
observed_category = placeholder.get(VProps.CATEGORY)
self.assertEqual(observed_category, EntityCategory.RESOURCE)
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
self.assertEqual(is_placeholder, True)
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
self.assertEqual(vitrage_is_placeholder, True)
def test_snapshot_transform(self):
vals_list = mock_driver.simple_static_generators(snapshot_events=1)
@ -106,17 +106,19 @@ class TestStaticTransformer(base.BaseTest):
def _validate_vertex(self, vertex, event):
self._validate_common_props(vertex, event)
self.assertEqual(vertex[VProps.SAMPLE_TIMESTAMP],
self.assertEqual(vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP],
event[DSProps.SAMPLE_DATE])
for k, v in event.get(StaticFields.METADATA, {}):
self.assertEqual(vertex[k], v)
def _validate_common_props(self, vertex, event):
self.assertEqual(vertex[VProps.CATEGORY], EntityCategory.RESOURCE)
self.assertEqual(vertex[VProps.TYPE], event[VProps.TYPE])
self.assertEqual(vertex[VProps.ID], event[VProps.ID])
self.assertFalse(vertex[VProps.IS_DELETED])
self.assertEqual(vertex[VProps.VITRAGE_CATEGORY],
EntityCategory.RESOURCE)
self.assertEqual(vertex[VProps.VITRAGE_TYPE],
event[StaticFields.TYPE])
self.assertEqual(vertex[VProps.ID], event[StaticFields.ID])
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
def _validate_neighbors(self, neighbors, vertex_id, event):
for i in range(len(neighbors)):
@ -139,4 +141,4 @@ class TestStaticTransformer(base.BaseTest):
def _validate_neighbor_vertex_props(self, vertex, event):
self._validate_common_props(vertex, event)
self.assertTrue(vertex[VProps.IS_PLACEHOLDER])
self.assertTrue(vertex[VProps.VITRAGE_IS_PLACEHOLDER])

View File

@ -20,7 +20,7 @@ from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceOpts as DSOpts
from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import GraphAction
from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.static import StaticFields
from vitrage.datasources.static_physical import driver
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
from vitrage.datasources.static_physical import SWITCH
@ -111,25 +111,25 @@ class TestStaticPhysicalDriver(base.BaseTest):
GraphAction.UPDATE_ENTITY)
# Test Assertions
status = any(change[VProps.TYPE] == SWITCH and
change[VProps.ID] == '12345' for change in changes)
status = any(change[StaticFields.TYPE] == SWITCH and
change[StaticFields.ID] == '12345' for change in changes)
self.assertEqual(False, status)
status = any(change[VProps.TYPE] == SWITCH and
change[VProps.ID] == '23456' and
status = any(change[StaticFields.TYPE] == SWITCH and
change[StaticFields.ID] == '23456' and
change[DSProps.EVENT_TYPE] == GraphAction.DELETE_ENTITY
for change in changes)
self.assertEqual(True, status)
status = any(change[VProps.TYPE] == SWITCH and
change[VProps.ID] == '34567' for change in changes)
status = any(change[StaticFields.TYPE] == SWITCH and
change[StaticFields.ID] == '34567' for change in changes)
self.assertEqual(True, status)
status = any(change[VProps.TYPE] == SWITCH and
change[VProps.ID] == '45678' for change in changes)
status = any(change[StaticFields.TYPE] == SWITCH and
change[StaticFields.ID] == '45678' for change in changes)
self.assertEqual(True, status)
status = any(change[VProps.TYPE] == SWITCH and
change[VProps.ID] == '56789' for change in changes)
status = any(change[StaticFields.TYPE] == SWITCH and
change[StaticFields.ID] == '56789' for change in changes)
self.assertEqual(True, status)
self.assertEqual(4, len(changes))

View File

@ -25,6 +25,7 @@ from vitrage.common.constants import UpdateMethod
from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.host.transformer import HostTransformer
from vitrage.datasources.static import StaticFields
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
from vitrage.datasources.static_physical.transformer \
import StaticPhysicalTransformer
@ -66,10 +67,10 @@ class TestStaticPhysicalTransformer(base.BaseTest):
# Test action
properties = {
VProps.TYPE: switch_type,
VProps.VITRAGE_TYPE: switch_type,
VProps.ID: switch_name,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: timestamp
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
}
placeholder = \
static_transformer.create_neighbor_placeholder_vertex(**properties)
@ -82,20 +83,20 @@ class TestStaticPhysicalTransformer(base.BaseTest):
switch_type, switch_name)
self.assertEqual(tuple(observed_id_values), expected_id_values)
observed_time = placeholder.get(VProps.SAMPLE_TIMESTAMP)
observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
self.assertEqual(observed_time, timestamp)
observed_subtype = placeholder.get(VProps.TYPE)
observed_subtype = placeholder.get(VProps.VITRAGE_TYPE)
self.assertEqual(observed_subtype, switch_type)
observed_entity_id = placeholder.get(VProps.ID)
self.assertEqual(observed_entity_id, switch_name)
observed_category = placeholder.get(VProps.CATEGORY)
self.assertEqual(observed_category, EntityCategory.RESOURCE)
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
self.assertEqual(is_placeholder, True)
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
self.assertEqual(vitrage_is_placeholder, True)
def test_key_values(self):
LOG.debug('Static Physical transformer test: get key values')
@ -171,20 +172,22 @@ class TestStaticPhysicalTransformer(base.BaseTest):
self.assertEqual(edge.label, EdgeLabel.CONTAINS)
def _validate_common_vertex_props(self, vertex, event):
self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY])
self.assertEqual(event[VProps.TYPE], vertex[VProps.TYPE])
self.assertEqual(event[VProps.ID], vertex[VProps.ID])
self.assertEqual(EntityCategory.RESOURCE,
vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(event[StaticFields.TYPE],
vertex[VProps.VITRAGE_TYPE])
self.assertEqual(event[StaticFields.ID], vertex[VProps.ID])
def _validate_switch_vertex_props(self, vertex, event):
self._validate_common_vertex_props(vertex, event)
self.assertEqual(event[DSProps.SAMPLE_DATE],
vertex[VProps.SAMPLE_TIMESTAMP])
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP])
self.assertEqual(event[VProps.NAME], vertex[VProps.NAME])
self.assertEqual(event[VProps.STATE], vertex[VProps.STATE])
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.IS_DELETED])
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
def _validate_host_vertex_props(self, vertex, event):
self._validate_common_vertex_props(vertex, event)
self.assertTrue(vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.IS_DELETED])
self.assertTrue(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])

View File

@ -36,8 +36,9 @@ class BaseAlarmTransformerTest(BaseTransformerTest):
expected_name,
expected_datasource_name)
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
self.assertEqual(expected_sample_time, vertex[VProps.SAMPLE_TIMESTAMP])
self.assertEqual(EntityCategory.ALARM, vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(expected_sample_time,
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP])
if self._is_erroneous(vertex):
self.assertEqual(AlarmProps.ACTIVE_STATE, vertex[VProps.STATE])
@ -55,9 +56,10 @@ class BaseAlarmTransformerTest(BaseTransformerTest):
host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
properties = {
VProps.ID: host_name,
VProps.TYPE: NOVA_HOST_DATASOURCE,
VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.SAMPLE_TIMESTAMP: wrapper.vertex[VProps.SAMPLE_TIMESTAMP],
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE,
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
VProps.VITRAGE_SAMPLE_TIMESTAMP:
wrapper.vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP],
}
expected_neighbor = host_transformer.\
create_neighbor_placeholder_vertex(**properties)

View File

@ -23,6 +23,6 @@ class BaseTransformerTest(base.BaseTest):
vertex,
expected_name,
expected_datasource_name):
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
self.assertEqual(expected_datasource_name, vertex[VProps.TYPE])
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertEqual(expected_datasource_name, vertex[VProps.VITRAGE_TYPE])
self.assertEqual(expected_name, vertex[VProps.NAME])

View File

@ -103,7 +103,7 @@ class ZabbixTransformerTest(base.BaseTest):
neighbor = neighbors[0]
# Right now we are support only host as a resource
if neighbor.vertex[VProps.TYPE] == NOVA_HOST_DATASOURCE:
if neighbor.vertex[VProps.VITRAGE_TYPE] == NOVA_HOST_DATASOURCE:
self._validate_host_neighbor(neighbors[0], alarm)
self._validate_action(alarm, wrapper)
@ -120,8 +120,9 @@ class ZabbixTransformerTest(base.BaseTest):
def _validate_vertex(self, vertex, event):
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
self.assertEqual(EntityCategory.ALARM, vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(event[DSProps.ENTITY_TYPE],
vertex[VProps.VITRAGE_TYPE])
self.assertEqual(event[ZabbixProps.DESCRIPTION],
vertex[VProps.NAME])
@ -138,8 +139,8 @@ class ZabbixTransformerTest(base.BaseTest):
event[ZabbixProps.PRIORITY])
self.assertEqual(event_severity, vertex[VProps.SEVERITY])
self.assertFalse(vertex[VProps.IS_DELETED])
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
def _validate_host_neighbor(self, neighbor, event):
@ -151,13 +152,15 @@ class ZabbixTransformerTest(base.BaseTest):
self.assertEqual(NOVA_HOST_DATASOURCE, key_fields[1])
self.assertEqual(event[ZabbixProps.RESOURCE_NAME], key_fields[2])
self.assertFalse(host_vertex[VProps.IS_DELETED])
self.assertTrue(host_vertex[VProps.IS_PLACEHOLDER])
self.assertFalse(host_vertex[VProps.VITRAGE_IS_DELETED])
self.assertTrue(host_vertex[VProps.VITRAGE_IS_PLACEHOLDER])
self.assertEqual(EntityCategory.RESOURCE, host_vertex[VProps.CATEGORY])
self.assertEqual(EntityCategory.RESOURCE,
host_vertex[VProps.VITRAGE_CATEGORY])
self.assertEqual(event[ZabbixProps.RESOURCE_NAME],
host_vertex[VProps.ID])
self.assertEqual(NOVA_HOST_DATASOURCE, host_vertex[VProps.TYPE])
self.assertEqual(NOVA_HOST_DATASOURCE,
host_vertex[VProps.VITRAGE_TYPE])
edge = neighbor.edge
self.assertEqual(EdgeLabel.ON, edge.label)

View File

@ -152,13 +152,13 @@ class TestEntityGraphUnitBase(base.BaseTest):
def _create_alarm(vitrage_id, alarm_type, project_id=None, metadata=None):
return graph_utils.create_vertex(
vitrage_id,
vitrage_category=EntityCategory.ALARM,
vitrage_type=alarm_type,
vitrage_sample_timestamp=None,
vitrage_is_deleted=False,
vitrage_is_placeholder=False,
entity_id=vitrage_id,
entity_category=EntityCategory.ALARM,
entity_type=alarm_type,
entity_state='active',
is_deleted=False,
sample_timestamp=None,
is_placeholder=False,
project_id=project_id,
metadata=metadata
)
@ -167,13 +167,13 @@ class TestEntityGraphUnitBase(base.BaseTest):
def _create_resource(vitrage_id, resource_type, project_id=None):
return graph_utils.create_vertex(
vitrage_id,
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=resource_type,
vitrage_sample_timestamp=None,
vitrage_is_deleted=False,
vitrage_is_placeholder=False,
entity_id=vitrage_id,
entity_category=EntityCategory.RESOURCE,
entity_type=resource_type,
entity_state='active',
is_deleted=False,
sample_timestamp=None,
is_placeholder=False,
project_id=project_id
)

View File

@ -14,7 +14,7 @@
from oslo_config import cfg
from vitrage.common.constants import VertexProperties
from vitrage.common.constants import VertexProperties as VProps
from vitrage.entity_graph import transformer_manager
from vitrage.graph import driver as graph
from vitrage.tests.unit.entity_graph.base import TestEntityGraphUnitBase
@ -32,20 +32,24 @@ class TestBaseProcessor(TestEntityGraphUnitBase):
cls.transform = transformer_manager.TransformerManager(cls.conf)
@staticmethod
def _update_vertex_to_graph(entity_graph, category, type_, id_,
is_deleted, is_placeholder_data,
def _update_vertex_to_graph(entity_graph,
vitrage_category,
vitrage_type,
id_,
vitrage_is_deleted,
vitrage_is_placeholder,
additional_prop):
# create vertex properties
prop = {key: value for key, value in additional_prop.items()}
prop[VertexProperties.CATEGORY] = category
prop[VertexProperties.TYPE] = type_
prop[VertexProperties.ID] = id_
prop[VertexProperties.IS_DELETED] = is_deleted
prop[VertexProperties.IS_PLACEHOLDER] = is_placeholder_data
prop[VProps.VITRAGE_CATEGORY] = vitrage_category
prop[VProps.VITRAGE_TYPE] = vitrage_type
prop[VProps.ID] = id_
prop[VProps.VITRAGE_IS_DELETED] = vitrage_is_deleted
prop[VProps.VITRAGE_IS_PLACEHOLDER] = vitrage_is_placeholder
# TODO(Alexey): change back to original method
# vertex_id = self.transform.get_key(prop)
vertex_id = category + "_" + type_ + "_" + id_
vertex_id = vitrage_category + "_" + vitrage_type + "_" + id_
vertex = graph.Vertex(vertex_id, prop)
entity_graph.add_vertex(vertex)

View File

@ -92,7 +92,7 @@ class TestProcessor(TestEntityGraphUnitBase):
# update instance event with state running
vertex.properties[VProps.STATE] = 'RUNNING'
vertex.properties[VProps.SAMPLE_TIMESTAMP] = str(utcnow())
vertex.properties[VProps.VITRAGE_SAMPLE_TIMESTAMP] = str(utcnow())
processor.update_entity(vertex, neighbors)
# check state
@ -148,9 +148,9 @@ class TestProcessor(TestEntityGraphUnitBase):
'backup')
mock_neighbor = graph_utils.create_vertex(
"asdjashdkahsdashdalksjhd",
vitrage_category="RESOURCE",
vitrage_type="nova.instance",
entity_id="wtw64768476",
entity_category="RESOURCE",
entity_type="nova.instance",
entity_state="AVAILABLE",
)
new_neighbors = [Neighbor(mock_neighbor, new_edge)]
@ -187,7 +187,7 @@ class TestProcessor(TestEntityGraphUnitBase):
vertex2.vertex_id,
'backup')
self.assertEqual(3, processor.entity_graph.num_edges())
self.assertEqual(True, edge_from_graph[EProps.IS_DELETED])
self.assertEqual(True, edge_from_graph[EProps.VITRAGE_IS_DELETED])
def test_remove_deleted_entity(self):
# setup
@ -195,7 +195,7 @@ class TestProcessor(TestEntityGraphUnitBase):
spec_type=self.INSTANCE_SPEC,
datasource_action=DSAction.INIT_SNAPSHOT)
self.assertEqual(1, processor.entity_graph.num_edges())
vertex[VProps.IS_DELETED] = True
vertex[VProps.VITRAGE_IS_DELETED] = True
processor.entity_graph.update_vertex(vertex)
# action
@ -235,9 +235,9 @@ class TestProcessor(TestEntityGraphUnitBase):
# update instance event with state running
(neighbor_vertex, neighbor_edge) = neighbors[0]
old_label = neighbor_edge.label
neighbor_vertex[VProps.IS_PLACEHOLDER] = False
neighbor_vertex[VProps.VITRAGE_IS_PLACEHOLDER] = False
processor.entity_graph.update_vertex(neighbor_vertex)
neighbor_vertex[VProps.IS_PLACEHOLDER] = True
neighbor_vertex[VProps.VITRAGE_IS_PLACEHOLDER] = True
neighbor_edge.label = 'new label'
processor._update_neighbors(vertex, neighbors)
@ -254,9 +254,9 @@ class TestProcessor(TestEntityGraphUnitBase):
vertex.vertex_id,
neighbor_edge.label)
self.assertIsNotNone(old_edge)
self.assertEqual(old_edge[EProps.IS_DELETED], True)
self.assertEqual(old_edge[EProps.VITRAGE_IS_DELETED], True)
self.assertIsNotNone(new_edge)
self.assertEqual(new_edge[EProps.IS_DELETED], False)
self.assertEqual(new_edge[EProps.VITRAGE_IS_DELETED], False)
# update instance with the same neighbor
processor._update_neighbors(vertex, neighbors)
@ -291,7 +291,7 @@ class TestProcessor(TestEntityGraphUnitBase):
neighbor_edge.label)
self.assertIsNone(old_edge)
self.assertIsNotNone(new_edge)
self.assertEqual(new_edge[EProps.IS_DELETED], False)
self.assertEqual(new_edge[EProps.VITRAGE_IS_DELETED], False)
# update instance with the same neighbor
processor._update_neighbors(vertex, neighbors)
@ -314,7 +314,7 @@ class TestProcessor(TestEntityGraphUnitBase):
self.NUM_VERTICES_AFTER_DELETION,
self.NUM_EDGES_AFTER_DELETION)
def test_calculate_aggregated_state(self):
def test_calculate_vitrage_aggregated_state(self):
# setup
instances = []
for i in range(6):
@ -324,67 +324,67 @@ class TestProcessor(TestEntityGraphUnitBase):
# action
# state already exists and its updated
instances[0][0][VProps.STATE] = 'SUSPENDED'
instances[0][1]._calculate_aggregated_state(instances[0][0],
GraphAction.UPDATE_ENTITY)
instances[0][1]._calculate_vitrage_aggregated_state(
instances[0][0], GraphAction.UPDATE_ENTITY)
# vitrage state doesn't exist and its updated
instances[1][0][VProps.STATE] = None
instances[1][1].entity_graph.update_vertex(instances[1][0])
instances[1][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
instances[1][1]._calculate_aggregated_state(instances[1][0],
GraphAction.UPDATE_ENTITY)
instances[1][1]._calculate_vitrage_aggregated_state(
instances[1][0], GraphAction.UPDATE_ENTITY)
# state exists and vitrage state changes
instances[2][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
instances[2][1]._calculate_aggregated_state(instances[2][0],
GraphAction.UPDATE_ENTITY)
instances[2][1]._calculate_vitrage_aggregated_state(
instances[2][0], GraphAction.UPDATE_ENTITY)
# vitrage state exists and state changes
instances[3][0][VProps.STATE] = None
instances[3][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
instances[3][1].entity_graph.update_vertex(instances[3][0])
instances[3][0][VProps.STATE] = 'SUSPENDED'
instances[3][1]._calculate_aggregated_state(instances[3][0],
GraphAction.UPDATE_ENTITY)
instances[3][1]._calculate_vitrage_aggregated_state(
instances[3][0], GraphAction.UPDATE_ENTITY)
# state and vitrage state exists and state changes
instances[4][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
instances[4][1].entity_graph.update_vertex(instances[4][0])
instances[4][0][VProps.STATE] = 'SUSPENDED'
instances[4][1]._calculate_aggregated_state(instances[4][0],
GraphAction.UPDATE_ENTITY)
instances[4][1]._calculate_vitrage_aggregated_state(
instances[4][0], GraphAction.UPDATE_ENTITY)
# state and vitrage state exists and vitrage state changes
instances[5][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
instances[5][1].entity_graph.update_vertex(instances[5][0])
instances[5][1]._calculate_aggregated_state(instances[5][0],
GraphAction.UPDATE_ENTITY)
instances[5][1]._calculate_vitrage_aggregated_state(
instances[5][0], GraphAction.UPDATE_ENTITY)
# test assertions
self.assertEqual('SUSPENDED',
instances[0][0][VProps.AGGREGATED_STATE])
instances[0][0][VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
instances[0][0][VProps.OPERATIONAL_STATE])
instances[0][0][VProps.VITRAGE_OPERATIONAL_STATE])
self.assertEqual('SUBOPTIMAL',
instances[1][0][VProps.AGGREGATED_STATE])
instances[1][0][VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
instances[1][0][VProps.OPERATIONAL_STATE])
instances[1][0][VProps.VITRAGE_OPERATIONAL_STATE])
self.assertEqual('SUBOPTIMAL',
instances[2][0][VProps.AGGREGATED_STATE])
instances[2][0][VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
instances[2][0][VProps.OPERATIONAL_STATE])
instances[2][0][VProps.VITRAGE_OPERATIONAL_STATE])
self.assertEqual('SUSPENDED',
instances[3][0][VProps.AGGREGATED_STATE])
instances[3][0][VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
instances[3][0][VProps.OPERATIONAL_STATE])
instances[3][0][VProps.VITRAGE_OPERATIONAL_STATE])
self.assertEqual('SUSPENDED',
instances[4][0][VProps.AGGREGATED_STATE])
instances[4][0][VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
instances[4][0][VProps.OPERATIONAL_STATE])
instances[4][0][VProps.VITRAGE_OPERATIONAL_STATE])
self.assertEqual('SUBOPTIMAL',
instances[5][0][VProps.AGGREGATED_STATE])
instances[5][0][VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
instances[5][0][VProps.OPERATIONAL_STATE])
instances[5][0][VProps.VITRAGE_OPERATIONAL_STATE])
def _create_and_check_entity(self, processor=None, **kwargs):
# create instance event with host neighbor
@ -413,6 +413,6 @@ class TestProcessor(TestEntityGraphUnitBase):
else:
deleted_edges = processor.entity_graph.get_edges(
vertex_id,
attr_filter={VProps.IS_DELETED: True})
attr_filter={VProps.VITRAGE_IS_DELETED: True})
self.assertEqual(num_edges + len(deleted_edges),
processor.entity_graph.num_edges())

View File

@ -99,55 +99,57 @@ class TestDatasourceInfoMapper(base.BaseTest):
missing_states + erroneous_values
self.assertEqual(num_valid_datasources, len(conf.datasources.types))
def test_operational_state_exists(self):
def test_vitrage_operational_state_exists(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
# action
operational_state = \
state_manager.operational_state(NOVA_INSTANCE_DATASOURCE,
'BUILDING')
vitrage_operational_state = \
state_manager.vitrage_operational_state(NOVA_INSTANCE_DATASOURCE,
'BUILDING')
# test assertions
self.assertEqual(OperationalResourceState.TRANSIENT, operational_state)
self.assertEqual(OperationalResourceState.TRANSIENT,
vitrage_operational_state)
def test_operational_state_not_exists(self):
def test_vitrage_operational_state_not_exists(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
# action
operational_state = \
state_manager.operational_state(NOVA_INSTANCE_DATASOURCE,
'NON EXISTING STATE')
# test assertions
self.assertEqual(OperationalResourceState.NA, operational_state)
def test_operational_state_datasource_not_exists_and_state_not_exist(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
# action
operational_state = \
state_manager.operational_state('NON EXISTING DATASOURCE',
'BUILDING')
vitrage_operational_state = \
state_manager.vitrage_operational_state(NOVA_INSTANCE_DATASOURCE,
'NON EXISTING STATE')
# test assertions
self.assertEqual(OperationalResourceState.NA,
operational_state)
vitrage_operational_state)
def test_operational_state_datasource_not_exists_and_state_exist(self):
def test_vitrage_operational_state_DS_not_exists_and_state_not_exist(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
# action
operational_state = \
state_manager.operational_state('NON EXISTING DATASOURCE',
'AVAILABLE')
vitrage_operational_state = \
state_manager.vitrage_operational_state('NON EXISTING DATASOURCE',
'BUILDING')
# test assertions
self.assertEqual(OperationalResourceState.NA,
vitrage_operational_state)
def test_vitrage_operational_state_DS_not_exists_and_state_exist(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
# action
vitrage_operational_state = \
state_manager.vitrage_operational_state('NON EXISTING DATASOURCE',
'AVAILABLE')
# test assertions
self.assertEqual(OperationalResourceState.OK,
operational_state)
vitrage_operational_state)
def test_state_priority(self):
# setup
@ -186,110 +188,115 @@ class TestDatasourceInfoMapper(base.BaseTest):
self.assertEqual(10,
state_priority)
def test_aggregated_state(self):
def test_vitrage_aggregated_state(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
metadata1 = {VProps.VITRAGE_STATE: 'SUSPENDED'}
new_vertex1 = create_vertex('12345',
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NOVA_INSTANCE_DATASOURCE,
entity_state='ACTIVE',
entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_INSTANCE_DATASOURCE,
metadata=metadata1)
metadata2 = {VProps.VITRAGE_STATE: 'ACTIVE'}
new_vertex2 = create_vertex('23456',
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NOVA_INSTANCE_DATASOURCE,
entity_state='SUSPENDED',
entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_INSTANCE_DATASOURCE,
metadata=metadata2)
# action
state_manager.aggregated_state(new_vertex1, None)
state_manager.aggregated_state(new_vertex2, None)
state_manager.vitrage_aggregated_state(new_vertex1, None)
state_manager.vitrage_aggregated_state(new_vertex2, None)
# test assertions
self.assertEqual('SUSPENDED', new_vertex1[VProps.AGGREGATED_STATE])
self.assertEqual('SUSPENDED',
new_vertex1[VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
new_vertex1[VProps.OPERATIONAL_STATE])
self.assertEqual('SUSPENDED', new_vertex2[VProps.AGGREGATED_STATE])
new_vertex1[VProps.VITRAGE_OPERATIONAL_STATE])
self.assertEqual('SUSPENDED',
new_vertex2[VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
new_vertex2[VProps.OPERATIONAL_STATE])
new_vertex2[VProps.VITRAGE_OPERATIONAL_STATE])
def test_aggregated_state_functionalities(self):
def test_vitrage_aggregated_state_functionalities(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
new_vertex1 = create_vertex('12345',
entity_state='ACTIVE',
entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_INSTANCE_DATASOURCE)
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NOVA_INSTANCE_DATASOURCE,
entity_state='ACTIVE')
metadata2 = {VProps.VITRAGE_STATE: 'SUBOPTIMAL'}
new_vertex2 = create_vertex('23456',
entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_INSTANCE_DATASOURCE,
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NOVA_INSTANCE_DATASOURCE,
metadata=metadata2)
metadata3 = {VProps.VITRAGE_STATE: 'SUBOPTIMAL'}
new_vertex3 = create_vertex('34567',
entity_state='ACTIVE',
entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_INSTANCE_DATASOURCE)
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NOVA_INSTANCE_DATASOURCE,
entity_state='ACTIVE')
graph_vertex3 = create_vertex('34567',
vitrage_category=EntityCategory.RESOURCE,
vitrage_type=NOVA_INSTANCE_DATASOURCE,
entity_state='SUSPENDED',
entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_INSTANCE_DATASOURCE,
metadata=metadata3)
# action
state_manager.aggregated_state(new_vertex1,
None)
state_manager.aggregated_state(new_vertex2,
None)
state_manager.aggregated_state(new_vertex3,
graph_vertex3)
# test assertions
self.assertEqual('ACTIVE', new_vertex1[VProps.AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.OK,
new_vertex1[VProps.OPERATIONAL_STATE])
self.assertEqual('SUBOPTIMAL', new_vertex2[VProps.AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
new_vertex2[VProps.OPERATIONAL_STATE])
self.assertEqual('SUBOPTIMAL', new_vertex3[VProps.AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
new_vertex3[VProps.OPERATIONAL_STATE])
def test_aggregated_state_datasource_not_exists(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
metadata = {VProps.VITRAGE_STATE: 'SUSPENDED'}
new_vertex = create_vertex('12345',
entity_state='ACTIVE',
entity_category=EntityCategory.RESOURCE,
entity_type='NON EXISTING DATASOURCE',
metadata=metadata)
# action
state_manager.aggregated_state(new_vertex, None)
state_manager.vitrage_aggregated_state(new_vertex1,
None)
state_manager.vitrage_aggregated_state(new_vertex2,
None)
state_manager.vitrage_aggregated_state(new_vertex3,
graph_vertex3)
# test assertions
self.assertEqual('ACTIVE',
new_vertex[VProps.AGGREGATED_STATE])
new_vertex1[VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.OK,
new_vertex[VProps.OPERATIONAL_STATE])
new_vertex1[VProps.VITRAGE_OPERATIONAL_STATE])
self.assertEqual('SUBOPTIMAL',
new_vertex2[VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
new_vertex2[VProps.VITRAGE_OPERATIONAL_STATE])
self.assertEqual('SUBOPTIMAL',
new_vertex3[VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
new_vertex3[VProps.VITRAGE_OPERATIONAL_STATE])
def test_aggregated_state_datasource_not_exists_and_wrong_state(self):
def test_vitrage_aggregated_state_datasource_not_exists(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
metadata = {VProps.VITRAGE_STATE: 'SUSPENDED'}
new_vertex = create_vertex('12345',
entity_state='NON EXISTING STATE',
entity_category=EntityCategory.RESOURCE,
entity_type='NON EXISTING DATASOURCE',
vitrage_category=EntityCategory.RESOURCE,
vitrage_type='NON EXISTING DATASOURCE',
entity_state='ACTIVE',
metadata=metadata)
# action
state_manager.aggregated_state(new_vertex, None)
state_manager.vitrage_aggregated_state(new_vertex, None)
# test assertions
self.assertEqual('ACTIVE',
new_vertex[VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.OK,
new_vertex[VProps.VITRAGE_OPERATIONAL_STATE])
def test_vitrage_aggregated_state_DS_not_exists_and_wrong_state(self):
# setup
state_manager = DatasourceInfoMapper(self.conf)
metadata = {VProps.VITRAGE_STATE: 'SUSPENDED'}
new_vertex = create_vertex('12345',
vitrage_category=EntityCategory.RESOURCE,
vitrage_type='NON EXISTING DATASOURCE',
entity_state='NON EXISTING STATE',
metadata=metadata)
# action
state_manager.vitrage_aggregated_state(new_vertex, None)
# test assertions
self.assertEqual('NON EXISTING STATE',
new_vertex[VProps.AGGREGATED_STATE])
new_vertex[VProps.VITRAGE_AGGREGATED_STATE])
self.assertEqual(OperationalResourceState.NA,
new_vertex[VProps.OPERATIONAL_STATE])
new_vertex[VProps.VITRAGE_OPERATIONAL_STATE])

View File

@ -31,7 +31,7 @@ class RaiseAlarmRecipeTest(base.BaseTest):
@classmethod
def setUpClass(cls):
cls.target_props = {VProps.TYPE: NOVA_HOST_DATASOURCE}
cls.target_props = {VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE}
cls.target_vertex = Vertex('RESOURCE:nova.host:test1',
cls.target_props)
cls.targets = {TFields.TARGET: cls.target_vertex}
@ -66,7 +66,7 @@ class RaiseAlarmRecipeTest(base.BaseTest):
alarm_vitrage_resource_type = \
add_vertex_step_params[VProps.VITRAGE_RESOURCE_TYPE]
self.assertEqual(self.target_vertex.properties[VProps.TYPE],
self.assertEqual(self.target_vertex.properties[VProps.VITRAGE_TYPE],
alarm_vitrage_resource_type)
def test_get_undo_recipe(self):
@ -97,5 +97,5 @@ class RaiseAlarmRecipeTest(base.BaseTest):
alarm_vitrage_resource_type = \
remove_vertex_step_params[VProps.VITRAGE_RESOURCE_TYPE]
self.assertEqual(self.target_vertex.properties[VProps.TYPE],
self.assertEqual(self.target_vertex.properties[VProps.VITRAGE_TYPE],
alarm_vitrage_resource_type)

View File

@ -12,6 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from vitrage.common.constants import EntityCategory
from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
from vitrage.datasources.zabbix import ZABBIX_DATASOURCE
from vitrage.evaluator.actions.evaluator_event_transformer \
import VITRAGE_DATASOURCE
from vitrage.evaluator.equivalence_data import EquivalenceData
from vitrage.tests import base
from vitrage.tests.mocks import utils
@ -34,15 +40,15 @@ class EquivalenceTemplateTest(base.BaseTest):
expected = [
frozenset([
frozenset([('category', 'ALARM'),
('type', 'nagios'),
('name', 'host_problem')]),
frozenset([('category', 'ALARM'),
('type', 'zabbix'),
('name', 'host_fail')]),
frozenset([('category', 'ALARM'),
('type', 'vitrage'),
('name', 'host_down')])
frozenset([(VProps.VITRAGE_CATEGORY, EntityCategory.ALARM),
(VProps.VITRAGE_TYPE, NAGIOS_DATASOURCE),
(VProps.NAME, 'host_problem')]),
frozenset([(VProps.VITRAGE_CATEGORY, EntityCategory.ALARM),
(VProps.VITRAGE_TYPE, ZABBIX_DATASOURCE),
(VProps.NAME, 'host_fail')]),
frozenset([(VProps.VITRAGE_CATEGORY, EntityCategory.ALARM),
(VProps.VITRAGE_TYPE, VITRAGE_DATASOURCE),
(VProps.NAME, 'host_down')])
]),
]

View File

@ -11,10 +11,13 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
from oslo_config import cfg
from vitrage.common.constants import EntityCategory
from vitrage.common.constants import VertexProperties as VProps
from vitrage.evaluator.scenario_repository import ScenarioRepository
from vitrage.evaluator.template_validation.template_syntax_validator import \
syntax_validation
@ -117,11 +120,11 @@ class EquivalentScenarioTest(base.BaseTest):
def test_expansion(self):
entity_scenarios = self.scenario_repository.entity_scenarios
for entity_key, scenarios in entity_scenarios.items():
if ('category', 'ALARM') in entity_key:
for key, scenarios in entity_scenarios.items():
if (VProps.VITRAGE_CATEGORY, EntityCategory.ALARM) in key:
# scenarios expanded on the other alarm
self.assertEqual(len(scenarios), 2)
if ('category', 'RESOURCE') in entity_key:
if (VProps.VITRAGE_CATEGORY, EntityCategory.RESOURCE) in key:
# Scenarios expanded on the two alarms. Each alarm is expanded
# to two equivalent alarms. Thus 2 x 2 = 4 in total
self.assertEqual(len(scenarios), 4)

Some files were not shown because too many files have changed in this diff Show More