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:
parent
0af2b7ceb5
commit
3b1de001ec
@ -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
|
a. Driver and transformer with the path to your driver and transformer
|
||||||
classes respectively.
|
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.
|
this datasource. The options are (string): push, pull or none.
|
||||||
c. In addition to those three, you may add any other configuration options
|
c. In addition to those three, you may add any other configuration options
|
||||||
you may need for your datasource.
|
you may need for your datasource.
|
||||||
|
@ -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
|
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 Vitrage. This way we can know which severity is more important.
|
||||||
In addition we also normalize the severities for the horizon UI (called
|
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.
|
Horizon.
|
||||||
|
|
||||||
This page explains how to handle this mapping for a given
|
This page explains how to handle this mapping for a given
|
||||||
|
@ -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
|
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 Vitrage. This way we can know which state is more important.
|
||||||
In addition we also normalize the states for the horizon UI (called
|
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
|
This page explains how to handle this mapping for a given
|
||||||
data-source.
|
data-source.
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ The following describes all the possible status code and their messages:
|
|||||||
+------------------+---------------------------------------------------------+-------------------------------+
|
+------------------+---------------------------------------------------------+-------------------------------+
|
||||||
| 43 | At least one entity must be defined | syntax |
|
| 43 | At least one entity must be defined | syntax |
|
||||||
+------------------+---------------------------------------------------------+-------------------------------+
|
+------------------+---------------------------------------------------------+-------------------------------+
|
||||||
| 45 | Invalid entity category. Category must be from types: | syntax |
|
| 45 | Invalid entity category. Category must be from | syntax |
|
||||||
| | [entities_categories] | |
|
| | types: [entities_categories] | |
|
||||||
+------------------+---------------------------------------------------------+-------------------------------+
|
+------------------+---------------------------------------------------------+-------------------------------+
|
||||||
| 46 | Entity field is required | syntax |
|
| 46 | Entity field is required | syntax |
|
||||||
+------------------+---------------------------------------------------------+-------------------------------+
|
+------------------+---------------------------------------------------------+-------------------------------+
|
||||||
|
@ -60,13 +60,13 @@ Let's take a basic template as example
|
|||||||
|
|
||||||
expected_entities = {
|
expected_entities = {
|
||||||
'alarm': Vertex(vertex_id='alarm',
|
'alarm': Vertex(vertex_id='alarm',
|
||||||
properties={'category': 'ALARM',
|
properties={'vitrage_category': 'ALARM',
|
||||||
'type': 'nagios',
|
'vitrage_type': 'nagios',
|
||||||
'name': 'HOST_HIGH_CPU_LOAD'
|
'name': 'HOST_HIGH_CPU_LOAD',
|
||||||
}),
|
}),
|
||||||
'resource': Vertex(vertex_id='resource',
|
'resource': Vertex(vertex_id='resource',
|
||||||
properties={'category': 'RESOURCE',
|
properties={'vitrage_category': 'RESOURCE',
|
||||||
'type': 'nova.host'
|
'vitrage_type': 'nova.host',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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": {},
|
"graph": {},
|
||||||
"nodes": [
|
"nodes": [
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-8",
|
"name": "vm-8",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "20d12a8a-ea9a-89c6-5947-83bea959362e",
|
"id": "20d12a8a-ea9a-89c6-5947-83bea959362e",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:20d12a8a-ea9a-89c6-5947-83bea959362e"
|
"vitrage_id": "RESOURCE:nova.instance:20d12a8a-ea9a-89c6-5947-83bea959362e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-2",
|
"name": "vm-2",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "dc35fa2f-4515-1653-ef6b-03b471bb395b",
|
"id": "dc35fa2f-4515-1653-ef6b-03b471bb395b",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:dc35fa2f-4515-1653-ef6b-03b471bb395b"
|
"vitrage_id": "RESOURCE:nova.instance:dc35fa2f-4515-1653-ef6b-03b471bb395b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-13",
|
"name": "vm-13",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "9879cf5a-bdcf-3651-3017-961ed887ec86",
|
"id": "9879cf5a-bdcf-3651-3017-961ed887ec86",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:9879cf5a-bdcf-3651-3017-961ed887ec86"
|
"vitrage_id": "RESOURCE:nova.instance:9879cf5a-bdcf-3651-3017-961ed887ec86"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-10",
|
"name": "vm-10",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "fe124f4b-9ed7-4591-fcd1-803cf5c33cb1",
|
"id": "fe124f4b-9ed7-4591-fcd1-803cf5c33cb1",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:fe124f4b-9ed7-4591-fcd1-803cf5c33cb1"
|
"vitrage_id": "RESOURCE:nova.instance:fe124f4b-9ed7-4591-fcd1-803cf5c33cb1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-11",
|
"name": "vm-11",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "f2e48a97-7350-061e-12d3-84c6dc3e67c0",
|
"id": "f2e48a97-7350-061e-12d3-84c6dc3e67c0",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:f2e48a97-7350-061e-12d3-84c6dc3e67c0"
|
"vitrage_id": "RESOURCE:nova.instance:f2e48a97-7350-061e-12d3-84c6dc3e67c0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "host-2",
|
"name": "host-2",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "available",
|
"state": "available",
|
||||||
"type": "nova.host",
|
"vitrage_type": "nova.host",
|
||||||
"id": "host-2",
|
"id": "host-2",
|
||||||
"vitrage_id": "RESOURCE:nova.host:host-2"
|
"vitrage_id": "RESOURCE:nova.host:host-2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "host-3",
|
"name": "host-3",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "available",
|
"state": "available",
|
||||||
"type": "nova.host",
|
"vitrage_type": "nova.host",
|
||||||
"id": "host-3",
|
"id": "host-3",
|
||||||
"vitrage_id": "RESOURCE:nova.host:host-3"
|
"vitrage_id": "RESOURCE:nova.host:host-3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "host-0",
|
"name": "host-0",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "available",
|
"state": "available",
|
||||||
"type": "nova.host",
|
"vitrage_type": "nova.host",
|
||||||
"id": "host-0",
|
"id": "host-0",
|
||||||
"vitrage_id": "RESOURCE:nova.host:host-0"
|
"vitrage_id": "RESOURCE:nova.host:host-0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "host-1",
|
"name": "host-1",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "available",
|
"state": "available",
|
||||||
"type": "nova.host",
|
"vitrage_type": "nova.host",
|
||||||
"id": "host-1",
|
"id": "host-1",
|
||||||
"vitrage_id": "RESOURCE:nova.host:host-1"
|
"vitrage_id": "RESOURCE:nova.host:host-1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-9",
|
"name": "vm-9",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "275097cf-954e-8e24-b185-9514e24b8591",
|
"id": "275097cf-954e-8e24-b185-9514e24b8591",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:275097cf-954e-8e24-b185-9514e24b8591"
|
"vitrage_id": "RESOURCE:nova.instance:275097cf-954e-8e24-b185-9514e24b8591"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-1",
|
"name": "vm-1",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "a0f0805f-c804-cffe-c25a-1b38f555ed68",
|
"id": "a0f0805f-c804-cffe-c25a-1b38f555ed68",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:a0f0805f-c804-cffe-c25a-1b38f555ed68"
|
"vitrage_id": "RESOURCE:nova.instance:a0f0805f-c804-cffe-c25a-1b38f555ed68"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-14",
|
"name": "vm-14",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "56af57d2-34a4-19b1-5106-b613637a11a7",
|
"id": "56af57d2-34a4-19b1-5106-b613637a11a7",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:56af57d2-34a4-19b1-5106-b613637a11a7"
|
"vitrage_id": "RESOURCE:nova.instance:56af57d2-34a4-19b1-5106-b613637a11a7"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "zone-1",
|
"name": "zone-1",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "available",
|
"state": "available",
|
||||||
"type": "nova.zone",
|
"vitrage_type": "nova.zone",
|
||||||
"id": "zone-1",
|
"id": "zone-1",
|
||||||
"vitrage_id": "RESOURCE:nova.zone:zone-1"
|
"vitrage_id": "RESOURCE:nova.zone:zone-1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-3",
|
"name": "vm-3",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "16e14c58-d254-2bec-53e4-c766e48810aa",
|
"id": "16e14c58-d254-2bec-53e4-c766e48810aa",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:16e14c58-d254-2bec-53e4-c766e48810aa"
|
"vitrage_id": "RESOURCE:nova.instance:16e14c58-d254-2bec-53e4-c766e48810aa"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-7",
|
"name": "vm-7",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "f35a1e10-74ff-7332-8edf-83cd6ffcb2de",
|
"id": "f35a1e10-74ff-7332-8edf-83cd6ffcb2de",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:f35a1e10-74ff-7332-8edf-83cd6ffcb2de"
|
"vitrage_id": "RESOURCE:nova.instance:f35a1e10-74ff-7332-8edf-83cd6ffcb2de"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-4",
|
"name": "vm-4",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z?vitrage_id=all",
|
"update_timestamp": "2015-12-01T12:46:41Z?vitrage_id=all",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "ea8a450e-cab1-2272-f431-494b40c5c378",
|
"id": "ea8a450e-cab1-2272-f431-494b40c5c378",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:ea8a450e-cab1-2272-f431-494b40c5c378"
|
"vitrage_id": "RESOURCE:nova.instance:ea8a450e-cab1-2272-f431-494b40c5c378"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-6",
|
"name": "vm-6",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "6e42bdc3-b776-1b2c-2c7d-b7a8bb98f721",
|
"id": "6e42bdc3-b776-1b2c-2c7d-b7a8bb98f721",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:6e42bdc3-b776-1b2c-2c7d-b7a8bb98f721"
|
"vitrage_id": "RESOURCE:nova.instance:6e42bdc3-b776-1b2c-2c7d-b7a8bb98f721"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-5",
|
"name": "vm-5",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "8c951613-c660-87c0-c18b-0fa3293ce8d8",
|
"id": "8c951613-c660-87c0-c18b-0fa3293ce8d8",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:8c951613-c660-87c0-c18b-0fa3293ce8d8"
|
"vitrage_id": "RESOURCE:nova.instance:8c951613-c660-87c0-c18b-0fa3293ce8d8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "zone-0",
|
"name": "zone-0",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "available",
|
"state": "available",
|
||||||
"type": "nova.zone",
|
"vitrage_type": "nova.zone",
|
||||||
"id": "zone-0",
|
"id": "zone-0",
|
||||||
"vitrage_id": "RESOURCE:nova.zone:zone-0"
|
"vitrage_id": "RESOURCE:nova.zone:zone-0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-0",
|
"name": "vm-0",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "78353ce4-2710-49b5-1341-b8cbb6000ebc",
|
"id": "78353ce4-2710-49b5-1341-b8cbb6000ebc",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:78353ce4-2710-49b5-1341-b8cbb6000ebc"
|
"vitrage_id": "RESOURCE:nova.instance:78353ce4-2710-49b5-1341-b8cbb6000ebc"
|
||||||
},TODO
|
},TODO
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-12",
|
"name": "vm-12",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "35bf479a-75d9-80a9-874e-d3b50fb2dd2e",
|
"id": "35bf479a-75d9-80a9-874e-d3b50fb2dd2e",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:35bf479a-75d9-80a9-874e-d3b50fb2dd2e"
|
"vitrage_id": "RESOURCE:nova.instance:35bf479a-75d9-80a9-874e-d3b50fb2dd2e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "openstack.cluster",
|
"name": "openstack.cluster",
|
||||||
"type": "openstack.cluster",
|
"vitrage_type": "openstack.cluster",
|
||||||
"id": "openstack.cluster",
|
"id": "openstack.cluster",
|
||||||
"vitrage_id": "RESOURCE:openstack.cluster"
|
"vitrage_id": "RESOURCE:openstack.cluster"
|
||||||
}
|
}
|
||||||
@ -473,147 +473,147 @@ Response Examples
|
|||||||
"links": [
|
"links": [
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 3,
|
"target": 3,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 5
|
"source": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 1,
|
"target": 1,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 5
|
"source": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 16,
|
"target": 16,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 5
|
"source": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 11,
|
"target": 11,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 5
|
"source": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 13,
|
"target": 13,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 6
|
"source": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 4,
|
"target": 4,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 6
|
"source": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 14,
|
"target": 14,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 6
|
"source": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 20,
|
"target": 20,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 7
|
"source": 7
|
||||||
},?vitrage_id=all
|
},?vitrage_id=all
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 0,
|
"target": 0,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 7
|
"source": 7
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 19,
|
"target": 19,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 7
|
"source": 7
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 15,
|
"target": 15,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 7
|
"source": 7
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 9,
|
"target": 9,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 8
|
"source": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 10,
|
"target": 10,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 8
|
"source": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 2,
|
"target": 2,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 8
|
"source": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 17,
|
"target": 17,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 8
|
"source": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 6,
|
"target": 6,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 12
|
"source": 12
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 8,
|
"target": 8,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 12
|
"source": 12
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 5,
|
"target": 5,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 18
|
"source": 18
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 7,
|
"target": 7,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 18
|
"source": 18
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 18,
|
"target": 18,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 21
|
"source": 21
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relationship_name": "contains",
|
"relationship_name": "contains",
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"target": 12,
|
"target": 12,
|
||||||
"key": "contains",
|
"key": "contains",
|
||||||
"source": 21
|
"source": 21
|
||||||
@ -685,8 +685,8 @@ Response Examples
|
|||||||
},
|
},
|
||||||
"nodes": [
|
"nodes": [
|
||||||
{
|
{
|
||||||
"category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"type": "nagios",
|
"vitrage_type": "nagios",
|
||||||
"name": "CPU load",
|
"name": "CPU load",
|
||||||
"state": "Active",
|
"state": "Active",
|
||||||
"severity": "WARNING",
|
"severity": "WARNING",
|
||||||
@ -699,8 +699,8 @@ Response Examples
|
|||||||
"vitrage_id": "ALARM:nagios:host0:CPU load"
|
"vitrage_id": "ALARM:nagios:host0:CPU load"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"type": "vitrage",
|
"vitrage_type": "vitrage",
|
||||||
"name": "Machine Suboptimal",
|
"name": "Machine Suboptimal",
|
||||||
"state": "Active",
|
"state": "Active",
|
||||||
"severity": "WARNING",
|
"severity": "WARNING",
|
||||||
@ -712,8 +712,8 @@ Response Examples
|
|||||||
"vitrage_id": "ALARM:vitrage:vm0:Machine Suboptimal"
|
"vitrage_id": "ALARM:vitrage:vm0:Machine Suboptimal"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"type": "vitrage",
|
"vitrage_type": "vitrage",
|
||||||
"name": "Machine Suboptimal",
|
"name": "Machine Suboptimal",
|
||||||
"state": "Active",
|
"state": "Active",
|
||||||
"severity": "WARNING",
|
"severity": "WARNING",
|
||||||
@ -799,8 +799,8 @@ Response Examples
|
|||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"type": "nagios",
|
"vitrage_type": "nagios",
|
||||||
"name": "CPU load",
|
"name": "CPU load",
|
||||||
"state": "Active",
|
"state": "Active",
|
||||||
"severity": "WARNING",
|
"severity": "WARNING",
|
||||||
@ -814,8 +814,8 @@ Response Examples
|
|||||||
"normalized_severity": "WARNING"
|
"normalized_severity": "WARNING"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"type": "vitrage",
|
"vitrage_type": "vitrage",
|
||||||
"name": "Machine Suboptimal",
|
"name": "Machine Suboptimal",
|
||||||
"state": "Active",
|
"state": "Active",
|
||||||
"severity": "CRITICAL",
|
"severity": "CRITICAL",
|
||||||
@ -828,8 +828,8 @@ Response Examples
|
|||||||
"normalized_severity": "CRITICAL"
|
"normalized_severity": "CRITICAL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"type": "vitrage",
|
"vitrage_type": "vitrage",
|
||||||
"name": "Machine Suboptimal",
|
"name": "Machine Suboptimal",
|
||||||
"state": "Active",
|
"state": "Active",
|
||||||
"severity": "CRITICAL",
|
"severity": "CRITICAL",
|
||||||
@ -842,8 +842,8 @@ Response Examples
|
|||||||
"normalized_severity": "CRITICAL"
|
"normalized_severity": "CRITICAL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"type": "aodh",
|
"vitrage_type": "aodh",
|
||||||
"name": "Memory overload",
|
"name": "Memory overload",
|
||||||
"state": "Active",
|
"state": "Active",
|
||||||
"severity": "WARNING",
|
"severity": "WARNING",
|
||||||
@ -1130,30 +1130,30 @@ Response Examples
|
|||||||
"entities": [
|
"entities": [
|
||||||
{
|
{
|
||||||
"entity": {
|
"entity": {
|
||||||
"category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"type": "nagios",
|
"vitrage_type": "nagios",
|
||||||
"name": "check_libvirtd",
|
"name": "check_libvirtd",
|
||||||
"template_id": "alarm_1"
|
"template_id": "alarm_1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"entity": {
|
"entity": {
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"type": "nova.host",
|
"vitrage_type": "nova.host",
|
||||||
"template_id": "host"
|
"template_id": "host"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"entity": {
|
"entity": {
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"template_id": "instance"
|
"template_id": "instance"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"entity": {
|
"entity": {
|
||||||
"category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"type": "vitrage",
|
"vitrage_type": "vitrage",
|
||||||
"name": "exploding_world",
|
"name": "exploding_world",
|
||||||
"template_id": "alarm_2"
|
"template_id": "alarm_2"
|
||||||
}
|
}
|
||||||
@ -1317,9 +1317,9 @@ Response Examples
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"vitrage_id": "RESOURCE:nova.host:cloud",
|
"vitrage_id": "RESOURCE:nova.host:cloud",
|
||||||
"aggregated_state": "AVAILABLE",
|
"vitrage_aggregated_state": "AVAILABLE",
|
||||||
"state": "available",
|
"state": "available",
|
||||||
"type": "nova.host",
|
"vitrage_type": "nova.host",
|
||||||
"id": "cloud",
|
"id": "cloud",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "cloud",
|
"name": "cloud",
|
||||||
@ -1387,14 +1387,14 @@ Response Examples
|
|||||||
::
|
::
|
||||||
|
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "vm-1",
|
"name": "vm-1",
|
||||||
"update_timestamp": "2015-12-01T12:46:41Z",
|
"update_timestamp": "2015-12-01T12:46:41Z",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
"project_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "dc35fa2f-4515-1653-ef6b-03b471bb395b",
|
"id": "dc35fa2f-4515-1653-ef6b-03b471bb395b",
|
||||||
"vitrage_id": "RESOURCE:nova.instance:dc35fa2f-4515-1653-ef6b-03b471bb395b"
|
"vitrage_id": "RESOURCE:nova.instance:dc35fa2f-4515-1653-ef6b-03b471bb395b"
|
||||||
}
|
}
|
||||||
|
@ -294,26 +294,26 @@ Adding/removing a template
|
|||||||
Common parameters and their acceptable values - for writing templates
|
Common parameters and their acceptable values - for writing templates
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
+-------------------+---------------+-------------------------+------------------------------------+
|
+-------------------+-----------------------+-------------------------+------------------------------------+
|
||||||
| block | key | supported values | comments |
|
| block | key | supported values | comments |
|
||||||
+===================+===============+=========================+====================================+
|
+===================+=======================+=========================+====================================+
|
||||||
| entity | category | ALARM | |
|
| entity | category | ALARM | |
|
||||||
| | | RESOURCE | |
|
| | | RESOURCE | |
|
||||||
+-------------------+---------------+-------------------------+------------------------------------+
|
+-------------------+-----------------------+-------------------------+------------------------------------+
|
||||||
| entity (ALARM) | type | any string | |
|
| entity (ALARM) | type | any string | |
|
||||||
+-------------------+---------------+-------------------------+------------------------------------+
|
+-------------------+-----------------------+-------------------------+------------------------------------+
|
||||||
| entity (RESOURCE) | type | openstack.cluster, | These are for the datasources that |
|
| entity (RESOURCE) | type | openstack.cluster, | These are for the datasources that |
|
||||||
| | | nova.zone, | come with vitrage by default. |
|
| | | nova.zone, | come with vitrage by default. |
|
||||||
| | | nova.host, | Adding datasources will add more |
|
| | | nova.host, | Adding datasources will add more |
|
||||||
| | | nova.instance, | supported types, as defined in the |
|
| | | nova.instance, | supported types, as defined in the |
|
||||||
| | | cinder.volume, | datasource transformer |
|
| | | cinder.volume, | datasource transformer |
|
||||||
| | | switch | |
|
| | | switch | |
|
||||||
+-------------------+---------------+-------------------------+------------------------------------+
|
+-------------------+-----------------------+-------------------------+------------------------------------+
|
||||||
| action | action_type | raise_alarm, | |
|
| action | action_type | raise_alarm, | |
|
||||||
| | | set_state, | |
|
| | | set_state, | |
|
||||||
| | | add_causal_relationship | |
|
| | | add_causal_relationship | |
|
||||||
| | | mark_down | |
|
| | | mark_down | |
|
||||||
+-------------------+---------------+-------------------------+------------------------------------+
|
+-------------------+-----------------------+-------------------------+------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
Supported Actions
|
Supported Actions
|
||||||
|
@ -48,10 +48,10 @@ class AlarmApis(EntityGraphApisBase):
|
|||||||
is_admin_project)
|
is_admin_project)
|
||||||
alarms = set(alarms)
|
alarms = set(alarms)
|
||||||
else:
|
else:
|
||||||
alarms = self.entity_graph.neighbors(
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
vitrage_id,
|
VProps.VITRAGE_IS_DELETED: False}
|
||||||
vertex_attr_filter={VProps.CATEGORY: EntityCategory.ALARM,
|
alarms = self.entity_graph.neighbors(vitrage_id,
|
||||||
VProps.IS_DELETED: False})
|
vertex_attr_filter=query)
|
||||||
|
|
||||||
return json.dumps({'alarms': [v.properties for v in alarms]})
|
return json.dumps({'alarms': [v.properties for v in alarms]})
|
||||||
|
|
||||||
|
@ -30,15 +30,15 @@ LOG = log.getLogger(__name__)
|
|||||||
# Used for Sunburst to show only specific resources
|
# Used for Sunburst to show only specific resources
|
||||||
TREE_TOPOLOGY_QUERY = {
|
TREE_TOPOLOGY_QUERY = {
|
||||||
'and': [
|
'and': [
|
||||||
{'==': {VProps.CATEGORY: EntityCategory.RESOURCE}},
|
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}},
|
||||||
{'==': {VProps.IS_DELETED: False}},
|
{'==': {VProps.VITRAGE_IS_DELETED: False}},
|
||||||
{'==': {VProps.IS_PLACEHOLDER: False}},
|
{'==': {VProps.VITRAGE_IS_PLACEHOLDER: False}},
|
||||||
{
|
{
|
||||||
'or': [
|
'or': [
|
||||||
{'==': {VProps.TYPE: OPENSTACK_CLUSTER}},
|
{'==': {VProps.VITRAGE_TYPE: OPENSTACK_CLUSTER}},
|
||||||
{'==': {VProps.TYPE: NOVA_INSTANCE_DATASOURCE}},
|
{'==': {VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE}},
|
||||||
{'==': {VProps.TYPE: NOVA_HOST_DATASOURCE}},
|
{'==': {VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE}},
|
||||||
{'==': {VProps.TYPE: NOVA_ZONE_DATASOURCE}}
|
{'==': {VProps.VITRAGE_TYPE: NOVA_ZONE_DATASOURCE}}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -46,12 +46,12 @@ TREE_TOPOLOGY_QUERY = {
|
|||||||
|
|
||||||
TOPOLOGY_AND_ALARMS_QUERY = {
|
TOPOLOGY_AND_ALARMS_QUERY = {
|
||||||
'and': [
|
'and': [
|
||||||
{'==': {VProps.IS_DELETED: False}},
|
{'==': {VProps.VITRAGE_IS_DELETED: False}},
|
||||||
{'==': {VProps.IS_PLACEHOLDER: False}},
|
{'==': {VProps.VITRAGE_IS_PLACEHOLDER: False}},
|
||||||
{
|
{
|
||||||
'or': [
|
'or': [
|
||||||
{'==': {VProps.CATEGORY: EntityCategory.ALARM}},
|
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}},
|
||||||
{'==': {VProps.CATEGORY: EntityCategory.RESOURCE}}
|
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -59,31 +59,31 @@ TOPOLOGY_AND_ALARMS_QUERY = {
|
|||||||
|
|
||||||
RCA_QUERY = {
|
RCA_QUERY = {
|
||||||
'and': [
|
'and': [
|
||||||
{'==': {VProps.CATEGORY: EntityCategory.ALARM}},
|
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}},
|
||||||
{'==': {VProps.IS_DELETED: False}}
|
{'==': {VProps.VITRAGE_IS_DELETED: False}}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
ALARMS_ALL_QUERY = {
|
ALARMS_ALL_QUERY = {
|
||||||
'and': [
|
'and': [
|
||||||
{'==': {VProps.CATEGORY: EntityCategory.ALARM}},
|
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}},
|
||||||
{'==': {VProps.IS_DELETED: False}}
|
{'==': {VProps.VITRAGE_IS_DELETED: False}}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
ALARM_QUERY = {
|
ALARM_QUERY = {
|
||||||
VProps.CATEGORY: EntityCategory.ALARM,
|
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: False,
|
VProps.VITRAGE_IS_DELETED: False,
|
||||||
VProps.IS_PLACEHOLDER: False
|
VProps.VITRAGE_IS_PLACEHOLDER: False
|
||||||
}
|
}
|
||||||
|
|
||||||
EDGE_QUERY = {'==': {EProps.IS_DELETED: False}}
|
EDGE_QUERY = {'==': {EProps.VITRAGE_IS_DELETED: False}}
|
||||||
|
|
||||||
RESOURCES_ALL_QUERY = {
|
RESOURCES_ALL_QUERY = {
|
||||||
'and': [
|
'and': [
|
||||||
{'==': {VProps.CATEGORY: EntityCategory.RESOURCE}},
|
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}},
|
||||||
{'==': {VProps.IS_DELETED: False}},
|
{'==': {VProps.VITRAGE_IS_DELETED: False}},
|
||||||
{'==': {VProps.IS_PLACEHOLDER: False}}
|
{'==': {VProps.VITRAGE_IS_PLACEHOLDER: False}}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,13 +93,13 @@ class EntityGraphApisBase(object):
|
|||||||
IS_ADMIN_PROJECT_PROPERTY = 'is_admin'
|
IS_ADMIN_PROJECT_PROPERTY = 'is_admin'
|
||||||
|
|
||||||
@staticmethod
|
@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
|
"""Generate query with tenant data
|
||||||
|
|
||||||
Creates query for entity graph which takes into consideration the
|
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 project_id: string
|
||||||
:type is_admin: boolean
|
:type is_admin: boolean
|
||||||
:rtype: dictionary
|
:rtype: dictionary
|
||||||
@ -107,9 +107,9 @@ class EntityGraphApisBase(object):
|
|||||||
|
|
||||||
query = {
|
query = {
|
||||||
'and': [
|
'and': [
|
||||||
{'==': {VProps.IS_DELETED: False}},
|
{'==': {VProps.VITRAGE_IS_DELETED: False}},
|
||||||
{'==': {VProps.IS_PLACEHOLDER: False}},
|
{'==': {VProps.VITRAGE_IS_PLACEHOLDER: False}},
|
||||||
{'==': {VProps.CATEGORY: category}}
|
{'==': {VProps.VITRAGE_CATEGORY: vitrage_category}}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class EntityGraphApisBase(object):
|
|||||||
for alarm in alarms:
|
for alarm in alarms:
|
||||||
alarm_project_id = alarm.get(VProps.PROJECT_ID, None)
|
alarm_project_id = alarm.get(VProps.PROJECT_ID, None)
|
||||||
if not alarm_project_id:
|
if not alarm_project_id:
|
||||||
cat_filter = {VProps.CATEGORY: EntityCategory.RESOURCE}
|
cat_filter = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}
|
||||||
alarms_resource = \
|
alarms_resource = \
|
||||||
self.entity_graph.neighbors(alarm.vertex_id,
|
self.entity_graph.neighbors(alarm.vertex_id,
|
||||||
vertex_attr_filter=cat_filter)
|
vertex_attr_filter=cat_filter)
|
||||||
@ -183,7 +183,7 @@ class EntityGraphApisBase(object):
|
|||||||
entities = self.entity_graph.neighbors(entity.vertex_id,
|
entities = self.entity_graph.neighbors(entity.vertex_id,
|
||||||
direction=Direction.OUT)
|
direction=Direction.OUT)
|
||||||
for entity in entities:
|
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)
|
resource_project_id = entity.get(VProps.PROJECT_ID)
|
||||||
if resource_project_id == project_id or \
|
if resource_project_id == project_id or \
|
||||||
(not resource_project_id and is_admin_project):
|
(not resource_project_id and is_admin_project):
|
||||||
|
@ -47,7 +47,7 @@ class ResourceApis(EntityGraphApisBase):
|
|||||||
query = copy.deepcopy(resource_query)
|
query = copy.deepcopy(resource_query)
|
||||||
|
|
||||||
if resource_type:
|
if resource_type:
|
||||||
type_query = {'==': {VProps.TYPE: resource_type}}
|
type_query = {'==': {VProps.VITRAGE_TYPE: resource_type}}
|
||||||
query['and'].append(type_query)
|
query['and'].append(type_query)
|
||||||
|
|
||||||
resources = self.entity_graph.get_vertices(query_dict=query)
|
resources = self.entity_graph.get_vertices(query_dict=query)
|
||||||
|
@ -65,7 +65,7 @@ class TopologyApis(EntityGraphApisBase):
|
|||||||
q = query if query else TOPOLOGY_AND_ALARMS_QUERY
|
q = query if query else TOPOLOGY_AND_ALARMS_QUERY
|
||||||
graph = ga.create_graph_from_matching_vertices(
|
graph = ga.create_graph_from_matching_vertices(
|
||||||
query_dict=q,
|
query_dict=q,
|
||||||
edge_attr_filter={VProps.IS_DELETED: False})
|
edge_attr_filter={VProps.VITRAGE_IS_DELETED: False})
|
||||||
else:
|
else:
|
||||||
graph = self._get_topology_for_specific_project(
|
graph = self._get_topology_for_specific_project(
|
||||||
ga,
|
ga,
|
||||||
@ -115,7 +115,7 @@ class TopologyApis(EntityGraphApisBase):
|
|||||||
|
|
||||||
tmp_graph = ga.create_graph_from_matching_vertices(query_dict=q)
|
tmp_graph = ga.create_graph_from_matching_vertices(query_dict=q)
|
||||||
graph = self._create_graph_of_connected_components(ga, tmp_graph, root)
|
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,
|
self._remove_unnecessary_elements(ga,
|
||||||
graph,
|
graph,
|
||||||
project_id,
|
project_id,
|
||||||
@ -153,7 +153,7 @@ class TopologyApis(EntityGraphApisBase):
|
|||||||
|
|
||||||
for alarm in graph.get_vertices(query_dict=ALARMS_ALL_QUERY):
|
for alarm in graph.get_vertices(query_dict=ALARMS_ALL_QUERY):
|
||||||
if not alarm.get(VProps.PROJECT_ID, None):
|
if not alarm.get(VProps.PROJECT_ID, None):
|
||||||
cat_filter = {VProps.CATEGORY: EntityCategory.RESOURCE}
|
cat_filter = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}
|
||||||
resource_neighbors = \
|
resource_neighbors = \
|
||||||
self.entity_graph.neighbors(alarm.vertex_id,
|
self.entity_graph.neighbors(alarm.vertex_id,
|
||||||
vertex_attr_filter=cat_filter)
|
vertex_attr_filter=cat_filter)
|
||||||
@ -220,7 +220,7 @@ class TopologyApis(EntityGraphApisBase):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _find_instance_in_graph(graph):
|
def _find_instance_in_graph(graph):
|
||||||
for node, node_data in graph.nodes_iter(data=True):
|
for node, node_data in graph.nodes_iter(data=True):
|
||||||
if node_data[VProps.CATEGORY] == EntityCategory.RESOURCE and \
|
if node_data[VProps.VITRAGE_CATEGORY] == EntityCategory.RESOURCE and \
|
||||||
node_data[VProps.TYPE] == NOVA_INSTANCE_DATASOURCE:
|
node_data[VProps.VITRAGE_TYPE] == NOVA_INSTANCE_DATASOURCE:
|
||||||
return node
|
return node
|
||||||
return None
|
return None
|
||||||
|
@ -15,23 +15,24 @@
|
|||||||
|
|
||||||
|
|
||||||
class VertexProperties(object):
|
class VertexProperties(object):
|
||||||
CATEGORY = 'category'
|
VITRAGE_CATEGORY = 'vitrage_category'
|
||||||
TYPE = 'type'
|
VITRAGE_TYPE = 'vitrage_type'
|
||||||
ID = 'id'
|
VITRAGE_ID = 'vitrage_id'
|
||||||
IS_DELETED = 'is_deleted'
|
|
||||||
STATE = 'state'
|
|
||||||
VITRAGE_STATE = 'vitrage_state'
|
VITRAGE_STATE = 'vitrage_state'
|
||||||
AGGREGATED_STATE = 'aggregated_state'
|
VITRAGE_IS_DELETED = 'vitrage_is_deleted'
|
||||||
OPERATIONAL_STATE = 'operational_state'
|
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'
|
PROJECT_ID = 'project_id'
|
||||||
UPDATE_TIMESTAMP = 'update_timestamp'
|
UPDATE_TIMESTAMP = 'update_timestamp'
|
||||||
SAMPLE_TIMESTAMP = 'sample_timestamp'
|
|
||||||
NAME = 'name'
|
NAME = 'name'
|
||||||
IS_PLACEHOLDER = 'is_placeholder'
|
|
||||||
SEVERITY = 'severity'
|
SEVERITY = 'severity'
|
||||||
AGGREGATED_SEVERITY = 'aggregated_severity'
|
|
||||||
OPERATIONAL_SEVERITY = 'operational_severity'
|
|
||||||
VITRAGE_ID = 'vitrage_id'
|
|
||||||
IS_MARKED_DOWN = 'is_marked_down'
|
IS_MARKED_DOWN = 'is_marked_down'
|
||||||
INFO = 'info'
|
INFO = 'info'
|
||||||
GRAPH_INDEX = 'graph_index'
|
GRAPH_INDEX = 'graph_index'
|
||||||
@ -45,7 +46,7 @@ class VertexProperties(object):
|
|||||||
|
|
||||||
class EdgeProperties(object):
|
class EdgeProperties(object):
|
||||||
RELATIONSHIP_TYPE = 'relationship_type'
|
RELATIONSHIP_TYPE = 'relationship_type'
|
||||||
IS_DELETED = 'is_deleted'
|
VITRAGE_IS_DELETED = 'vitrage_is_deleted'
|
||||||
UPDATE_TIMESTAMP = 'update_timestamp'
|
UPDATE_TIMESTAMP = 'update_timestamp'
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ class AlarmDriverBase(DriverBase):
|
|||||||
super(DriverBase, self).__init__()
|
super(DriverBase, self).__init__()
|
||||||
self.cache = dict()
|
self.cache = dict()
|
||||||
|
|
||||||
def _entity_type(self):
|
def _vitrage_type(self):
|
||||||
"""Return the type of the datasource """
|
"""Return the vitrage_type of the datasource """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _alarm_key(self, alarm):
|
def _alarm_key(self, alarm):
|
||||||
@ -74,12 +74,12 @@ class AlarmDriverBase(DriverBase):
|
|||||||
|
|
||||||
def get_all(self, datasource_action):
|
def get_all(self, datasource_action):
|
||||||
return self.make_pickleable(self._get_all_alarms(),
|
return self.make_pickleable(self._get_all_alarms(),
|
||||||
self._entity_type(),
|
self._vitrage_type(),
|
||||||
datasource_action)
|
datasource_action)
|
||||||
|
|
||||||
def get_changes(self, datasource_action):
|
def get_changes(self, datasource_action):
|
||||||
return self.make_pickleable(self._get_changed_alarms(),
|
return self.make_pickleable(self._get_changed_alarms(),
|
||||||
self._entity_type(),
|
self._vitrage_type(),
|
||||||
datasource_action)
|
datasource_action)
|
||||||
|
|
||||||
def _get_all_alarms(self):
|
def _get_all_alarms(self):
|
||||||
|
@ -42,7 +42,7 @@ class AodhDriver(AlarmDriverBase):
|
|||||||
self._client = os_clients.ceilometer_client(self.conf)
|
self._client = os_clients.ceilometer_client(self.conf)
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
def _entity_type(self):
|
def _vitrage_type(self):
|
||||||
return AODH_DATASOURCE
|
return AODH_DATASOURCE
|
||||||
|
|
||||||
def _alarm_key(self, alarm):
|
def _alarm_key(self, alarm):
|
||||||
|
@ -24,6 +24,8 @@ from vitrage.datasources.aodh.properties import AodhProperties as AodhProps
|
|||||||
from vitrage.datasources.aodh.properties import AodhState
|
from vitrage.datasources.aodh.properties import AodhState
|
||||||
from vitrage.datasources import transformer_base as tbase
|
from vitrage.datasources import transformer_base as tbase
|
||||||
from vitrage.datasources.transformer_base import Neighbor
|
from vitrage.datasources.transformer_base import Neighbor
|
||||||
|
from vitrage.evaluator.actions.evaluator_event_transformer \
|
||||||
|
import VITRAGE_DATASOURCE
|
||||||
import vitrage.graph.utils as graph_utils
|
import vitrage.graph.utils as graph_utils
|
||||||
from vitrage.utils import datetime as datetime_utils
|
from vitrage.utils import datetime as datetime_utils
|
||||||
|
|
||||||
@ -67,18 +69,18 @@ class AodhTransformer(AlarmTransformerBase):
|
|||||||
metadata[AodhProps.STATE_TIMESTAMP] = \
|
metadata[AodhProps.STATE_TIMESTAMP] = \
|
||||||
entity_event[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(
|
update_timestamp = self._format_update_timestamp(
|
||||||
AodhTransformer._timestamp(entity_event), sample_timestamp)
|
AodhTransformer._timestamp(entity_event), vitrage_sample_timestamp)
|
||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(entity_event),
|
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_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),
|
entity_state=self._get_alarm_state(entity_event),
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -110,16 +112,16 @@ class AodhTransformer(AlarmTransformerBase):
|
|||||||
AodhProps.DESCRIPTION: entity_event[AodhProps.DESCRIPTION],
|
AodhProps.DESCRIPTION: entity_event[AodhProps.DESCRIPTION],
|
||||||
VProps.PROJECT_ID: entity_event[AodhProps.PROJECT_ID],
|
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(
|
update_timestamp = self._format_update_timestamp(
|
||||||
AodhTransformer._timestamp(entity_event), sample_timestamp)
|
AodhTransformer._timestamp(entity_event), vitrage_sample_timestamp)
|
||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(entity_event),
|
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_id=entity_event.get(AodhProps.ALARM_ID),
|
||||||
entity_category=EntityCategory.ALARM,
|
|
||||||
entity_type='vitrage',
|
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -148,7 +150,7 @@ class AodhTransformer(AlarmTransformerBase):
|
|||||||
return None
|
return None
|
||||||
return {VProps.ID: affected_resource_id}
|
return {VProps.ID: affected_resource_id}
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return AODH_DATASOURCE
|
return AODH_DATASOURCE
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,15 +112,15 @@ class CinderVolumeTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
entity_key = self._create_entity_key(entity_event)
|
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(
|
return graph_utils.create_vertex(
|
||||||
entity_key,
|
entity_key,
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=CINDER_VOLUME_DATASOURCE,
|
||||||
|
vitrage_sample_timestamp=vitrage_sample_timestamp,
|
||||||
entity_id=volume_id,
|
entity_id=volume_id,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=CINDER_VOLUME_DATASOURCE,
|
|
||||||
entity_state=volume_state,
|
entity_state=volume_state,
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -159,5 +159,5 @@ class CinderVolumeTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
return neighbors
|
return neighbors
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return CINDER_VOLUME_DATASOURCE
|
return CINDER_VOLUME_DATASOURCE
|
||||||
|
@ -37,7 +37,7 @@ class CollectdDriver(AlarmDriverBase):
|
|||||||
CollectdDriver.conf_map = \
|
CollectdDriver.conf_map = \
|
||||||
CollectdDriver._configuration_mapping(conf)
|
CollectdDriver._configuration_mapping(conf)
|
||||||
|
|
||||||
def _entity_type(self):
|
def _vitrage_type(self):
|
||||||
return COLLECTD_DATASOURCE
|
return COLLECTD_DATASOURCE
|
||||||
|
|
||||||
def _alarm_key(self, alarm):
|
def _alarm_key(self, alarm):
|
||||||
|
@ -45,7 +45,7 @@ class CollectdTransformer(AlarmTransformerBase):
|
|||||||
|
|
||||||
update_timestamp = entity_event['timestamp']
|
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 \
|
entity_state = AlarmProps.INACTIVE_STATE \
|
||||||
if self._ok_status(entity_event) else AlarmProps.ACTIVE_STATE
|
if self._ok_status(entity_event) else AlarmProps.ACTIVE_STATE
|
||||||
@ -59,10 +59,10 @@ class CollectdTransformer(AlarmTransformerBase):
|
|||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(entity_event),
|
self._create_entity_key(entity_event),
|
||||||
entity_category=EntityCategory.ALARM,
|
vitrage_category=EntityCategory.ALARM,
|
||||||
entity_type=entity_event[DSProps.ENTITY_TYPE],
|
vitrage_type=entity_event[DSProps.ENTITY_TYPE],
|
||||||
|
vitrage_sample_timestamp=vitrage_sample_timestamp,
|
||||||
entity_state=entity_state,
|
entity_state=entity_state,
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class CollectdTransformer(AlarmTransformerBase):
|
|||||||
resource_name,
|
resource_name,
|
||||||
alarm_id))
|
alarm_id))
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return COLLECTD_DATASOURCE
|
return COLLECTD_DATASOURCE
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -47,7 +47,7 @@ class ConsistencyTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
entity_event[VProps.VITRAGE_ID],
|
entity_event[VProps.VITRAGE_ID],
|
||||||
sample_timestamp=entity_event[DSProps.SAMPLE_DATE],
|
vitrage_sample_timestamp=entity_event[DSProps.SAMPLE_DATE],
|
||||||
metadata=metadata
|
metadata=metadata
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,5 +60,5 @@ class ConsistencyTransformer(ResourceTransformerBase):
|
|||||||
def _create_update_neighbors(self, entity_event):
|
def _create_update_neighbors(self, entity_event):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return CONSISTENCY_DATASOURCE
|
return CONSISTENCY_DATASOURCE
|
||||||
|
@ -37,7 +37,7 @@ class DoctorDriver(AlarmDriverBase):
|
|||||||
self.conf = conf
|
self.conf = conf
|
||||||
self._client = None
|
self._client = None
|
||||||
|
|
||||||
def _entity_type(self):
|
def _vitrage_type(self):
|
||||||
return DOCTOR_DATASOURCE
|
return DOCTOR_DATASOURCE
|
||||||
|
|
||||||
def _alarm_key(self, alarm):
|
def _alarm_key(self, alarm):
|
||||||
|
@ -54,10 +54,10 @@ class DoctorTransformer(AlarmTransformerBase):
|
|||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(entity_event),
|
self._create_entity_key(entity_event),
|
||||||
entity_category=EntityCategory.ALARM,
|
vitrage_category=EntityCategory.ALARM,
|
||||||
entity_type=entity_event[DSProps.ENTITY_TYPE],
|
vitrage_type=entity_event[DSProps.ENTITY_TYPE],
|
||||||
|
vitrage_sample_timestamp=entity_event[DSProps.SAMPLE_DATE],
|
||||||
entity_state=self._get_alarm_state(entity_event),
|
entity_state=self._get_alarm_state(entity_event),
|
||||||
sample_timestamp=entity_event[DSProps.SAMPLE_DATE],
|
|
||||||
update_timestamp=entity_event[DoctorProps.UPDATE_TIME],
|
update_timestamp=entity_event[DoctorProps.UPDATE_TIME],
|
||||||
metadata=details)
|
metadata=details)
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class DoctorTransformer(AlarmTransformerBase):
|
|||||||
entity_event[EventProps.TYPE],
|
entity_event[EventProps.TYPE],
|
||||||
get_detail(entity_event, DoctorDetails.HOSTNAME)))
|
get_detail(entity_event, DoctorDetails.HOSTNAME)))
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return DOCTOR_DATASOURCE
|
return DOCTOR_DATASOURCE
|
||||||
|
|
||||||
def _ok_status(self, entity_event):
|
def _ok_status(self, entity_event):
|
||||||
|
@ -91,15 +91,15 @@ class HeatStackTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
entity_key = self._create_entity_key(entity_event)
|
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(
|
return graph_utils.create_vertex(
|
||||||
entity_key,
|
entity_key,
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=HEAT_STACK_DATASOURCE,
|
||||||
|
vitrage_sample_timestamp=vitrage_sample_timestamp,
|
||||||
entity_id=stack_id,
|
entity_id=stack_id,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=HEAT_STACK_DATASOURCE,
|
|
||||||
entity_state=stack_state,
|
entity_state=stack_state,
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -133,5 +133,5 @@ class HeatStackTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
return neighbors
|
return neighbors
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return HEAT_STACK_DATASOURCE
|
return HEAT_STACK_DATASOURCE
|
||||||
|
@ -46,7 +46,7 @@ class NagiosConfig(object):
|
|||||||
config[NAME])
|
config[NAME])
|
||||||
|
|
||||||
def get_vitrage_resource(self, nagios_host):
|
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
|
Go over the configuration mappings one by one, and return the resource
|
||||||
by the first mapping that applies to nagios host name.
|
by the first mapping that applies to nagios host name.
|
||||||
|
@ -37,7 +37,7 @@ class NagiosDriver(AlarmDriverBase):
|
|||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.config = NagiosConfig(conf)
|
self.config = NagiosConfig(conf)
|
||||||
|
|
||||||
def _entity_type(self):
|
def _vitrage_type(self):
|
||||||
return NAGIOS_DATASOURCE
|
return NAGIOS_DATASOURCE
|
||||||
|
|
||||||
def _alarm_key(self, alarm):
|
def _alarm_key(self, alarm):
|
||||||
|
@ -42,9 +42,10 @@ class NagiosTransformer(AlarmTransformerBase):
|
|||||||
entity_event[NagiosProperties.LAST_CHECK],
|
entity_event[NagiosProperties.LAST_CHECK],
|
||||||
'%Y-%m-%d %H:%M:%S',
|
'%Y-%m-%d %H:%M:%S',
|
||||||
tbase.TIMESTAMP_FORMAT)
|
tbase.TIMESTAMP_FORMAT)
|
||||||
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
|
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
|
||||||
update_timestamp = self._format_update_timestamp(update_timestamp,
|
update_timestamp = \
|
||||||
sample_timestamp)
|
self._format_update_timestamp(update_timestamp,
|
||||||
|
vitrage_sample_timestamp)
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
VProps.NAME: entity_event[NagiosProperties.SERVICE],
|
VProps.NAME: entity_event[NagiosProperties.SERVICE],
|
||||||
@ -55,10 +56,10 @@ class NagiosTransformer(AlarmTransformerBase):
|
|||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(entity_event),
|
self._create_entity_key(entity_event),
|
||||||
entity_category=EntityCategory.ALARM,
|
vitrage_category=EntityCategory.ALARM,
|
||||||
entity_type=entity_event[DSProps.ENTITY_TYPE],
|
vitrage_type=entity_event[DSProps.ENTITY_TYPE],
|
||||||
|
vitrage_sample_timestamp=vitrage_sample_timestamp,
|
||||||
entity_state=self._get_alarm_state(entity_event),
|
entity_state=self._get_alarm_state(entity_event),
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -93,5 +94,5 @@ class NagiosTransformer(AlarmTransformerBase):
|
|||||||
resource_name,
|
resource_name,
|
||||||
alarm_name))
|
alarm_name))
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return NAGIOS_DATASOURCE
|
return NAGIOS_DATASOURCE
|
||||||
|
@ -87,15 +87,15 @@ class NetworkTransformer(ResourceTransformerBase):
|
|||||||
VProps.PROJECT_ID: project_id,
|
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(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(entity_event),
|
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_id=entity_id,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=NEUTRON_NETWORK_DATASOURCE,
|
|
||||||
entity_state=state,
|
entity_state=state,
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -107,5 +107,5 @@ class NetworkTransformer(ResourceTransformerBase):
|
|||||||
key_fields = self._key_values(NEUTRON_NETWORK_DATASOURCE, network_id)
|
key_fields = self._key_values(NEUTRON_NETWORK_DATASOURCE, network_id)
|
||||||
return tbase.build_key(key_fields)
|
return tbase.build_key(key_fields)
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return NEUTRON_NETWORK_DATASOURCE
|
return NEUTRON_NETWORK_DATASOURCE
|
||||||
|
@ -105,15 +105,15 @@ class PortTransformer(ResourceTransformerBase):
|
|||||||
'host_id': entity_event.get('binding:host_id'),
|
'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(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(entity_event),
|
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_id=entity_id,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=NEUTRON_PORT_DATASOURCE,
|
|
||||||
entity_state=state,
|
entity_state=state,
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -159,5 +159,5 @@ class PortTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
return tbase.build_key(key_fields)
|
return tbase.build_key(key_fields)
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return NEUTRON_PORT_DATASOURCE
|
return NEUTRON_PORT_DATASOURCE
|
||||||
|
@ -48,16 +48,17 @@ class HostTransformer(ResourceTransformerBase):
|
|||||||
metadata = {VProps.NAME: host_name}
|
metadata = {VProps.NAME: host_name}
|
||||||
entity_key = self._create_entity_key(entity_event)
|
entity_key = self._create_entity_key(entity_event)
|
||||||
|
|
||||||
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
|
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
|
||||||
update_timestamp = self._format_update_timestamp(None,
|
update_timestamp = \
|
||||||
sample_timestamp)
|
self._format_update_timestamp(None,
|
||||||
|
vitrage_sample_timestamp)
|
||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
entity_key,
|
entity_key,
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=NOVA_HOST_DATASOURCE,
|
||||||
|
vitrage_sample_timestamp=vitrage_sample_timestamp,
|
||||||
entity_id=host_name,
|
entity_id=host_name,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=NOVA_HOST_DATASOURCE,
|
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -83,5 +84,5 @@ class HostTransformer(ResourceTransformerBase):
|
|||||||
key_fields = self._key_values(NOVA_HOST_DATASOURCE, host_name)
|
key_fields = self._key_values(NOVA_HOST_DATASOURCE, host_name)
|
||||||
return transformer_base.build_key(key_fields)
|
return transformer_base.build_key(key_fields)
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return NOVA_HOST_DATASOURCE
|
return NOVA_HOST_DATASOURCE
|
||||||
|
@ -62,21 +62,21 @@ class InstanceTransformer(ResourceTransformerBase):
|
|||||||
'host_id': host
|
'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
|
# TODO(Alexey): need to check that only the UPDATE datasource_action
|
||||||
# will update the UPDATE_TIMESTAMP property
|
# will update the UPDATE_TIMESTAMP property
|
||||||
update_timestamp = self._format_update_timestamp(
|
update_timestamp = self._format_update_timestamp(
|
||||||
extract_field_value(entity_event, DSProps.SAMPLE_DATE),
|
extract_field_value(entity_event, DSProps.SAMPLE_DATE),
|
||||||
sample_timestamp)
|
vitrage_sample_timestamp)
|
||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(entity_event),
|
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_id=entity_id,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=NOVA_INSTANCE_DATASOURCE,
|
|
||||||
entity_state=state,
|
entity_state=state,
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -106,5 +106,5 @@ class InstanceTransformer(ResourceTransformerBase):
|
|||||||
instance_id))
|
instance_id))
|
||||||
return tbase.build_key(key_fields)
|
return tbase.build_key(key_fields)
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return NOVA_INSTANCE_DATASOURCE
|
return NOVA_INSTANCE_DATASOURCE
|
||||||
|
@ -61,17 +61,18 @@ class ZoneTransformer(ResourceTransformerBase):
|
|||||||
}
|
}
|
||||||
entity_key = self._create_entity_key(entity_event)
|
entity_key = self._create_entity_key(entity_event)
|
||||||
|
|
||||||
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
|
vitrage_sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
|
||||||
update_timestamp = self._format_update_timestamp(None,
|
update_timestamp = \
|
||||||
sample_timestamp)
|
self._format_update_timestamp(None,
|
||||||
|
vitrage_sample_timestamp)
|
||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
entity_key,
|
entity_key,
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=NOVA_ZONE_DATASOURCE,
|
||||||
|
vitrage_sample_timestamp=vitrage_sample_timestamp,
|
||||||
entity_id=zone_name,
|
entity_id=zone_name,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=NOVA_ZONE_DATASOURCE,
|
|
||||||
entity_state=state,
|
entity_state=state,
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ class ZoneTransformer(ResourceTransformerBase):
|
|||||||
def _create_zone_neighbors(self, entity_event):
|
def _create_zone_neighbors(self, entity_event):
|
||||||
neighbors = []
|
neighbors = []
|
||||||
metadata = {
|
metadata = {
|
||||||
VProps.IS_PLACEHOLDER: False,
|
VProps.VITRAGE_IS_PLACEHOLDER: False,
|
||||||
VProps.STATE: 'available',
|
VProps.STATE: 'available',
|
||||||
VProps.NAME: OPENSTACK_CLUSTER
|
VProps.NAME: OPENSTACK_CLUSTER
|
||||||
}
|
}
|
||||||
@ -113,7 +114,7 @@ class ZoneTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
VProps.STATE: host_state,
|
VProps.STATE: host_state,
|
||||||
VProps.IS_PLACEHOLDER: False
|
VProps.VITRAGE_IS_PLACEHOLDER: False
|
||||||
}
|
}
|
||||||
|
|
||||||
host_neighbor = self._create_neighbor(entity_event,
|
host_neighbor = self._create_neighbor(entity_event,
|
||||||
@ -133,5 +134,5 @@ class ZoneTransformer(ResourceTransformerBase):
|
|||||||
key_fields = self._key_values(NOVA_ZONE_DATASOURCE, zone_name)
|
key_fields = self._key_values(NOVA_ZONE_DATASOURCE, zone_name)
|
||||||
return tbase.build_key(key_fields)
|
return tbase.build_key(key_fields)
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return NOVA_ZONE_DATASOURCE
|
return NOVA_ZONE_DATASOURCE
|
||||||
|
@ -28,7 +28,9 @@ LOG = log.getLogger(__name__)
|
|||||||
|
|
||||||
class StaticDriver(DriverBase):
|
class StaticDriver(DriverBase):
|
||||||
# base fields are required for all entities, others are treated as metadata
|
# 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):
|
def __init__(self, conf):
|
||||||
super(StaticDriver, self).__init__()
|
super(StaticDriver, self).__init__()
|
||||||
@ -121,9 +123,11 @@ class StaticDriver(DriverBase):
|
|||||||
"""Expand config id to neighbor entity
|
"""Expand config id to neighbor entity
|
||||||
|
|
||||||
rel={'source': 's1', 'target': 'r1', 'relationship_type': 'attached'}
|
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',
|
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()
|
rel = rel.copy()
|
||||||
|
@ -46,27 +46,27 @@ class StaticTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
def _create_entity_key(self, entity_event):
|
def _create_entity_key(self, entity_event):
|
||||||
entity_id = entity_event[VProps.ID]
|
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)
|
key_fields = self._key_values(entity_type, entity_id)
|
||||||
return transformer_base.build_key(key_fields)
|
return transformer_base.build_key(key_fields)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_type():
|
def get_vitrage_type():
|
||||||
return STATIC_DATASOURCE
|
return STATIC_DATASOURCE
|
||||||
|
|
||||||
def _create_vertex(self, entity_event):
|
def _create_vertex(self, entity_event):
|
||||||
|
|
||||||
entity_type = entity_event[VProps.TYPE]
|
entity_type = entity_event[StaticFields.TYPE]
|
||||||
entity_id = entity_event[VProps.ID]
|
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:
|
if entity_type in self.transformers:
|
||||||
properties = {
|
properties = {
|
||||||
VProps.TYPE: entity_type,
|
VProps.VITRAGE_TYPE: entity_type,
|
||||||
VProps.ID: entity_id,
|
VProps.ID: entity_id,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: sample_timestamp,
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_timestamp,
|
||||||
VProps.IS_PLACEHOLDER: False
|
VProps.VITRAGE_IS_PLACEHOLDER: False
|
||||||
}
|
}
|
||||||
return self.create_neighbor_placeholder_vertex(**properties)
|
return self.create_neighbor_placeholder_vertex(**properties)
|
||||||
else:
|
else:
|
||||||
@ -74,15 +74,15 @@ class StaticTransformer(ResourceTransformerBase):
|
|||||||
state = entity_event[VProps.STATE]
|
state = entity_event[VProps.STATE]
|
||||||
update_timestamp = self._format_update_timestamp(
|
update_timestamp = self._format_update_timestamp(
|
||||||
update_timestamp=None,
|
update_timestamp=None,
|
||||||
sample_timestamp=sample_timestamp)
|
sample_timestamp=vitrage_sample_timestamp)
|
||||||
metadata = entity_event.get(StaticFields.METADATA, {})
|
metadata = entity_event.get(StaticFields.METADATA, {})
|
||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
entity_key,
|
entity_key,
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=entity_type,
|
||||||
|
vitrage_sample_timestamp=vitrage_sample_timestamp,
|
||||||
entity_id=entity_id,
|
entity_id=entity_id,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=entity_type,
|
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
entity_state=state,
|
entity_state=state,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
@ -103,7 +103,7 @@ class StaticTransformer(ResourceTransformerBase):
|
|||||||
return self._create_neighbor(
|
return self._create_neighbor(
|
||||||
entity_event,
|
entity_event,
|
||||||
neighbor[VProps.ID],
|
neighbor[VProps.ID],
|
||||||
neighbor[VProps.TYPE],
|
neighbor[StaticFields.TYPE],
|
||||||
rel[StaticFields.RELATIONSHIP_TYPE],
|
rel[StaticFields.RELATIONSHIP_TYPE],
|
||||||
is_entity_source=is_entity_source)
|
is_entity_source=is_entity_source)
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ from oslo_log import log
|
|||||||
|
|
||||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||||
from vitrage.common.constants import GraphAction
|
from vitrage.common.constants import GraphAction
|
||||||
from vitrage.common.constants import VertexProperties as VProps
|
|
||||||
from vitrage.datasources.driver_base import DriverBase
|
from vitrage.datasources.driver_base import DriverBase
|
||||||
from vitrage.datasources.static.driver import StaticDriver
|
from vitrage.datasources.static.driver import StaticDriver
|
||||||
|
from vitrage.datasources.static import StaticFields
|
||||||
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
|
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
|
||||||
from vitrage.utils import file as file_utils
|
from vitrage.utils import file as file_utils
|
||||||
|
|
||||||
@ -149,8 +149,8 @@ class StaticPhysicalDriver(DriverBase):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _find_entity(new_entity, entities):
|
def _find_entity(new_entity, entities):
|
||||||
for entity in entities:
|
for entity in entities:
|
||||||
if entity[VProps.TYPE] == new_entity[VProps.TYPE] \
|
if entity[StaticFields.TYPE] == new_entity[StaticFields.TYPE] \
|
||||||
and entity[VProps.ID] == new_entity[VProps.ID]:
|
and entity[StaticFields.ID] == new_entity[StaticFields.ID]:
|
||||||
return entity
|
return entity
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ from vitrage.common.constants import VertexProperties as VProps
|
|||||||
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
|
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
|
||||||
from vitrage.datasources.resource_transformer_base import \
|
from vitrage.datasources.resource_transformer_base import \
|
||||||
ResourceTransformerBase
|
ResourceTransformerBase
|
||||||
|
from vitrage.datasources.static import StaticFields
|
||||||
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
|
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
|
||||||
from vitrage.datasources.static_physical import SWITCH
|
from vitrage.datasources.static_physical import SWITCH
|
||||||
from vitrage.datasources import transformer_base
|
from vitrage.datasources import transformer_base
|
||||||
@ -47,22 +48,22 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
def _create_vertex(self, entity_event):
|
def _create_vertex(self, entity_event):
|
||||||
|
|
||||||
entity_type = entity_event[VProps.TYPE]
|
entity_type = entity_event[StaticFields.TYPE]
|
||||||
entity_id = entity_event[VProps.ID]
|
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 = self._format_update_timestamp(
|
||||||
update_timestamp=None,
|
update_timestamp=None,
|
||||||
sample_timestamp=sample_timestamp)
|
sample_timestamp=vitrage_sample_timestamp)
|
||||||
state = entity_event[VProps.STATE]
|
state = entity_event[VProps.STATE]
|
||||||
entity_key = self._create_entity_key(entity_event)
|
entity_key = self._create_entity_key(entity_event)
|
||||||
metadata = self._extract_metadata(entity_event)
|
metadata = self._extract_metadata(entity_event)
|
||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
entity_key,
|
entity_key,
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=entity_type,
|
||||||
|
vitrage_sample_timestamp=vitrage_sample_timestamp,
|
||||||
entity_id=entity_id,
|
entity_id=entity_id,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=entity_type,
|
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
entity_state=state,
|
entity_state=state,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
@ -75,14 +76,14 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
def _create_static_physical_neighbors(self, entity_event):
|
def _create_static_physical_neighbors(self, entity_event):
|
||||||
neighbors = []
|
neighbors = []
|
||||||
entity_type = entity_event[VProps.TYPE]
|
entity_type = entity_event[StaticFields.TYPE]
|
||||||
|
|
||||||
for neighbor_details in entity_event.get(
|
for neighbor_details in entity_event.get(
|
||||||
self.RELATIONSHIPS_SECTION, {}):
|
self.RELATIONSHIPS_SECTION, {}):
|
||||||
# TODO(alexey): need to decide what to do if one of the entities
|
# TODO(alexey): need to decide what to do if one of the entities
|
||||||
# fails
|
# fails
|
||||||
neighbor_id = neighbor_details[VProps.ID]
|
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]
|
relation_type = neighbor_details[self.RELATION_TYPE]
|
||||||
is_entity_source = not self._find_relation_direction_source(
|
is_entity_source = not self._find_relation_direction_source(
|
||||||
entity_type, neighbor_type)
|
entity_type, neighbor_type)
|
||||||
@ -98,7 +99,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
|
|||||||
|
|
||||||
def _create_entity_key(self, entity_event):
|
def _create_entity_key(self, entity_event):
|
||||||
entity_id = entity_event[VProps.ID]
|
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)
|
key_fields = self._key_values(entity_type, entity_id)
|
||||||
return transformer_base.build_key(key_fields)
|
return transformer_base.build_key(key_fields)
|
||||||
|
|
||||||
@ -121,5 +122,5 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
|
|||||||
relationship = (SWITCH, SWITCH)
|
relationship = (SWITCH, SWITCH)
|
||||||
self.relation_direction[relationship] = True
|
self.relation_direction[relationship] = True
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return STATIC_PHYSICAL_DATASOURCE
|
return STATIC_PHYSICAL_DATASOURCE
|
||||||
|
@ -74,9 +74,9 @@ def create_cluster_placeholder_vertex():
|
|||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
key,
|
key,
|
||||||
|
vitrage_category=cons.EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=OPENSTACK_CLUSTER,
|
||||||
entity_id=CLUSTER_ID,
|
entity_id=CLUSTER_ID,
|
||||||
entity_category=cons.EntityCategory.RESOURCE,
|
|
||||||
entity_type=OPENSTACK_CLUSTER,
|
|
||||||
entity_state=AVAILABLE,
|
entity_state=AVAILABLE,
|
||||||
metadata=metadata
|
metadata=metadata
|
||||||
)
|
)
|
||||||
@ -136,9 +136,11 @@ class TransformerBase(object):
|
|||||||
|
|
||||||
def _create_entity_vertex(self, entity_event):
|
def _create_entity_vertex(self, entity_event):
|
||||||
if is_update_event(entity_event) and \
|
if is_update_event(entity_event) and \
|
||||||
opt_exists(self.conf, self.get_type()) and \
|
opt_exists(self.conf, self.get_vitrage_type()) and \
|
||||||
opt_exists(self.conf[self.get_type()], DSOpts.UPDATE_METHOD):
|
opt_exists(self.conf[self.get_vitrage_type()],
|
||||||
update_method = self.conf[self.get_type()].update_method.lower()
|
DSOpts.UPDATE_METHOD):
|
||||||
|
update_method = \
|
||||||
|
self.conf[self.get_vitrage_type()].update_method.lower()
|
||||||
if update_method == UpdateMethod.PUSH:
|
if update_method == UpdateMethod.PUSH:
|
||||||
return self._create_update_entity_vertex(entity_event)
|
return self._create_update_entity_vertex(entity_event)
|
||||||
elif update_method == UpdateMethod.PULL:
|
elif update_method == UpdateMethod.PULL:
|
||||||
@ -205,12 +207,12 @@ class TransformerBase(object):
|
|||||||
metadata = {} if metadata is None else metadata
|
metadata = {} if metadata is None else metadata
|
||||||
# create placeholder vertex
|
# create placeholder vertex
|
||||||
entity_vitrage_id = self._create_entity_key(entity_event)
|
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 = {
|
properties = {
|
||||||
VProps.ID: neighbor_id,
|
VProps.ID: neighbor_id,
|
||||||
VProps.TYPE: neighbor_datasource_type,
|
VProps.VITRAGE_TYPE: neighbor_datasource_type,
|
||||||
VProps.CATEGORY: neighbor_category,
|
VProps.VITRAGE_CATEGORY: neighbor_category,
|
||||||
VProps.SAMPLE_TIMESTAMP: sample_timestamp,
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_timestamp,
|
||||||
self.METADATA: metadata
|
self.METADATA: metadata
|
||||||
}
|
}
|
||||||
neighbor_vertex = \
|
neighbor_vertex = \
|
||||||
@ -244,7 +246,7 @@ class TransformerBase(object):
|
|||||||
return (EntityCategory.RESOURCE,) + args
|
return (EntityCategory.RESOURCE,) + args
|
||||||
|
|
||||||
def create_neighbor_placeholder_vertex(self, **kwargs):
|
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")
|
LOG.error("Can't create placeholder vertex. Missing property TYPE")
|
||||||
raise ValueError('Missing property TYPE')
|
raise ValueError('Missing property TYPE')
|
||||||
|
|
||||||
@ -256,15 +258,17 @@ class TransformerBase(object):
|
|||||||
if self.METADATA in kwargs:
|
if self.METADATA in kwargs:
|
||||||
metadata = kwargs[self.METADATA]
|
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(
|
return graph_utils.create_vertex(
|
||||||
build_key(key_fields),
|
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_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)
|
metadata=metadata)
|
||||||
|
|
||||||
def _extract_graph_action(self, entity_event):
|
def _extract_graph_action(self, entity_event):
|
||||||
@ -300,9 +304,8 @@ class TransformerBase(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _create_end_vertex(entity_event):
|
def _create_end_vertex(entity_event):
|
||||||
entity_type = entity_event[DSProps.ENTITY_TYPE]
|
entity_type = entity_event[DSProps.ENTITY_TYPE]
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex('END_MESSAGE:' + entity_type,
|
||||||
'END_MESSAGE:' + entity_type,
|
vitrage_type=entity_type)
|
||||||
entity_type=entity_type)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _is_end_message(entity_event):
|
def _is_end_message(entity_event):
|
||||||
@ -325,16 +328,17 @@ class TransformerBase(object):
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
-------
|
-------
|
||||||
query = {'type': 'nova.instance'}
|
query = {'vitrage_type': 'nova.instance'}
|
||||||
Before transform is called the result of running the query against
|
Before transform is called the result of running the query against
|
||||||
the topology graph will be updated to event[QUERY_RESULT]
|
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
|
return None
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
"""Returns the type of the datasource
|
"""Returns the vitrage_type of the datasource
|
||||||
|
|
||||||
:return: datasource type
|
:return: datasource type
|
||||||
:rtype: String
|
:rtype: String
|
||||||
|
@ -64,7 +64,7 @@ class ZabbixDriver(AlarmDriverBase):
|
|||||||
LOG.exception('pyzabbix.ZabbixAPI %s', e)
|
LOG.exception('pyzabbix.ZabbixAPI %s', e)
|
||||||
self._client = None
|
self._client = None
|
||||||
|
|
||||||
def _entity_type(self):
|
def _vitrage_type(self):
|
||||||
return ZABBIX_DATASOURCE
|
return ZABBIX_DATASOURCE
|
||||||
|
|
||||||
def _alarm_key(self, alarm):
|
def _alarm_key(self, alarm):
|
||||||
|
@ -46,10 +46,11 @@ class ZabbixTransformer(AlarmTransformerBase):
|
|||||||
|
|
||||||
update_timestamp = entity_event[ZProps.TIMESTAMP]
|
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,
|
update_timestamp = \
|
||||||
sample_timestamp)
|
self._format_update_timestamp(update_timestamp,
|
||||||
|
vitrage_sample_timestamp)
|
||||||
|
|
||||||
zabbix_hostname = entity_event[ZProps.ZABBIX_RESOURCE_NAME]
|
zabbix_hostname = entity_event[ZProps.ZABBIX_RESOURCE_NAME]
|
||||||
vitrage_hostname = entity_event[ZProps.RESOURCE_NAME]
|
vitrage_hostname = entity_event[ZProps.RESOURCE_NAME]
|
||||||
@ -70,10 +71,10 @@ class ZabbixTransformer(AlarmTransformerBase):
|
|||||||
|
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(entity_event),
|
self._create_entity_key(entity_event),
|
||||||
entity_category=EntityCategory.ALARM,
|
vitrage_category=EntityCategory.ALARM,
|
||||||
entity_type=entity_event[DSProps.ENTITY_TYPE],
|
vitrage_type=entity_event[DSProps.ENTITY_TYPE],
|
||||||
|
vitrage_sample_timestamp=vitrage_sample_timestamp,
|
||||||
entity_state=entity_state,
|
entity_state=entity_state,
|
||||||
sample_timestamp=sample_timestamp,
|
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -121,5 +122,5 @@ class ZabbixTransformer(AlarmTransformerBase):
|
|||||||
ZProps.ZABBIX_TIMESTAMP_FORMAT,
|
ZProps.ZABBIX_TIMESTAMP_FORMAT,
|
||||||
tbase.TIMESTAMP_FORMAT)
|
tbase.TIMESTAMP_FORMAT)
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return ZABBIX_DATASOURCE
|
return ZABBIX_DATASOURCE
|
||||||
|
@ -24,7 +24,8 @@ from vitrage.common.constants import GraphAction
|
|||||||
from vitrage.common.constants import VertexProperties as VProps
|
from vitrage.common.constants import VertexProperties as VProps
|
||||||
from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE
|
from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE
|
||||||
from vitrage.datasources import OPENSTACK_CLUSTER
|
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
|
from vitrage.utils.datetime import utcnow
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
@ -77,14 +78,14 @@ class ConsistencyEnforcer(object):
|
|||||||
try:
|
try:
|
||||||
LOG.debug('Consistency Periodic Process - Started')
|
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()
|
old_deleted_entities = self._find_old_deleted_entities()
|
||||||
LOG.debug('Found %s vertices to be deleted by consistency service'
|
LOG.debug('Found %s vertices to be deleted by consistency service'
|
||||||
': %s', len(old_deleted_entities), old_deleted_entities)
|
': %s', len(old_deleted_entities), old_deleted_entities)
|
||||||
self._push_events_to_queue(old_deleted_entities,
|
self._push_events_to_queue(old_deleted_entities,
|
||||||
GraphAction.REMOVE_DELETED_ENTITY)
|
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()
|
stale_entities = self._find_stale_entities()
|
||||||
LOG.debug('Found %s vertices to be marked as deleted by '
|
LOG.debug('Found %s vertices to be marked as deleted by '
|
||||||
'consistency service: %s', len(stale_entities),
|
'consistency service: %s', len(stale_entities),
|
||||||
@ -96,12 +97,13 @@ class ConsistencyEnforcer(object):
|
|||||||
'Error in deleting vertices from entity_graph: %s', e)
|
'Error in deleting vertices from entity_graph: %s', e)
|
||||||
|
|
||||||
def _find_stale_entities(self):
|
def _find_stale_entities(self):
|
||||||
|
vitrage_sample_tstmp = str(utcnow() - timedelta(
|
||||||
|
seconds=2 * self.conf.datasources.snapshots_interval))
|
||||||
query = {
|
query = {
|
||||||
'and': [
|
'and': [
|
||||||
{'!=': {VProps.TYPE: VITRAGE_TYPE}},
|
{'!=': {VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE}},
|
||||||
{'<': {VProps.SAMPLE_TIMESTAMP: str(utcnow() - timedelta(
|
{'<': {VProps.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_tstmp}},
|
||||||
seconds=2 * self.conf.datasources.snapshots_interval))}},
|
{'==': {VProps.VITRAGE_IS_DELETED: False}}
|
||||||
{'==': {VProps.IS_DELETED: False}}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,11 +112,12 @@ class ConsistencyEnforcer(object):
|
|||||||
return set(self._filter_vertices_to_be_deleted(vertices))
|
return set(self._filter_vertices_to_be_deleted(vertices))
|
||||||
|
|
||||||
def _find_old_deleted_entities(self):
|
def _find_old_deleted_entities(self):
|
||||||
|
vitrage_sample_tstmp = str(utcnow() - timedelta(
|
||||||
|
seconds=self.conf.consistency.min_time_to_delete))
|
||||||
query = {
|
query = {
|
||||||
'and': [
|
'and': [
|
||||||
{'==': {VProps.IS_DELETED: True}},
|
{'==': {VProps.VITRAGE_IS_DELETED: True}},
|
||||||
{'<': {VProps.SAMPLE_TIMESTAMP: str(utcnow() - timedelta(
|
{'<': {VProps.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_tstmp}}
|
||||||
seconds=self.conf.consistency.min_time_to_delete))}}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,9 +128,9 @@ class ConsistencyEnforcer(object):
|
|||||||
def _find_old_deduced_alarms(self, timestamp):
|
def _find_old_deduced_alarms(self, timestamp):
|
||||||
query = {
|
query = {
|
||||||
'and': [
|
'and': [
|
||||||
{'==': {VProps.CATEGORY: EntityCategory.ALARM}},
|
{'==': {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}},
|
||||||
{'==': {VProps.TYPE: VITRAGE_TYPE}},
|
{'==': {VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE}},
|
||||||
{'<': {VProps.SAMPLE_TIMESTAMP: timestamp}}
|
{'<': {VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp}}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return self.graph.get_vertices(query_dict=query)
|
return self.graph.get_vertices(query_dict=query)
|
||||||
@ -159,8 +162,8 @@ class ConsistencyEnforcer(object):
|
|||||||
DSProps.EVENT_TYPE: action,
|
DSProps.EVENT_TYPE: action,
|
||||||
VProps.VITRAGE_ID: vertex[VProps.VITRAGE_ID],
|
VProps.VITRAGE_ID: vertex[VProps.VITRAGE_ID],
|
||||||
VProps.ID: vertex.get(VProps.ID, None),
|
VProps.ID: vertex.get(VProps.ID, None),
|
||||||
VProps.TYPE: vertex[VProps.TYPE],
|
VProps.VITRAGE_TYPE: vertex[VProps.VITRAGE_TYPE],
|
||||||
VProps.CATEGORY: vertex[VProps.CATEGORY],
|
VProps.VITRAGE_CATEGORY: vertex[VProps.VITRAGE_CATEGORY],
|
||||||
VProps.IS_REAL_VITRAGE_ID: True
|
VProps.IS_REAL_VITRAGE_ID: True
|
||||||
}
|
}
|
||||||
self.evaluator_queue.put(event)
|
self.evaluator_queue.put(event)
|
||||||
@ -169,8 +172,8 @@ class ConsistencyEnforcer(object):
|
|||||||
def _filter_vertices_to_be_deleted(vertices):
|
def _filter_vertices_to_be_deleted(vertices):
|
||||||
return list(filter(
|
return list(filter(
|
||||||
lambda ver:
|
lambda ver:
|
||||||
not (ver[VProps.CATEGORY] == EntityCategory.RESOURCE and
|
not (ver[VProps.VITRAGE_CATEGORY] == EntityCategory.RESOURCE and
|
||||||
ver[VProps.TYPE] == OPENSTACK_CLUSTER), vertices))
|
ver[VProps.VITRAGE_TYPE] == OPENSTACK_CLUSTER), vertices))
|
||||||
|
|
||||||
def _wait_for_action(self, function):
|
def _wait_for_action(self, function):
|
||||||
count_retries = 0
|
count_retries = 0
|
||||||
|
@ -30,10 +30,10 @@ class AlarmHandler(HandlerBase):
|
|||||||
return [VProps.SEVERITY]
|
return [VProps.SEVERITY]
|
||||||
|
|
||||||
def set_operational_value(self, new_vertex, operational_value):
|
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):
|
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):
|
def default_values(self):
|
||||||
return [(None, OperationalAlarmSeverity.NA, 0)]
|
return [(None, OperationalAlarmSeverity.NA, 0)]
|
||||||
|
@ -39,7 +39,7 @@ class DatasourceInfoMapper(object):
|
|||||||
self.category_normalizer = self._init_category_normalizer()
|
self.category_normalizer = self._init_category_normalizer()
|
||||||
self.datasources_state_confs = self._load_state_configurations()
|
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,
|
return self._get_state_data(datasource_name,
|
||||||
state,
|
state,
|
||||||
self.OPERATIONAL_VALUES)
|
self.OPERATIONAL_VALUES)
|
||||||
@ -49,20 +49,20 @@ class DatasourceInfoMapper(object):
|
|||||||
state,
|
state,
|
||||||
self.PRIORITY_VALUES)
|
self.PRIORITY_VALUES)
|
||||||
|
|
||||||
def aggregated_state(self, new_vertex, graph_vertex):
|
def vitrage_aggregated_state(self, new_vertex, graph_vertex):
|
||||||
datasource_name = new_vertex[VProps.TYPE] if \
|
datasource_name = new_vertex[VProps.VITRAGE_TYPE] if \
|
||||||
VProps.TYPE in new_vertex.properties else \
|
VProps.VITRAGE_TYPE in new_vertex.properties else \
|
||||||
graph_vertex[VProps.TYPE]
|
graph_vertex[VProps.VITRAGE_TYPE]
|
||||||
|
|
||||||
category = new_vertex[VProps.CATEGORY] if \
|
vitrage_category = new_vertex[VProps.VITRAGE_CATEGORY] if \
|
||||||
VProps.CATEGORY in new_vertex.properties else \
|
VProps.VITRAGE_CATEGORY in new_vertex.properties else \
|
||||||
graph_vertex[VProps.CATEGORY]
|
graph_vertex[VProps.VITRAGE_CATEGORY]
|
||||||
|
|
||||||
if datasource_name in self.datasources_state_confs or \
|
if datasource_name in self.datasources_state_confs or \
|
||||||
datasource_name not in self.conf.datasources.types:
|
datasource_name not in self.conf.datasources.types:
|
||||||
value_properties = \
|
value_properties = \
|
||||||
self.category_normalizer[category].value_properties()
|
self.category_normalizer[vitrage_category].value_properties()
|
||||||
operational_state, aggregated_state, state_priority = \
|
vitrage_operational_state, vitrage_aggregated_state, state_priority = \
|
||||||
self._find_operational_state_and_priority(new_vertex,
|
self._find_operational_state_and_priority(new_vertex,
|
||||||
graph_vertex,
|
graph_vertex,
|
||||||
value_properties[0],
|
value_properties[0],
|
||||||
@ -76,18 +76,18 @@ class DatasourceInfoMapper(object):
|
|||||||
property_,
|
property_,
|
||||||
datasource_name)
|
datasource_name)
|
||||||
if t_state_priority > state_priority:
|
if t_state_priority > state_priority:
|
||||||
operational_state = t_operational_state
|
vitrage_operational_state = t_operational_state
|
||||||
aggregated_state = t_aggregated_state
|
vitrage_aggregated_state = t_aggregated_state
|
||||||
state_priority = t_state_priority
|
state_priority = t_state_priority
|
||||||
|
|
||||||
self.category_normalizer[category].set_aggregated_value(
|
self.category_normalizer[vitrage_category].set_aggregated_value(
|
||||||
new_vertex, aggregated_state)
|
new_vertex, vitrage_aggregated_state)
|
||||||
self.category_normalizer[category].set_operational_value(
|
self.category_normalizer[vitrage_category].set_operational_value(
|
||||||
new_vertex, operational_state)
|
new_vertex, vitrage_operational_state)
|
||||||
else:
|
else:
|
||||||
self.category_normalizer[category].set_aggregated_value(
|
self.category_normalizer[vitrage_category].set_aggregated_value(
|
||||||
new_vertex, self.UNDEFINED_DATASOURCE)
|
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)
|
new_vertex, self.UNDEFINED_DATASOURCE)
|
||||||
|
|
||||||
def get_datasource_priorities(self, datasource_name=None):
|
def get_datasource_priorities(self, datasource_name=None):
|
||||||
@ -140,7 +140,7 @@ class DatasourceInfoMapper(object):
|
|||||||
states = {}
|
states = {}
|
||||||
priorities = {}
|
priorities = {}
|
||||||
config = file_utils.load_yaml_file(full_path, with_exception=True)
|
config = file_utils.load_yaml_file(full_path, with_exception=True)
|
||||||
category = config['category']
|
vitrage_category = config['category']
|
||||||
|
|
||||||
for item in config['values']:
|
for item in config['values']:
|
||||||
aggregated_values = item['aggregated values']
|
aggregated_values = item['aggregated values']
|
||||||
@ -153,9 +153,9 @@ class DatasourceInfoMapper(object):
|
|||||||
states[original_value.upper()] = operational_value
|
states[original_value.upper()] = operational_value
|
||||||
priorities[original_value.upper()] = priority_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
|
return states, priorities
|
||||||
|
|
||||||
@ -208,13 +208,13 @@ class DatasourceInfoMapper(object):
|
|||||||
|
|
||||||
upper_state = state if not state else state.upper()
|
upper_state = state if not state else state.upper()
|
||||||
|
|
||||||
operational_state = self.operational_state(datasource_name,
|
vitrage_operational_state = self.vitrage_operational_state(
|
||||||
upper_state)
|
datasource_name, upper_state)
|
||||||
|
|
||||||
state_priority = self.state_priority(datasource_name,
|
state_priority = self.state_priority(datasource_name,
|
||||||
upper_state)
|
upper_state)
|
||||||
|
|
||||||
return operational_state, upper_state, state_priority
|
return vitrage_operational_state, upper_state, state_priority
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_all_local_variables_of_class(class_instance):
|
def _get_all_local_variables_of_class(class_instance):
|
||||||
|
@ -29,11 +29,12 @@ class ResourceHandler(HandlerBase):
|
|||||||
def value_properties(self):
|
def value_properties(self):
|
||||||
return [VProps.STATE, VProps.VITRAGE_STATE]
|
return [VProps.STATE, VProps.VITRAGE_STATE]
|
||||||
|
|
||||||
def set_operational_value(self, new_vertex, operational_value):
|
def set_operational_value(self, new_vertex, vitrage_operational_value):
|
||||||
new_vertex[VProps.OPERATIONAL_STATE] = operational_value
|
new_vertex[VProps.VITRAGE_OPERATIONAL_STATE] = \
|
||||||
|
vitrage_operational_value
|
||||||
|
|
||||||
def set_aggregated_value(self, new_vertex, aggregated_value):
|
def set_aggregated_value(self, new_vertex, vitrage_aggregated_value):
|
||||||
new_vertex[VProps.AGGREGATED_STATE] = aggregated_value
|
new_vertex[VProps.VITRAGE_AGGREGATED_STATE] = vitrage_aggregated_value
|
||||||
|
|
||||||
def default_values(self):
|
def default_values(self):
|
||||||
return [(None, OperationalResourceState.NA, 0)]
|
return [(None, OperationalResourceState.NA, 0)]
|
||||||
|
@ -55,7 +55,7 @@ class GraphNotifier(object):
|
|||||||
change that happened. None if the element was just created.
|
change that happened. None if the element was just created.
|
||||||
:param current: The graph element (vertex or edge) after the
|
:param current: The graph element (vertex or edge) after the
|
||||||
change that happened. Deleted elements should arrive with 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
|
:param graph: The graph
|
||||||
"""
|
"""
|
||||||
notification_types = _get_notification_type(before, current, is_vertex)
|
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):
|
def _is_active_deduced_alarm(vertex):
|
||||||
if not vertex:
|
if not vertex:
|
||||||
return False
|
return False
|
||||||
if vertex.get(VProps.CATEGORY) == EntityCategory.ALARM and \
|
if vertex.get(VProps.VITRAGE_CATEGORY) == EntityCategory.ALARM and \
|
||||||
vertex.get(VProps.TYPE) == evaluator.VITRAGE_TYPE:
|
vertex.get(VProps.VITRAGE_TYPE) == evaluator.VITRAGE_DATASOURCE:
|
||||||
return _is_relevant_vertex(vertex)
|
return _is_relevant_vertex(vertex)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -118,14 +118,14 @@ def _is_active_deduced_alarm(vertex):
|
|||||||
def _is_marked_down(vertex):
|
def _is_marked_down(vertex):
|
||||||
if not vertex:
|
if not vertex:
|
||||||
return False
|
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:
|
vertex.get(VProps.IS_MARKED_DOWN) is True:
|
||||||
return _is_relevant_vertex(vertex)
|
return _is_relevant_vertex(vertex)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _is_relevant_vertex(vertex):
|
def _is_relevant_vertex(vertex):
|
||||||
if vertex.get(VProps.IS_DELETED, False) or \
|
if vertex.get(VProps.VITRAGE_IS_DELETED, False) or \
|
||||||
vertex.get(VProps.IS_PLACEHOLDER, False):
|
vertex.get(VProps.VITRAGE_IS_PLACEHOLDER, False):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -64,7 +64,7 @@ class Processor(processor.ProcessorBase):
|
|||||||
|
|
||||||
self._enrich_event(event)
|
self._enrich_event(event)
|
||||||
entity = self.transformer_manager.transform(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)
|
self.actions[entity.action](entity.vertex, entity.neighbors)
|
||||||
|
|
||||||
def create_entity(self, new_vertex, neighbors):
|
def create_entity(self, new_vertex, neighbors):
|
||||||
@ -198,7 +198,7 @@ class Processor(processor.ProcessorBase):
|
|||||||
def remove_deleted_entity(self, vertex, neighbors):
|
def remove_deleted_entity(self, vertex, neighbors):
|
||||||
"""Removes the deleted vertex from the entity graph
|
"""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
|
:param vertex: The vertex to be removed from the graph
|
||||||
:type vertex: Vertex
|
:type vertex: Vertex
|
||||||
@ -218,7 +218,8 @@ class Processor(processor.ProcessorBase):
|
|||||||
LOG.warning("Delete event arrived on invalid resource: %s", vertex)
|
LOG.warning("Delete event arrived on invalid resource: %s", vertex)
|
||||||
|
|
||||||
def handle_end_message(self, vertex, neighbors):
|
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) == \
|
if len(self.initialization_status.end_messages) == \
|
||||||
len(self.conf.datasources.types):
|
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 not graph_vertex or not PUtils.is_deleted(graph_vertex):
|
||||||
if PUtils.can_update_vertex(graph_vertex, vertex):
|
if PUtils.can_update_vertex(graph_vertex, vertex):
|
||||||
LOG.debug("Updates vertex: %s", 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,
|
PUtils.update_entity_graph_vertex(self.entity_graph,
|
||||||
graph_vertex,
|
graph_vertex,
|
||||||
vertex)
|
vertex)
|
||||||
@ -336,7 +337,7 @@ class Processor(processor.ProcessorBase):
|
|||||||
GraphAction.END_MESSAGE: self.handle_end_message
|
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")
|
LOG.debug("calculate event state")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -359,7 +360,7 @@ class Processor(processor.ProcessorBase):
|
|||||||
action, vertex)
|
action, vertex)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
self.state_manager.aggregated_state(vertex, graph_vertex)
|
self.state_manager.vitrage_aggregated_state(vertex, graph_vertex)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception("Calculate aggregated state failed - %s", e)
|
LOG.exception("Calculate aggregated state failed - %s", e)
|
||||||
|
|
||||||
@ -408,7 +409,7 @@ class Processor(processor.ProcessorBase):
|
|||||||
and not include_deleted):
|
and not include_deleted):
|
||||||
|
|
||||||
vitrage_id = uuidutils.generate_uuid()
|
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
|
self.entity_graph.root_id = vitrage_id
|
||||||
else:
|
else:
|
||||||
vitrage_id = graph_vertex[VProps.VITRAGE_ID]
|
vitrage_id = graph_vertex[VProps.VITRAGE_ID]
|
||||||
@ -429,9 +430,10 @@ class Processor(processor.ProcessorBase):
|
|||||||
edge.source_id = vitrage_id
|
edge.source_id = vitrage_id
|
||||||
edge.target_id = neighbor_vertex.vertex_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:
|
or not neighbors:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -441,11 +443,12 @@ class Processor(processor.ProcessorBase):
|
|||||||
|
|
||||||
for neighbor in neighbors:
|
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] = \
|
vertex.properties[VProps.VITRAGE_RESOURCE_ID] = \
|
||||||
neighbor.vertex.vertex_id
|
neighbor.vertex.vertex_id
|
||||||
vertex.properties[VProps.VITRAGE_RESOURCE_TYPE] = \
|
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):
|
def _get_single_graph_vertex_by_props(self, vertex, include_deleted=False):
|
||||||
"""Returns a single vertex by it's defining properties
|
"""Returns a single vertex by it's defining properties
|
||||||
@ -470,7 +473,7 @@ class Processor(processor.ProcessorBase):
|
|||||||
graph_vertices.append(tmp_vertex)
|
graph_vertices.append(tmp_vertex)
|
||||||
else:
|
else:
|
||||||
for tmp_vertex in received_graph_vertices:
|
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)
|
graph_vertices.append(tmp_vertex)
|
||||||
|
|
||||||
if len(graph_vertices) > 1:
|
if len(graph_vertices) > 1:
|
||||||
|
@ -28,12 +28,12 @@ LOG = log.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def is_newer_vertex(prev_vertex, new_vertex):
|
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:
|
if not prev_timestamp:
|
||||||
return True
|
return True
|
||||||
prev_time = parser.parse(prev_timestamp)
|
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:
|
if not new_timestamp:
|
||||||
return False
|
return False
|
||||||
new_time = parser.parse(new_timestamp)
|
new_time = parser.parse(new_timestamp)
|
||||||
@ -43,17 +43,19 @@ def is_newer_vertex(prev_vertex, new_vertex):
|
|||||||
|
|
||||||
def is_deleted(item):
|
def is_deleted(item):
|
||||||
return item and \
|
return item and \
|
||||||
(isinstance(item, Vertex) and item.get(VProps.IS_DELETED, False)) or\
|
(isinstance(item, Vertex) and
|
||||||
(isinstance(item, Edge) and item.get(EProps.IS_DELETED, False))
|
item.get(VProps.VITRAGE_IS_DELETED, False)) or \
|
||||||
|
(isinstance(item, Edge) and
|
||||||
|
item.get(EProps.VITRAGE_IS_DELETED, False))
|
||||||
|
|
||||||
|
|
||||||
def mark_deleted(g, item):
|
def mark_deleted(g, item):
|
||||||
if isinstance(item, Vertex):
|
if isinstance(item, Vertex):
|
||||||
item[VProps.IS_DELETED] = True
|
item[VProps.VITRAGE_IS_DELETED] = True
|
||||||
item[VProps.SAMPLE_TIMESTAMP] = str(utcnow())
|
item[VProps.VITRAGE_SAMPLE_TIMESTAMP] = str(utcnow())
|
||||||
g.update_vertex(item)
|
g.update_vertex(item)
|
||||||
elif isinstance(item, Edge):
|
elif isinstance(item, Edge):
|
||||||
item[EProps.IS_DELETED] = True
|
item[EProps.VITRAGE_IS_DELETED] = True
|
||||||
item[EProps.UPDATE_TIMESTAMP] = str(utcnow())
|
item[EProps.UPDATE_TIMESTAMP] = str(utcnow())
|
||||||
g.update_edge(item)
|
g.update_edge(item)
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ def mark_deleted(g, item):
|
|||||||
def delete_placeholder_vertex(g, vertex):
|
def delete_placeholder_vertex(g, vertex):
|
||||||
"""Checks if it is a placeholder vertex, and if so deletes it """
|
"""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
|
return
|
||||||
if not any(True for neighbor_edge in g.get_edges(vertex.vertex_id)
|
if not any(True for neighbor_edge in g.get_edges(vertex.vertex_id)
|
||||||
if not is_deleted(neighbor_edge)):
|
if not is_deleted(neighbor_edge)):
|
||||||
@ -79,29 +81,31 @@ def find_neighbor_types(neighbors):
|
|||||||
|
|
||||||
|
|
||||||
def get_vertex_types(vertex):
|
def get_vertex_types(vertex):
|
||||||
category = vertex[VProps.CATEGORY]
|
vitrage_category = vertex[VProps.VITRAGE_CATEGORY]
|
||||||
type_ = vertex[VProps.TYPE]
|
vitrage_type = vertex[VProps.VITRAGE_TYPE]
|
||||||
return category, type_
|
return vitrage_category, vitrage_type
|
||||||
|
|
||||||
|
|
||||||
def get_defining_properties(vertex):
|
def get_defining_properties(vertex):
|
||||||
if vertex.get(VProps.CATEGORY) == EntityCategory.ALARM:
|
if vertex.get(VProps.VITRAGE_CATEGORY) == EntityCategory.ALARM:
|
||||||
dp = (vertex.get(VProps.TYPE), vertex.get(VProps.ID),
|
dp = (vertex.get(VProps.VITRAGE_TYPE), vertex.get(VProps.ID),
|
||||||
vertex.get(VProps.RESOURCE_ID), vertex.get(VProps.NAME))
|
vertex.get(VProps.RESOURCE_ID), vertex.get(VProps.NAME))
|
||||||
else:
|
else:
|
||||||
dp = (vertex.get(VProps.TYPE), vertex.get(VProps.ID))
|
dp = (vertex.get(VProps.VITRAGE_TYPE), vertex.get(VProps.ID))
|
||||||
return hash(dp)
|
return hash(dp)
|
||||||
|
|
||||||
|
|
||||||
def can_update_vertex(graph_vertex, new_vertex):
|
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):
|
def update_entity_graph_vertex(g, graph_vertex, updated_vertex):
|
||||||
if updated_vertex[VProps.IS_PLACEHOLDER] and \
|
if updated_vertex[VProps.VITRAGE_IS_PLACEHOLDER] and \
|
||||||
graph_vertex and not graph_vertex[VProps.IS_PLACEHOLDER]:
|
graph_vertex and not graph_vertex[VProps.VITRAGE_IS_PLACEHOLDER]:
|
||||||
|
|
||||||
updated_vertex[VProps.IS_PLACEHOLDER] = False
|
updated_vertex[VProps.VITRAGE_IS_PLACEHOLDER] = False
|
||||||
updated_vertex[VProps.IS_DELETED] = graph_vertex[VProps.IS_DELETED]
|
updated_vertex[VProps.VITRAGE_IS_DELETED] = \
|
||||||
|
graph_vertex[VProps.VITRAGE_IS_DELETED]
|
||||||
|
|
||||||
g.update_vertex(updated_vertex)
|
g.update_vertex(updated_vertex)
|
||||||
|
@ -22,7 +22,8 @@ from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE
|
|||||||
from vitrage.datasources.consistency.transformer import ConsistencyTransformer
|
from vitrage.datasources.consistency.transformer import ConsistencyTransformer
|
||||||
from vitrage.evaluator.actions.evaluator_event_transformer import \
|
from vitrage.evaluator.actions.evaluator_event_transformer import \
|
||||||
EvaluatorEventTransformer
|
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
|
from vitrage.utils import opt_exists
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -53,7 +54,7 @@ class TransformerManager(object):
|
|||||||
LOG.exception('Failed to register transformer %s. '
|
LOG.exception('Failed to register transformer %s. '
|
||||||
'Exception: %s', datasource_type, e)
|
'Exception: %s', datasource_type, e)
|
||||||
|
|
||||||
transformers[VITRAGE_TYPE] = importutils.import_object(
|
transformers[VITRAGE_DATASOURCE] = importutils.import_object(
|
||||||
"%s.%s" % (EvaluatorEventTransformer.__module__,
|
"%s.%s" % (EvaluatorEventTransformer.__module__,
|
||||||
EvaluatorEventTransformer.__name__), transformers, conf)
|
EvaluatorEventTransformer.__name__), transformers, conf)
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ from vitrage.common.constants import DatasourceProperties as DSProps
|
|||||||
from vitrage.common.constants import VertexProperties as VProps
|
from vitrage.common.constants import VertexProperties as VProps
|
||||||
from vitrage.evaluator.actions.base import ActionMode
|
from vitrage.evaluator.actions.base import ActionMode
|
||||||
from vitrage.evaluator.actions.base import ActionType
|
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_EDGE
|
||||||
from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX
|
from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX
|
||||||
from vitrage.evaluator.actions.recipes.action_steps import REMOVE_EDGE
|
from vitrage.evaluator.actions.recipes.action_steps import REMOVE_EDGE
|
||||||
@ -104,9 +105,9 @@ class ActionExecutor(object):
|
|||||||
def _add_default_properties(event):
|
def _add_default_properties(event):
|
||||||
|
|
||||||
event[DSProps.DATASOURCE_ACTION] = AType.UPDATE
|
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.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
|
@staticmethod
|
||||||
def _register_action_recipes():
|
def _register_action_recipes():
|
||||||
|
@ -36,7 +36,7 @@ from vitrage.graph import Vertex
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
VITRAGE_TYPE = 'vitrage'
|
VITRAGE_DATASOURCE = 'vitrage'
|
||||||
|
|
||||||
|
|
||||||
class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
||||||
@ -63,8 +63,9 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
|||||||
if event_type == UPDATE_VERTEX:
|
if event_type == UPDATE_VERTEX:
|
||||||
properties = {
|
properties = {
|
||||||
VProps.UPDATE_TIMESTAMP: update_timestamp,
|
VProps.UPDATE_TIMESTAMP: update_timestamp,
|
||||||
VProps.SAMPLE_TIMESTAMP: event[VProps.SAMPLE_TIMESTAMP],
|
VProps.VITRAGE_SAMPLE_TIMESTAMP:
|
||||||
VProps.IS_PLACEHOLDER: False,
|
event[VProps.VITRAGE_SAMPLE_TIMESTAMP],
|
||||||
|
VProps.VITRAGE_IS_PLACEHOLDER: False,
|
||||||
VProps.RESOURCE_ID: event.get(TFields.TARGET)
|
VProps.RESOURCE_ID: event.get(TFields.TARGET)
|
||||||
}
|
}
|
||||||
if VProps.IS_REAL_VITRAGE_ID in event:
|
if VProps.IS_REAL_VITRAGE_ID in event:
|
||||||
@ -89,9 +90,10 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
|||||||
}
|
}
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
self._create_entity_key(event),
|
self._create_entity_key(event),
|
||||||
entity_category=EntityCategory.ALARM,
|
vitrage_category=EntityCategory.ALARM,
|
||||||
entity_type=VITRAGE_TYPE,
|
vitrage_type=VITRAGE_DATASOURCE,
|
||||||
sample_timestamp=event[VProps.SAMPLE_TIMESTAMP],
|
vitrage_sample_timestamp=event[
|
||||||
|
VProps.VITRAGE_SAMPLE_TIMESTAMP],
|
||||||
update_timestamp=update_timestamp,
|
update_timestamp=update_timestamp,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
@ -104,7 +106,6 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
|||||||
return self._create_vitrage_neighbors(event)
|
return self._create_vitrage_neighbors(event)
|
||||||
|
|
||||||
def _create_vitrage_neighbors(self, event):
|
def _create_vitrage_neighbors(self, event):
|
||||||
|
|
||||||
event_type = event[EVALUATOR_EVENT_TYPE]
|
event_type = event[EVALUATOR_EVENT_TYPE]
|
||||||
|
|
||||||
timestamp = transformer_base.convert_timestamp_format(
|
timestamp = transformer_base.convert_timestamp_format(
|
||||||
@ -113,6 +114,7 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if event_type in [ADD_EDGE, REMOVE_EDGE]:
|
if event_type in [ADD_EDGE, REMOVE_EDGE]:
|
||||||
|
|
||||||
relation_edge = graph_utils.create_edge(
|
relation_edge = graph_utils.create_edge(
|
||||||
source_id=event[TFields.SOURCE],
|
source_id=event[TFields.SOURCE],
|
||||||
target_id=event[TFields.TARGET],
|
target_id=event[TFields.TARGET],
|
||||||
@ -122,6 +124,7 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
|||||||
return [Neighbor(None, relation_edge)]
|
return [Neighbor(None, relation_edge)]
|
||||||
|
|
||||||
if event_type == ADD_VERTEX:
|
if event_type == ADD_VERTEX:
|
||||||
|
|
||||||
relation_edge = graph_utils.create_edge(
|
relation_edge = graph_utils.create_edge(
|
||||||
source_id=self._create_entity_key(event),
|
source_id=self._create_entity_key(event),
|
||||||
target_id=event[TFields.TARGET],
|
target_id=event[TFields.TARGET],
|
||||||
@ -129,12 +132,13 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
|||||||
update_timestamp=timestamp)
|
update_timestamp=timestamp)
|
||||||
|
|
||||||
neighbor_props = {
|
neighbor_props = {
|
||||||
VProps.IS_PLACEHOLDER: True,
|
VProps.VITRAGE_IS_PLACEHOLDER: True,
|
||||||
VProps.UPDATE_TIMESTAMP: timestamp,
|
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.IS_REAL_VITRAGE_ID: True,
|
||||||
VProps.TYPE: event[VProps.VITRAGE_RESOURCE_TYPE],
|
VProps.VITRAGE_TYPE: event[VProps.VITRAGE_RESOURCE_TYPE],
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
}
|
}
|
||||||
neighbor = Vertex(event[TFields.TARGET], neighbor_props)
|
neighbor = Vertex(event[TFields.TARGET], neighbor_props)
|
||||||
return [Neighbor(neighbor, relation_edge)]
|
return [Neighbor(neighbor, relation_edge)]
|
||||||
@ -166,10 +170,10 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
|||||||
return transformer_base.build_key(key_fields)
|
return transformer_base.build_key(key_fields)
|
||||||
|
|
||||||
def _key_values(self, *args):
|
def _key_values(self, *args):
|
||||||
return (EntityCategory.ALARM, VITRAGE_TYPE) + args
|
return (EntityCategory.ALARM, VITRAGE_DATASOURCE) + args
|
||||||
|
|
||||||
def create_neighbor_placeholder_vertex(self, **kwargs):
|
def create_neighbor_placeholder_vertex(self, **kwargs):
|
||||||
LOG.info('Evaluator does not create placeholders')
|
LOG.info('Evaluator does not create placeholders')
|
||||||
|
|
||||||
def get_type(self):
|
def get_vitrage_type(self):
|
||||||
return VITRAGE_TYPE
|
return VITRAGE_DATASOURCE
|
||||||
|
@ -53,9 +53,9 @@ class SetStateTools(object):
|
|||||||
def get_score(self, action_info):
|
def get_score(self, action_info):
|
||||||
state = action_info.specs.properties[TemplateFields.STATE].upper()
|
state = action_info.specs.properties[TemplateFields.STATE].upper()
|
||||||
target_resource = action_info.specs.targets[TemplateFields.TARGET]
|
target_resource = action_info.specs.targets[TemplateFields.TARGET]
|
||||||
target_type = target_resource[VProps.TYPE]
|
target_vitrage_type = target_resource[VProps.VITRAGE_TYPE]
|
||||||
score_name = \
|
score_name = target_vitrage_type \
|
||||||
target_type if target_type in self.scores else DEFAULT_INFO_MAPPER
|
if target_vitrage_type in self.scores else DEFAULT_INFO_MAPPER
|
||||||
return self.scores[score_name].get(state, 0)
|
return self.scores[score_name].get(state, 0)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -58,7 +58,7 @@ class RaiseAlarm(base.Recipe):
|
|||||||
target_resource = action_spec.targets[TFields.TARGET]
|
target_resource = action_spec.targets[TFields.TARGET]
|
||||||
add_vertex_params = {
|
add_vertex_params = {
|
||||||
TFields.TARGET: target_resource.vertex_id,
|
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)
|
add_vertex_params.update(action_spec.properties)
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
from vitrage.common.constants import TemplateTopologyFields
|
from vitrage.common.constants import TemplateTopologyFields
|
||||||
from vitrage.common.exception import VitrageError
|
from vitrage.common.exception import VitrageError
|
||||||
|
from vitrage.evaluator.template_data import TemplateData
|
||||||
|
|
||||||
|
|
||||||
class Fields(TemplateTopologyFields):
|
class Fields(TemplateTopologyFields):
|
||||||
@ -51,7 +52,9 @@ class EquivalenceData(object):
|
|||||||
for entity_def in equivalent_entities:
|
for entity_def in equivalent_entities:
|
||||||
entity_props = {(k, v)
|
entity_props = {(k, v)
|
||||||
for k, v in entity_def[Fields.ENTITY].items()}
|
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:
|
if entity_key in equivalence:
|
||||||
raise VitrageError('duplicated entities found in '
|
raise VitrageError('duplicated entities found in '
|
||||||
'equivalence')
|
'equivalence')
|
||||||
|
@ -77,7 +77,7 @@ class ScenarioEvaluator(object):
|
|||||||
change that happened. None if the element was just created.
|
change that happened. None if the element was just created.
|
||||||
:param current: The graph element (vertex or edge) after the
|
:param current: The graph element (vertex or edge) after the
|
||||||
change that happened. Deleted elements should arrive with 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:
|
if not self.enabled:
|
||||||
@ -118,8 +118,8 @@ class ScenarioEvaluator(object):
|
|||||||
|
|
||||||
def _get_element_scenarios(self, element, is_vertex):
|
def _get_element_scenarios(self, element, is_vertex):
|
||||||
if not element \
|
if not element \
|
||||||
or element.get(VProps.IS_DELETED) \
|
or element.get(VProps.VITRAGE_IS_DELETED) \
|
||||||
or element.get(EProps.IS_DELETED):
|
or element.get(EProps.VITRAGE_IS_DELETED):
|
||||||
return []
|
return []
|
||||||
elif is_vertex:
|
elif is_vertex:
|
||||||
return self._scenario_repo.get_scenarios_by_vertex(element)
|
return self._scenario_repo.get_scenarios_by_vertex(element)
|
||||||
@ -310,8 +310,8 @@ class ScenarioEvaluator(object):
|
|||||||
|
|
||||||
connected_component = self.get_connected_component(subgraph,
|
connected_component = self.get_connected_component(subgraph,
|
||||||
action_target)
|
action_target)
|
||||||
# change the is_deleted and negative_condition props to false when
|
# change the vitrage_is_deleted and negative_condition props to
|
||||||
# is_switch_mode=true so that when we have an event on a
|
# 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
|
# negative_condition=true edge it will find the correct subgraph
|
||||||
self._switch_edge_negative_props(is_switch_mode, scenario_edge,
|
self._switch_edge_negative_props(is_switch_mode, scenario_edge,
|
||||||
subgraph, False)
|
subgraph, False)
|
||||||
@ -349,7 +349,7 @@ class ScenarioEvaluator(object):
|
|||||||
status):
|
status):
|
||||||
if is_switch_mode:
|
if is_switch_mode:
|
||||||
scenario_edge.edge[NEG_CONDITION] = status
|
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)
|
subgraph.update_edge(scenario_edge.edge)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -52,6 +52,19 @@ def copy_edge_desc(edge_desc):
|
|||||||
# noinspection PyAttributeOutsideInit
|
# noinspection PyAttributeOutsideInit
|
||||||
class TemplateData(object):
|
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):
|
def __init__(self, template_def):
|
||||||
|
|
||||||
self.name = template_def[TFields.METADATA][TFields.NAME]
|
self.name = template_def[TFields.METADATA][TFields.NAME]
|
||||||
@ -105,7 +118,8 @@ class TemplateData(object):
|
|||||||
|
|
||||||
entity_dict = entity_def[TFields.ENTITY]
|
entity_dict = entity_def[TFields.ENTITY]
|
||||||
template_id = entity_dict[TFields.TEMPLATE_ID]
|
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)
|
entities[template_id] = Vertex(template_id, properties)
|
||||||
|
|
||||||
return entities
|
return entities
|
||||||
@ -143,6 +157,24 @@ class TemplateData(object):
|
|||||||
return dict((key, var_dict[key]) for key in var_dict
|
return dict((key, var_dict[key]) for key in var_dict
|
||||||
if key not in ignore_ids)
|
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):
|
def _build_scenarios(self, scenarios_defs):
|
||||||
|
|
||||||
scenarios = []
|
scenarios = []
|
||||||
@ -347,14 +379,14 @@ class TemplateData(object):
|
|||||||
variable, var_type = extract_var(term.symbol_name)
|
variable, var_type = extract_var(term.symbol_name)
|
||||||
if var_type == ENTITY:
|
if var_type == ENTITY:
|
||||||
vertex = variable.copy()
|
vertex = variable.copy()
|
||||||
vertex[VProps.IS_DELETED] = False
|
vertex[VProps.VITRAGE_IS_DELETED] = False
|
||||||
vertex[VProps.IS_PLACEHOLDER] = False
|
vertex[VProps.VITRAGE_IS_PLACEHOLDER] = False
|
||||||
condition_g.add_vertex(vertex)
|
condition_g.add_vertex(vertex)
|
||||||
|
|
||||||
else: # type = relationship
|
else: # type = relationship
|
||||||
# prevent overwritten of NEG_CONDITION and IS_DELETED
|
# prevent overwritten of NEG_CONDITION and
|
||||||
# property when there are both "not A" and "A" in same
|
# VITRAGE_IS_DELETED property when there are both "not A"
|
||||||
# template
|
# and "A" in same template
|
||||||
edge_desc = copy_edge_desc(variable)
|
edge_desc = copy_edge_desc(variable)
|
||||||
cls._set_edge_relationship_info(edge_desc, term.positive)
|
cls._set_edge_relationship_info(edge_desc, term.positive)
|
||||||
cls._add_edge_relationship(condition_g, edge_desc)
|
cls._add_edge_relationship(condition_g, edge_desc)
|
||||||
@ -366,15 +398,15 @@ class TemplateData(object):
|
|||||||
is_positive_condition):
|
is_positive_condition):
|
||||||
if not is_positive_condition:
|
if not is_positive_condition:
|
||||||
edge_description.edge[NEG_CONDITION] = True
|
edge_description.edge[NEG_CONDITION] = True
|
||||||
edge_description.edge[EProps.IS_DELETED] = True
|
edge_description.edge[EProps.VITRAGE_IS_DELETED] = True
|
||||||
else:
|
else:
|
||||||
edge_description.edge[EProps.IS_DELETED] = False
|
edge_description.edge[EProps.VITRAGE_IS_DELETED] = False
|
||||||
edge_description.edge[NEG_CONDITION] = False
|
edge_description.edge[NEG_CONDITION] = False
|
||||||
|
|
||||||
edge_description.source[VProps.IS_DELETED] = False
|
edge_description.source[VProps.VITRAGE_IS_DELETED] = False
|
||||||
edge_description.source[VProps.IS_PLACEHOLDER] = False
|
edge_description.source[VProps.VITRAGE_IS_PLACEHOLDER] = False
|
||||||
edge_description.target[VProps.IS_DELETED] = False
|
edge_description.target[VProps.VITRAGE_IS_DELETED] = False
|
||||||
edge_description.target[VProps.IS_PLACEHOLDER] = False
|
edge_description.target[VProps.VITRAGE_IS_PLACEHOLDER] = False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _add_edge_relationship(condition_graph, edge_description):
|
def _add_edge_relationship(condition_graph, edge_description):
|
||||||
|
@ -316,12 +316,12 @@ def _validate_template_id(definitions_index, id_to_check):
|
|||||||
return get_correct_result(RESULT_DESCRIPTION)
|
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 \
|
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' \
|
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))
|
LOG.error('%s status code: %s' % (msg, 132))
|
||||||
return get_fault_result(RESULT_DESCRIPTION, 132, msg)
|
return get_fault_result(RESULT_DESCRIPTION, 132, msg)
|
||||||
|
|
||||||
|
@ -191,7 +191,8 @@ class NXAlgorithm(GraphAlgorithm):
|
|||||||
has real neighbors in the entity graph.
|
has real neighbors in the entity graph.
|
||||||
"""
|
"""
|
||||||
if self.graph.neighbors(ge_v_id,
|
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)
|
template_vertex = subgraph.get_vertex(sge_v_id)
|
||||||
graph_vertex = self.graph.get_vertex(ge_v_id)
|
graph_vertex = self.graph.get_vertex(ge_v_id)
|
||||||
match = Mapping(template_vertex, graph_vertex, True)
|
match = Mapping(template_vertex, graph_vertex, True)
|
||||||
|
@ -42,18 +42,18 @@ def create_predicate(query_dict):
|
|||||||
--------------
|
--------------
|
||||||
query_dict = {
|
query_dict = {
|
||||||
'and': [
|
'and': [
|
||||||
{'==': {'TYPE': 'ALARM'}},
|
{'==': {'CATEGORY': 'ALARM'}},
|
||||||
{'or': [
|
{'or': [
|
||||||
{'>': {'TIME': 150}},
|
{'>': {'TIME': 150}},
|
||||||
{'==': {'IS_DELETED': True}}
|
{'==': {'VITRAGE_IS_DELETED': True}}
|
||||||
]}
|
]}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Example Output:
|
Example Output:
|
||||||
--------------
|
--------------
|
||||||
lambda item: ((item['TYPE']== 'ALARM') and
|
lambda item: ((item['CATEGORY']== 'ALARM') and
|
||||||
((item['TIME']> 150) or (item['IS_DELETED']== True)))
|
((item['TIME']> 150) or (item['VITRAGE_IS_DELETED']== True)))
|
||||||
|
|
||||||
Example Usage:
|
Example Usage:
|
||||||
--------------
|
--------------
|
||||||
|
@ -19,14 +19,14 @@ from vitrage.graph.driver.elements import Vertex
|
|||||||
|
|
||||||
|
|
||||||
def create_vertex(vitrage_id,
|
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_id=None,
|
||||||
entity_category=None,
|
|
||||||
entity_type=None,
|
|
||||||
entity_state=None,
|
entity_state=None,
|
||||||
is_deleted=False,
|
|
||||||
sample_timestamp=None,
|
|
||||||
update_timestamp=None,
|
update_timestamp=None,
|
||||||
is_placeholder=False,
|
|
||||||
project_id=None,
|
project_id=None,
|
||||||
metadata=None):
|
metadata=None):
|
||||||
"""A builder to create a vertex
|
"""A builder to create a vertex
|
||||||
@ -35,22 +35,22 @@ def create_vertex(vitrage_id,
|
|||||||
:type vitrage_id: str
|
:type vitrage_id: str
|
||||||
:param entity_id:
|
:param entity_id:
|
||||||
:type entity_id: str
|
:type entity_id: str
|
||||||
:param entity_category:
|
:param vitrage_category:
|
||||||
:type entity_category: str
|
:type vitrage_category: str
|
||||||
:param entity_type:
|
:param vitrage_type:
|
||||||
:type entity_type: str
|
:type vitrage_type: str
|
||||||
:param entity_state:
|
:param entity_state:
|
||||||
:type entity_state: str
|
:type entity_state: str
|
||||||
:param is_deleted:
|
:param vitrage_is_deleted:
|
||||||
:type is_deleted: boolean
|
:type vitrage_is_deleted: boolean
|
||||||
:param update_timestamp:
|
:param update_timestamp:
|
||||||
:type update_timestamp: str
|
:type update_timestamp: str
|
||||||
:param sample_timestamp:
|
:param vitrage_sample_timestamp:
|
||||||
:type sample_timestamp: str
|
:type vitrage_sample_timestamp: str
|
||||||
:param metadata:
|
:param metadata:
|
||||||
:type metadata: dict
|
:type metadata: dict
|
||||||
:param is_placeholder:
|
:param vitrage_is_placeholder:
|
||||||
:type is_placeholder: boolean
|
:type vitrage_is_placeholder: boolean
|
||||||
:param project_id:
|
:param project_id:
|
||||||
:type project_id: str
|
:type project_id: str
|
||||||
:return:
|
:return:
|
||||||
@ -60,12 +60,12 @@ def create_vertex(vitrage_id,
|
|||||||
properties = {
|
properties = {
|
||||||
VConst.ID: entity_id,
|
VConst.ID: entity_id,
|
||||||
VConst.STATE: entity_state,
|
VConst.STATE: entity_state,
|
||||||
VConst.TYPE: entity_type,
|
VConst.VITRAGE_TYPE: vitrage_type,
|
||||||
VConst.CATEGORY: entity_category,
|
VConst.VITRAGE_CATEGORY: vitrage_category,
|
||||||
VConst.IS_DELETED: is_deleted,
|
VConst.VITRAGE_IS_DELETED: vitrage_is_deleted,
|
||||||
VConst.UPDATE_TIMESTAMP: update_timestamp,
|
VConst.UPDATE_TIMESTAMP: update_timestamp,
|
||||||
VConst.SAMPLE_TIMESTAMP: sample_timestamp,
|
VConst.VITRAGE_SAMPLE_TIMESTAMP: vitrage_sample_timestamp,
|
||||||
VConst.IS_PLACEHOLDER: is_placeholder,
|
VConst.VITRAGE_IS_PLACEHOLDER: vitrage_is_placeholder,
|
||||||
VConst.VITRAGE_ID: vitrage_id,
|
VConst.VITRAGE_ID: vitrage_id,
|
||||||
VConst.PROJECT_ID: project_id
|
VConst.PROJECT_ID: project_id
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ def create_vertex(vitrage_id,
|
|||||||
def create_edge(source_id,
|
def create_edge(source_id,
|
||||||
target_id,
|
target_id,
|
||||||
relationship_type,
|
relationship_type,
|
||||||
is_deleted=False,
|
vitrage_is_deleted=False,
|
||||||
update_timestamp=None,
|
update_timestamp=None,
|
||||||
metadata=None):
|
metadata=None):
|
||||||
"""A builder to create an edge
|
"""A builder to create an edge
|
||||||
@ -92,8 +92,8 @@ def create_edge(source_id,
|
|||||||
:type target_id: str
|
:type target_id: str
|
||||||
:param relationship_type:
|
:param relationship_type:
|
||||||
:type relationship_type: str
|
:type relationship_type: str
|
||||||
:param is_deleted:
|
:param vitrage_is_deleted:
|
||||||
:type is_deleted: str
|
:type vitrage_is_deleted: str
|
||||||
:param metadata:
|
:param metadata:
|
||||||
:type metadata: dict
|
:type metadata: dict
|
||||||
:return:
|
:return:
|
||||||
@ -101,7 +101,7 @@ def create_edge(source_id,
|
|||||||
"""
|
"""
|
||||||
properties = {
|
properties = {
|
||||||
EConst.UPDATE_TIMESTAMP: update_timestamp,
|
EConst.UPDATE_TIMESTAMP: update_timestamp,
|
||||||
EConst.IS_DELETED: is_deleted,
|
EConst.VITRAGE_IS_DELETED: vitrage_is_deleted,
|
||||||
EConst.RELATIONSHIP_TYPE: relationship_type,
|
EConst.RELATIONSHIP_TYPE: relationship_type,
|
||||||
}
|
}
|
||||||
if metadata:
|
if metadata:
|
||||||
|
@ -33,7 +33,7 @@ class NovaNotifier(NotifierBase):
|
|||||||
self.client = os_clients.nova_client(conf)
|
self.client = os_clients.nova_client(conf)
|
||||||
|
|
||||||
def process_event(self, data, event_type):
|
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:
|
if event_type == NotifierEventTypes.ACTIVATE_MARK_DOWN_EVENT:
|
||||||
self._mark_host_down(data.get(VProps.ID), True)
|
self._mark_host_down(data.get(VProps.ID), True)
|
||||||
elif event_type == NotifierEventTypes.DEACTIVATE_MARK_DOWN_EVENT:
|
elif event_type == NotifierEventTypes.DEACTIVATE_MARK_DOWN_EVENT:
|
||||||
|
@ -151,7 +151,7 @@ class SnmpSender(SnmpSenderBase):
|
|||||||
if not severity_mapping:
|
if not severity_mapping:
|
||||||
return None
|
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)
|
state = alert_values.get(VProps.STATE)
|
||||||
|
|
||||||
if state in severity_mapping:
|
if state in severity_mapping:
|
||||||
|
@ -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.rca import RcaApis
|
||||||
from vitrage.api_handler.apis.resource import ResourceApis
|
from vitrage.api_handler.apis.resource import ResourceApis
|
||||||
from vitrage.api_handler.apis.topology import TopologyApis
|
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 EntityCategory
|
||||||
from vitrage.common.constants import VertexProperties as VProps
|
from vitrage.common.constants import VertexProperties as VProps
|
||||||
from vitrage.datasources import NOVA_HOST_DATASOURCE
|
from vitrage.datasources import NOVA_HOST_DATASOURCE
|
||||||
@ -370,7 +371,8 @@ class TestApis(TestEntityGraphUnitBase):
|
|||||||
tmp_project_id = alarm.get(VProps.PROJECT_ID, None)
|
tmp_project_id = alarm.get(VProps.PROJECT_ID, None)
|
||||||
condition = True
|
condition = True
|
||||||
if check_alarm_category:
|
if check_alarm_category:
|
||||||
condition = alarm[VProps.CATEGORY] == EntityCategory.ALARM
|
condition = \
|
||||||
|
alarm[VProps.VITRAGE_CATEGORY] == EntityCategory.ALARM
|
||||||
if project_id:
|
if project_id:
|
||||||
condition = condition and \
|
condition = condition and \
|
||||||
(not tmp_project_id or
|
(not tmp_project_id or
|
||||||
@ -381,11 +383,12 @@ class TestApis(TestEntityGraphUnitBase):
|
|||||||
resource_type, project_id=None):
|
resource_type, project_id=None):
|
||||||
self.assertEqual(resource[VProps.VITRAGE_ID], vitrage_id)
|
self.assertEqual(resource[VProps.VITRAGE_ID], vitrage_id)
|
||||||
self.assertEqual(resource[VProps.ID], vitrage_id)
|
self.assertEqual(resource[VProps.ID], vitrage_id)
|
||||||
self.assertEqual(resource[VProps.CATEGORY], EntityCategory.RESOURCE)
|
self.assertEqual(resource[VProps.VITRAGE_CATEGORY],
|
||||||
self.assertEqual(resource[VProps.TYPE], resource_type)
|
EntityCategory.RESOURCE)
|
||||||
|
self.assertEqual(resource[VProps.VITRAGE_TYPE], resource_type)
|
||||||
self.assertEqual(resource[VProps.STATE], 'active')
|
self.assertEqual(resource[VProps.STATE], 'active')
|
||||||
self.assertFalse(resource[VProps.IS_DELETED])
|
self.assertFalse(resource[VProps.VITRAGE_IS_DELETED])
|
||||||
self.assertFalse(resource[VProps.IS_PLACEHOLDER])
|
self.assertFalse(resource[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
if project_id:
|
if project_id:
|
||||||
self.assertEqual(resource[VProps.PROJECT_ID], 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_vertex = self._create_alarm(
|
||||||
'alarm_on_host',
|
'alarm_on_host',
|
||||||
'alarm_on_host',
|
'alarm_on_host',
|
||||||
metadata={'type': 'nova.host',
|
metadata={VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE,
|
||||||
'name': 'host_1',
|
VProps.NAME: 'host_1',
|
||||||
'resource_id': 'host_1'})
|
VProps.RESOURCE_ID: 'host_1'})
|
||||||
alarm_on_instance_1_vertex = self._create_alarm(
|
alarm_on_instance_1_vertex = self._create_alarm(
|
||||||
'alarm_on_instance_1',
|
'alarm_on_instance_1',
|
||||||
'deduced_alarm',
|
'deduced_alarm',
|
||||||
project_id='project_1',
|
project_id='project_1',
|
||||||
metadata={'type': 'nova.instance',
|
metadata={VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
|
||||||
'name': 'instance_1',
|
VProps.NAME: 'instance_1',
|
||||||
'resource_id': 'sdg7849ythksjdg'})
|
VProps.RESOURCE_ID: 'sdg7849ythksjdg'})
|
||||||
alarm_on_instance_2_vertex = self._create_alarm(
|
alarm_on_instance_2_vertex = self._create_alarm(
|
||||||
'alarm_on_instance_2',
|
'alarm_on_instance_2',
|
||||||
'deduced_alarm',
|
'deduced_alarm',
|
||||||
metadata={'type': 'nova.instance',
|
metadata={VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
|
||||||
'name': 'instance_2',
|
VProps.NAME: 'instance_2',
|
||||||
'resource_id': 'nbfhsdugf'})
|
VProps.RESOURCE_ID: 'nbfhsdugf'})
|
||||||
alarm_on_instance_3_vertex = self._create_alarm(
|
alarm_on_instance_3_vertex = self._create_alarm(
|
||||||
'alarm_on_instance_3',
|
'alarm_on_instance_3',
|
||||||
'deduced_alarm',
|
'deduced_alarm',
|
||||||
project_id='project_2',
|
project_id='project_2',
|
||||||
metadata={'type': 'nova.instance',
|
metadata={VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
|
||||||
'name': 'instance_3',
|
VProps.NAME: 'instance_3',
|
||||||
'resource_id': 'nbffhsdasdugf'})
|
VProps.RESOURCE_ID: 'nbffhsdasdugf'})
|
||||||
alarm_on_instance_4_vertex = self._create_alarm(
|
alarm_on_instance_4_vertex = self._create_alarm(
|
||||||
'alarm_on_instance_4',
|
'alarm_on_instance_4',
|
||||||
'deduced_alarm',
|
'deduced_alarm',
|
||||||
metadata={'type': 'nova.instance',
|
metadata={VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
|
||||||
'name': 'instance_4',
|
VProps.NAME: 'instance_4',
|
||||||
'resource_id': 'ngsuy76hgd87f'})
|
VProps.RESOURCE_ID: 'ngsuy76hgd87f'})
|
||||||
|
|
||||||
# create links
|
# create links
|
||||||
edges = list()
|
edges = list()
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
cluster_vertex.vertex_id,
|
cluster_vertex.vertex_id,
|
||||||
zone_vertex.vertex_id,
|
zone_vertex.vertex_id,
|
||||||
'contains'))
|
EdgeLabel.CONTAINS))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
zone_vertex.vertex_id,
|
zone_vertex.vertex_id,
|
||||||
host_vertex.vertex_id,
|
host_vertex.vertex_id,
|
||||||
'contains'))
|
EdgeLabel.CONTAINS))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
host_vertex.vertex_id,
|
host_vertex.vertex_id,
|
||||||
instance_1_vertex.vertex_id,
|
instance_1_vertex.vertex_id,
|
||||||
'contains'))
|
EdgeLabel.CONTAINS))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
host_vertex.vertex_id,
|
host_vertex.vertex_id,
|
||||||
instance_2_vertex.vertex_id,
|
instance_2_vertex.vertex_id,
|
||||||
'contains'))
|
EdgeLabel.CONTAINS))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
host_vertex.vertex_id,
|
host_vertex.vertex_id,
|
||||||
instance_3_vertex.vertex_id,
|
instance_3_vertex.vertex_id,
|
||||||
'contains'))
|
EdgeLabel.CONTAINS))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
host_vertex.vertex_id,
|
host_vertex.vertex_id,
|
||||||
instance_4_vertex.vertex_id,
|
instance_4_vertex.vertex_id,
|
||||||
'contains'))
|
EdgeLabel.CONTAINS))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
alarm_on_host_vertex.vertex_id,
|
alarm_on_host_vertex.vertex_id,
|
||||||
host_vertex.vertex_id,
|
host_vertex.vertex_id,
|
||||||
'on'))
|
EdgeLabel.ON))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
alarm_on_instance_1_vertex.vertex_id,
|
alarm_on_instance_1_vertex.vertex_id,
|
||||||
instance_1_vertex.vertex_id,
|
instance_1_vertex.vertex_id,
|
||||||
'on'))
|
EdgeLabel.ON))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
alarm_on_instance_2_vertex.vertex_id,
|
alarm_on_instance_2_vertex.vertex_id,
|
||||||
instance_2_vertex.vertex_id,
|
instance_2_vertex.vertex_id,
|
||||||
'on'))
|
EdgeLabel.ON))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
alarm_on_instance_3_vertex.vertex_id,
|
alarm_on_instance_3_vertex.vertex_id,
|
||||||
instance_3_vertex.vertex_id,
|
instance_3_vertex.vertex_id,
|
||||||
'on'))
|
EdgeLabel.ON))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
alarm_on_instance_4_vertex.vertex_id,
|
alarm_on_instance_4_vertex.vertex_id,
|
||||||
instance_4_vertex.vertex_id,
|
instance_4_vertex.vertex_id,
|
||||||
'on'))
|
EdgeLabel.ON))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
alarm_on_host_vertex.vertex_id,
|
alarm_on_host_vertex.vertex_id,
|
||||||
alarm_on_instance_1_vertex.vertex_id,
|
alarm_on_instance_1_vertex.vertex_id,
|
||||||
'causes'))
|
EdgeLabel.CAUSES))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
alarm_on_host_vertex.vertex_id,
|
alarm_on_host_vertex.vertex_id,
|
||||||
alarm_on_instance_2_vertex.vertex_id,
|
alarm_on_instance_2_vertex.vertex_id,
|
||||||
'causes'))
|
EdgeLabel.CAUSES))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
alarm_on_host_vertex.vertex_id,
|
alarm_on_host_vertex.vertex_id,
|
||||||
alarm_on_instance_3_vertex.vertex_id,
|
alarm_on_instance_3_vertex.vertex_id,
|
||||||
'causes'))
|
EdgeLabel.CAUSES))
|
||||||
edges.append(graph_utils.create_edge(
|
edges.append(graph_utils.create_edge(
|
||||||
alarm_on_host_vertex.vertex_id,
|
alarm_on_host_vertex.vertex_id,
|
||||||
alarm_on_instance_4_vertex.vertex_id,
|
alarm_on_instance_4_vertex.vertex_id,
|
||||||
'causes'))
|
EdgeLabel.CAUSES))
|
||||||
|
|
||||||
# add vertices to graph
|
# add vertices to graph
|
||||||
graph.add_vertex(cluster_vertex)
|
graph.add_vertex(cluster_vertex)
|
||||||
|
@ -78,8 +78,8 @@ class TestAodhAlarms(TestDataSourcesBase):
|
|||||||
|
|
||||||
aodh_vertices = processor.entity_graph.get_vertices(
|
aodh_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter={
|
vertex_attr_filter={
|
||||||
VProps.CATEGORY: EntityCategory.ALARM,
|
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: AODH_DATASOURCE
|
VProps.VITRAGE_TYPE: AODH_DATASOURCE
|
||||||
})
|
})
|
||||||
self.assertEqual(1, len(aodh_vertices))
|
self.assertEqual(1, len(aodh_vertices))
|
||||||
|
|
||||||
@ -88,4 +88,4 @@ class TestAodhAlarms(TestDataSourcesBase):
|
|||||||
self.assertEqual(1, len(aodh_neighbors))
|
self.assertEqual(1, len(aodh_neighbors))
|
||||||
|
|
||||||
self.assertEqual(NOVA_HOST_DATASOURCE,
|
self.assertEqual(NOVA_HOST_DATASOURCE,
|
||||||
aodh_neighbors[0][VProps.TYPE])
|
aodh_neighbors[0][VProps.VITRAGE_TYPE])
|
||||||
|
@ -19,10 +19,10 @@ from vitrage.tests.functional.base import TestFunctionalBase
|
|||||||
|
|
||||||
class TestDataSourcesBase(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={
|
entity_vertices = graph.get_vertices(vertex_attr_filter={
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: type_
|
VProps.VITRAGE_TYPE: vitrage_type
|
||||||
})
|
})
|
||||||
self.assertGreater(len(entity_vertices), 0)
|
self.assertGreater(len(entity_vertices), 0)
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ class TestCinderVolume(TestDataSourcesBase):
|
|||||||
|
|
||||||
cinder_vertices = processor.entity_graph.get_vertices(
|
cinder_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter={
|
vertex_attr_filter={
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: CINDER_VOLUME_DATASOURCE
|
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE
|
||||||
})
|
})
|
||||||
self.assertEqual(1, len(cinder_vertices))
|
self.assertEqual(1, len(cinder_vertices))
|
||||||
|
|
||||||
@ -85,4 +85,4 @@ class TestCinderVolume(TestDataSourcesBase):
|
|||||||
self.assertEqual(1, len(cinder_neighbors))
|
self.assertEqual(1, len(cinder_neighbors))
|
||||||
|
|
||||||
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
|
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
|
||||||
cinder_neighbors[0][VProps.TYPE])
|
cinder_neighbors[0][VProps.VITRAGE_TYPE])
|
||||||
|
@ -72,22 +72,22 @@ class TestHeatStack(TestDataSourcesBase):
|
|||||||
|
|
||||||
stack_vertices = processor.entity_graph.get_vertices(
|
stack_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter={
|
vertex_attr_filter={
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: HEAT_STACK_DATASOURCE
|
VProps.VITRAGE_TYPE: HEAT_STACK_DATASOURCE
|
||||||
})
|
})
|
||||||
self.assertEqual(1, len(stack_vertices))
|
self.assertEqual(1, len(stack_vertices))
|
||||||
|
|
||||||
instance_vertices = processor.entity_graph.get_vertices(
|
instance_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter={
|
vertex_attr_filter={
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
|
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
|
||||||
})
|
})
|
||||||
self.assertEqual(self.NUM_INSTANCES + 1, len(instance_vertices))
|
self.assertEqual(self.NUM_INSTANCES + 1, len(instance_vertices))
|
||||||
|
|
||||||
cinder_vertices = processor.entity_graph.get_vertices(
|
cinder_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter={
|
vertex_attr_filter={
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: CINDER_VOLUME_DATASOURCE
|
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE
|
||||||
})
|
})
|
||||||
self.assertEqual(1, len(cinder_vertices))
|
self.assertEqual(1, len(cinder_vertices))
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ class TestNagios(TestDataSourcesBase):
|
|||||||
|
|
||||||
nagios_vertices = processor.entity_graph.get_vertices(
|
nagios_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter={
|
vertex_attr_filter={
|
||||||
VProps.CATEGORY: EntityCategory.ALARM,
|
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: NAGIOS_DATASOURCE
|
VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE
|
||||||
})
|
})
|
||||||
self.assertEqual(1, len(nagios_vertices))
|
self.assertEqual(1, len(nagios_vertices))
|
||||||
|
|
||||||
@ -84,4 +84,4 @@ class TestNagios(TestDataSourcesBase):
|
|||||||
self.assertEqual(1, len(nagios_neighbors))
|
self.assertEqual(1, len(nagios_neighbors))
|
||||||
|
|
||||||
self.assertEqual(NOVA_HOST_DATASOURCE,
|
self.assertEqual(NOVA_HOST_DATASOURCE,
|
||||||
nagios_neighbors[0][VProps.TYPE])
|
nagios_neighbors[0][VProps.VITRAGE_TYPE])
|
||||||
|
@ -81,8 +81,8 @@ class TestStaticPhysical(TestDataSourcesBase):
|
|||||||
|
|
||||||
static_physical_vertices = processor.entity_graph.get_vertices(
|
static_physical_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter={
|
vertex_attr_filter={
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: SWITCH
|
VProps.VITRAGE_TYPE: SWITCH
|
||||||
})
|
})
|
||||||
self.assertEqual(1, len(static_physical_vertices))
|
self.assertEqual(1, len(static_physical_vertices))
|
||||||
|
|
||||||
@ -91,4 +91,4 @@ class TestStaticPhysical(TestDataSourcesBase):
|
|||||||
self.assertEqual(1, len(static_physical_neighbors))
|
self.assertEqual(1, len(static_physical_neighbors))
|
||||||
|
|
||||||
self.assertEqual(NOVA_HOST_DATASOURCE,
|
self.assertEqual(NOVA_HOST_DATASOURCE,
|
||||||
static_physical_neighbors[0][VProps.TYPE])
|
static_physical_neighbors[0][VProps.VITRAGE_TYPE])
|
||||||
|
@ -30,7 +30,8 @@ from vitrage.entity_graph.consistency.consistency_enforcer \
|
|||||||
import ConsistencyEnforcer
|
import ConsistencyEnforcer
|
||||||
from vitrage.entity_graph.initialization_status import InitializationStatus
|
from vitrage.entity_graph.initialization_status import InitializationStatus
|
||||||
from vitrage.entity_graph.processor.processor import Processor
|
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_evaluator import ScenarioEvaluator
|
||||||
from vitrage.evaluator.scenario_repository import ScenarioRepository
|
from vitrage.evaluator.scenario_repository import ScenarioRepository
|
||||||
import vitrage.graph.utils as graph_utils
|
import vitrage.graph.utils as graph_utils
|
||||||
@ -117,30 +118,30 @@ class TestConsistencyFunctional(TestFunctionalBase):
|
|||||||
num_of_host_alarms * num_instances_per_host
|
num_of_host_alarms * num_instances_per_host
|
||||||
num_undeleted_vertices_in_graph = \
|
num_undeleted_vertices_in_graph = \
|
||||||
len(self.processor.entity_graph.get_vertices(vertex_attr_filter={
|
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() +
|
self.assertEqual(self._num_total_expected_vertices() +
|
||||||
num_correct_alarms,
|
num_correct_alarms,
|
||||||
num_undeleted_vertices_in_graph)
|
num_undeleted_vertices_in_graph)
|
||||||
|
|
||||||
alarm_vertices_in_graph = self.processor.entity_graph.get_vertices({
|
alarm_vertices_in_graph = self.processor.entity_graph.get_vertices({
|
||||||
VProps.CATEGORY: EntityCategory.ALARM,
|
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: False
|
VProps.VITRAGE_IS_DELETED: False
|
||||||
})
|
})
|
||||||
self.assertEqual(num_correct_alarms, len(alarm_vertices_in_graph))
|
self.assertEqual(num_correct_alarms, len(alarm_vertices_in_graph))
|
||||||
|
|
||||||
is_deleted_alarm_vertices_in_graph = \
|
is_deleted_alarm_vertices_in_graph = \
|
||||||
self.processor.entity_graph.get_vertices({
|
self.processor.entity_graph.get_vertices({
|
||||||
VProps.CATEGORY: EntityCategory.ALARM,
|
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: True
|
VProps.VITRAGE_IS_DELETED: True
|
||||||
})
|
})
|
||||||
self.assertEqual(num_of_host_alarms * num_instances_per_host,
|
self.assertEqual(num_of_host_alarms * num_instances_per_host,
|
||||||
len(is_deleted_alarm_vertices_in_graph))
|
len(is_deleted_alarm_vertices_in_graph))
|
||||||
|
|
||||||
instance_vertices = self.processor.entity_graph.get_vertices({
|
instance_vertices = self.processor.entity_graph.get_vertices({
|
||||||
VProps.CATEGORY: EntityCategory.ALARM,
|
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: VITRAGE_TYPE,
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.IS_DELETED: False
|
VProps.VITRAGE_IS_DELETED: False
|
||||||
})
|
})
|
||||||
self.assertEqual(num_of_host_alarms * num_instances_per_host,
|
self.assertEqual(num_of_host_alarms * num_instances_per_host,
|
||||||
len(instance_vertices))
|
len(instance_vertices))
|
||||||
@ -157,14 +158,14 @@ class TestConsistencyFunctional(TestFunctionalBase):
|
|||||||
|
|
||||||
# Test Assertions
|
# Test Assertions
|
||||||
instance_vertices = self.processor.entity_graph.get_vertices({
|
instance_vertices = self.processor.entity_graph.get_vertices({
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
|
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
|
||||||
})
|
})
|
||||||
deleted_instance_vertices = \
|
deleted_instance_vertices = \
|
||||||
self.processor.entity_graph.get_vertices({
|
self.processor.entity_graph.get_vertices({
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: NOVA_INSTANCE_DATASOURCE,
|
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
|
||||||
VProps.IS_DELETED: True
|
VProps.VITRAGE_IS_DELETED: True
|
||||||
})
|
})
|
||||||
self.assertEqual(self.NUM_INSTANCES - 3, len(instance_vertices))
|
self.assertEqual(self.NUM_INSTANCES - 3, len(instance_vertices))
|
||||||
self.assertEqual(self._num_total_expected_vertices() - 3,
|
self.assertEqual(self._num_total_expected_vertices() - 3,
|
||||||
@ -183,8 +184,8 @@ class TestConsistencyFunctional(TestFunctionalBase):
|
|||||||
|
|
||||||
# check number of instances in graph
|
# check number of instances in graph
|
||||||
instance_vertices = self.processor.entity_graph.get_vertices({
|
instance_vertices = self.processor.entity_graph.get_vertices({
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
|
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
|
||||||
})
|
})
|
||||||
self.assertEqual(self.NUM_INSTANCES, len(instance_vertices))
|
self.assertEqual(self.NUM_INSTANCES, len(instance_vertices))
|
||||||
|
|
||||||
@ -193,13 +194,13 @@ class TestConsistencyFunctional(TestFunctionalBase):
|
|||||||
|
|
||||||
# set part of the instances as deleted
|
# set part of the instances as deleted
|
||||||
for i in range(3, 6):
|
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])
|
self.processor.entity_graph.update_vertex(instance_vertices[i])
|
||||||
|
|
||||||
# set part of the instances as deleted
|
# set part of the instances as deleted
|
||||||
for i in range(6, 9):
|
for i in range(6, 9):
|
||||||
instance_vertices[i][VProps.IS_DELETED] = True
|
instance_vertices[i][VProps.VITRAGE_IS_DELETED] = True
|
||||||
instance_vertices[i][VProps.SAMPLE_TIMESTAMP] = str(
|
instance_vertices[i][VProps.VITRAGE_SAMPLE_TIMESTAMP] = str(
|
||||||
current_time + timedelta(seconds=2 * consistency_interval + 1))
|
current_time + timedelta(seconds=2 * consistency_interval + 1))
|
||||||
self.processor.entity_graph.update_vertex(instance_vertices[i])
|
self.processor.entity_graph.update_vertex(instance_vertices[i])
|
||||||
|
|
||||||
@ -215,8 +216,8 @@ class TestConsistencyFunctional(TestFunctionalBase):
|
|||||||
def _add_alarms(self):
|
def _add_alarms(self):
|
||||||
# find hosts and instances
|
# find hosts and instances
|
||||||
host_vertices = self.processor.entity_graph.get_vertices({
|
host_vertices = self.processor.entity_graph.get_vertices({
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: NOVA_HOST_DATASOURCE
|
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE
|
||||||
})
|
})
|
||||||
|
|
||||||
# add host alarms + deduced alarms
|
# add host alarms + deduced alarms
|
||||||
@ -249,7 +250,7 @@ class TestConsistencyFunctional(TestFunctionalBase):
|
|||||||
|
|
||||||
def _update_timestamp(self, lst, timestamp):
|
def _update_timestamp(self, lst, timestamp):
|
||||||
for vertex in lst:
|
for vertex in lst:
|
||||||
vertex[VProps.SAMPLE_TIMESTAMP] = str(timestamp)
|
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP] = str(timestamp)
|
||||||
self.processor.entity_graph.update_vertex(vertex)
|
self.processor.entity_graph.update_vertex(vertex)
|
||||||
|
|
||||||
def _process_events(self):
|
def _process_events(self):
|
||||||
|
@ -49,9 +49,9 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
|
|||||||
entity = processor.transformer_manager.transform(event)
|
entity = processor.transformer_manager.transform(event)
|
||||||
processor._find_and_fix_graph_vertex(entity.vertex, [])
|
processor._find_and_fix_graph_vertex(entity.vertex, [])
|
||||||
vertex = processor.entity_graph.get_vertex(entity.vertex.vertex_id)
|
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,
|
self.assertEqual(OperationalResourceState.OK,
|
||||||
vertex[VProps.OPERATIONAL_STATE])
|
vertex[VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
|
|
||||||
def test_state_on_neighbor_update(self):
|
def test_state_on_neighbor_update(self):
|
||||||
# setup
|
# setup
|
||||||
@ -61,7 +61,7 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
|
|||||||
self.assertEqual(2, processor.entity_graph.num_vertices())
|
self.assertEqual(2, processor.entity_graph.num_vertices())
|
||||||
|
|
||||||
neighbors[0].vertex[VProps.STATE] = 'available'
|
neighbors[0].vertex[VProps.STATE] = 'available'
|
||||||
neighbors[0].vertex[VProps.IS_PLACEHOLDER] = False
|
neighbors[0].vertex[VProps.VITRAGE_IS_PLACEHOLDER] = False
|
||||||
|
|
||||||
# action
|
# action
|
||||||
processor._connect_neighbors(neighbors, [], GraphAction.UPDATE_ENTITY)
|
processor._connect_neighbors(neighbors, [], GraphAction.UPDATE_ENTITY)
|
||||||
@ -69,6 +69,7 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
|
|||||||
# test assertions
|
# test assertions
|
||||||
neighbor_vertex = processor.entity_graph.get_vertex(
|
neighbor_vertex = processor.entity_graph.get_vertex(
|
||||||
neighbors[0].vertex.vertex_id)
|
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,
|
self.assertEqual(OperationalResourceState.OK,
|
||||||
neighbor_vertex[VProps.OPERATIONAL_STATE])
|
neighbor_vertex[VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
|
@ -12,10 +12,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from six.moves import queue
|
||||||
|
|
||||||
from oslo_config import cfg
|
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 DatasourceProperties as DSProp
|
||||||
from vitrage.common.constants import EdgeLabel
|
from vitrage.common.constants import EdgeLabel
|
||||||
from vitrage.common.constants import EntityCategory
|
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.alarm_properties import AlarmProperties as AlarmProps
|
||||||
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
|
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
|
||||||
from vitrage.datasources.nagios.properties import NagiosProperties as NProps
|
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.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 \
|
from vitrage.entity_graph.mappings.operational_resource_state import \
|
||||||
OperationalResourceState
|
OperationalResourceState
|
||||||
from vitrage.evaluator.actions.action_executor import ActionExecutor
|
from vitrage.evaluator.actions.action_executor import ActionExecutor
|
||||||
from vitrage.evaluator.actions.base import ActionMode
|
from vitrage.evaluator.actions.base import ActionMode
|
||||||
from vitrage.evaluator.actions.base import ActionType
|
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_data import ActionSpecs
|
||||||
from vitrage.evaluator.template_fields import TemplateFields as TFields
|
from vitrage.evaluator.template_fields import TemplateFields as TFields
|
||||||
from vitrage.opts import register_opts
|
from vitrage.opts import register_opts
|
||||||
@ -54,7 +61,7 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
# Test Setup
|
# Test Setup
|
||||||
processor = self._create_processor_with_graph(self.conf, uuid=True)
|
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(
|
host_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter=vertex_attrs)
|
vertex_attr_filter=vertex_attrs)
|
||||||
host_vertex_before = host_vertices[0]
|
host_vertex_before = host_vertices[0]
|
||||||
@ -74,12 +81,14 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
host_vertex_before.vertex_id)
|
host_vertex_before.vertex_id)
|
||||||
|
|
||||||
# Test Assertions
|
# 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,
|
self.assertNotEqual(agg_state_before,
|
||||||
OperationalResourceState.SUBOPTIMAL)
|
OperationalResourceState.SUBOPTIMAL)
|
||||||
self.assertNotIn(VProps.VITRAGE_STATE, host_vertex_before.properties)
|
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)
|
self.assertEqual(agg_state_after, OperationalResourceState.SUBOPTIMAL)
|
||||||
v_state_after = host_vertex_after.get(VProps.VITRAGE_STATE)
|
v_state_after = host_vertex_after.get(VProps.VITRAGE_STATE)
|
||||||
self.assertEqual(v_state_after, OperationalResourceState.SUBOPTIMAL)
|
self.assertEqual(v_state_after, OperationalResourceState.SUBOPTIMAL)
|
||||||
@ -92,7 +101,8 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
host_vertex_before.vertex_id)
|
host_vertex_before.vertex_id)
|
||||||
|
|
||||||
# Test Assertions
|
# 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.assertEqual(agg_state_after_undo, agg_state_before)
|
||||||
self.assertNotIn(
|
self.assertNotIn(
|
||||||
VProps.VITRAGE_STATE, host_vertex_after_undo.properties)
|
VProps.VITRAGE_STATE, host_vertex_after_undo.properties)
|
||||||
@ -102,7 +112,7 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
# Test Setup
|
# Test Setup
|
||||||
processor = self._create_processor_with_graph(self.conf, uuid=True)
|
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(
|
host_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter=vertex_attrs)
|
vertex_attr_filter=vertex_attrs)
|
||||||
host_vertex_before = host_vertices[0]
|
host_vertex_before = host_vertices[0]
|
||||||
@ -139,7 +149,7 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
# Test Setup
|
# Test Setup
|
||||||
processor = self._create_processor_with_graph(self.conf, uuid=True)
|
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(
|
host_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter=vertex_attrs)
|
vertex_attr_filter=vertex_attrs)
|
||||||
|
|
||||||
@ -153,7 +163,7 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
host_2.get(VProps.ID), NOVA_HOST_DATASOURCE)
|
host_2.get(VProps.ID), NOVA_HOST_DATASOURCE)
|
||||||
processor.process_event(nagios_event2)
|
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(
|
alarms_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter=alarms_attrs)
|
vertex_attr_filter=alarms_attrs)
|
||||||
|
|
||||||
@ -189,7 +199,7 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
# Test Setup
|
# Test Setup
|
||||||
processor = self._create_processor_with_graph(self.conf, uuid=True)
|
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(
|
host_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter=vertex_attrs)
|
vertex_attr_filter=vertex_attrs)
|
||||||
|
|
||||||
@ -207,7 +217,7 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
# Raise alarm action adds new vertex with type vitrage to the graph
|
# Raise alarm action adds new vertex with type vitrage to the graph
|
||||||
action_spec = ActionSpecs(ActionType.RAISE_ALARM, targets, props)
|
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(
|
before_alarms = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter=alarm_vertex_attrs)
|
vertex_attr_filter=alarm_vertex_attrs)
|
||||||
event_queue = queue.Queue()
|
event_queue = queue.Queue()
|
||||||
@ -226,13 +236,13 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
|
|
||||||
alarm = after_alarms[0]
|
alarm = after_alarms[0]
|
||||||
|
|
||||||
self.assertEqual(alarm.properties[VProps.CATEGORY],
|
self.assertEqual(alarm.properties[VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
EntityCategory.ALARM)
|
||||||
self.assertEqual(alarm.properties[VProps.TYPE],
|
self.assertEqual(alarm.properties[VProps.VITRAGE_TYPE],
|
||||||
VITRAGE_TYPE)
|
VITRAGE_DATASOURCE)
|
||||||
self.assertEqual(alarm.properties[VProps.SEVERITY],
|
self.assertEqual(alarm.properties[VProps.SEVERITY],
|
||||||
props[TFields.SEVERITY])
|
props[TFields.SEVERITY])
|
||||||
self.assertEqual(alarm.properties[VProps.OPERATIONAL_SEVERITY],
|
self.assertEqual(alarm.properties[VProps.VITRAGE_OPERATIONAL_SEVERITY],
|
||||||
props[TFields.SEVERITY])
|
props[TFields.SEVERITY])
|
||||||
self.assertEqual(alarm.properties[VProps.STATE],
|
self.assertEqual(alarm.properties[VProps.STATE],
|
||||||
AlarmProps.ACTIVE_STATE)
|
AlarmProps.ACTIVE_STATE)
|
||||||
@ -247,7 +257,7 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
# Test Setup
|
# Test Setup
|
||||||
processor = self._create_processor_with_graph(self.conf, uuid=True)
|
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(
|
host_vertices = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter=vertex_attrs)
|
vertex_attr_filter=vertex_attrs)
|
||||||
|
|
||||||
@ -269,8 +279,8 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
|
|
||||||
processor.process_event(add_vertex_event)
|
processor.process_event(add_vertex_event)
|
||||||
|
|
||||||
alarm_vertex_attrs = {VProps.TYPE: VITRAGE_TYPE,
|
alarm_vertex_attrs = {VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.IS_DELETED: False}
|
VProps.VITRAGE_IS_DELETED: False}
|
||||||
before_alarms = processor.entity_graph.get_vertices(
|
before_alarms = processor.entity_graph.get_vertices(
|
||||||
vertex_attr_filter=alarm_vertex_attrs)
|
vertex_attr_filter=alarm_vertex_attrs)
|
||||||
|
|
||||||
@ -295,10 +305,10 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
NProps.RESOURCE_NAME: resource_name,
|
NProps.RESOURCE_NAME: resource_name,
|
||||||
NProps.RESOURCE_TYPE: resource_type,
|
NProps.RESOURCE_TYPE: resource_type,
|
||||||
NProps.SERVICE: 'Check_MK',
|
NProps.SERVICE: 'Check_MK',
|
||||||
NProps.STATUS: 'CRITICAL',
|
NProps.STATUS: NagiosTestStatus.CRITICAL,
|
||||||
NProps.STATUS_INFO: 'test test test',
|
NProps.STATUS_INFO: 'test test test',
|
||||||
DSProp.DATASOURCE_ACTION: 'snapshot',
|
DSProp.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT,
|
||||||
DSProp.ENTITY_TYPE: 'nagios',
|
DSProp.ENTITY_TYPE: NAGIOS_DATASOURCE,
|
||||||
DSProp.SAMPLE_DATE: '2016-02-07 15:26:04'}
|
DSProp.SAMPLE_DATE: '2016-02-07 15:26:04'}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -306,13 +316,14 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
|
|
||||||
return {TTFields.TARGET: target_vertex.vertex_id,
|
return {TTFields.TARGET: target_vertex.vertex_id,
|
||||||
VProps.UPDATE_TIMESTAMP: '2016-03-17 11:33:32.443002',
|
VProps.UPDATE_TIMESTAMP: '2016-03-17 11:33:32.443002',
|
||||||
DSProp.DATASOURCE_ACTION: 'update',
|
DSProp.DATASOURCE_ACTION: DatasourceAction.UPDATE,
|
||||||
TFields.ALARM_NAME: alarm_name,
|
TFields.ALARM_NAME: alarm_name,
|
||||||
VProps.STATE: 'Active',
|
VProps.STATE: 'Active',
|
||||||
VProps.TYPE: 'add_vertex',
|
EVALUATOR_EVENT_TYPE: ADD_VERTEX,
|
||||||
DSProp.ENTITY_TYPE: 'vitrage',
|
DSProp.ENTITY_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.SEVERITY: 'CRITICAL',
|
VProps.SEVERITY: OperationalAlarmSeverity.CRITICAL,
|
||||||
VProps.VITRAGE_ID: 'mock_vitrage_id',
|
VProps.VITRAGE_ID: 'mock_vitrage_id',
|
||||||
VProps.VITRAGE_RESOURCE_TYPE: 'nova.host',
|
VProps.VITRAGE_RESOURCE_TYPE: NOVA_HOST_DATASOURCE,
|
||||||
VProps.CATEGORY: 'ALARM',
|
VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.SAMPLE_TIMESTAMP: '2016-03-17 11:33:32.443002+00:00'}
|
VProps.VITRAGE_SAMPLE_TIMESTAMP:
|
||||||
|
'2016-03-17 11:33:32.443002+00:00'}
|
||||||
|
@ -18,11 +18,13 @@ from oslo_config import cfg
|
|||||||
|
|
||||||
from vitrage.common.constants import DatasourceAction
|
from vitrage.common.constants import DatasourceAction
|
||||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
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 EdgeProperties as EProps
|
||||||
from vitrage.common.constants import EntityCategory
|
from vitrage.common.constants import EntityCategory
|
||||||
from vitrage.common.constants import VertexProperties as VProps
|
from vitrage.common.constants import VertexProperties as VProps
|
||||||
from vitrage.datasources.cinder.volume.transformer import \
|
from vitrage.datasources.cinder.volume.transformer import \
|
||||||
CINDER_VOLUME_DATASOURCE
|
CINDER_VOLUME_DATASOURCE
|
||||||
|
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
|
||||||
from vitrage.datasources.nagios.properties import NagiosProperties
|
from vitrage.datasources.nagios.properties import NagiosProperties
|
||||||
from vitrage.datasources.nagios.properties import NagiosTestStatus
|
from vitrage.datasources.nagios.properties import NagiosTestStatus
|
||||||
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
|
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.host import NOVA_HOST_DATASOURCE
|
||||||
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
|
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
|
||||||
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
|
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
|
||||||
|
from vitrage.evaluator.actions.evaluator_event_transformer \
|
||||||
|
import VITRAGE_DATASOURCE
|
||||||
from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
|
from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
|
||||||
from vitrage.evaluator.scenario_repository import ScenarioRepository
|
from vitrage.evaluator.scenario_repository import ScenarioRepository
|
||||||
from vitrage.graph import create_edge
|
from vitrage.graph import create_edge
|
||||||
@ -80,7 +84,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
processor.entity_graph)
|
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')
|
'host should be AVAILABLE when starting')
|
||||||
|
|
||||||
# generate nagios alarm to trigger template scenario
|
# 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,
|
host_v = self.get_host_after_event(event_queue, warning_test,
|
||||||
processor, _TARGET_HOST)
|
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')
|
'host should be SUBOPTIMAL with warning alarm')
|
||||||
|
|
||||||
# next disable the alarm
|
# next disable the alarm
|
||||||
warning_test['status'] = 'OK'
|
warning_test['status'] = 'OK'
|
||||||
host_v = self.get_host_after_event(event_queue, warning_test,
|
host_v = self.get_host_after_event(event_queue, warning_test,
|
||||||
processor, _TARGET_HOST)
|
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')
|
'host should be AVAILABLE when alarm disabled')
|
||||||
|
|
||||||
def test_overlapping_deduced_state_1(self):
|
def test_overlapping_deduced_state_1(self):
|
||||||
@ -109,7 +113,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
processor.entity_graph)
|
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')
|
'host should be AVAILABLE when starting')
|
||||||
|
|
||||||
# generate nagios alarm to trigger
|
# generate nagios alarm to trigger
|
||||||
@ -120,7 +124,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
|
|
||||||
host_v = self.get_host_after_event(event_queue, warning_test,
|
host_v = self.get_host_after_event(event_queue, warning_test,
|
||||||
processor, _TARGET_HOST)
|
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')
|
'host should be SUBOPTIMAL with warning alarm')
|
||||||
|
|
||||||
# generate CRITICAL nagios alarm to trigger
|
# generate CRITICAL nagios alarm to trigger
|
||||||
@ -131,21 +135,21 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
|
|
||||||
host_v = self.get_host_after_event(event_queue, critical_test,
|
host_v = self.get_host_after_event(event_queue, critical_test,
|
||||||
processor, _TARGET_HOST)
|
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')
|
'host should be ERROR with critical alarm')
|
||||||
|
|
||||||
# next disable the critical alarm
|
# next disable the critical alarm
|
||||||
critical_test['status'] = 'OK'
|
critical_test['status'] = 'OK'
|
||||||
host_v = self.get_host_after_event(event_queue, critical_test,
|
host_v = self.get_host_after_event(event_queue, critical_test,
|
||||||
processor, _TARGET_HOST)
|
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')
|
'host should be SUBOPTIMAL with only warning alarm')
|
||||||
|
|
||||||
# next disable the alarm
|
# next disable the alarm
|
||||||
warning_test['status'] = 'OK'
|
warning_test['status'] = 'OK'
|
||||||
host_v = self.get_host_after_event(event_queue, warning_test,
|
host_v = self.get_host_after_event(event_queue, warning_test,
|
||||||
processor, _TARGET_HOST)
|
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')
|
'host should be AVAILABLE after alarm disabled')
|
||||||
|
|
||||||
def test_overlapping_deduced_state_2(self):
|
def test_overlapping_deduced_state_2(self):
|
||||||
@ -156,7 +160,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
processor.entity_graph)
|
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')
|
'host should be AVAILABLE when starting')
|
||||||
|
|
||||||
# generate CRITICAL nagios alarm to trigger
|
# generate CRITICAL nagios alarm to trigger
|
||||||
@ -167,7 +171,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
|
|
||||||
host_v = self.get_host_after_event(event_queue, critical_test,
|
host_v = self.get_host_after_event(event_queue, critical_test,
|
||||||
processor, _TARGET_HOST)
|
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')
|
'host should be ERROR with critical alarm')
|
||||||
|
|
||||||
# generate WARNING nagios alarm to trigger
|
# generate WARNING nagios alarm to trigger
|
||||||
@ -178,14 +182,14 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
|
|
||||||
host_v = self.get_host_after_event(event_queue, warning_test,
|
host_v = self.get_host_after_event(event_queue, warning_test,
|
||||||
processor, _TARGET_HOST)
|
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')
|
'host should be ERROR with critical alarm')
|
||||||
|
|
||||||
# next disable the critical alarm
|
# next disable the critical alarm
|
||||||
critical_test['status'] = 'OK'
|
critical_test['status'] = 'OK'
|
||||||
host_v = self.get_host_after_event(event_queue, critical_test,
|
host_v = self.get_host_after_event(event_queue, critical_test,
|
||||||
processor, _TARGET_HOST)
|
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')
|
'host should be SUBOPTIMAL with only warning alarm')
|
||||||
|
|
||||||
def test_deduced_alarm(self):
|
def test_deduced_alarm(self):
|
||||||
@ -196,7 +200,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
processor.entity_graph)
|
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')
|
'host should be AVAILABLE when starting')
|
||||||
|
|
||||||
# generate CRITICAL nagios alarm to trigger
|
# generate CRITICAL nagios alarm to trigger
|
||||||
@ -342,8 +346,8 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
"""Handles a simple not operator use case
|
"""Handles a simple not operator use case
|
||||||
|
|
||||||
We have created the following template: if there is a neutron.port that
|
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
|
doesn't have a nagios alarm of vitrage_type PORT_PROBLEM on it, then
|
||||||
deduced alarm on the port called simple_port_deduced_alarm.
|
raise a deduced alarm on the port called simple_port_deduced_alarm.
|
||||||
The test has 5 steps in it:
|
The test has 5 steps in it:
|
||||||
1. create neutron.network and neutron.port and check that the
|
1. create neutron.network and neutron.port and check that the
|
||||||
simple_port_deduced_alarm is raised on the neutron.port because it
|
simple_port_deduced_alarm is raised on the neutron.port because it
|
||||||
@ -377,8 +381,8 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
|
|
||||||
# find instances
|
# find instances
|
||||||
query = {
|
query = {
|
||||||
VProps.CATEGORY: 'RESOURCE',
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
|
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
|
||||||
}
|
}
|
||||||
instance_ver = entity_graph.get_vertices(vertex_attr_filter=query)[0]
|
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',
|
'updated_at': '2015-12-01T12:46:41Z',
|
||||||
'status': 'active',
|
'status': 'active',
|
||||||
'id': '12345',
|
'id': '12345',
|
||||||
'vitrage_entity_type': 'neutron.network',
|
DSProps.ENTITY_TYPE: NEUTRON_NETWORK_DATASOURCE,
|
||||||
'vitrage_datasource_action': 'snapshot',
|
DSProps.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT,
|
||||||
'vitrage_sample_date': '2015-12-01T12:46:41Z',
|
DSProps.SAMPLE_DATE: '2015-12-01T12:46:41Z',
|
||||||
}
|
}
|
||||||
|
|
||||||
# update port
|
# update port
|
||||||
@ -401,9 +405,9 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
'updated_at': '2015-12-01T12:46:41Z',
|
'updated_at': '2015-12-01T12:46:41Z',
|
||||||
'status': 'active',
|
'status': 'active',
|
||||||
'id': '54321',
|
'id': '54321',
|
||||||
'vitrage_entity_type': 'neutron.port',
|
DSProps.ENTITY_TYPE: NEUTRON_PORT_DATASOURCE,
|
||||||
'vitrage_datasource_action': 'snapshot',
|
DSProps.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT,
|
||||||
'vitrage_sample_date': '2015-12-01T12:46:41Z',
|
DSProps.SAMPLE_DATE: '2015-12-01T12:46:41Z',
|
||||||
'network_id': '12345',
|
'network_id': '12345',
|
||||||
'device_id': instance_ver.get(VProps.ID),
|
'device_id': instance_ver.get(VProps.ID),
|
||||||
'device_owner': 'compute:nova',
|
'device_owner': 'compute:nova',
|
||||||
@ -413,12 +417,13 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
processor.process_event(network_event)
|
processor.process_event(network_event)
|
||||||
processor.process_event(port_event)
|
processor.process_event(port_event)
|
||||||
port_vertex = entity_graph.get_vertices(
|
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():
|
while not event_queue.empty():
|
||||||
processor.process_event(event_queue.get())
|
processor.process_event(event_queue.get())
|
||||||
|
|
||||||
# test asserts
|
# test asserts
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM}
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}
|
||||||
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(num_orig_vertices + num_added_vertices +
|
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,
|
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges,
|
||||||
entity_graph.num_edges())
|
entity_graph.num_edges())
|
||||||
self.assertEqual(1, len(port_neighbors))
|
self.assertEqual(1, len(port_neighbors))
|
||||||
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(port_neighbors[0][VProps.NAME],
|
||||||
'simple_port_deduced_alarm')
|
'simple_port_deduced_alarm')
|
||||||
|
|
||||||
@ -454,35 +460,41 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
||||||
num_nagios_alarm_edges, entity_graph.num_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,
|
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(port_neighbors))
|
self.assertEqual(1, len(port_neighbors))
|
||||||
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(port_neighbors[0][VProps.NAME],
|
||||||
'simple_port_deduced_alarm')
|
'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,
|
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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.NAME], 'PORT_PROBLEM')
|
||||||
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
|
||||||
self.assertEqual(port_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# ################### STEP 3 ###################
|
# ################### STEP 3 ###################
|
||||||
# disable connection between port and alarm
|
# 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 = \
|
nagios_vertex = \
|
||||||
processor.entity_graph.get_vertices(vertex_attr_filter=query)[0]
|
processor.entity_graph.get_vertices(vertex_attr_filter=query)[0]
|
||||||
nagios_edge = [e for e in processor.entity_graph.get_edges(
|
nagios_edge = [e for e in processor.entity_graph.get_edges(
|
||||||
nagios_vertex.vertex_id)][0]
|
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)
|
processor.entity_graph.update_edge(nagios_edge)
|
||||||
while not event_queue.empty():
|
while not event_queue.empty():
|
||||||
processor.process_event(event_queue.get())
|
processor.process_event(event_queue.get())
|
||||||
@ -498,40 +510,47 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
||||||
num_nagios_alarm_edges + 1, entity_graph.num_edges())
|
num_nagios_alarm_edges + 1, entity_graph.num_edges())
|
||||||
|
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'vitrage',
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: True}
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
is_deleted = True
|
VProps.VITRAGE_IS_DELETED: True}
|
||||||
|
vitrage_is_deleted = True
|
||||||
for counter in range(0, 1):
|
for counter in range(0, 1):
|
||||||
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(port_neighbors))
|
self.assertEqual(1, len(port_neighbors))
|
||||||
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(port_neighbors[0][VProps.NAME],
|
||||||
'simple_port_deduced_alarm')
|
'simple_port_deduced_alarm')
|
||||||
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], is_deleted)
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED],
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
vitrage_is_deleted)
|
||||||
VProps.TYPE: 'vitrage', VProps.IS_DELETED: False}
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
is_deleted = False
|
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,
|
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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.NAME], 'PORT_PROBLEM')
|
||||||
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
|
||||||
|
|
||||||
# ################### STEP 4 ###################
|
# ################### STEP 4 ###################
|
||||||
# enable connection between port and alarm
|
# 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 = \
|
nagios_vertex = \
|
||||||
processor.entity_graph.get_vertices(vertex_attr_filter=query)[0]
|
processor.entity_graph.get_vertices(vertex_attr_filter=query)[0]
|
||||||
nagios_edge = [e for e in processor.entity_graph.get_edges(
|
nagios_edge = [e for e in processor.entity_graph.get_edges(
|
||||||
nagios_vertex.vertex_id)][0]
|
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)
|
processor.entity_graph.update_edge(nagios_edge)
|
||||||
while not event_queue.empty():
|
while not event_queue.empty():
|
||||||
processor.process_event(event_queue.get())
|
processor.process_event(event_queue.get())
|
||||||
@ -547,35 +566,41 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
||||||
num_nagios_alarm_edges + 1, entity_graph.num_edges())
|
num_nagios_alarm_edges + 1, entity_graph.num_edges())
|
||||||
|
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM, VProps.TYPE: 'vitrage',
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: True}
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
is_deleted = True
|
VProps.VITRAGE_IS_DELETED: True}
|
||||||
|
vitrage_is_deleted = True
|
||||||
for counter in range(0, 1):
|
for counter in range(0, 1):
|
||||||
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(2, len(port_neighbors))
|
self.assertEqual(2, len(port_neighbors))
|
||||||
for in_counter in range(0, 1):
|
for in_counter in range(0, 1):
|
||||||
self.assertEqual(port_neighbors[in_counter][VProps.CATEGORY],
|
self.assertEqual(
|
||||||
|
port_neighbors[in_counter][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
EntityCategory.ALARM)
|
||||||
self.assertEqual(port_neighbors[in_counter][VProps.TYPE],
|
self.assertEqual(port_neighbors[in_counter]
|
||||||
'vitrage')
|
[VProps.VITRAGE_TYPE], VITRAGE_DATASOURCE)
|
||||||
self.assertEqual(port_neighbors[in_counter][VProps.NAME],
|
self.assertEqual(port_neighbors[in_counter][VProps.NAME],
|
||||||
'simple_port_deduced_alarm')
|
'simple_port_deduced_alarm')
|
||||||
self.assertEqual(
|
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,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage', VProps.IS_DELETED: False}
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
is_deleted = False
|
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,
|
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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.NAME], 'PORT_PROBLEM')
|
||||||
self.assertEqual(port_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
|
||||||
|
|
||||||
# ################### STEP 5 ###################
|
# ################### STEP 5 ###################
|
||||||
# disable PORT_PROBLEM alarm
|
# disable PORT_PROBLEM alarm
|
||||||
@ -591,50 +616,57 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
# new alarm doesn't update same deleted alarm.
|
# new alarm doesn't update same deleted alarm.
|
||||||
# Instead, it keeps the old one and creates a new one
|
# Instead, it keeps the old one and creates a new one
|
||||||
# Since this is the second test, there are already two
|
# Since this is the second test, there are already two
|
||||||
# alarms of this type
|
# alarms of this vitrage_type
|
||||||
2,
|
2,
|
||||||
entity_graph.num_vertices())
|
entity_graph.num_vertices())
|
||||||
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
||||||
num_nagios_alarm_edges + 2, entity_graph.num_edges())
|
num_nagios_alarm_edges + 2, entity_graph.num_edges())
|
||||||
|
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage', VProps.IS_DELETED: True}
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
is_deleted = True
|
VProps.VITRAGE_IS_DELETED: True}
|
||||||
|
vitrage_is_deleted = True
|
||||||
for counter in range(0, 1):
|
for counter in range(0, 1):
|
||||||
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(2, len(port_neighbors))
|
self.assertEqual(2, len(port_neighbors))
|
||||||
for in_counter in range(0, 1):
|
for in_counter in range(0, 1):
|
||||||
self.assertEqual(port_neighbors[in_counter][VProps.CATEGORY],
|
self.assertEqual(
|
||||||
|
port_neighbors[in_counter][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
EntityCategory.ALARM)
|
||||||
self.assertEqual(port_neighbors[in_counter][VProps.TYPE],
|
self.assertEqual(port_neighbors[in_counter]
|
||||||
'vitrage')
|
[VProps.VITRAGE_TYPE], VITRAGE_DATASOURCE)
|
||||||
self.assertEqual(port_neighbors[in_counter][VProps.NAME],
|
self.assertEqual(port_neighbors[in_counter][VProps.NAME],
|
||||||
'simple_port_deduced_alarm')
|
'simple_port_deduced_alarm')
|
||||||
self.assertEqual(
|
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,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage', VProps.IS_DELETED: False}
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
is_deleted = False
|
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,
|
port_neighbors = entity_graph.neighbors(port_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(port_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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.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):
|
def test_complex_not_operator_deduced_alarm(self):
|
||||||
"""Handles a complex not operator use case
|
"""Handles a complex not operator use case
|
||||||
|
|
||||||
We have created the following template: if there is a openstack.cluster
|
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
|
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
|
there is no nagios alarm of vitrage_type CLUSTER_PROBLEM on the cluster
|
||||||
nagios alarm of type NETWORK_PROBLEM on the neutron.network, then raise
|
and no nagios alarm of vitrage_type NETWORK_PROBLEM on the
|
||||||
a deduced alarm on the nova.zone called complex_zone_deduced_alarm.
|
neutron.network, then raise a deduced alarm on the nova.zone called
|
||||||
|
complex_zone_deduced_alarm.
|
||||||
The test has 3 steps in it:
|
The test has 3 steps in it:
|
||||||
1. create a neutron.network and connect it to a zone, and check that
|
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
|
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',
|
'updated_at': '2015-12-01T12:46:41Z',
|
||||||
'status': 'active',
|
'status': 'active',
|
||||||
'id': '12345',
|
'id': '12345',
|
||||||
'vitrage_entity_type': 'neutron.network',
|
DSProps.ENTITY_TYPE: NEUTRON_NETWORK_DATASOURCE,
|
||||||
'vitrage_datasource_action': 'snapshot',
|
DSProps.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT,
|
||||||
'vitrage_sample_date': '2015-12-01T12:46:41Z',
|
DSProps.SAMPLE_DATE: '2015-12-01T12:46:41Z',
|
||||||
}
|
}
|
||||||
|
|
||||||
# process events
|
# process events
|
||||||
processor.process_event(zone_event)
|
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]
|
zone_vertex = entity_graph.get_vertices(vertex_attr_filter=query)[0]
|
||||||
processor.process_event(network_event)
|
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]
|
network_vertex = entity_graph.get_vertices(vertex_attr_filter=query)[0]
|
||||||
|
|
||||||
# add edge between network and zone
|
# add edge between network and zone
|
||||||
@ -696,7 +729,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
processor.process_event(event_queue.get())
|
processor.process_event(event_queue.get())
|
||||||
|
|
||||||
# test asserts
|
# test asserts
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM}
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM}
|
||||||
zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id,
|
zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(num_orig_vertices + num_added_vertices +
|
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,
|
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges,
|
||||||
entity_graph.num_edges())
|
entity_graph.num_edges())
|
||||||
self.assertEqual(1, len(zone_neighbors))
|
self.assertEqual(1, len(zone_neighbors))
|
||||||
self.assertEqual(zone_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(zone_neighbors[0][VProps.NAME],
|
||||||
'complex_zone_deduced_alarm')
|
'complex_zone_deduced_alarm')
|
||||||
|
|
||||||
@ -732,26 +766,30 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
||||||
num_network_alarm_edges, entity_graph.num_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,
|
network_neighbors = entity_graph.neighbors(network_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(network_neighbors))
|
self.assertEqual(1, len(network_neighbors))
|
||||||
self.assertEqual(network_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(network_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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.NAME], 'NETWORK_PROBLEM')
|
||||||
self.assertEqual(network_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(network_neighbors[0][VProps.VITRAGE_IS_DELETED],
|
||||||
self.assertEqual(network_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
False)
|
||||||
|
self.assertEqual(network_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id,
|
zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(zone_neighbors))
|
self.assertEqual(1, len(zone_neighbors))
|
||||||
self.assertEqual(zone_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(zone_neighbors[0][VProps.NAME],
|
||||||
'complex_zone_deduced_alarm')
|
'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 ###################
|
# ################### STEP 3 ###################
|
||||||
# delete NETWORK_PROBLEM alarm
|
# delete NETWORK_PROBLEM alarm
|
||||||
@ -770,35 +808,38 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges +
|
||||||
num_network_alarm_edges + 1, entity_graph.num_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,
|
network_neighbors = entity_graph.neighbors(network_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(network_neighbors))
|
self.assertEqual(1, len(network_neighbors))
|
||||||
self.assertEqual(network_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(network_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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.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,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: True}
|
VProps.VITRAGE_IS_DELETED: True}
|
||||||
is_deleted = True
|
vitrage_is_deleted = True
|
||||||
# Alarm History is saved. We are testing the deleted alarm and
|
# Alarm History is saved. We are testing the deleted alarm and
|
||||||
# then we are testing the live alarm
|
# then we are testing the live alarm
|
||||||
for counter in range(0, 1):
|
for counter in range(0, 1):
|
||||||
zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id,
|
zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(zone_neighbors))
|
self.assertEqual(1, len(zone_neighbors))
|
||||||
self.assertEqual(zone_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(zone_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(zone_neighbors[0][VProps.NAME],
|
||||||
'complex_zone_deduced_alarm')
|
'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,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: False}
|
VProps.VITRAGE_IS_DELETED: False}
|
||||||
is_deleted = False
|
vitrage_is_deleted = False
|
||||||
|
|
||||||
def test_ha(self):
|
def test_ha(self):
|
||||||
event_queue, processor, evaluator = self._init_system()
|
event_queue, processor, evaluator = self._init_system()
|
||||||
@ -806,15 +847,15 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
|
|
||||||
# find host
|
# find host
|
||||||
query = {
|
query = {
|
||||||
VProps.CATEGORY: 'RESOURCE',
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: NOVA_HOST_DATASOURCE
|
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE
|
||||||
}
|
}
|
||||||
hosts = entity_graph.get_vertices(vertex_attr_filter=query)
|
hosts = entity_graph.get_vertices(vertex_attr_filter=query)
|
||||||
|
|
||||||
# find instances on host
|
# find instances on host
|
||||||
query = {
|
query = {
|
||||||
VProps.CATEGORY: 'RESOURCE',
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: NOVA_INSTANCE_DATASOURCE
|
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE
|
||||||
}
|
}
|
||||||
instances = entity_graph.neighbors(hosts[0].vertex_id,
|
instances = entity_graph.neighbors(hosts[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
@ -847,29 +888,34 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
self.assertEqual(num_orig_edges + num_volumes + num_deduced_alarms,
|
self.assertEqual(num_orig_edges + num_volumes + num_deduced_alarms,
|
||||||
entity_graph.num_edges())
|
entity_graph.num_edges())
|
||||||
|
|
||||||
query = {VProps.CATEGORY: EntityCategory.RESOURCE,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: CINDER_VOLUME_DATASOURCE}
|
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE}
|
||||||
instance_neighbors = entity_graph.neighbors(instances[0].vertex_id,
|
instance_neighbors = entity_graph.neighbors(instances[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(instance_neighbors))
|
self.assertEqual(1, len(instance_neighbors))
|
||||||
self.assertEqual(instance_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.RESOURCE)
|
EntityCategory.RESOURCE)
|
||||||
self.assertEqual(instance_neighbors[0][VProps.TYPE],
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE],
|
||||||
CINDER_VOLUME_DATASOURCE)
|
CINDER_VOLUME_DATASOURCE)
|
||||||
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-1')
|
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-1')
|
||||||
self.assertEqual(instance_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED],
|
||||||
self.assertEqual(instance_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
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,
|
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(host_neighbors[0][VProps.NAME],
|
||||||
'ha_warning_deduced_alarm')
|
'ha_warning_deduced_alarm')
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# ################### STEP 2 ###################
|
# ################### STEP 2 ###################
|
||||||
# Add cinder volume 2
|
# Add cinder volume 2
|
||||||
@ -894,48 +940,54 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
entity_graph.num_edges())
|
entity_graph.num_edges())
|
||||||
|
|
||||||
# check instance neighbors
|
# check instance neighbors
|
||||||
query = {VProps.CATEGORY: EntityCategory.RESOURCE,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: CINDER_VOLUME_DATASOURCE}
|
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE}
|
||||||
instance_neighbors = entity_graph.neighbors(instances[1].vertex_id,
|
instance_neighbors = entity_graph.neighbors(instances[1].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(instance_neighbors))
|
self.assertEqual(1, len(instance_neighbors))
|
||||||
self.assertEqual(instance_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.RESOURCE)
|
EntityCategory.RESOURCE)
|
||||||
self.assertEqual(instance_neighbors[0][VProps.TYPE],
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE],
|
||||||
CINDER_VOLUME_DATASOURCE)
|
CINDER_VOLUME_DATASOURCE)
|
||||||
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-2')
|
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-2')
|
||||||
self.assertEqual(instance_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED],
|
||||||
self.assertEqual(instance_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
False)
|
||||||
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# check ha_error_deduced_alarm
|
# check ha_error_deduced_alarm
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage',
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.NAME: 'ha_error_deduced_alarm'}
|
VProps.NAME: 'ha_error_deduced_alarm'}
|
||||||
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(host_neighbors))
|
self.assertEqual(1, len(host_neighbors))
|
||||||
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(host_neighbors[0][VProps.NAME],
|
||||||
'ha_error_deduced_alarm')
|
'ha_error_deduced_alarm')
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# check ha_warning_deduced_alarm
|
# check ha_warning_deduced_alarm
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage',
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.NAME: 'ha_warning_deduced_alarm'}
|
VProps.NAME: 'ha_warning_deduced_alarm'}
|
||||||
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(host_neighbors))
|
self.assertEqual(1, len(host_neighbors))
|
||||||
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(host_neighbors[0][VProps.NAME],
|
||||||
'ha_warning_deduced_alarm')
|
'ha_warning_deduced_alarm')
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# ################### STEP 3 ###################
|
# ################### STEP 3 ###################
|
||||||
# Remove Cinder Volume 2
|
# Remove Cinder Volume 2
|
||||||
@ -959,65 +1011,73 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
self.assertEqual(num_orig_edges + num_volumes + num_deduced_alarms + 1,
|
self.assertEqual(num_orig_edges + num_volumes + num_deduced_alarms + 1,
|
||||||
entity_graph.num_edges())
|
entity_graph.num_edges())
|
||||||
|
|
||||||
query = {VProps.CATEGORY: EntityCategory.RESOURCE,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: CINDER_VOLUME_DATASOURCE}
|
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE}
|
||||||
instance_neighbors = entity_graph.neighbors(instances[1].vertex_id,
|
instance_neighbors = entity_graph.neighbors(instances[1].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(instance_neighbors))
|
self.assertEqual(1, len(instance_neighbors))
|
||||||
self.assertEqual(instance_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.RESOURCE)
|
EntityCategory.RESOURCE)
|
||||||
self.assertEqual(instance_neighbors[0][VProps.TYPE],
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE],
|
||||||
CINDER_VOLUME_DATASOURCE)
|
CINDER_VOLUME_DATASOURCE)
|
||||||
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-2')
|
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-2')
|
||||||
self.assertEqual(instance_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED],
|
||||||
self.assertEqual(instance_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
False)
|
||||||
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# check ha_error_deduced_alarm
|
# check ha_error_deduced_alarm
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage',
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.NAME: 'ha_error_deduced_alarm'}
|
VProps.NAME: 'ha_error_deduced_alarm'}
|
||||||
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(host_neighbors))
|
self.assertEqual(1, len(host_neighbors))
|
||||||
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(host_neighbors[0][VProps.NAME],
|
||||||
'ha_error_deduced_alarm')
|
'ha_error_deduced_alarm')
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# check new ha_warning_deduced_alarm
|
# check new ha_warning_deduced_alarm
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage',
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.NAME: 'ha_warning_deduced_alarm',
|
VProps.NAME: 'ha_warning_deduced_alarm',
|
||||||
VProps.IS_DELETED: False}
|
VProps.VITRAGE_IS_DELETED: False}
|
||||||
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(host_neighbors))
|
self.assertEqual(1, len(host_neighbors))
|
||||||
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(host_neighbors[0][VProps.NAME],
|
||||||
'ha_warning_deduced_alarm')
|
'ha_warning_deduced_alarm')
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], False)
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# check old deleted ha_warning_deduced_alarm
|
# check old deleted ha_warning_deduced_alarm
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage',
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.NAME: 'ha_warning_deduced_alarm',
|
VProps.NAME: 'ha_warning_deduced_alarm',
|
||||||
VProps.IS_DELETED: True}
|
VProps.VITRAGE_IS_DELETED: True}
|
||||||
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(host_neighbors))
|
self.assertEqual(1, len(host_neighbors))
|
||||||
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(host_neighbors[0][VProps.NAME],
|
||||||
'ha_warning_deduced_alarm')
|
'ha_warning_deduced_alarm')
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# ################### STEP 4 ###################
|
# ################### STEP 4 ###################
|
||||||
# Remove Cinder Volume 1
|
# Remove Cinder Volume 1
|
||||||
@ -1041,57 +1101,65 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
self.assertEqual(num_orig_edges + num_volumes + num_deduced_alarms + 1,
|
self.assertEqual(num_orig_edges + num_volumes + num_deduced_alarms + 1,
|
||||||
entity_graph.num_edges())
|
entity_graph.num_edges())
|
||||||
|
|
||||||
query = {VProps.CATEGORY: EntityCategory.RESOURCE,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.TYPE: CINDER_VOLUME_DATASOURCE}
|
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE}
|
||||||
instance_neighbors = entity_graph.neighbors(instances[0].vertex_id,
|
instance_neighbors = entity_graph.neighbors(instances[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(instance_neighbors))
|
self.assertEqual(1, len(instance_neighbors))
|
||||||
self.assertEqual(instance_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.RESOURCE)
|
EntityCategory.RESOURCE)
|
||||||
self.assertEqual(instance_neighbors[0][VProps.TYPE],
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE],
|
||||||
CINDER_VOLUME_DATASOURCE)
|
CINDER_VOLUME_DATASOURCE)
|
||||||
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-1')
|
self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-1')
|
||||||
self.assertEqual(instance_neighbors[0][VProps.IS_DELETED], False)
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED],
|
||||||
self.assertEqual(instance_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
False)
|
||||||
|
self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# check ha_error_deduced_alarm
|
# check ha_error_deduced_alarm
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage',
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.NAME: 'ha_error_deduced_alarm'}
|
VProps.NAME: 'ha_error_deduced_alarm'}
|
||||||
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(1, len(host_neighbors))
|
self.assertEqual(1, len(host_neighbors))
|
||||||
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(host_neighbors[0][VProps.NAME],
|
||||||
'ha_error_deduced_alarm')
|
'ha_error_deduced_alarm')
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
# check old ha_warning_deduced_alarm
|
# check old ha_warning_deduced_alarm
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.TYPE: 'vitrage',
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.NAME: 'ha_warning_deduced_alarm'}
|
VProps.NAME: 'ha_warning_deduced_alarm'}
|
||||||
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
host_neighbors = entity_graph.neighbors(hosts[0].vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(2, len(host_neighbors))
|
self.assertEqual(2, len(host_neighbors))
|
||||||
|
|
||||||
self.assertEqual(host_neighbors[0][VProps.CATEGORY],
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY],
|
||||||
EntityCategory.ALARM)
|
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],
|
self.assertEqual(host_neighbors[0][VProps.NAME],
|
||||||
'ha_warning_deduced_alarm')
|
'ha_warning_deduced_alarm')
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_DELETED], True)
|
self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True)
|
||||||
self.assertEqual(host_neighbors[0][VProps.IS_PLACEHOLDER], False)
|
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)
|
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],
|
self.assertEqual(host_neighbors[1][VProps.NAME],
|
||||||
'ha_warning_deduced_alarm')
|
'ha_warning_deduced_alarm')
|
||||||
self.assertEqual(host_neighbors[1][VProps.IS_DELETED], True)
|
self.assertEqual(host_neighbors[1][VProps.VITRAGE_IS_DELETED], True)
|
||||||
self.assertEqual(host_neighbors[1][VProps.IS_PLACEHOLDER], False)
|
self.assertEqual(host_neighbors[1][VProps.VITRAGE_IS_PLACEHOLDER],
|
||||||
|
False)
|
||||||
|
|
||||||
def test_simple_or_operator_deduced_alarm(self):
|
def test_simple_or_operator_deduced_alarm(self):
|
||||||
"""Handles a simple not operator use case
|
"""Handles a simple not operator use case
|
||||||
@ -1107,7 +1175,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
processor.entity_graph)
|
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')
|
'host should be AVAILABLE when starting')
|
||||||
|
|
||||||
# generate nagios alarm1 to trigger, raise alarm3
|
# generate nagios alarm1 to trigger, raise alarm3
|
||||||
@ -1174,7 +1242,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
_TARGET_HOST,
|
_TARGET_HOST,
|
||||||
entity_graph)
|
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')
|
'host should be AVAILABLE when starting')
|
||||||
|
|
||||||
# generate nagios alarm_a to trigger
|
# generate nagios alarm_a to trigger
|
||||||
@ -1231,14 +1299,14 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
|||||||
alarms = self._get_alarms_on_host(host_v, entity_graph)
|
alarms = self._get_alarms_on_host(host_v, entity_graph)
|
||||||
self.assertEqual(3, len(alarms))
|
self.assertEqual(3, len(alarms))
|
||||||
|
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: True}
|
VProps.VITRAGE_IS_DELETED: True}
|
||||||
deleted_alarms = entity_graph.neighbors(host_v.vertex_id,
|
deleted_alarms = entity_graph.neighbors(host_v.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(num_orig_vertices + len(deleted_alarms) + 3,
|
self.assertEqual(num_orig_vertices + len(deleted_alarms) + 3,
|
||||||
entity_graph.num_vertices())
|
entity_graph.num_vertices())
|
||||||
|
|
||||||
query = {VProps.IS_DELETED: True}
|
query = {VProps.VITRAGE_IS_DELETED: True}
|
||||||
deleted_edges = entity_graph.neighbors(host_v.vertex_id,
|
deleted_edges = entity_graph.neighbors(host_v.vertex_id,
|
||||||
edge_attr_filter=query)
|
edge_attr_filter=query)
|
||||||
self.assertEqual(num_orig_edges + len(deleted_edges) + 3,
|
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)
|
alarms = self._get_alarms_on_host(host_v, entity_graph)
|
||||||
self.assertEqual(1, len(alarms))
|
self.assertEqual(1, len(alarms))
|
||||||
|
|
||||||
query = {VProps.CATEGORY: EntityCategory.ALARM,
|
query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: True}
|
VProps.VITRAGE_IS_DELETED: True}
|
||||||
deleted_alarms = entity_graph.neighbors(host_v.vertex_id,
|
deleted_alarms = entity_graph.neighbors(host_v.vertex_id,
|
||||||
vertex_attr_filter=query)
|
vertex_attr_filter=query)
|
||||||
self.assertEqual(num_orig_vertices + len(deleted_alarms) + 1,
|
self.assertEqual(num_orig_vertices + len(deleted_alarms) + 1,
|
||||||
entity_graph.num_vertices())
|
entity_graph.num_vertices())
|
||||||
|
|
||||||
query = {VProps.IS_DELETED: True}
|
query = {VProps.VITRAGE_IS_DELETED: True}
|
||||||
deleted_edges = entity_graph.neighbors(host_v.vertex_id,
|
deleted_edges = entity_graph.neighbors(host_v.vertex_id,
|
||||||
edge_attr_filter=query)
|
edge_attr_filter=query)
|
||||||
self.assertEqual(num_orig_edges + len(deleted_edges) + 1,
|
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,
|
def _get_entity_from_graph(entity_type, entity_name,
|
||||||
entity_id,
|
entity_id,
|
||||||
entity_graph):
|
entity_graph):
|
||||||
vertex_attrs = {VProps.TYPE: entity_type,
|
vertex_attrs = {VProps.VITRAGE_TYPE: entity_type,
|
||||||
VProps.ID: entity_id,
|
VProps.ID: entity_id,
|
||||||
VProps.NAME: entity_name}
|
VProps.NAME: entity_name}
|
||||||
vertices = entity_graph.get_vertices(vertex_attr_filter=vertex_attrs)
|
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):
|
def _get_deduced_alarms_on_host(host_v, entity_graph):
|
||||||
v_id = host_v.vertex_id
|
v_id = host_v.vertex_id
|
||||||
vertex_attrs = {VProps.NAME: 'deduced_alarm',
|
vertex_attrs = {VProps.NAME: 'deduced_alarm',
|
||||||
VProps.TYPE: 'vitrage',
|
VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE,
|
||||||
VProps.IS_DELETED: False, }
|
VProps.VITRAGE_IS_DELETED: False, }
|
||||||
return entity_graph.neighbors(v_id=v_id,
|
return entity_graph.neighbors(v_id=v_id,
|
||||||
vertex_attr_filter=vertex_attrs)
|
vertex_attr_filter=vertex_attrs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_alarms_on_host(host_v, entity_graph):
|
def _get_alarms_on_host(host_v, entity_graph):
|
||||||
v_id = host_v.vertex_id
|
v_id = host_v.vertex_id
|
||||||
vertex_attrs = {VProps.CATEGORY: EntityCategory.ALARM,
|
vertex_attrs = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
VProps.IS_DELETED: False, }
|
VProps.VITRAGE_IS_DELETED: False, }
|
||||||
return entity_graph.neighbors(v_id=v_id,
|
return entity_graph.neighbors(v_id=v_id,
|
||||||
vertex_attr_filter=vertex_attrs)
|
vertex_attr_filter=vertex_attrs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_alarm_causes(alarm_v, entity_graph):
|
def _get_alarm_causes(alarm_v, entity_graph):
|
||||||
v_id = alarm_v.vertex_id
|
v_id = alarm_v.vertex_id
|
||||||
edge_attrs = {EProps.RELATIONSHIP_TYPE: "causes",
|
edge_attrs = {EProps.RELATIONSHIP_TYPE: EdgeLabel.CAUSES,
|
||||||
EProps.IS_DELETED: False, }
|
EProps.VITRAGE_IS_DELETED: False, }
|
||||||
return entity_graph.neighbors(v_id=v_id, edge_attr_filter=edge_attrs)
|
return entity_graph.neighbors(v_id=v_id, edge_attr_filter=edge_attrs)
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
|
|
||||||
"""Methods for generating driver events
|
"""Methods for generating driver events
|
||||||
|
|
||||||
For each type of entity, need to supply configuration files that specify (a
|
For each vitrage_type of entity, need to supply configuration files that
|
||||||
regex of) what can be returned, which will be used to generate driver events
|
specify (a regex of) what can be returned, which will be used to generate
|
||||||
|
driver events
|
||||||
|
|
||||||
usage example:
|
usage example:
|
||||||
test_entity_spec_list = [
|
test_entity_spec_list = [
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"vitrage_entity_type": "nova.host",
|
"vitrage_entity_type": "nova.host",
|
||||||
"zone": "zone0",
|
"zone": "zone0",
|
||||||
"id": "compute-0-0.local",
|
"id": "compute-0-0.local",
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"vitrage_id": "compute-0-0.local",
|
"vitrage_id": "compute-0-0.local",
|
||||||
"vitrage_datasource_action": "init_snapshot",
|
"vitrage_datasource_action": "init_snapshot",
|
||||||
"vitrage_sample_date": "2015-12-01T12:46:41Z"
|
"vitrage_sample_date": "2015-12-01T12:46:41Z"
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
"key_name": null,
|
"key_name": null,
|
||||||
"OS-EXT-SRV-ATTR:hypervisor_hostname": "nyakar-devstack",
|
"OS-EXT-SRV-ATTR:hypervisor_hostname": "nyakar-devstack",
|
||||||
"name": "vm2",
|
"name": "vm2",
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"created": "2015-11-25T14:18:07Z",
|
"created": "2015-11-25T14:18:07Z",
|
||||||
"tenant_id": "0683517e1e354d2ba25cba6937f44e79",
|
"tenant_id": "0683517e1e354d2ba25cba6937f44e79",
|
||||||
"os-extended-volumes:volumes_attached": [],
|
"os-extended-volumes:volumes_attached": [],
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name": "[switch|host|custom]-[1-9]",
|
"name": "[switch|host|custom]-[1-9]",
|
||||||
"id": "[1-9]{5}",
|
"id": "[1-9]{5}",
|
||||||
"static_id": "[shc][1-9]",
|
"static_id": "[shc][1-9]",
|
||||||
"type": "[switch|nova.host|custom]",
|
"vitrage_type": "[switch|nova.host|custom]",
|
||||||
"state": "available",
|
"state": "available",
|
||||||
"vitrage_datasource_action": "snapshot",
|
"vitrage_datasource_action": "snapshot",
|
||||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"zoneName": "zone0",
|
"zoneName": "zone0",
|
||||||
"id": "zone0",
|
"id": "zone0",
|
||||||
"vitrage_id": "zone0",
|
"vitrage_id": "zone0",
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"zoneState": {
|
"zoneState": {
|
||||||
"available": "True"
|
"available": "True"
|
||||||
}
|
}
|
||||||
|
@ -18,18 +18,18 @@
|
|||||||
"vitrage_sample_date": "2016-11-29T06:31:50.094836",
|
"vitrage_sample_date": "2016-11-29T06:31:50.094836",
|
||||||
"graph_query_result": [
|
"graph_query_result": [
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "dwj",
|
"name": "dwj",
|
||||||
"update_timestamp": "2016-12-02 07:18:05.628479+00:00",
|
"update_timestamp": "2016-12-02 07:18:05.628479+00:00",
|
||||||
"sample_timestamp": "2016-12-02 07:18:05.628479+00:00",
|
"vitrage_sample_timestamp": "2016-12-02 07:18:05.628479+00:00",
|
||||||
"operational_state": "OK",
|
"vitrage_operational_state": "OK",
|
||||||
"aggregated_state": "ACTIVE",
|
"vitrage_aggregated_state": "ACTIVE",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"graph_index": 3,
|
"graph_index": 3,
|
||||||
"project_id": "f0895991f44044ccba8e62b201b70360",
|
"project_id": "f0895991f44044ccba8e62b201b70360",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "3dcee183-ca42-4ccb-84af-9f0196b2e160"
|
"id": "3dcee183-ca42-4ccb-84af-9f0196b2e160"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -18,18 +18,18 @@
|
|||||||
"vitrage_sample_date": "2016-11-29T06:31:50.094836",
|
"vitrage_sample_date": "2016-11-29T06:31:50.094836",
|
||||||
"graph_query_result": [
|
"graph_query_result": [
|
||||||
{
|
{
|
||||||
"category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"is_placeholder": false,
|
"vitrage_is_placeholder": false,
|
||||||
"is_deleted": false,
|
"vitrage_is_deleted": false,
|
||||||
"name": "test",
|
"name": "test",
|
||||||
"update_timestamp": "2016-12-02 07:18:05.628479+00:00",
|
"update_timestamp": "2016-12-02 07:18:05.628479+00:00",
|
||||||
"sample_timestamp": "2016-12-02 07:18:05.628479+00:00",
|
"vitrage_sample_timestamp": "2016-12-02 07:18:05.628479+00:00",
|
||||||
"operational_state": "OK",
|
"vitrage_operational_state": "OK",
|
||||||
"aggregated_state": "ACTIVE",
|
"vitrage_aggregated_state": "ACTIVE",
|
||||||
"state": "ACTIVE",
|
"state": "ACTIVE",
|
||||||
"graph_index": 3,
|
"graph_index": 3,
|
||||||
"project_id": "f0895991f44044ccba8e62b201b70360",
|
"project_id": "f0895991f44044ccba8e62b201b70360",
|
||||||
"type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"id": "3dcee183-ca42-4ccb-84af-9f0196b2e160"
|
"id": "3dcee183-ca42-4ccb-84af-9f0196b2e160"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -15,9 +15,9 @@ snmp_tree:
|
|||||||
next:
|
next:
|
||||||
name:
|
name:
|
||||||
oid: 1
|
oid: 1
|
||||||
is_deleted:
|
vitrage_is_deleted:
|
||||||
oid: 2
|
oid: 2
|
||||||
operational_severity:
|
vitrage_operational_severity:
|
||||||
oid: 3
|
oid: 3
|
||||||
ALARM_PREFIX:
|
ALARM_PREFIX:
|
||||||
oid: 2
|
oid: 2
|
||||||
|
@ -11,9 +11,9 @@ snmp_tree:
|
|||||||
next:
|
next:
|
||||||
name:
|
name:
|
||||||
oid: 1
|
oid: 1
|
||||||
is_deleted:
|
vitrage_is_deleted:
|
||||||
oid: 2
|
oid: 2
|
||||||
operational_severity:
|
vitrage_operational_severity:
|
||||||
oid: 3
|
oid: 3
|
||||||
ALARM_PREFIX:
|
ALARM_PREFIX:
|
||||||
oid: 2
|
oid: 2
|
||||||
|
@ -31,8 +31,9 @@ class AodhTransformerBaseTest(base.BaseTest):
|
|||||||
|
|
||||||
def _validate_aodh_vertex_props(self, vertex, event):
|
def _validate_aodh_vertex_props(self, vertex, event):
|
||||||
|
|
||||||
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
|
self.assertEqual(EntityCategory.ALARM, vertex[VProps.VITRAGE_CATEGORY])
|
||||||
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
|
self.assertEqual(event[DSProps.ENTITY_TYPE],
|
||||||
|
vertex[VProps.VITRAGE_TYPE])
|
||||||
self.assertEqual(event[AodhProps.NAME], vertex[VProps.NAME])
|
self.assertEqual(event[AodhProps.NAME], vertex[VProps.NAME])
|
||||||
self.assertEqual(event[AodhProps.SEVERITY], vertex[VProps.SEVERITY])
|
self.assertEqual(event[AodhProps.SEVERITY], vertex[VProps.SEVERITY])
|
||||||
self.assertEqual(event[AodhProps.DESCRIPTION],
|
self.assertEqual(event[AodhProps.DESCRIPTION],
|
||||||
@ -50,7 +51,7 @@ class AodhTransformerBaseTest(base.BaseTest):
|
|||||||
self.assertEqual(event[AodhProps.STATE_TIMESTAMP],
|
self.assertEqual(event[AodhProps.STATE_TIMESTAMP],
|
||||||
vertex[AodhProps.STATE_TIMESTAMP])
|
vertex[AodhProps.STATE_TIMESTAMP])
|
||||||
self.assertEqual(event[DSProps.SAMPLE_DATE],
|
self.assertEqual(event[DSProps.SAMPLE_DATE],
|
||||||
vertex[VProps.SAMPLE_TIMESTAMP])
|
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP])
|
||||||
|
|
||||||
event_status = event[AodhProps.STATE]
|
event_status = event[AodhProps.STATE]
|
||||||
if event_status == AodhState.OK:
|
if event_status == AodhState.OK:
|
||||||
@ -59,8 +60,8 @@ class AodhTransformerBaseTest(base.BaseTest):
|
|||||||
else:
|
else:
|
||||||
self.assertEqual(AlarmProps.ACTIVE_STATE,
|
self.assertEqual(AlarmProps.ACTIVE_STATE,
|
||||||
vertex[VProps.STATE])
|
vertex[VProps.STATE])
|
||||||
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
self.assertFalse(vertex[VProps.IS_DELETED])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
|
|
||||||
def _validate_action(self, alarm, wrapper):
|
def _validate_action(self, alarm, wrapper):
|
||||||
if DSProps.EVENT_TYPE in alarm \
|
if DSProps.EVENT_TYPE in alarm \
|
||||||
@ -94,12 +95,12 @@ class AodhTransformerBaseTest(base.BaseTest):
|
|||||||
alarm_vertex_id):
|
alarm_vertex_id):
|
||||||
# validate neighbor vertex
|
# validate neighbor vertex
|
||||||
self.assertEqual(EntityCategory.RESOURCE,
|
self.assertEqual(EntityCategory.RESOURCE,
|
||||||
alarm_neighbor.vertex[VProps.CATEGORY])
|
alarm_neighbor.vertex[VProps.VITRAGE_CATEGORY])
|
||||||
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
|
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.assertEqual(resource_id, alarm_neighbor.vertex[VProps.ID])
|
||||||
self.assertFalse(alarm_neighbor.vertex[VProps.IS_PLACEHOLDER])
|
self.assertFalse(alarm_neighbor.vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
self.assertFalse(alarm_neighbor.vertex[VProps.IS_DELETED])
|
self.assertFalse(alarm_neighbor.vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
|
|
||||||
# Validate neighbor edge
|
# Validate neighbor edge
|
||||||
edge = alarm_neighbor.edge
|
edge = alarm_neighbor.edge
|
||||||
@ -108,7 +109,7 @@ class AodhTransformerBaseTest(base.BaseTest):
|
|||||||
self.assertEqual(edge.label, EdgeLabel.ON)
|
self.assertEqual(edge.label, EdgeLabel.ON)
|
||||||
|
|
||||||
def _convert_dist_to_vertex(self, neighbor):
|
def _convert_dist_to_vertex(self, neighbor):
|
||||||
ver_id = neighbor[VProps.CATEGORY] + \
|
ver_id = neighbor[VProps.VITRAGE_CATEGORY] + \
|
||||||
TransformerBase.KEY_SEPARATOR + neighbor[VProps.TYPE] + \
|
TransformerBase.KEY_SEPARATOR + neighbor[VProps.VITRAGE_TYPE] + \
|
||||||
TransformerBase.KEY_SEPARATOR + neighbor[VProps.ID]
|
TransformerBase.KEY_SEPARATOR + neighbor[VProps.ID]
|
||||||
return Vertex(vertex_id=ver_id, properties=neighbor)
|
return Vertex(vertex_id=ver_id, properties=neighbor)
|
||||||
|
@ -65,9 +65,9 @@ class TestCinderVolumeTransformer(base.BaseTest):
|
|||||||
timestamp = datetime.datetime.utcnow()
|
timestamp = datetime.datetime.utcnow()
|
||||||
properties = {
|
properties = {
|
||||||
VProps.ID: volume_id,
|
VProps.ID: volume_id,
|
||||||
VProps.TYPE: CINDER_VOLUME_DATASOURCE,
|
VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: timestamp
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
|
||||||
}
|
}
|
||||||
transformer = self.transformers[CINDER_VOLUME_DATASOURCE]
|
transformer = self.transformers[CINDER_VOLUME_DATASOURCE]
|
||||||
|
|
||||||
@ -82,20 +82,20 @@ class TestCinderVolumeTransformer(base.BaseTest):
|
|||||||
volume_id)
|
volume_id)
|
||||||
self.assertEqual(tuple(observed_id_values), expected_id_values)
|
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)
|
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)
|
self.assertEqual(observed_type, CINDER_VOLUME_DATASOURCE)
|
||||||
|
|
||||||
observed_entity_id = placeholder.get(VProps.ID)
|
observed_entity_id = placeholder.get(VProps.ID)
|
||||||
self.assertEqual(observed_entity_id, volume_id)
|
self.assertEqual(observed_entity_id, volume_id)
|
||||||
|
|
||||||
observed_category = placeholder.get(VProps.CATEGORY)
|
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
|
||||||
self.assertEqual(observed_category, EntityCategory.RESOURCE)
|
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
|
||||||
|
|
||||||
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
|
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
|
||||||
self.assertEqual(is_placeholder, True)
|
self.assertEqual(vitrage_is_placeholder, True)
|
||||||
|
|
||||||
def test_key_values(self):
|
def test_key_values(self):
|
||||||
LOG.debug('Cinder Volume transformer test: get key values')
|
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)
|
is_update_event = tbase.is_update_event(event)
|
||||||
|
|
||||||
self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY])
|
self.assertEqual(EntityCategory.RESOURCE,
|
||||||
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
|
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'
|
id_field_path = 'volume_id' if is_update_event else 'id'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -173,7 +175,7 @@ class TestCinderVolumeTransformer(base.BaseTest):
|
|||||||
vertex[VProps.ID])
|
vertex[VProps.ID])
|
||||||
|
|
||||||
self.assertEqual(event[DSProps.SAMPLE_DATE],
|
self.assertEqual(event[DSProps.SAMPLE_DATE],
|
||||||
vertex[VProps.SAMPLE_TIMESTAMP])
|
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP])
|
||||||
|
|
||||||
name_field_path = 'display_name'
|
name_field_path = 'display_name'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -195,8 +197,8 @@ class TestCinderVolumeTransformer(base.BaseTest):
|
|||||||
tbase.extract_field_value(event, volume_type_field_path),
|
tbase.extract_field_value(event, volume_type_field_path),
|
||||||
vertex[CinderProps.VOLUME_TYPE])
|
vertex[CinderProps.VOLUME_TYPE])
|
||||||
|
|
||||||
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
self.assertFalse(vertex[VProps.IS_DELETED])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
|
|
||||||
def _validate_neighbors(self, neighbors, volume_vertex_id, event):
|
def _validate_neighbors(self, neighbors, volume_vertex_id, event):
|
||||||
instance_counter = 0
|
instance_counter = 0
|
||||||
@ -220,12 +222,13 @@ class TestCinderVolumeTransformer(base.BaseTest):
|
|||||||
volume_vertex_id):
|
volume_vertex_id):
|
||||||
# validate neighbor vertex
|
# validate neighbor vertex
|
||||||
self.assertEqual(EntityCategory.RESOURCE,
|
self.assertEqual(EntityCategory.RESOURCE,
|
||||||
instance_neighbor.vertex[VProps.CATEGORY])
|
instance_neighbor.vertex[VProps.VITRAGE_CATEGORY])
|
||||||
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
|
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.assertEqual(instance_id, instance_neighbor.vertex[VProps.ID])
|
||||||
self.assertTrue(instance_neighbor.vertex[VProps.IS_PLACEHOLDER])
|
self.assertTrue(
|
||||||
self.assertFalse(instance_neighbor.vertex[VProps.IS_DELETED])
|
instance_neighbor.vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
|
self.assertFalse(instance_neighbor.vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
|
|
||||||
# Validate neighbor edge
|
# Validate neighbor edge
|
||||||
edge = instance_neighbor.edge
|
edge = instance_neighbor.edge
|
||||||
|
@ -101,5 +101,6 @@ class TestConsistencyTransformer(base.BaseTest):
|
|||||||
vertex_id = vertex.vertex_id
|
vertex_id = vertex.vertex_id
|
||||||
self.assertIsNotNone(vertex_id)
|
self.assertIsNotNone(vertex_id)
|
||||||
|
|
||||||
sample_timestamp = vertex.get(VProps.SAMPLE_TIMESTAMP, None)
|
vitrage_sample_timestamp = \
|
||||||
self.assertIsNotNone(sample_timestamp)
|
vertex.get(VProps.VITRAGE_SAMPLE_TIMESTAMP, None)
|
||||||
|
self.assertIsNotNone(vitrage_sample_timestamp)
|
||||||
|
@ -66,9 +66,9 @@ class TestHeatStackTransformer(base.BaseTest):
|
|||||||
timestamp = datetime.datetime.utcnow()
|
timestamp = datetime.datetime.utcnow()
|
||||||
properties = {
|
properties = {
|
||||||
VProps.ID: stack_id,
|
VProps.ID: stack_id,
|
||||||
VProps.TYPE: HEAT_STACK_DATASOURCE,
|
VProps.VITRAGE_TYPE: HEAT_STACK_DATASOURCE,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: timestamp
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
|
||||||
}
|
}
|
||||||
transformer = self.transformers[HEAT_STACK_DATASOURCE]
|
transformer = self.transformers[HEAT_STACK_DATASOURCE]
|
||||||
|
|
||||||
@ -83,20 +83,20 @@ class TestHeatStackTransformer(base.BaseTest):
|
|||||||
stack_id)
|
stack_id)
|
||||||
self.assertEqual(tuple(observed_id_values), expected_id_values)
|
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)
|
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)
|
self.assertEqual(observed_type, HEAT_STACK_DATASOURCE)
|
||||||
|
|
||||||
observed_entity_id = placeholder.get(VProps.ID)
|
observed_entity_id = placeholder.get(VProps.ID)
|
||||||
self.assertEqual(observed_entity_id, stack_id)
|
self.assertEqual(observed_entity_id, stack_id)
|
||||||
|
|
||||||
observed_category = placeholder.get(VProps.CATEGORY)
|
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
|
||||||
self.assertEqual(observed_category, EntityCategory.RESOURCE)
|
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
|
||||||
|
|
||||||
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
|
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
|
||||||
self.assertEqual(is_placeholder, True)
|
self.assertEqual(vitrage_is_placeholder, True)
|
||||||
|
|
||||||
def test_key_values(self):
|
def test_key_values(self):
|
||||||
LOG.debug('Heat Stack transformer test: get key values')
|
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)
|
is_update_event = tbase.is_update_event(event)
|
||||||
|
|
||||||
self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY])
|
self.assertEqual(EntityCategory.RESOURCE,
|
||||||
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
|
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'
|
id_field_path = 'stack_identity' if is_update_event else 'id'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -174,7 +176,7 @@ class TestHeatStackTransformer(base.BaseTest):
|
|||||||
vertex[VProps.ID])
|
vertex[VProps.ID])
|
||||||
|
|
||||||
self.assertEqual(event[DSProps.SAMPLE_DATE],
|
self.assertEqual(event[DSProps.SAMPLE_DATE],
|
||||||
vertex[VProps.SAMPLE_TIMESTAMP])
|
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP])
|
||||||
|
|
||||||
name_field_path = 'stack_name'
|
name_field_path = 'stack_name'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -186,8 +188,8 @@ class TestHeatStackTransformer(base.BaseTest):
|
|||||||
tbase.extract_field_value(event, state_field_path),
|
tbase.extract_field_value(event, state_field_path),
|
||||||
vertex[VProps.STATE])
|
vertex[VProps.STATE])
|
||||||
|
|
||||||
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
self.assertFalse(vertex[VProps.IS_DELETED])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
|
|
||||||
def _validate_neighbors(self, neighbors, stack_vertex_id, event):
|
def _validate_neighbors(self, neighbors, stack_vertex_id, event):
|
||||||
self.assertEqual(2, len(neighbors))
|
self.assertEqual(2, len(neighbors))
|
||||||
@ -211,12 +213,13 @@ class TestHeatStackTransformer(base.BaseTest):
|
|||||||
stack_vertex_id):
|
stack_vertex_id):
|
||||||
# validate neighbor vertex
|
# validate neighbor vertex
|
||||||
self.assertEqual(EntityCategory.RESOURCE,
|
self.assertEqual(EntityCategory.RESOURCE,
|
||||||
instance_neighbor.vertex[VProps.CATEGORY])
|
instance_neighbor.vertex[VProps.VITRAGE_CATEGORY])
|
||||||
self.assertEqual(datasource_type,
|
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.assertEqual(instance_id, instance_neighbor.vertex[VProps.ID])
|
||||||
self.assertTrue(instance_neighbor.vertex[VProps.IS_PLACEHOLDER])
|
self.assertTrue(
|
||||||
self.assertFalse(instance_neighbor.vertex[VProps.IS_DELETED])
|
instance_neighbor.vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
|
self.assertFalse(instance_neighbor.vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
|
|
||||||
# Validate neighbor edge
|
# Validate neighbor edge
|
||||||
edge = instance_neighbor.edge
|
edge = instance_neighbor.edge
|
||||||
|
@ -100,7 +100,7 @@ class NagiosTransformerTest(base.BaseTest):
|
|||||||
neighbor = neighbors[0]
|
neighbor = neighbors[0]
|
||||||
|
|
||||||
# Right now we are support only host as a resource
|
# 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_host_neighbor(neighbors[0], alarm)
|
||||||
|
|
||||||
self._validate_action(alarm, wrapper)
|
self._validate_action(alarm, wrapper)
|
||||||
@ -117,8 +117,9 @@ class NagiosTransformerTest(base.BaseTest):
|
|||||||
|
|
||||||
def _validate_vertex(self, vertex, event):
|
def _validate_vertex(self, vertex, event):
|
||||||
|
|
||||||
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
|
self.assertEqual(EntityCategory.ALARM, vertex[VProps.VITRAGE_CATEGORY])
|
||||||
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
|
self.assertEqual(event[DSProps.ENTITY_TYPE],
|
||||||
|
vertex[VProps.VITRAGE_TYPE])
|
||||||
self.assertEqual(event[NagiosProperties.SERVICE], vertex[VProps.NAME])
|
self.assertEqual(event[NagiosProperties.SERVICE], vertex[VProps.NAME])
|
||||||
self.assertEqual(datetime_utils.change_to_utc_time_and_format(
|
self.assertEqual(datetime_utils.change_to_utc_time_and_format(
|
||||||
event[NagiosProperties.LAST_CHECK],
|
event[NagiosProperties.LAST_CHECK],
|
||||||
@ -143,8 +144,8 @@ class NagiosTransformerTest(base.BaseTest):
|
|||||||
self.assertEqual(event[NagiosProperties.STATUS_INFO],
|
self.assertEqual(event[NagiosProperties.STATUS_INFO],
|
||||||
vertex[VProps.INFO])
|
vertex[VProps.INFO])
|
||||||
|
|
||||||
self.assertFalse(vertex[VProps.IS_DELETED])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
|
|
||||||
def _validate_host_neighbor(self, neighbor, event):
|
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(NOVA_HOST_DATASOURCE, key_fields[1])
|
||||||
self.assertEqual(event[NagiosProperties.RESOURCE_NAME], key_fields[2])
|
self.assertEqual(event[NagiosProperties.RESOURCE_NAME], key_fields[2])
|
||||||
|
|
||||||
self.assertFalse(host_vertex[VProps.IS_DELETED])
|
self.assertFalse(host_vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
self.assertTrue(host_vertex[VProps.IS_PLACEHOLDER])
|
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],
|
self.assertEqual(event[NagiosProperties.RESOURCE_NAME],
|
||||||
host_vertex[VProps.ID])
|
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
|
edge = neighbor.edge
|
||||||
self.assertEqual(EdgeLabel.ON, edge.label)
|
self.assertEqual(EdgeLabel.ON, edge.label)
|
||||||
|
@ -67,9 +67,9 @@ class NovaHostTransformerTest(base.BaseTest):
|
|||||||
# Test action
|
# Test action
|
||||||
properties = {
|
properties = {
|
||||||
VProps.ID: host_name,
|
VProps.ID: host_name,
|
||||||
VProps.TYPE: NOVA_HOST_DATASOURCE,
|
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: timestamp
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
|
||||||
}
|
}
|
||||||
placeholder = \
|
placeholder = \
|
||||||
host_transformer.create_neighbor_placeholder_vertex(**properties)
|
host_transformer.create_neighbor_placeholder_vertex(**properties)
|
||||||
@ -82,20 +82,20 @@ class NovaHostTransformerTest(base.BaseTest):
|
|||||||
host_name)
|
host_name)
|
||||||
self.assertEqual(tuple(observed_id_values), expected_id_values)
|
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)
|
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)
|
self.assertEqual(observed_subtype, NOVA_HOST_DATASOURCE)
|
||||||
|
|
||||||
observed_entity_id = placeholder.get(VProps.ID)
|
observed_entity_id = placeholder.get(VProps.ID)
|
||||||
self.assertEqual(observed_entity_id, host_name)
|
self.assertEqual(observed_entity_id, host_name)
|
||||||
|
|
||||||
observed_category = placeholder.get(VProps.CATEGORY)
|
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
|
||||||
self.assertEqual(observed_category, EntityCategory.RESOURCE)
|
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
|
||||||
|
|
||||||
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
|
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
|
||||||
self.assertEqual(is_placeholder, True)
|
self.assertEqual(vitrage_is_placeholder, True)
|
||||||
|
|
||||||
def test_key_values(self):
|
def test_key_values(self):
|
||||||
|
|
||||||
@ -149,9 +149,9 @@ class NovaHostTransformerTest(base.BaseTest):
|
|||||||
zt = self.transformers[NOVA_ZONE_DATASOURCE]
|
zt = self.transformers[NOVA_ZONE_DATASOURCE]
|
||||||
properties = {
|
properties = {
|
||||||
VProps.ID: zone_name,
|
VProps.ID: zone_name,
|
||||||
VProps.TYPE: NOVA_ZONE_DATASOURCE,
|
VProps.VITRAGE_TYPE: NOVA_ZONE_DATASOURCE,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: time
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: time
|
||||||
}
|
}
|
||||||
expected_neighbor = \
|
expected_neighbor = \
|
||||||
zt.create_neighbor_placeholder_vertex(**properties)
|
zt.create_neighbor_placeholder_vertex(**properties)
|
||||||
@ -175,27 +175,27 @@ class NovaHostTransformerTest(base.BaseTest):
|
|||||||
self.assertEqual(expected_id, observed_id)
|
self.assertEqual(expected_id, observed_id)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
EntityCategory.RESOURCE,
|
EntityCategory.RESOURCE,
|
||||||
vertex[VProps.CATEGORY]
|
vertex[VProps.VITRAGE_CATEGORY]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
NOVA_HOST_DATASOURCE,
|
NOVA_HOST_DATASOURCE,
|
||||||
vertex[VProps.TYPE]
|
vertex[VProps.VITRAGE_TYPE]
|
||||||
)
|
)
|
||||||
|
|
||||||
expected_timestamp = event[DSProps.SAMPLE_DATE]
|
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)
|
self.assertEqual(expected_timestamp, observed_timestamp)
|
||||||
|
|
||||||
expected_name = extract_value(event, '_info', 'host_name')
|
expected_name = extract_value(event, '_info', 'host_name')
|
||||||
observed_name = vertex[VProps.NAME]
|
observed_name = vertex[VProps.NAME]
|
||||||
self.assertEqual(expected_name, observed_name)
|
self.assertEqual(expected_name, observed_name)
|
||||||
|
|
||||||
is_placeholder = vertex[VProps.IS_PLACEHOLDER]
|
vitrage_is_placeholder = vertex[VProps.VITRAGE_IS_PLACEHOLDER]
|
||||||
self.assertFalse(is_placeholder)
|
self.assertFalse(vitrage_is_placeholder)
|
||||||
|
|
||||||
is_deleted = vertex[VProps.IS_DELETED]
|
vitrage_is_deleted = vertex[VProps.VITRAGE_IS_DELETED]
|
||||||
self.assertFalse(is_deleted)
|
self.assertFalse(vitrage_is_deleted)
|
||||||
|
|
||||||
def test_extract_event_action(self):
|
def test_extract_event_action(self):
|
||||||
LOG.debug('Test extract event action')
|
LOG.debug('Test extract event action')
|
||||||
|
@ -64,9 +64,9 @@ class NovaInstanceTransformerTest(base.BaseTest):
|
|||||||
timestamp = datetime.datetime.utcnow()
|
timestamp = datetime.datetime.utcnow()
|
||||||
properties = {
|
properties = {
|
||||||
VProps.ID: instance_id,
|
VProps.ID: instance_id,
|
||||||
VProps.TYPE: NOVA_INSTANCE_DATASOURCE,
|
VProps.VITRAGE_TYPE: NOVA_INSTANCE_DATASOURCE,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: timestamp
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
|
||||||
}
|
}
|
||||||
transformer = self.transformers[NOVA_INSTANCE_DATASOURCE]
|
transformer = self.transformers[NOVA_INSTANCE_DATASOURCE]
|
||||||
|
|
||||||
@ -81,20 +81,20 @@ class NovaInstanceTransformerTest(base.BaseTest):
|
|||||||
instance_id)
|
instance_id)
|
||||||
self.assertEqual(tuple(observed_id_values), expected_id_values)
|
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)
|
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)
|
self.assertEqual(observed_type, NOVA_INSTANCE_DATASOURCE)
|
||||||
|
|
||||||
observed_entity_id = placeholder.get(VProps.ID)
|
observed_entity_id = placeholder.get(VProps.ID)
|
||||||
self.assertEqual(observed_entity_id, instance_id)
|
self.assertEqual(observed_entity_id, instance_id)
|
||||||
|
|
||||||
observed_category = placeholder.get(VProps.CATEGORY)
|
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
|
||||||
self.assertEqual(observed_category, EntityCategory.RESOURCE)
|
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
|
||||||
|
|
||||||
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
|
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
|
||||||
self.assertEqual(is_placeholder, True)
|
self.assertEqual(vitrage_is_placeholder, True)
|
||||||
|
|
||||||
def test_snapshot_event_transform(self):
|
def test_snapshot_event_transform(self):
|
||||||
LOG.debug('Test tactual transform action for '
|
LOG.debug('Test tactual transform action for '
|
||||||
@ -173,10 +173,10 @@ class NovaInstanceTransformerTest(base.BaseTest):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
EntityCategory.RESOURCE,
|
EntityCategory.RESOURCE,
|
||||||
vertex[VProps.CATEGORY]
|
vertex[VProps.VITRAGE_CATEGORY]
|
||||||
)
|
)
|
||||||
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
|
self.assertEqual(NOVA_INSTANCE_DATASOURCE,
|
||||||
vertex[VProps.TYPE])
|
vertex[VProps.VITRAGE_TYPE])
|
||||||
|
|
||||||
expected_project = extract_value(event, 'tenant_id')
|
expected_project = extract_value(event, 'tenant_id')
|
||||||
observed_project = vertex[VProps.PROJECT_ID]
|
observed_project = vertex[VProps.PROJECT_ID]
|
||||||
@ -188,7 +188,7 @@ class NovaInstanceTransformerTest(base.BaseTest):
|
|||||||
self.assertEqual(expected_state, observed_state)
|
self.assertEqual(expected_state, observed_state)
|
||||||
|
|
||||||
expected_timestamp = event[DSProps.SAMPLE_DATE]
|
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)
|
self.assertEqual(expected_timestamp, observed_timestamp)
|
||||||
|
|
||||||
name = 'hostname' if is_update_event else 'name'
|
name = 'hostname' if is_update_event else 'name'
|
||||||
@ -196,11 +196,11 @@ class NovaInstanceTransformerTest(base.BaseTest):
|
|||||||
observed_name = vertex[VProps.NAME]
|
observed_name = vertex[VProps.NAME]
|
||||||
self.assertEqual(expected_name, observed_name)
|
self.assertEqual(expected_name, observed_name)
|
||||||
|
|
||||||
is_placeholder = vertex[VProps.IS_PLACEHOLDER]
|
vitrage_is_placeholder = vertex[VProps.VITRAGE_IS_PLACEHOLDER]
|
||||||
self.assertFalse(is_placeholder)
|
self.assertFalse(vitrage_is_placeholder)
|
||||||
|
|
||||||
is_deleted = vertex[VProps.IS_DELETED]
|
vitrage_is_deleted = vertex[VProps.VITRAGE_IS_DELETED]
|
||||||
self.assertFalse(is_deleted)
|
self.assertFalse(vitrage_is_deleted)
|
||||||
|
|
||||||
def _validate_host_neighbor(self, h_neighbor, event):
|
def _validate_host_neighbor(self, h_neighbor, event):
|
||||||
|
|
||||||
@ -214,9 +214,9 @@ class NovaInstanceTransformerTest(base.BaseTest):
|
|||||||
ht = self.transformers[NOVA_HOST_DATASOURCE]
|
ht = self.transformers[NOVA_HOST_DATASOURCE]
|
||||||
properties = {
|
properties = {
|
||||||
VProps.ID: host_name,
|
VProps.ID: host_name,
|
||||||
VProps.TYPE: NOVA_HOST_DATASOURCE,
|
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: time
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: time
|
||||||
}
|
}
|
||||||
expected_neighbor = \
|
expected_neighbor = \
|
||||||
ht.create_neighbor_placeholder_vertex(**properties)
|
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(host_vertex_id, neighbor.vertex.vertex_id)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
time,
|
time,
|
||||||
neighbor.vertex.get(VProps.SAMPLE_TIMESTAMP)
|
neighbor.vertex.get(VProps.VITRAGE_SAMPLE_TIMESTAMP)
|
||||||
)
|
)
|
||||||
|
|
||||||
# test relation edge
|
# test relation edge
|
||||||
|
@ -68,9 +68,9 @@ class NovaZoneTransformerTest(base.BaseTest):
|
|||||||
# Test action
|
# Test action
|
||||||
properties = {
|
properties = {
|
||||||
VProps.ID: zone_name,
|
VProps.ID: zone_name,
|
||||||
VProps.TYPE: NOVA_ZONE_DATASOURCE,
|
VProps.VITRAGE_TYPE: NOVA_ZONE_DATASOURCE,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: timestamp
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
|
||||||
}
|
}
|
||||||
placeholder = \
|
placeholder = \
|
||||||
zone_transformer.create_neighbor_placeholder_vertex(**properties)
|
zone_transformer.create_neighbor_placeholder_vertex(**properties)
|
||||||
@ -82,20 +82,20 @@ class NovaZoneTransformerTest(base.BaseTest):
|
|||||||
_key_values(NOVA_ZONE_DATASOURCE, zone_name)
|
_key_values(NOVA_ZONE_DATASOURCE, zone_name)
|
||||||
self.assertEqual(tuple(observed_id_values), expected_id_values)
|
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)
|
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)
|
self.assertEqual(observed_subtype, NOVA_ZONE_DATASOURCE)
|
||||||
|
|
||||||
observed_entity_id = placeholder.get(VProps.ID)
|
observed_entity_id = placeholder.get(VProps.ID)
|
||||||
self.assertEqual(observed_entity_id, zone_name)
|
self.assertEqual(observed_entity_id, zone_name)
|
||||||
|
|
||||||
observed_category = placeholder.get(VProps.CATEGORY)
|
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
|
||||||
self.assertEqual(observed_category, EntityCategory.RESOURCE)
|
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
|
||||||
|
|
||||||
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
|
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
|
||||||
self.assertEqual(is_placeholder, True)
|
self.assertEqual(vitrage_is_placeholder, True)
|
||||||
|
|
||||||
def test_key_values(self):
|
def test_key_values(self):
|
||||||
LOG.debug('Zone transformer test: get key values')
|
LOG.debug('Zone transformer test: get key values')
|
||||||
@ -146,7 +146,7 @@ class NovaZoneTransformerTest(base.BaseTest):
|
|||||||
cluster_neighbors_counter = 0
|
cluster_neighbors_counter = 0
|
||||||
|
|
||||||
for neighbor in neighbors:
|
for neighbor in neighbors:
|
||||||
vertex_type = neighbor.vertex.get(VProps.TYPE)
|
vertex_type = neighbor.vertex.get(VProps.VITRAGE_TYPE)
|
||||||
|
|
||||||
if OPENSTACK_CLUSTER == vertex_type:
|
if OPENSTACK_CLUSTER == vertex_type:
|
||||||
cluster_neighbors_counter += 1
|
cluster_neighbors_counter += 1
|
||||||
@ -192,11 +192,11 @@ class NovaZoneTransformerTest(base.BaseTest):
|
|||||||
host_vertex.get(VProps.STATE)
|
host_vertex.get(VProps.STATE)
|
||||||
)
|
)
|
||||||
|
|
||||||
is_placeholder = host_vertex[VProps.IS_PLACEHOLDER]
|
vitrage_is_placeholder = host_vertex[VProps.VITRAGE_IS_PLACEHOLDER]
|
||||||
self.assertFalse(is_placeholder)
|
self.assertFalse(vitrage_is_placeholder)
|
||||||
|
|
||||||
is_deleted = host_vertex[VProps.IS_DELETED]
|
vitrage_is_deleted = host_vertex[VProps.VITRAGE_IS_DELETED]
|
||||||
self.assertFalse(is_deleted)
|
self.assertFalse(vitrage_is_deleted)
|
||||||
|
|
||||||
# Validate neighbor edge
|
# Validate neighbor edge
|
||||||
edge = host_neighbor.edge
|
edge = host_neighbor.edge
|
||||||
@ -209,15 +209,15 @@ class NovaZoneTransformerTest(base.BaseTest):
|
|||||||
self.assertEqual(cluster_neighbor.vertex[VProps.VITRAGE_ID],
|
self.assertEqual(cluster_neighbor.vertex[VProps.VITRAGE_ID],
|
||||||
cluster_neighbor.vertex.vertex_id)
|
cluster_neighbor.vertex.vertex_id)
|
||||||
self.assertEqual(False,
|
self.assertEqual(False,
|
||||||
cluster_neighbor.vertex[VProps.IS_DELETED])
|
cluster_neighbor.vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
self.assertEqual(EntityCategory.RESOURCE,
|
self.assertEqual(EntityCategory.RESOURCE,
|
||||||
cluster_neighbor.vertex[VProps.CATEGORY])
|
cluster_neighbor.vertex[VProps.VITRAGE_CATEGORY])
|
||||||
self.assertEqual(CLUSTER_ID,
|
self.assertEqual(CLUSTER_ID,
|
||||||
cluster_neighbor.vertex[VProps.ID])
|
cluster_neighbor.vertex[VProps.ID])
|
||||||
self.assertEqual(False,
|
self.assertEqual(False, cluster_neighbor.vertex[
|
||||||
cluster_neighbor.vertex[VProps.IS_PLACEHOLDER])
|
VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
self.assertEqual(OPENSTACK_CLUSTER,
|
self.assertEqual(OPENSTACK_CLUSTER,
|
||||||
cluster_neighbor.vertex[VProps.TYPE])
|
cluster_neighbor.vertex[VProps.VITRAGE_TYPE])
|
||||||
|
|
||||||
# Validate neighbor edge
|
# Validate neighbor edge
|
||||||
edge = cluster_neighbor.edge
|
edge = cluster_neighbor.edge
|
||||||
@ -236,13 +236,13 @@ class NovaZoneTransformerTest(base.BaseTest):
|
|||||||
self.assertEqual(expected_id, observed_id)
|
self.assertEqual(expected_id, observed_id)
|
||||||
|
|
||||||
self.assertEqual(EntityCategory.RESOURCE,
|
self.assertEqual(EntityCategory.RESOURCE,
|
||||||
vertex[VProps.CATEGORY])
|
vertex[VProps.VITRAGE_CATEGORY])
|
||||||
|
|
||||||
self.assertEqual(NOVA_ZONE_DATASOURCE,
|
self.assertEqual(NOVA_ZONE_DATASOURCE,
|
||||||
vertex[VProps.TYPE])
|
vertex[VProps.VITRAGE_TYPE])
|
||||||
|
|
||||||
expected_timestamp = event[DSProps.SAMPLE_DATE]
|
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)
|
self.assertEqual(expected_timestamp, observed_timestamp)
|
||||||
|
|
||||||
expected_name = extract_value(event, 'zoneName')
|
expected_name = extract_value(event, 'zoneName')
|
||||||
@ -259,8 +259,8 @@ class NovaZoneTransformerTest(base.BaseTest):
|
|||||||
observed_state = vertex[VProps.STATE]
|
observed_state = vertex[VProps.STATE]
|
||||||
self.assertEqual(expected_state, observed_state)
|
self.assertEqual(expected_state, observed_state)
|
||||||
|
|
||||||
is_placeholder = vertex[VProps.IS_PLACEHOLDER]
|
vitrage_is_placeholder = vertex[VProps.VITRAGE_IS_PLACEHOLDER]
|
||||||
self.assertFalse(is_placeholder)
|
self.assertFalse(vitrage_is_placeholder)
|
||||||
|
|
||||||
is_deleted = vertex[VProps.IS_DELETED]
|
vitrage_is_deleted = vertex[VProps.VITRAGE_IS_DELETED]
|
||||||
self.assertFalse(is_deleted)
|
self.assertFalse(vitrage_is_deleted)
|
||||||
|
@ -57,10 +57,10 @@ class TestStaticTransformer(base.BaseTest):
|
|||||||
|
|
||||||
def test_create_placeholder_vertex(self):
|
def test_create_placeholder_vertex(self):
|
||||||
properties = {
|
properties = {
|
||||||
VProps.TYPE: self.entity_type,
|
VProps.VITRAGE_TYPE: self.entity_type,
|
||||||
VProps.ID: self.entity_id,
|
VProps.ID: self.entity_id,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: self.timestamp
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: self.timestamp
|
||||||
}
|
}
|
||||||
placeholder = self.transformer.create_neighbor_placeholder_vertex(
|
placeholder = self.transformer.create_neighbor_placeholder_vertex(
|
||||||
**properties)
|
**properties)
|
||||||
@ -69,20 +69,20 @@ class TestStaticTransformer(base.BaseTest):
|
|||||||
expected_entity_id = 'RESOURCE:static:12345'
|
expected_entity_id = 'RESOURCE:static:12345'
|
||||||
self.assertEqual(observed_entity_id, expected_entity_id)
|
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)
|
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)
|
self.assertEqual(observed_subtype, self.entity_type)
|
||||||
|
|
||||||
observed_entity_id = placeholder.get(VProps.ID)
|
observed_entity_id = placeholder.get(VProps.ID)
|
||||||
self.assertEqual(observed_entity_id, self.entity_id)
|
self.assertEqual(observed_entity_id, self.entity_id)
|
||||||
|
|
||||||
observed_category = placeholder.get(VProps.CATEGORY)
|
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
|
||||||
self.assertEqual(observed_category, EntityCategory.RESOURCE)
|
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
|
||||||
|
|
||||||
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
|
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
|
||||||
self.assertEqual(is_placeholder, True)
|
self.assertEqual(vitrage_is_placeholder, True)
|
||||||
|
|
||||||
def test_snapshot_transform(self):
|
def test_snapshot_transform(self):
|
||||||
vals_list = mock_driver.simple_static_generators(snapshot_events=1)
|
vals_list = mock_driver.simple_static_generators(snapshot_events=1)
|
||||||
@ -106,17 +106,19 @@ class TestStaticTransformer(base.BaseTest):
|
|||||||
|
|
||||||
def _validate_vertex(self, vertex, event):
|
def _validate_vertex(self, vertex, event):
|
||||||
self._validate_common_props(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])
|
event[DSProps.SAMPLE_DATE])
|
||||||
|
|
||||||
for k, v in event.get(StaticFields.METADATA, {}):
|
for k, v in event.get(StaticFields.METADATA, {}):
|
||||||
self.assertEqual(vertex[k], v)
|
self.assertEqual(vertex[k], v)
|
||||||
|
|
||||||
def _validate_common_props(self, vertex, event):
|
def _validate_common_props(self, vertex, event):
|
||||||
self.assertEqual(vertex[VProps.CATEGORY], EntityCategory.RESOURCE)
|
self.assertEqual(vertex[VProps.VITRAGE_CATEGORY],
|
||||||
self.assertEqual(vertex[VProps.TYPE], event[VProps.TYPE])
|
EntityCategory.RESOURCE)
|
||||||
self.assertEqual(vertex[VProps.ID], event[VProps.ID])
|
self.assertEqual(vertex[VProps.VITRAGE_TYPE],
|
||||||
self.assertFalse(vertex[VProps.IS_DELETED])
|
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):
|
def _validate_neighbors(self, neighbors, vertex_id, event):
|
||||||
for i in range(len(neighbors)):
|
for i in range(len(neighbors)):
|
||||||
@ -139,4 +141,4 @@ class TestStaticTransformer(base.BaseTest):
|
|||||||
|
|
||||||
def _validate_neighbor_vertex_props(self, vertex, event):
|
def _validate_neighbor_vertex_props(self, vertex, event):
|
||||||
self._validate_common_props(vertex, event)
|
self._validate_common_props(vertex, event)
|
||||||
self.assertTrue(vertex[VProps.IS_PLACEHOLDER])
|
self.assertTrue(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
|
@ -20,7 +20,7 @@ from vitrage.common.constants import DatasourceAction
|
|||||||
from vitrage.common.constants import DatasourceOpts as DSOpts
|
from vitrage.common.constants import DatasourceOpts as DSOpts
|
||||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||||
from vitrage.common.constants import GraphAction
|
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 driver
|
||||||
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
|
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
|
||||||
from vitrage.datasources.static_physical import SWITCH
|
from vitrage.datasources.static_physical import SWITCH
|
||||||
@ -111,25 +111,25 @@ class TestStaticPhysicalDriver(base.BaseTest):
|
|||||||
GraphAction.UPDATE_ENTITY)
|
GraphAction.UPDATE_ENTITY)
|
||||||
|
|
||||||
# Test Assertions
|
# Test Assertions
|
||||||
status = any(change[VProps.TYPE] == SWITCH and
|
status = any(change[StaticFields.TYPE] == SWITCH and
|
||||||
change[VProps.ID] == '12345' for change in changes)
|
change[StaticFields.ID] == '12345' for change in changes)
|
||||||
self.assertEqual(False, status)
|
self.assertEqual(False, status)
|
||||||
|
|
||||||
status = any(change[VProps.TYPE] == SWITCH and
|
status = any(change[StaticFields.TYPE] == SWITCH and
|
||||||
change[VProps.ID] == '23456' and
|
change[StaticFields.ID] == '23456' and
|
||||||
change[DSProps.EVENT_TYPE] == GraphAction.DELETE_ENTITY
|
change[DSProps.EVENT_TYPE] == GraphAction.DELETE_ENTITY
|
||||||
for change in changes)
|
for change in changes)
|
||||||
self.assertEqual(True, status)
|
self.assertEqual(True, status)
|
||||||
|
|
||||||
status = any(change[VProps.TYPE] == SWITCH and
|
status = any(change[StaticFields.TYPE] == SWITCH and
|
||||||
change[VProps.ID] == '34567' for change in changes)
|
change[StaticFields.ID] == '34567' for change in changes)
|
||||||
self.assertEqual(True, status)
|
self.assertEqual(True, status)
|
||||||
|
|
||||||
status = any(change[VProps.TYPE] == SWITCH and
|
status = any(change[StaticFields.TYPE] == SWITCH and
|
||||||
change[VProps.ID] == '45678' for change in changes)
|
change[StaticFields.ID] == '45678' for change in changes)
|
||||||
self.assertEqual(True, status)
|
self.assertEqual(True, status)
|
||||||
status = any(change[VProps.TYPE] == SWITCH and
|
status = any(change[StaticFields.TYPE] == SWITCH and
|
||||||
change[VProps.ID] == '56789' for change in changes)
|
change[StaticFields.ID] == '56789' for change in changes)
|
||||||
self.assertEqual(True, status)
|
self.assertEqual(True, status)
|
||||||
|
|
||||||
self.assertEqual(4, len(changes))
|
self.assertEqual(4, len(changes))
|
||||||
|
@ -25,6 +25,7 @@ from vitrage.common.constants import UpdateMethod
|
|||||||
from vitrage.common.constants import VertexProperties as VProps
|
from vitrage.common.constants import VertexProperties as VProps
|
||||||
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
|
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
|
||||||
from vitrage.datasources.nova.host.transformer import HostTransformer
|
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 import STATIC_PHYSICAL_DATASOURCE
|
||||||
from vitrage.datasources.static_physical.transformer \
|
from vitrage.datasources.static_physical.transformer \
|
||||||
import StaticPhysicalTransformer
|
import StaticPhysicalTransformer
|
||||||
@ -66,10 +67,10 @@ class TestStaticPhysicalTransformer(base.BaseTest):
|
|||||||
|
|
||||||
# Test action
|
# Test action
|
||||||
properties = {
|
properties = {
|
||||||
VProps.TYPE: switch_type,
|
VProps.VITRAGE_TYPE: switch_type,
|
||||||
VProps.ID: switch_name,
|
VProps.ID: switch_name,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: timestamp
|
VProps.VITRAGE_SAMPLE_TIMESTAMP: timestamp
|
||||||
}
|
}
|
||||||
placeholder = \
|
placeholder = \
|
||||||
static_transformer.create_neighbor_placeholder_vertex(**properties)
|
static_transformer.create_neighbor_placeholder_vertex(**properties)
|
||||||
@ -82,20 +83,20 @@ class TestStaticPhysicalTransformer(base.BaseTest):
|
|||||||
switch_type, switch_name)
|
switch_type, switch_name)
|
||||||
self.assertEqual(tuple(observed_id_values), expected_id_values)
|
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)
|
self.assertEqual(observed_time, timestamp)
|
||||||
|
|
||||||
observed_subtype = placeholder.get(VProps.TYPE)
|
observed_subtype = placeholder.get(VProps.VITRAGE_TYPE)
|
||||||
self.assertEqual(observed_subtype, switch_type)
|
self.assertEqual(observed_subtype, switch_type)
|
||||||
|
|
||||||
observed_entity_id = placeholder.get(VProps.ID)
|
observed_entity_id = placeholder.get(VProps.ID)
|
||||||
self.assertEqual(observed_entity_id, switch_name)
|
self.assertEqual(observed_entity_id, switch_name)
|
||||||
|
|
||||||
observed_category = placeholder.get(VProps.CATEGORY)
|
observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY)
|
||||||
self.assertEqual(observed_category, EntityCategory.RESOURCE)
|
self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE)
|
||||||
|
|
||||||
is_placeholder = placeholder.get(VProps.IS_PLACEHOLDER)
|
vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER)
|
||||||
self.assertEqual(is_placeholder, True)
|
self.assertEqual(vitrage_is_placeholder, True)
|
||||||
|
|
||||||
def test_key_values(self):
|
def test_key_values(self):
|
||||||
LOG.debug('Static Physical transformer test: get key values')
|
LOG.debug('Static Physical transformer test: get key values')
|
||||||
@ -171,20 +172,22 @@ class TestStaticPhysicalTransformer(base.BaseTest):
|
|||||||
self.assertEqual(edge.label, EdgeLabel.CONTAINS)
|
self.assertEqual(edge.label, EdgeLabel.CONTAINS)
|
||||||
|
|
||||||
def _validate_common_vertex_props(self, vertex, event):
|
def _validate_common_vertex_props(self, vertex, event):
|
||||||
self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY])
|
self.assertEqual(EntityCategory.RESOURCE,
|
||||||
self.assertEqual(event[VProps.TYPE], vertex[VProps.TYPE])
|
vertex[VProps.VITRAGE_CATEGORY])
|
||||||
self.assertEqual(event[VProps.ID], vertex[VProps.ID])
|
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):
|
def _validate_switch_vertex_props(self, vertex, event):
|
||||||
self._validate_common_vertex_props(vertex, event)
|
self._validate_common_vertex_props(vertex, event)
|
||||||
self.assertEqual(event[DSProps.SAMPLE_DATE],
|
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.NAME], vertex[VProps.NAME])
|
||||||
self.assertEqual(event[VProps.STATE], vertex[VProps.STATE])
|
self.assertEqual(event[VProps.STATE], vertex[VProps.STATE])
|
||||||
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
self.assertFalse(vertex[VProps.IS_DELETED])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
|
|
||||||
def _validate_host_vertex_props(self, vertex, event):
|
def _validate_host_vertex_props(self, vertex, event):
|
||||||
self._validate_common_vertex_props(vertex, event)
|
self._validate_common_vertex_props(vertex, event)
|
||||||
self.assertTrue(vertex[VProps.IS_PLACEHOLDER])
|
self.assertTrue(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
self.assertFalse(vertex[VProps.IS_DELETED])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
|
@ -36,8 +36,9 @@ class BaseAlarmTransformerTest(BaseTransformerTest):
|
|||||||
expected_name,
|
expected_name,
|
||||||
expected_datasource_name)
|
expected_datasource_name)
|
||||||
|
|
||||||
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
|
self.assertEqual(EntityCategory.ALARM, vertex[VProps.VITRAGE_CATEGORY])
|
||||||
self.assertEqual(expected_sample_time, vertex[VProps.SAMPLE_TIMESTAMP])
|
self.assertEqual(expected_sample_time,
|
||||||
|
vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP])
|
||||||
|
|
||||||
if self._is_erroneous(vertex):
|
if self._is_erroneous(vertex):
|
||||||
self.assertEqual(AlarmProps.ACTIVE_STATE, vertex[VProps.STATE])
|
self.assertEqual(AlarmProps.ACTIVE_STATE, vertex[VProps.STATE])
|
||||||
@ -55,9 +56,10 @@ class BaseAlarmTransformerTest(BaseTransformerTest):
|
|||||||
host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
|
host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
|
||||||
properties = {
|
properties = {
|
||||||
VProps.ID: host_name,
|
VProps.ID: host_name,
|
||||||
VProps.TYPE: NOVA_HOST_DATASOURCE,
|
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE,
|
||||||
VProps.CATEGORY: EntityCategory.RESOURCE,
|
VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
VProps.SAMPLE_TIMESTAMP: wrapper.vertex[VProps.SAMPLE_TIMESTAMP],
|
VProps.VITRAGE_SAMPLE_TIMESTAMP:
|
||||||
|
wrapper.vertex[VProps.VITRAGE_SAMPLE_TIMESTAMP],
|
||||||
}
|
}
|
||||||
expected_neighbor = host_transformer.\
|
expected_neighbor = host_transformer.\
|
||||||
create_neighbor_placeholder_vertex(**properties)
|
create_neighbor_placeholder_vertex(**properties)
|
||||||
|
@ -23,6 +23,6 @@ class BaseTransformerTest(base.BaseTest):
|
|||||||
vertex,
|
vertex,
|
||||||
expected_name,
|
expected_name,
|
||||||
expected_datasource_name):
|
expected_datasource_name):
|
||||||
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
self.assertEqual(expected_datasource_name, vertex[VProps.TYPE])
|
self.assertEqual(expected_datasource_name, vertex[VProps.VITRAGE_TYPE])
|
||||||
self.assertEqual(expected_name, vertex[VProps.NAME])
|
self.assertEqual(expected_name, vertex[VProps.NAME])
|
||||||
|
@ -103,7 +103,7 @@ class ZabbixTransformerTest(base.BaseTest):
|
|||||||
neighbor = neighbors[0]
|
neighbor = neighbors[0]
|
||||||
|
|
||||||
# Right now we are support only host as a resource
|
# 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_host_neighbor(neighbors[0], alarm)
|
||||||
|
|
||||||
self._validate_action(alarm, wrapper)
|
self._validate_action(alarm, wrapper)
|
||||||
@ -120,8 +120,9 @@ class ZabbixTransformerTest(base.BaseTest):
|
|||||||
|
|
||||||
def _validate_vertex(self, vertex, event):
|
def _validate_vertex(self, vertex, event):
|
||||||
|
|
||||||
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
|
self.assertEqual(EntityCategory.ALARM, vertex[VProps.VITRAGE_CATEGORY])
|
||||||
self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
|
self.assertEqual(event[DSProps.ENTITY_TYPE],
|
||||||
|
vertex[VProps.VITRAGE_TYPE])
|
||||||
self.assertEqual(event[ZabbixProps.DESCRIPTION],
|
self.assertEqual(event[ZabbixProps.DESCRIPTION],
|
||||||
vertex[VProps.NAME])
|
vertex[VProps.NAME])
|
||||||
|
|
||||||
@ -138,8 +139,8 @@ class ZabbixTransformerTest(base.BaseTest):
|
|||||||
event[ZabbixProps.PRIORITY])
|
event[ZabbixProps.PRIORITY])
|
||||||
self.assertEqual(event_severity, vertex[VProps.SEVERITY])
|
self.assertEqual(event_severity, vertex[VProps.SEVERITY])
|
||||||
|
|
||||||
self.assertFalse(vertex[VProps.IS_DELETED])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
self.assertFalse(vertex[VProps.IS_PLACEHOLDER])
|
self.assertFalse(vertex[VProps.VITRAGE_IS_PLACEHOLDER])
|
||||||
|
|
||||||
def _validate_host_neighbor(self, neighbor, event):
|
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(NOVA_HOST_DATASOURCE, key_fields[1])
|
||||||
self.assertEqual(event[ZabbixProps.RESOURCE_NAME], key_fields[2])
|
self.assertEqual(event[ZabbixProps.RESOURCE_NAME], key_fields[2])
|
||||||
|
|
||||||
self.assertFalse(host_vertex[VProps.IS_DELETED])
|
self.assertFalse(host_vertex[VProps.VITRAGE_IS_DELETED])
|
||||||
self.assertTrue(host_vertex[VProps.IS_PLACEHOLDER])
|
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],
|
self.assertEqual(event[ZabbixProps.RESOURCE_NAME],
|
||||||
host_vertex[VProps.ID])
|
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
|
edge = neighbor.edge
|
||||||
self.assertEqual(EdgeLabel.ON, edge.label)
|
self.assertEqual(EdgeLabel.ON, edge.label)
|
||||||
|
@ -152,13 +152,13 @@ class TestEntityGraphUnitBase(base.BaseTest):
|
|||||||
def _create_alarm(vitrage_id, alarm_type, project_id=None, metadata=None):
|
def _create_alarm(vitrage_id, alarm_type, project_id=None, metadata=None):
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
vitrage_id,
|
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_id=vitrage_id,
|
||||||
entity_category=EntityCategory.ALARM,
|
|
||||||
entity_type=alarm_type,
|
|
||||||
entity_state='active',
|
entity_state='active',
|
||||||
is_deleted=False,
|
|
||||||
sample_timestamp=None,
|
|
||||||
is_placeholder=False,
|
|
||||||
project_id=project_id,
|
project_id=project_id,
|
||||||
metadata=metadata
|
metadata=metadata
|
||||||
)
|
)
|
||||||
@ -167,13 +167,13 @@ class TestEntityGraphUnitBase(base.BaseTest):
|
|||||||
def _create_resource(vitrage_id, resource_type, project_id=None):
|
def _create_resource(vitrage_id, resource_type, project_id=None):
|
||||||
return graph_utils.create_vertex(
|
return graph_utils.create_vertex(
|
||||||
vitrage_id,
|
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_id=vitrage_id,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=resource_type,
|
|
||||||
entity_state='active',
|
entity_state='active',
|
||||||
is_deleted=False,
|
|
||||||
sample_timestamp=None,
|
|
||||||
is_placeholder=False,
|
|
||||||
project_id=project_id
|
project_id=project_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
from oslo_config import cfg
|
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.entity_graph import transformer_manager
|
||||||
from vitrage.graph import driver as graph
|
from vitrage.graph import driver as graph
|
||||||
from vitrage.tests.unit.entity_graph.base import TestEntityGraphUnitBase
|
from vitrage.tests.unit.entity_graph.base import TestEntityGraphUnitBase
|
||||||
@ -32,20 +32,24 @@ class TestBaseProcessor(TestEntityGraphUnitBase):
|
|||||||
cls.transform = transformer_manager.TransformerManager(cls.conf)
|
cls.transform = transformer_manager.TransformerManager(cls.conf)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _update_vertex_to_graph(entity_graph, category, type_, id_,
|
def _update_vertex_to_graph(entity_graph,
|
||||||
is_deleted, is_placeholder_data,
|
vitrage_category,
|
||||||
|
vitrage_type,
|
||||||
|
id_,
|
||||||
|
vitrage_is_deleted,
|
||||||
|
vitrage_is_placeholder,
|
||||||
additional_prop):
|
additional_prop):
|
||||||
# create vertex properties
|
# create vertex properties
|
||||||
prop = {key: value for key, value in additional_prop.items()}
|
prop = {key: value for key, value in additional_prop.items()}
|
||||||
prop[VertexProperties.CATEGORY] = category
|
prop[VProps.VITRAGE_CATEGORY] = vitrage_category
|
||||||
prop[VertexProperties.TYPE] = type_
|
prop[VProps.VITRAGE_TYPE] = vitrage_type
|
||||||
prop[VertexProperties.ID] = id_
|
prop[VProps.ID] = id_
|
||||||
prop[VertexProperties.IS_DELETED] = is_deleted
|
prop[VProps.VITRAGE_IS_DELETED] = vitrage_is_deleted
|
||||||
prop[VertexProperties.IS_PLACEHOLDER] = is_placeholder_data
|
prop[VProps.VITRAGE_IS_PLACEHOLDER] = vitrage_is_placeholder
|
||||||
|
|
||||||
# TODO(Alexey): change back to original method
|
# TODO(Alexey): change back to original method
|
||||||
# vertex_id = self.transform.get_key(prop)
|
# 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)
|
vertex = graph.Vertex(vertex_id, prop)
|
||||||
entity_graph.add_vertex(vertex)
|
entity_graph.add_vertex(vertex)
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
|
|
||||||
# update instance event with state running
|
# update instance event with state running
|
||||||
vertex.properties[VProps.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)
|
processor.update_entity(vertex, neighbors)
|
||||||
|
|
||||||
# check state
|
# check state
|
||||||
@ -148,9 +148,9 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
'backup')
|
'backup')
|
||||||
mock_neighbor = graph_utils.create_vertex(
|
mock_neighbor = graph_utils.create_vertex(
|
||||||
"asdjashdkahsdashdalksjhd",
|
"asdjashdkahsdashdalksjhd",
|
||||||
|
vitrage_category="RESOURCE",
|
||||||
|
vitrage_type="nova.instance",
|
||||||
entity_id="wtw64768476",
|
entity_id="wtw64768476",
|
||||||
entity_category="RESOURCE",
|
|
||||||
entity_type="nova.instance",
|
|
||||||
entity_state="AVAILABLE",
|
entity_state="AVAILABLE",
|
||||||
)
|
)
|
||||||
new_neighbors = [Neighbor(mock_neighbor, new_edge)]
|
new_neighbors = [Neighbor(mock_neighbor, new_edge)]
|
||||||
@ -187,7 +187,7 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
vertex2.vertex_id,
|
vertex2.vertex_id,
|
||||||
'backup')
|
'backup')
|
||||||
self.assertEqual(3, processor.entity_graph.num_edges())
|
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):
|
def test_remove_deleted_entity(self):
|
||||||
# setup
|
# setup
|
||||||
@ -195,7 +195,7 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
spec_type=self.INSTANCE_SPEC,
|
spec_type=self.INSTANCE_SPEC,
|
||||||
datasource_action=DSAction.INIT_SNAPSHOT)
|
datasource_action=DSAction.INIT_SNAPSHOT)
|
||||||
self.assertEqual(1, processor.entity_graph.num_edges())
|
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)
|
processor.entity_graph.update_vertex(vertex)
|
||||||
|
|
||||||
# action
|
# action
|
||||||
@ -235,9 +235,9 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
# update instance event with state running
|
# update instance event with state running
|
||||||
(neighbor_vertex, neighbor_edge) = neighbors[0]
|
(neighbor_vertex, neighbor_edge) = neighbors[0]
|
||||||
old_label = neighbor_edge.label
|
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)
|
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'
|
neighbor_edge.label = 'new label'
|
||||||
|
|
||||||
processor._update_neighbors(vertex, neighbors)
|
processor._update_neighbors(vertex, neighbors)
|
||||||
@ -254,9 +254,9 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
vertex.vertex_id,
|
vertex.vertex_id,
|
||||||
neighbor_edge.label)
|
neighbor_edge.label)
|
||||||
self.assertIsNotNone(old_edge)
|
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.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
|
# update instance with the same neighbor
|
||||||
processor._update_neighbors(vertex, neighbors)
|
processor._update_neighbors(vertex, neighbors)
|
||||||
@ -291,7 +291,7 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
neighbor_edge.label)
|
neighbor_edge.label)
|
||||||
self.assertIsNone(old_edge)
|
self.assertIsNone(old_edge)
|
||||||
self.assertIsNotNone(new_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
|
# update instance with the same neighbor
|
||||||
processor._update_neighbors(vertex, neighbors)
|
processor._update_neighbors(vertex, neighbors)
|
||||||
@ -314,7 +314,7 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
self.NUM_VERTICES_AFTER_DELETION,
|
self.NUM_VERTICES_AFTER_DELETION,
|
||||||
self.NUM_EDGES_AFTER_DELETION)
|
self.NUM_EDGES_AFTER_DELETION)
|
||||||
|
|
||||||
def test_calculate_aggregated_state(self):
|
def test_calculate_vitrage_aggregated_state(self):
|
||||||
# setup
|
# setup
|
||||||
instances = []
|
instances = []
|
||||||
for i in range(6):
|
for i in range(6):
|
||||||
@ -324,67 +324,67 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
# action
|
# action
|
||||||
# state already exists and its updated
|
# state already exists and its updated
|
||||||
instances[0][0][VProps.STATE] = 'SUSPENDED'
|
instances[0][0][VProps.STATE] = 'SUSPENDED'
|
||||||
instances[0][1]._calculate_aggregated_state(instances[0][0],
|
instances[0][1]._calculate_vitrage_aggregated_state(
|
||||||
GraphAction.UPDATE_ENTITY)
|
instances[0][0], GraphAction.UPDATE_ENTITY)
|
||||||
|
|
||||||
# vitrage state doesn't exist and its updated
|
# vitrage state doesn't exist and its updated
|
||||||
instances[1][0][VProps.STATE] = None
|
instances[1][0][VProps.STATE] = None
|
||||||
instances[1][1].entity_graph.update_vertex(instances[1][0])
|
instances[1][1].entity_graph.update_vertex(instances[1][0])
|
||||||
instances[1][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
instances[1][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
||||||
instances[1][1]._calculate_aggregated_state(instances[1][0],
|
instances[1][1]._calculate_vitrage_aggregated_state(
|
||||||
GraphAction.UPDATE_ENTITY)
|
instances[1][0], GraphAction.UPDATE_ENTITY)
|
||||||
|
|
||||||
# state exists and vitrage state changes
|
# state exists and vitrage state changes
|
||||||
instances[2][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
instances[2][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
||||||
instances[2][1]._calculate_aggregated_state(instances[2][0],
|
instances[2][1]._calculate_vitrage_aggregated_state(
|
||||||
GraphAction.UPDATE_ENTITY)
|
instances[2][0], GraphAction.UPDATE_ENTITY)
|
||||||
|
|
||||||
# vitrage state exists and state changes
|
# vitrage state exists and state changes
|
||||||
instances[3][0][VProps.STATE] = None
|
instances[3][0][VProps.STATE] = None
|
||||||
instances[3][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
instances[3][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
||||||
instances[3][1].entity_graph.update_vertex(instances[3][0])
|
instances[3][1].entity_graph.update_vertex(instances[3][0])
|
||||||
instances[3][0][VProps.STATE] = 'SUSPENDED'
|
instances[3][0][VProps.STATE] = 'SUSPENDED'
|
||||||
instances[3][1]._calculate_aggregated_state(instances[3][0],
|
instances[3][1]._calculate_vitrage_aggregated_state(
|
||||||
GraphAction.UPDATE_ENTITY)
|
instances[3][0], GraphAction.UPDATE_ENTITY)
|
||||||
|
|
||||||
# state and vitrage state exists and state changes
|
# state and vitrage state exists and state changes
|
||||||
instances[4][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
instances[4][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
||||||
instances[4][1].entity_graph.update_vertex(instances[4][0])
|
instances[4][1].entity_graph.update_vertex(instances[4][0])
|
||||||
instances[4][0][VProps.STATE] = 'SUSPENDED'
|
instances[4][0][VProps.STATE] = 'SUSPENDED'
|
||||||
instances[4][1]._calculate_aggregated_state(instances[4][0],
|
instances[4][1]._calculate_vitrage_aggregated_state(
|
||||||
GraphAction.UPDATE_ENTITY)
|
instances[4][0], GraphAction.UPDATE_ENTITY)
|
||||||
|
|
||||||
# state and vitrage state exists and vitrage state changes
|
# state and vitrage state exists and vitrage state changes
|
||||||
instances[5][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
instances[5][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
||||||
instances[5][1].entity_graph.update_vertex(instances[5][0])
|
instances[5][1].entity_graph.update_vertex(instances[5][0])
|
||||||
instances[5][1]._calculate_aggregated_state(instances[5][0],
|
instances[5][1]._calculate_vitrage_aggregated_state(
|
||||||
GraphAction.UPDATE_ENTITY)
|
instances[5][0], GraphAction.UPDATE_ENTITY)
|
||||||
|
|
||||||
# test assertions
|
# test assertions
|
||||||
self.assertEqual('SUSPENDED',
|
self.assertEqual('SUSPENDED',
|
||||||
instances[0][0][VProps.AGGREGATED_STATE])
|
instances[0][0][VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
||||||
instances[0][0][VProps.OPERATIONAL_STATE])
|
instances[0][0][VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
self.assertEqual('SUBOPTIMAL',
|
self.assertEqual('SUBOPTIMAL',
|
||||||
instances[1][0][VProps.AGGREGATED_STATE])
|
instances[1][0][VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
||||||
instances[1][0][VProps.OPERATIONAL_STATE])
|
instances[1][0][VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
self.assertEqual('SUBOPTIMAL',
|
self.assertEqual('SUBOPTIMAL',
|
||||||
instances[2][0][VProps.AGGREGATED_STATE])
|
instances[2][0][VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
||||||
instances[2][0][VProps.OPERATIONAL_STATE])
|
instances[2][0][VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
self.assertEqual('SUSPENDED',
|
self.assertEqual('SUSPENDED',
|
||||||
instances[3][0][VProps.AGGREGATED_STATE])
|
instances[3][0][VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
||||||
instances[3][0][VProps.OPERATIONAL_STATE])
|
instances[3][0][VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
self.assertEqual('SUSPENDED',
|
self.assertEqual('SUSPENDED',
|
||||||
instances[4][0][VProps.AGGREGATED_STATE])
|
instances[4][0][VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
||||||
instances[4][0][VProps.OPERATIONAL_STATE])
|
instances[4][0][VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
self.assertEqual('SUBOPTIMAL',
|
self.assertEqual('SUBOPTIMAL',
|
||||||
instances[5][0][VProps.AGGREGATED_STATE])
|
instances[5][0][VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
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):
|
def _create_and_check_entity(self, processor=None, **kwargs):
|
||||||
# create instance event with host neighbor
|
# create instance event with host neighbor
|
||||||
@ -413,6 +413,6 @@ class TestProcessor(TestEntityGraphUnitBase):
|
|||||||
else:
|
else:
|
||||||
deleted_edges = processor.entity_graph.get_edges(
|
deleted_edges = processor.entity_graph.get_edges(
|
||||||
vertex_id,
|
vertex_id,
|
||||||
attr_filter={VProps.IS_DELETED: True})
|
attr_filter={VProps.VITRAGE_IS_DELETED: True})
|
||||||
self.assertEqual(num_edges + len(deleted_edges),
|
self.assertEqual(num_edges + len(deleted_edges),
|
||||||
processor.entity_graph.num_edges())
|
processor.entity_graph.num_edges())
|
||||||
|
@ -99,55 +99,57 @@ class TestDatasourceInfoMapper(base.BaseTest):
|
|||||||
missing_states + erroneous_values
|
missing_states + erroneous_values
|
||||||
self.assertEqual(num_valid_datasources, len(conf.datasources.types))
|
self.assertEqual(num_valid_datasources, len(conf.datasources.types))
|
||||||
|
|
||||||
def test_operational_state_exists(self):
|
def test_vitrage_operational_state_exists(self):
|
||||||
# setup
|
# setup
|
||||||
state_manager = DatasourceInfoMapper(self.conf)
|
state_manager = DatasourceInfoMapper(self.conf)
|
||||||
|
|
||||||
# action
|
# action
|
||||||
operational_state = \
|
vitrage_operational_state = \
|
||||||
state_manager.operational_state(NOVA_INSTANCE_DATASOURCE,
|
state_manager.vitrage_operational_state(NOVA_INSTANCE_DATASOURCE,
|
||||||
'BUILDING')
|
'BUILDING')
|
||||||
|
|
||||||
# test assertions
|
# 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
|
# setup
|
||||||
state_manager = DatasourceInfoMapper(self.conf)
|
state_manager = DatasourceInfoMapper(self.conf)
|
||||||
|
|
||||||
# action
|
# action
|
||||||
operational_state = \
|
vitrage_operational_state = \
|
||||||
state_manager.operational_state(NOVA_INSTANCE_DATASOURCE,
|
state_manager.vitrage_operational_state(NOVA_INSTANCE_DATASOURCE,
|
||||||
'NON EXISTING STATE')
|
'NON EXISTING STATE')
|
||||||
|
|
||||||
# test assertions
|
# test assertions
|
||||||
self.assertEqual(OperationalResourceState.NA, operational_state)
|
self.assertEqual(OperationalResourceState.NA,
|
||||||
|
vitrage_operational_state)
|
||||||
|
|
||||||
def test_operational_state_datasource_not_exists_and_state_not_exist(self):
|
def test_vitrage_operational_state_DS_not_exists_and_state_not_exist(self):
|
||||||
# setup
|
# setup
|
||||||
state_manager = DatasourceInfoMapper(self.conf)
|
state_manager = DatasourceInfoMapper(self.conf)
|
||||||
|
|
||||||
# action
|
# action
|
||||||
operational_state = \
|
vitrage_operational_state = \
|
||||||
state_manager.operational_state('NON EXISTING DATASOURCE',
|
state_manager.vitrage_operational_state('NON EXISTING DATASOURCE',
|
||||||
'BUILDING')
|
'BUILDING')
|
||||||
|
|
||||||
# test assertions
|
# test assertions
|
||||||
self.assertEqual(OperationalResourceState.NA,
|
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_exist(self):
|
||||||
# setup
|
# setup
|
||||||
state_manager = DatasourceInfoMapper(self.conf)
|
state_manager = DatasourceInfoMapper(self.conf)
|
||||||
|
|
||||||
# action
|
# action
|
||||||
operational_state = \
|
vitrage_operational_state = \
|
||||||
state_manager.operational_state('NON EXISTING DATASOURCE',
|
state_manager.vitrage_operational_state('NON EXISTING DATASOURCE',
|
||||||
'AVAILABLE')
|
'AVAILABLE')
|
||||||
|
|
||||||
# test assertions
|
# test assertions
|
||||||
self.assertEqual(OperationalResourceState.OK,
|
self.assertEqual(OperationalResourceState.OK,
|
||||||
operational_state)
|
vitrage_operational_state)
|
||||||
|
|
||||||
def test_state_priority(self):
|
def test_state_priority(self):
|
||||||
# setup
|
# setup
|
||||||
@ -186,110 +188,115 @@ class TestDatasourceInfoMapper(base.BaseTest):
|
|||||||
self.assertEqual(10,
|
self.assertEqual(10,
|
||||||
state_priority)
|
state_priority)
|
||||||
|
|
||||||
def test_aggregated_state(self):
|
def test_vitrage_aggregated_state(self):
|
||||||
# setup
|
# setup
|
||||||
state_manager = DatasourceInfoMapper(self.conf)
|
state_manager = DatasourceInfoMapper(self.conf)
|
||||||
metadata1 = {VProps.VITRAGE_STATE: 'SUSPENDED'}
|
metadata1 = {VProps.VITRAGE_STATE: 'SUSPENDED'}
|
||||||
new_vertex1 = create_vertex('12345',
|
new_vertex1 = create_vertex('12345',
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=NOVA_INSTANCE_DATASOURCE,
|
||||||
entity_state='ACTIVE',
|
entity_state='ACTIVE',
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=NOVA_INSTANCE_DATASOURCE,
|
|
||||||
metadata=metadata1)
|
metadata=metadata1)
|
||||||
metadata2 = {VProps.VITRAGE_STATE: 'ACTIVE'}
|
metadata2 = {VProps.VITRAGE_STATE: 'ACTIVE'}
|
||||||
new_vertex2 = create_vertex('23456',
|
new_vertex2 = create_vertex('23456',
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=NOVA_INSTANCE_DATASOURCE,
|
||||||
entity_state='SUSPENDED',
|
entity_state='SUSPENDED',
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=NOVA_INSTANCE_DATASOURCE,
|
|
||||||
metadata=metadata2)
|
metadata=metadata2)
|
||||||
|
|
||||||
# action
|
# action
|
||||||
state_manager.aggregated_state(new_vertex1, None)
|
state_manager.vitrage_aggregated_state(new_vertex1, None)
|
||||||
state_manager.aggregated_state(new_vertex2, None)
|
state_manager.vitrage_aggregated_state(new_vertex2, None)
|
||||||
|
|
||||||
# test assertions
|
# test assertions
|
||||||
self.assertEqual('SUSPENDED', new_vertex1[VProps.AGGREGATED_STATE])
|
self.assertEqual('SUSPENDED',
|
||||||
|
new_vertex1[VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
||||||
new_vertex1[VProps.OPERATIONAL_STATE])
|
new_vertex1[VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
self.assertEqual('SUSPENDED', new_vertex2[VProps.AGGREGATED_STATE])
|
self.assertEqual('SUSPENDED',
|
||||||
|
new_vertex2[VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
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
|
# setup
|
||||||
state_manager = DatasourceInfoMapper(self.conf)
|
state_manager = DatasourceInfoMapper(self.conf)
|
||||||
new_vertex1 = create_vertex('12345',
|
new_vertex1 = create_vertex('12345',
|
||||||
entity_state='ACTIVE',
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
vitrage_type=NOVA_INSTANCE_DATASOURCE,
|
||||||
entity_type=NOVA_INSTANCE_DATASOURCE)
|
entity_state='ACTIVE')
|
||||||
metadata2 = {VProps.VITRAGE_STATE: 'SUBOPTIMAL'}
|
metadata2 = {VProps.VITRAGE_STATE: 'SUBOPTIMAL'}
|
||||||
new_vertex2 = create_vertex('23456',
|
new_vertex2 = create_vertex('23456',
|
||||||
entity_category=EntityCategory.RESOURCE,
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
entity_type=NOVA_INSTANCE_DATASOURCE,
|
vitrage_type=NOVA_INSTANCE_DATASOURCE,
|
||||||
metadata=metadata2)
|
metadata=metadata2)
|
||||||
metadata3 = {VProps.VITRAGE_STATE: 'SUBOPTIMAL'}
|
metadata3 = {VProps.VITRAGE_STATE: 'SUBOPTIMAL'}
|
||||||
new_vertex3 = create_vertex('34567',
|
new_vertex3 = create_vertex('34567',
|
||||||
entity_state='ACTIVE',
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
entity_category=EntityCategory.RESOURCE,
|
vitrage_type=NOVA_INSTANCE_DATASOURCE,
|
||||||
entity_type=NOVA_INSTANCE_DATASOURCE)
|
entity_state='ACTIVE')
|
||||||
graph_vertex3 = create_vertex('34567',
|
graph_vertex3 = create_vertex('34567',
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type=NOVA_INSTANCE_DATASOURCE,
|
||||||
entity_state='SUSPENDED',
|
entity_state='SUSPENDED',
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type=NOVA_INSTANCE_DATASOURCE,
|
|
||||||
metadata=metadata3)
|
metadata=metadata3)
|
||||||
|
|
||||||
# action
|
# action
|
||||||
state_manager.aggregated_state(new_vertex1,
|
state_manager.vitrage_aggregated_state(new_vertex1,
|
||||||
None)
|
None)
|
||||||
state_manager.aggregated_state(new_vertex2,
|
state_manager.vitrage_aggregated_state(new_vertex2,
|
||||||
None)
|
None)
|
||||||
state_manager.aggregated_state(new_vertex3,
|
state_manager.vitrage_aggregated_state(new_vertex3,
|
||||||
graph_vertex3)
|
graph_vertex3)
|
||||||
|
|
||||||
# test assertions
|
# test assertions
|
||||||
self.assertEqual('ACTIVE', new_vertex1[VProps.AGGREGATED_STATE])
|
self.assertEqual('ACTIVE',
|
||||||
|
new_vertex1[VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.OK,
|
self.assertEqual(OperationalResourceState.OK,
|
||||||
new_vertex1[VProps.OPERATIONAL_STATE])
|
new_vertex1[VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
self.assertEqual('SUBOPTIMAL', new_vertex2[VProps.AGGREGATED_STATE])
|
self.assertEqual('SUBOPTIMAL',
|
||||||
|
new_vertex2[VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
||||||
new_vertex2[VProps.OPERATIONAL_STATE])
|
new_vertex2[VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
self.assertEqual('SUBOPTIMAL', new_vertex3[VProps.AGGREGATED_STATE])
|
self.assertEqual('SUBOPTIMAL',
|
||||||
|
new_vertex3[VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
self.assertEqual(OperationalResourceState.SUBOPTIMAL,
|
||||||
new_vertex3[VProps.OPERATIONAL_STATE])
|
new_vertex3[VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
|
|
||||||
def test_aggregated_state_datasource_not_exists(self):
|
def test_vitrage_aggregated_state_datasource_not_exists(self):
|
||||||
# setup
|
# setup
|
||||||
state_manager = DatasourceInfoMapper(self.conf)
|
state_manager = DatasourceInfoMapper(self.conf)
|
||||||
metadata = {VProps.VITRAGE_STATE: 'SUSPENDED'}
|
metadata = {VProps.VITRAGE_STATE: 'SUSPENDED'}
|
||||||
new_vertex = create_vertex('12345',
|
new_vertex = create_vertex('12345',
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type='NON EXISTING DATASOURCE',
|
||||||
entity_state='ACTIVE',
|
entity_state='ACTIVE',
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type='NON EXISTING DATASOURCE',
|
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
# action
|
# action
|
||||||
state_manager.aggregated_state(new_vertex, None)
|
state_manager.vitrage_aggregated_state(new_vertex, None)
|
||||||
|
|
||||||
# test assertions
|
# test assertions
|
||||||
self.assertEqual('ACTIVE',
|
self.assertEqual('ACTIVE',
|
||||||
new_vertex[VProps.AGGREGATED_STATE])
|
new_vertex[VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.OK,
|
self.assertEqual(OperationalResourceState.OK,
|
||||||
new_vertex[VProps.OPERATIONAL_STATE])
|
new_vertex[VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
|
|
||||||
def test_aggregated_state_datasource_not_exists_and_wrong_state(self):
|
def test_vitrage_aggregated_state_DS_not_exists_and_wrong_state(self):
|
||||||
# setup
|
# setup
|
||||||
state_manager = DatasourceInfoMapper(self.conf)
|
state_manager = DatasourceInfoMapper(self.conf)
|
||||||
metadata = {VProps.VITRAGE_STATE: 'SUSPENDED'}
|
metadata = {VProps.VITRAGE_STATE: 'SUSPENDED'}
|
||||||
new_vertex = create_vertex('12345',
|
new_vertex = create_vertex('12345',
|
||||||
|
vitrage_category=EntityCategory.RESOURCE,
|
||||||
|
vitrage_type='NON EXISTING DATASOURCE',
|
||||||
entity_state='NON EXISTING STATE',
|
entity_state='NON EXISTING STATE',
|
||||||
entity_category=EntityCategory.RESOURCE,
|
|
||||||
entity_type='NON EXISTING DATASOURCE',
|
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
|
||||||
# action
|
# action
|
||||||
state_manager.aggregated_state(new_vertex, None)
|
state_manager.vitrage_aggregated_state(new_vertex, None)
|
||||||
|
|
||||||
# test assertions
|
# test assertions
|
||||||
self.assertEqual('NON EXISTING STATE',
|
self.assertEqual('NON EXISTING STATE',
|
||||||
new_vertex[VProps.AGGREGATED_STATE])
|
new_vertex[VProps.VITRAGE_AGGREGATED_STATE])
|
||||||
self.assertEqual(OperationalResourceState.NA,
|
self.assertEqual(OperationalResourceState.NA,
|
||||||
new_vertex[VProps.OPERATIONAL_STATE])
|
new_vertex[VProps.VITRAGE_OPERATIONAL_STATE])
|
||||||
|
@ -31,7 +31,7 @@ class RaiseAlarmRecipeTest(base.BaseTest):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
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_vertex = Vertex('RESOURCE:nova.host:test1',
|
||||||
cls.target_props)
|
cls.target_props)
|
||||||
cls.targets = {TFields.TARGET: cls.target_vertex}
|
cls.targets = {TFields.TARGET: cls.target_vertex}
|
||||||
@ -66,7 +66,7 @@ class RaiseAlarmRecipeTest(base.BaseTest):
|
|||||||
|
|
||||||
alarm_vitrage_resource_type = \
|
alarm_vitrage_resource_type = \
|
||||||
add_vertex_step_params[VProps.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)
|
alarm_vitrage_resource_type)
|
||||||
|
|
||||||
def test_get_undo_recipe(self):
|
def test_get_undo_recipe(self):
|
||||||
@ -97,5 +97,5 @@ class RaiseAlarmRecipeTest(base.BaseTest):
|
|||||||
|
|
||||||
alarm_vitrage_resource_type = \
|
alarm_vitrage_resource_type = \
|
||||||
remove_vertex_step_params[VProps.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)
|
alarm_vitrage_resource_type)
|
||||||
|
@ -12,6 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# 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.evaluator.equivalence_data import EquivalenceData
|
||||||
from vitrage.tests import base
|
from vitrage.tests import base
|
||||||
from vitrage.tests.mocks import utils
|
from vitrage.tests.mocks import utils
|
||||||
@ -34,15 +40,15 @@ class EquivalenceTemplateTest(base.BaseTest):
|
|||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
frozenset([
|
frozenset([
|
||||||
frozenset([('category', 'ALARM'),
|
frozenset([(VProps.VITRAGE_CATEGORY, EntityCategory.ALARM),
|
||||||
('type', 'nagios'),
|
(VProps.VITRAGE_TYPE, NAGIOS_DATASOURCE),
|
||||||
('name', 'host_problem')]),
|
(VProps.NAME, 'host_problem')]),
|
||||||
frozenset([('category', 'ALARM'),
|
frozenset([(VProps.VITRAGE_CATEGORY, EntityCategory.ALARM),
|
||||||
('type', 'zabbix'),
|
(VProps.VITRAGE_TYPE, ZABBIX_DATASOURCE),
|
||||||
('name', 'host_fail')]),
|
(VProps.NAME, 'host_fail')]),
|
||||||
frozenset([('category', 'ALARM'),
|
frozenset([(VProps.VITRAGE_CATEGORY, EntityCategory.ALARM),
|
||||||
('type', 'vitrage'),
|
(VProps.VITRAGE_TYPE, VITRAGE_DATASOURCE),
|
||||||
('name', 'host_down')])
|
(VProps.NAME, 'host_down')])
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -11,10 +11,13 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from oslo_config import cfg
|
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.scenario_repository import ScenarioRepository
|
||||||
from vitrage.evaluator.template_validation.template_syntax_validator import \
|
from vitrage.evaluator.template_validation.template_syntax_validator import \
|
||||||
syntax_validation
|
syntax_validation
|
||||||
@ -117,11 +120,11 @@ class EquivalentScenarioTest(base.BaseTest):
|
|||||||
|
|
||||||
def test_expansion(self):
|
def test_expansion(self):
|
||||||
entity_scenarios = self.scenario_repository.entity_scenarios
|
entity_scenarios = self.scenario_repository.entity_scenarios
|
||||||
for entity_key, scenarios in entity_scenarios.items():
|
for key, scenarios in entity_scenarios.items():
|
||||||
if ('category', 'ALARM') in entity_key:
|
if (VProps.VITRAGE_CATEGORY, EntityCategory.ALARM) in key:
|
||||||
# scenarios expanded on the other alarm
|
# scenarios expanded on the other alarm
|
||||||
self.assertEqual(len(scenarios), 2)
|
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
|
# Scenarios expanded on the two alarms. Each alarm is expanded
|
||||||
# to two equivalent alarms. Thus 2 x 2 = 4 in total
|
# to two equivalent alarms. Thus 2 x 2 = 4 in total
|
||||||
self.assertEqual(len(scenarios), 4)
|
self.assertEqual(len(scenarios), 4)
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# 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.nova.host import NOVA_HOST_DATASOURCE
|
||||||
from vitrage.evaluator.template_data import ActionSpecs
|
from vitrage.evaluator.template_data import ActionSpecs
|
||||||
from vitrage.evaluator.template_data import ConditionVar
|
from vitrage.evaluator.template_data import ConditionVar
|
||||||
from vitrage.evaluator.template_data import EdgeDescription
|
from vitrage.evaluator.template_data import EdgeDescription
|
||||||
@ -43,22 +47,29 @@ class BasicTemplateTest(base.BaseTest):
|
|||||||
definitions = template_definition[TFields.DEFINITIONS]
|
definitions = template_definition[TFields.DEFINITIONS]
|
||||||
|
|
||||||
# Assertions
|
# Assertions
|
||||||
entities_definition = definitions[TFields.ENTITIES]
|
for definition in definitions[TFields.ENTITIES]:
|
||||||
self._validate_entities(entities, entities_definition)
|
for key, value in definition['entity'].items():
|
||||||
|
new_key = TemplateData.PROPS_CONVERSION[key] if key in \
|
||||||
|
TemplateData.PROPS_CONVERSION else key
|
||||||
|
del definition['entity'][key]
|
||||||
|
definition['entity'][new_key] = value
|
||||||
|
self._validate_entities(entities, definitions[TFields.ENTITIES])
|
||||||
|
|
||||||
relate_def = definitions[TFields.RELATIONSHIPS]
|
relate_def = definitions[TFields.RELATIONSHIPS]
|
||||||
self._validate_relationships(relationships, relate_def, entities)
|
self._validate_relationships(relationships, relate_def, entities)
|
||||||
self._validate_scenarios(scenarios, entities)
|
self._validate_scenarios(scenarios, entities)
|
||||||
|
|
||||||
expected_entities = {
|
expected_entities = {
|
||||||
'alarm': Vertex(vertex_id='alarm',
|
'alarm': Vertex(
|
||||||
properties={'category': 'ALARM',
|
vertex_id='alarm',
|
||||||
'type': 'nagios',
|
properties={VProps.VITRAGE_CATEGORY: EntityCategory.ALARM,
|
||||||
'name': 'host_problem'
|
VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE,
|
||||||
|
VProps.NAME: 'host_problem'
|
||||||
}),
|
}),
|
||||||
'resource': Vertex(vertex_id='resource',
|
'resource': Vertex(
|
||||||
properties={'category': 'RESOURCE',
|
vertex_id='resource',
|
||||||
'type': 'nova.host'
|
properties={VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
|
||||||
|
VProps.VITRAGE_TYPE: NOVA_HOST_DATASOURCE
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +131,7 @@ class BasicTemplateTest(base.BaseTest):
|
|||||||
self.assertIsInstance(entity, Vertex)
|
self.assertIsInstance(entity, Vertex)
|
||||||
self.assertEqual(entity_id, entity.vertex_id)
|
self.assertEqual(entity_id, entity.vertex_id)
|
||||||
self.assertIsNotNone(entity.properties)
|
self.assertIsNotNone(entity.properties)
|
||||||
self.assertIn(TFields.CATEGORY, entity.properties)
|
self.assertIn(VProps.VITRAGE_CATEGORY, entity.properties)
|
||||||
|
|
||||||
self.assertEqual(len(entities), len(entities_def))
|
self.assertEqual(len(entities), len(entities_def))
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user