From e6a92f568b1f83b8d372fcecd9e06f5ce3a9f86a Mon Sep 17 00:00:00 2001 From: dongwenjuan Date: Thu, 30 Mar 2017 13:44:31 +0800 Subject: [PATCH] fix the type of `all_tenants` The type of `all_tenants` become to str, not boolean after the cli send the request to server. Change-Id: I8219ae04c7c46a473874c487914764e8c6744af0 Signed-off-by: dongwenjuan --- vitrage/api/controllers/v1/__init__.py | 18 ------------------ vitrage/api/controllers/v1/alarm.py | 6 ++++-- vitrage/api/controllers/v1/rca.py | 2 ++ vitrage/api/controllers/v1/topology.py | 2 ++ .../tests/api/event/test_events.py | 2 +- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/vitrage/api/controllers/v1/__init__.py b/vitrage/api/controllers/v1/__init__.py index bf07874fd..e69de29bb 100644 --- a/vitrage/api/controllers/v1/__init__.py +++ b/vitrage/api/controllers/v1/__init__.py @@ -1,18 +0,0 @@ -# Copyright 2016 - Nokia Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from vitrage.common.constants import EntityCategory -from vitrage.common.constants import VertexProperties as VProps - -RCA_QUERY = {'==': {VProps. CATEGORY: EntityCategory.ALARM}} diff --git a/vitrage/api/controllers/v1/alarm.py b/vitrage/api/controllers/v1/alarm.py index 8d0938bf6..72abdbfee 100644 --- a/vitrage/api/controllers/v1/alarm.py +++ b/vitrage/api/controllers/v1/alarm.py @@ -16,6 +16,7 @@ import json import pecan from oslo_log import log +from oslo_utils.strutils import bool_from_string from pecan.core import abort from vitrage.api.controllers.rest import RootRestController @@ -29,10 +30,11 @@ class AlarmsController(RootRestController): @pecan.expose('json') def index(self, vitrage_id, all_tenants=False): - return self.post(vitrage_id, all_tenants) + return self.get(vitrage_id, all_tenants) @pecan.expose('json') - def post(self, vitrage_id, all_tenants=False): + def get(self, vitrage_id, all_tenants=False): + all_tenants = bool_from_string(all_tenants) if all_tenants: enforce("list alarms:all_tenants", pecan.request.headers, pecan.request.enforcer, {}) diff --git a/vitrage/api/controllers/v1/rca.py b/vitrage/api/controllers/v1/rca.py index c4914fee8..25e8e68e6 100644 --- a/vitrage/api/controllers/v1/rca.py +++ b/vitrage/api/controllers/v1/rca.py @@ -17,6 +17,7 @@ import json import pecan from oslo_log import log +from oslo_utils.strutils import bool_from_string from pecan.core import abort from vitrage.api.controllers.rest import RootRestController from vitrage.api.policy import enforce @@ -32,6 +33,7 @@ class RCAController(RootRestController): @pecan.expose('json') def get(self, alarm_id, all_tenants=False): + all_tenants = bool_from_string(all_tenants) if all_tenants: enforce('get rca:all_tenants', pecan.request.headers, pecan.request.enforcer, {}) diff --git a/vitrage/api/controllers/v1/topology.py b/vitrage/api/controllers/v1/topology.py index 615e3cb05..39d915c25 100644 --- a/vitrage/api/controllers/v1/topology.py +++ b/vitrage/api/controllers/v1/topology.py @@ -16,6 +16,7 @@ import json from oslo_log import log +from oslo_utils.strutils import bool_from_string import pecan from pecan.core import abort @@ -34,6 +35,7 @@ class TopologyController(RootRestController): @pecan.expose('json') def post(self, depth, graph_type, query, root, all_tenants=False): + all_tenants = bool_from_string(all_tenants) if all_tenants: enforce('get topology:all_tenants', pecan.request.headers, pecan.request.enforcer, {}) diff --git a/vitrage_tempest_tests/tests/api/event/test_events.py b/vitrage_tempest_tests/tests/api/event/test_events.py index 604feaf9a..862d4adf9 100644 --- a/vitrage_tempest_tests/tests/api/event/test_events.py +++ b/vitrage_tempest_tests/tests/api/event/test_events.py @@ -77,7 +77,7 @@ class TestEvents(base.BaseTestCase): def _check_alarms(self): api_alarms = self.vitrage_client.alarm.list(vitrage_id='all', - all_tenants=False) + all_tenants=True) if api_alarms: return True, api_alarms