diff --git a/etc/vitrage/policy.json b/etc/vitrage/policy.json index 64e1670fc..3c823c93a 100644 --- a/etc/vitrage/policy.json +++ b/etc/vitrage/policy.json @@ -2,5 +2,6 @@ "get topology": "role:admin", "get resource": "role:admin", "list resources": "role:admin", - "list alarms": "role:admin" + "list alarms": "role:admin", + "get rca": "role:admin" } \ No newline at end of file diff --git a/vitrage/api/controllers/v1/rca.py b/vitrage/api/controllers/v1/rca.py new file mode 100644 index 000000000..fff2b44e1 --- /dev/null +++ b/vitrage/api/controllers/v1/rca.py @@ -0,0 +1,37 @@ +# 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. + +import pecan + +from oslo_log import log +from pecan import rest +from vitrage.api.policy import enforce +# noinspection PyProtectedMember +from vitrage.i18n import _LI + +LOG = log.getLogger(__name__) + + +class RCAController(rest.RestController): + @pecan.expose('json') + def get(self, alarm_id): + enforce("get rca", pecan.request.headers, + pecan.request.enforcer, {}) + + LOG.info(_LI('received show rca with alarm id %s') % + alarm_id) + pecan.request.context = dict(query=None, depth=None, root=None, + graph_type="graph") + # todo (eyalb1) need to figure how to redirect + # redirect('/v1/topology/', internal=True) diff --git a/vitrage/api/controllers/v1/root.py b/vitrage/api/controllers/v1/root.py index cda82198f..7347bf6f0 100644 --- a/vitrage/api/controllers/v1/root.py +++ b/vitrage/api/controllers/v1/root.py @@ -11,6 +11,7 @@ # under the License. from vitrage.api.controllers.v1 import alarms +from vitrage.api.controllers.v1 import rca from vitrage.api.controllers.v1 import resource from vitrage.api.controllers.v1 import topology @@ -19,3 +20,4 @@ class V1Controller(object): topology = topology.TopologyController() resources = resource.ResourcesController() alarms = alarms.AlarmsController() + rca = rca.RCAController()