From 4d7f6753d6017c0175de9b14c437ac6dd4bc701a Mon Sep 17 00:00:00 2001 From: danoffek Date: Sun, 29 Jan 2017 15:10:12 +0000 Subject: [PATCH] no more mocks Change-Id: I001112faa4f8d7a8ba44cb719950f407af8d0d26 --- devstack/plugin.sh | 3 - etc/vitrage/alarms.sample.json | 64 ---- etc/vitrage/graph.sample.json | 434 ------------------------- etc/vitrage/rca.sample.json | 65 ---- etc/vitrage/vitrage.conf.sample | 3 - vitrage/api/__init__.py | 3 - vitrage/api/controllers/rest.py | 21 -- vitrage/api/controllers/v1/alarm.py | 5 +- vitrage/api/controllers/v1/rca.py | 5 +- vitrage/api/controllers/v1/topology.py | 5 +- 10 files changed, 3 insertions(+), 605 deletions(-) delete mode 100644 etc/vitrage/alarms.sample.json delete mode 100644 etc/vitrage/graph.sample.json delete mode 100644 etc/vitrage/rca.sample.json diff --git a/devstack/plugin.sh b/devstack/plugin.sh index c88eabda8..d355d0c12 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -161,9 +161,6 @@ function configure_vitrage { # add default datasources iniset $VITRAGE_CONF datasources types $VITRAGE_DEFAULT_DATASOURCES - # copy the mock sample files - cp $VITRAGE_DIR/etc/vitrage/*.sample.json $VITRAGE_CONF_DIR - # create some folders mkdir -p $VITRAGE_CONF_DIR/datasources_values mkdir -p $VITRAGE_CONF_DIR/static_datasources diff --git a/etc/vitrage/alarms.sample.json b/etc/vitrage/alarms.sample.json deleted file mode 100644 index 6313471f2..000000000 --- a/etc/vitrage/alarms.sample.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "alarms": - [ - { - "category": "ALARM", - "type": "nagios", - "name": "CPU load", - "state": "Active", - "severity": "WARNING", - "update_timestamp": "2015-12-01T12:46:41Z", - "info": "WARNING - 15min load 1.66 at 32 CPUs", - "resource_type": "nova.host", - "resource_name": "host-0", - "resource_id": "host-0", - "id": 0, - "vitrage_id": "ALARM:nagios:host0:CPU load", - "normalized_severity": "WARNING" - }, - { - "category": "ALARM", - "type": "vitrage", - "name": "Machine Suboptimal", - "state": "Active", - "severity": "CRITICAL", - "update_timestamp": "2015-12-01T12:46:41Z", - "resource_type": "nova.instance", - "resource_name": "vm0", - "resource_id": "20d12a8a-ea9a-89c6-5947-83bea959362e", - "id": 1, - "vitrage_id": "ALARM:vitrage:vm0:Machine Suboptimal", - "normalized_severity": "CRITICAL" - }, - { - "category": "ALARM", - "type": "vitrage", - "name": "Machine Suboptimal", - "state": "Active", - "severity": "CRITICAL", - "update_timestamp": "2015-12-01T12:46:41Z", - "resource_type": "nova.instance", - "resource_name": "vm1", - "resource_id": "275097cf-954e-8e24-b185-9514e24b8591", - "id": 2, - "vitrage_id": "ALARM:vitrage:vm1:Machine Suboptimal", - "normalized_severity": "CRITICAL" - }, - { - "category": "ALARM", - "type": "aodh", - "name": "Memory overload", - "state": "Active", - "severity": "WARNING", - "update_timestamp": "2015-12-01T12:46:41Z", - "info": "WARNING - 15min load 1.66 at 32 CPUs", - "resource_type": "nova.host", - "resource_name": "host-0", - "resource_id": "host-0", - "id": 3, - "vitrage_id": "ALARM:aodh:host0:Memory overload", - "normalized_severity": "WARNING" - } - ] -} - diff --git a/etc/vitrage/graph.sample.json b/etc/vitrage/graph.sample.json deleted file mode 100644 index dfc218c03..000000000 --- a/etc/vitrage/graph.sample.json +++ /dev/null @@ -1,434 +0,0 @@ -{ - "directed": true, - "graph": {}, - "nodes": [ - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-8", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "20d12a8a-ea9a-89c6-5947-83bea959362e", - "vitrage_id": "RESOURCE:nova.instance:20d12a8a-ea9a-89c6-5947-83bea959362e", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-2", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "dc35fa2f-4515-1653-ef6b-03b471bb395b", - "vitrage_id": "RESOURCE:nova.instance:dc35fa2f-4515-1653-ef6b-03b471bb395b", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-13", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "9879cf5a-bdcf-3651-3017-961ed887ec86", - "vitrage_id": "RESOURCE:nova.instance:9879cf5a-bdcf-3651-3017-961ed887ec86", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-10", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "fe124f4b-9ed7-4591-fcd1-803cf5c33cb1", - "vitrage_id": "RESOURCE:nova.instance:fe124f4b-9ed7-4591-fcd1-803cf5c33cb1", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-11", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "f2e48a97-7350-061e-12d3-84c6dc3e67c0", - "vitrage_id": "RESOURCE:nova.instance:f2e48a97-7350-061e-12d3-84c6dc3e67c0", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "host-2", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "available", - "type": "nova.host", - "id": "host-2", - "vitrage_id": "RESOURCE:nova.host:host-2", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "host-3", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "available", - "type": "nova.host", - "id": "host-3", - "vitrage_id": "RESOURCE:nova.host:host-3", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "host-0", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "available", - "type": "nova.host", - "id": "host-0", - "vitrage_id": "RESOURCE:nova.host:host-0", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "host-1", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "available", - "type": "nova.host", - "id": "host-1", - "vitrage_id": "RESOURCE:nova.host:host-1", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-9", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "275097cf-954e-8e24-b185-9514e24b8591", - "vitrage_id": "RESOURCE:nova.instance:275097cf-954e-8e24-b185-9514e24b8591", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-1", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "a0f0805f-c804-cffe-c25a-1b38f555ed68", - "vitrage_id": "RESOURCE:nova.instance:a0f0805f-c804-cffe-c25a-1b38f555ed68", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-14", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "56af57d2-34a4-19b1-5106-b613637a11a7", - "vitrage_id": "RESOURCE:nova.instance:56af57d2-34a4-19b1-5106-b613637a11a7", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "zone-1", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "available", - "type": "nova.zone", - "id": "zone-1", - "vitrage_id": "RESOURCE:nova.zone:zone-1", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-3", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "16e14c58-d254-2bec-53e4-c766e48810aa", - "vitrage_id": "RESOURCE:nova.instance:16e14c58-d254-2bec-53e4-c766e48810aa", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-7", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "SUSPENDED", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "f35a1e10-74ff-7332-8edf-83cd6ffcb2de", - "vitrage_id": "RESOURCE:nova.instance:f35a1e10-74ff-7332-8edf-83cd6ffcb2de", - "aggregated_state": "SUSPENDED" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-4", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "ea8a450e-cab1-2272-f431-494b40c5c378", - "vitrage_id": "RESOURCE:nova.instance:ea8a450e-cab1-2272-f431-494b40c5c378", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-6", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "6e42bdc3-b776-1b2c-2c7d-b7a8bb98f721", - "vitrage_id": "RESOURCE:nova.instance:6e42bdc3-b776-1b2c-2c7d-b7a8bb98f721", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-5", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ACTIVE", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "8c951613-c660-87c0-c18b-0fa3293ce8d8", - "vitrage_id": "RESOURCE:nova.instance:8c951613-c660-87c0-c18b-0fa3293ce8d8", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "zone-0", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "available", - "type": "nova.zone", - "id": "zone-0", - "vitrage_id": "RESOURCE:nova.zone:zone-0", - "aggregated_state": "RUNNING" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-0", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "ERROR", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "78353ce4-2710-49b5-1341-b8cbb6000ebc", - "vitrage_id": "RESOURCE:nova.instance:78353ce4-2710-49b5-1341-b8cbb6000ebc", - "aggregated_state": "ERROR" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "vm-12", - "update_timestamp": "2015-12-01T12:46:41Z", - "state": "PAUSED", - "project_id": "0683517e1e354d2ba25cba6937f44e79", - "type": "nova.instance", - "id": "35bf479a-75d9-80a9-874e-d3b50fb2dd2e", - "vitrage_id": "RESOURCE:nova.instance:35bf479a-75d9-80a9-874e-d3b50fb2dd2e", - "aggregated_state": "SUSPENDED" - }, - { - "category": "RESOURCE", - "is_placeholder": false, - "is_deleted": false, - "name": "openstack.cluster", - "type": "openstack.cluster", - "id": "openstack.cluster", - "vitrage_id": "RESOURCE:openstack.cluster", - "state": "available", - "aggregated_state": "RUNNING" - } - ], - "links": [ - { - "relationship_name": "contains", - "is_deleted": false, - "target": 3, - "key": "contains", - "source": 5 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 1, - "key": "contains", - "source": 5 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 16, - "key": "contains", - "source": 5 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 11, - "key": "contains", - "source": 5 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 13, - "key": "contains", - "source": 6 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 4, - "key": "contains", - "source": 6 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 14, - "key": "contains", - "source": 6 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 20, - "key": "contains", - "source": 7 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 0, - "key": "contains", - "source": 7 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 19, - "key": "contains", - "source": 7 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 15, - "key": "contains", - "source": 7 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 9, - "key": "contains", - "source": 8 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 10, - "key": "contains", - "source": 8 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 2, - "key": "contains", - "source": 8 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 17, - "key": "contains", - "source": 8 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 6, - "key": "contains", - "source": 12 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 8, - "key": "contains", - "source": 12 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 5, - "key": "contains", - "source": 18 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 7, - "key": "contains", - "source": 18 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 18, - "key": "contains", - "source": 21 - }, - { - "relationship_name": "contains", - "is_deleted": false, - "target": 12, - "key": "contains", - "source": 21 - } - ], - "multigraph": true -} \ No newline at end of file diff --git a/etc/vitrage/rca.sample.json b/etc/vitrage/rca.sample.json deleted file mode 100644 index 02520a43d..000000000 --- a/etc/vitrage/rca.sample.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "directed": true, - "graph": { - - }, - "nodes": [ - { - "category": "ALARM", - "type": "nagios", - "name": "CPU load", - "state": "Active", - "severity": "WARNING", - "update_timestamp": "2015-12-01T12:46:41Z", - "info": "WARNING - 15min load 1.66 at 32 CPUs", - "resource_type": "nova.host", - "resource_name": "host-0", - "resource_id": "host-0", - "id": 0, - "vitrage_id": "ALARM:nagios:host0:CPU load", - "normalized_severity": "WARNING" - }, - { - "category": "ALARM", - "type": "vitrage", - "name": "Machine Suboptimal", - "state": "Active", - "severity": "CRITICAL", - "update_timestamp": "2015-12-01T12:46:41Z", - "resource_type": "nova.instance", - "resource_name": "vm0", - "resource_id": "20d12a8a-ea9a-89c6-5947-83bea959362e", - "id": 1, - "vitrage_id": "ALARM:vitrage:vm0:Machine Suboptimal", - "normalized_severity": "CRITICAL" - }, - { - "category": "ALARM", - "type": "vitrage", - "name": "Machine Suboptimal", - "state": "Active", - "severity": "CRITICAL", - "update_timestamp": "2015-12-01T12:46:41Z", - "resource_type": "nova.instance", - "resource_name": "vm1", - "resource_id": "275097cf-954e-8e24-b185-9514e24b8591", - "id": 2, - "vitrage_id": "ALARM:vitrage:vm1:Machine Suboptimal", - "normalized_severity": "CRITICAL" - } - ], - "links": [ - { - "source": 0, - "target": 1, - "relationship": "causes" - }, - { - "source": 0, - "target": 2, - "relationship": "causes" - } - ], - "multigraph": false, - "inspected_index": 0 -} diff --git a/etc/vitrage/vitrage.conf.sample b/etc/vitrage/vitrage.conf.sample index 90181f595..f16d10d21 100644 --- a/etc/vitrage/vitrage.conf.sample +++ b/etc/vitrage/vitrage.conf.sample @@ -150,9 +150,6 @@ # Toggle Pecan Debug Middleware. (boolean value) #pecan_debug = false -# Toggle mock file for debugging. (boolean value) -#use_mock_file = false - [consistency] diff --git a/vitrage/api/__init__.py b/vitrage/api/__init__.py index 63f3763a7..bc319e189 100644 --- a/vitrage/api/__init__.py +++ b/vitrage/api/__init__.py @@ -34,7 +34,4 @@ OPTS = [ cfg.BoolOpt('pecan_debug', default=False, help='Toggle Pecan Debug Middleware.'), - - cfg.BoolOpt('use_mock_file', default=False, - help='Toggle mock file for debugging.'), ] diff --git a/vitrage/api/controllers/rest.py b/vitrage/api/controllers/rest.py index 60f916bf5..f48bb1c25 100644 --- a/vitrage/api/controllers/rest.py +++ b/vitrage/api/controllers/rest.py @@ -12,13 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. -import json - import networkx as nx from networkx.readwrite import json_graph from oslo_log import log -import pecan as pecan -from pecan import abort from pecan import rest from vitrage.datasources import OPENSTACK_CLUSTER @@ -36,20 +32,3 @@ class RootRestController(rest.RestController): if reverse: linked_graph = linked_graph.reverse() return json_graph.tree_data(linked_graph, root=root) - - @staticmethod - def get_mock_data(file_name, graph_type='graph'): - graph_file = pecan.request.cfg.find_file(file_name) - if graph_file is None: - abort(404, 'file %s not found' % file_name) - try: - with open(graph_file) as data_file: - graph = json.load(data_file) - if graph_type == 'graph': - return graph - if graph_type == 'tree': - return RootRestController.as_tree(graph) - - except Exception as e: - LOG.exception('failed to open file %s', e) - abort(404, str(e)) diff --git a/vitrage/api/controllers/v1/alarm.py b/vitrage/api/controllers/v1/alarm.py index 754139a10..fdfe073c2 100644 --- a/vitrage/api/controllers/v1/alarm.py +++ b/vitrage/api/controllers/v1/alarm.py @@ -46,10 +46,7 @@ class AlarmsController(RootRestController): vitrage_id) try: - if pecan.request.cfg.api.use_mock_file: - return self.get_mock_data('alarms.sample.json') - else: - return self._get_alarms(vitrage_id, all_tenants) + return self._get_alarms(vitrage_id, all_tenants) except Exception as e: LOG.exception('failed to get alarms %s', e) abort(404, str(e)) diff --git a/vitrage/api/controllers/v1/rca.py b/vitrage/api/controllers/v1/rca.py index 210c38bb1..1d22e647b 100644 --- a/vitrage/api/controllers/v1/rca.py +++ b/vitrage/api/controllers/v1/rca.py @@ -43,10 +43,7 @@ class RCAController(RootRestController): pecan.request.enforcer, {}) LOG.info(_LI('received show rca with alarm id %s') % alarm_id) - if pecan.request.cfg.api.use_mock_file: - return self.get_mock_data('rca.sample.json') - else: - return self.get_rca(alarm_id, all_tenants) + return self.get_rca(alarm_id, all_tenants) @staticmethod def get_rca(alarm_id, all_tenants): diff --git a/vitrage/api/controllers/v1/topology.py b/vitrage/api/controllers/v1/topology.py index d6b0de28c..8211f2844 100644 --- a/vitrage/api/controllers/v1/topology.py +++ b/vitrage/api/controllers/v1/topology.py @@ -51,10 +51,7 @@ class TopologyController(RootRestController): LOG.info(_LI("query is %s") % query) - if pecan.request.cfg.api.use_mock_file: - return self.get_mock_data('graph.sample.json', graph_type) - else: - return self.get_graph(graph_type, depth, query, root, all_tenants) + return self.get_graph(graph_type, depth, query, root, all_tenants) @staticmethod def get_graph(graph_type, depth, query, root, all_tenants):