Exemple #1
0
    def get(self, vitrage_id):

        LOG.info('get resource show with vitrage_id: %s', vitrage_id)

        enforce("get resource", pecan.request.headers, pecan.request.enforcer,
                {})

        return self._show_resource(vitrage_id)
Exemple #2
0
    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)
        if pecan.request.cfg.api.use_mock_file:
            return self.get_mock_data('rca.sample.json')
        else:
            return self.get_rca(alarm_id)
Exemple #3
0
    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)
        if pecan.request.cfg.api.use_mock_file:
            return self.get_mock_data('rca.sample.json')
        else:
            return self.get_rca(alarm_id)
Exemple #4
0
 def post(self, **kwargs):
     LOG.info("Add webhook with following props: %s" % str(kwargs))
     enforce('webhook add', pecan.request.headers, pecan.request.enforcer,
             {})
     try:
         return self._post(**kwargs)
     except Exception as e:
         LOG.exception('Failed to add webhooks %s', e)
         abort(400, str(e))
Exemple #5
0
    def get(self, vitrage_id):
        enforce("get alarm",
                pecan.request.headers,
                pecan.request.enforcer,
                {})

        LOG.info('returns show alarm with vitrage id %s', vitrage_id)

        return self._show_alarm(vitrage_id)
    def get(self, vitrage_id):
        enforce("get alarm", pecan.request.headers, pecan.request.enforcer, {})

        LOG.info('returns show alarm with vitrage id %s', vitrage_id)

        try:
            return self._show_alarm(vitrage_id)
        except Exception:
            LOG.exception('Failed to load JSON.')
            abort(404, "Failed to show alarm.")
Exemple #7
0
    def get(self):
        enforce("get resource", pecan.request.headers,
                pecan.request.enforcer, {})

        LOG.info(_LI('received get resource with id %s') % self.id)
        try:
            return self.get_resource(self.id)
        except Exception as e:
            LOG.exception("failed to get resource %s", e)
            abort(404, str(e))
Exemple #8
0
    def get(self):
        enforce('get resource', pecan.request.headers, pecan.request.enforcer,
                {})

        LOG.info(_LI('received get resource with id %s') % self.id)
        try:
            return self.get_resource(self.id)
        except Exception as e:
            LOG.exception('failed to get resource %s', e)
            abort(404, str(e))
Exemple #9
0
    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, {})
        else:
            enforce('get rca', pecan.request.headers, pecan.request.enforcer,
                    {})

        LOG.info('received show rca with alarm id %s', alarm_id)
        return self.get_rca(alarm_id, all_tenants)
Exemple #10
0
    def delete(self, id):

        LOG.info('delete webhook with id: %s', id)
        enforce("webhook delete", pecan.request.headers,
                pecan.request.enforcer, {})

        try:
            return self._delete_registration(id)
        except Exception:
            LOG.exception('Failed to delete webhook "%s"', id)
            abort(404, 'Failed to delete webhook.')
Exemple #11
0
    def get(self, vitrage_id):
        enforce("get alarm", pecan.request.headers, pecan.request.enforcer, {})

        LOG.info('returns show alarm with vitrage id %s', vitrage_id)

        try:
            return self._show_alarm(vitrage_id)
        except Exception as e:
            to_unicode = encodeutils.exception_to_unicode(e)
            LOG.exception('failed to load json %s ', to_unicode)
            abort(404, to_unicode)
Exemple #12
0
    def get(self, id):
        LOG.info('Show webhook with id: %s', id)

        enforce('webhook show', pecan.request.headers, pecan.request.enforcer,
                {})

        try:
            return self._get(id)
        except Exception as e:
            LOG.exception('Failed to get webhooks %s', e)
            abort(404, str(e))
Exemple #13
0
    def index(self, resource_type=None):
        enforce('list resources', pecan.request.headers,
                pecan.request.enforcer, {})

        LOG.info(_LI('received list resources with filter %s') % resource_type)

        try:
            return self.get_resources(resource_type)
        except Exception as e:
            LOG.exception('failed to get resources %s', e)
            abort(404, str(e))
Exemple #14
0
    def delete(self, **kwargs):
        uuid = kwargs['uuid']
        LOG.info("delete template. uuid: %s", str(uuid))

        enforce("template delete", pecan.request.headers,
                pecan.request.enforcer, {})
        try:
            return self._delete(uuid)
        except Exception:
            LOG.exception('Failed to delete template.')
            abort(404, 'Failed to delete template.')
Exemple #15
0
    def index(self, resource_type=None):
        enforce("list resources", pecan.request.headers,
                pecan.request.enforcer, {})

        LOG.info(_LI('received list resources with filter %s') % resource_type)

        try:
            return self.get_resources(resource_type)
        except Exception as e:
            LOG.exception("failed to get resources %s", e)
            abort(404, str(e))
Exemple #16
0
    def delete(self, id):

        LOG.info('delete webhook with id: %s', id)
        enforce("webhook delete", pecan.request.headers,
                pecan.request.enforcer, {})

        try:
            return self._delete_registration(id)
        except Exception as e:
            LOG.exception('Failed to delete webhook %s: ' '%s' % (id, str(e)))
            abort(404, str(e))
Exemple #17
0
    def get_all(self):

        LOG.info(_LI('returns template list'))

        enforce("template list", pecan.request.headers, pecan.request.enforcer,
                {})
        try:
            return self._get_templates()
        except Exception as e:
            LOG.exception('failed to get template list %s', e)
            abort(404, str(e))
Exemple #18
0
    def get_all(self):

        LOG.info('returns template list')

        enforce("template list", pecan.request.headers, pecan.request.enforcer,
                {})
        try:
            return self._get_templates()
        except Exception:
            LOG.exception('failed to get template list.')
            abort(404, 'Failed to get template list')
Exemple #19
0
    def post(self, **kwargs):
        LOG.info('Post event called with args: %s', kwargs)

        enforce("event post", pecan.request.headers, pecan.request.enforcer,
                {})

        event_time = kwargs['time']
        event_type = kwargs['type']
        details = kwargs['details']

        self.post_event(event_time, event_type, details)
Exemple #20
0
    def post(self, depth, graph_type, query, root):
        enforce("get topology", pecan.request.headers,
                pecan.request.enforcer, {})

        LOG.info(_LI('received get topology: depth->%(depth)s '
                     'graph_type->%(graph_type)s root->%(root)s') %
                 {'depth': depth, 'graph_type': graph_type, 'root': root})

        LOG.info(_LI("query is %s") % query)

        return self.get_graph(graph_type)
Exemple #21
0
    def get(self, template_uuid):

        LOG.info('get template content')

        enforce("template show", pecan.request.headers, pecan.request.enforcer,
                {})

        try:
            return self._show_template(template_uuid)
        except Exception:
            LOG.exception('Failed to show template %s.', template_uuid)
            abort(404, 'Failed to show template.')
Exemple #22
0
    def get(self, template_uuid):

        LOG.info(_LI('get template content'))

        enforce("template show", pecan.request.headers, pecan.request.enforcer,
                {})

        try:
            return self._show_template(template_uuid)
        except Exception as e:
            LOG.exception('failed to show template %s' % template_uuid, e)
            abort(404, str(e))
Exemple #23
0
    def get(self, vitrage_id):

        LOG.info('get resource show with vitrage_id: %s', vitrage_id)

        enforce("get resource", pecan.request.headers, pecan.request.enforcer,
                {})

        try:
            return self._show_resource(vitrage_id)
        except Exception as e:
            LOG.exception('failed to show resource %s, %s' % vitrage_id, e)
            abort(404, str(e))
Exemple #24
0
    def get_all(self):

        LOG.info('returns template list')

        enforce("template list", pecan.request.headers, pecan.request.enforcer,
                {})
        try:
            return self._get_templates()
        except Exception as e:
            to_unicode = encodeutils.exception_to_unicode(e)
            LOG.exception('failed to get template list %s', to_unicode)
            abort(404, to_unicode)
Exemple #25
0
 def get(self):
     enforce("get status", pecan.request.headers, pecan.request.enforcer,
             {})
     try:
         client = pecan.request.client.prepare(timeout=5)
         backend_is_alive = client.call(pecan.request.context, 'is_alive')
         if backend_is_alive:
             return {'reason': 'OK'}
         else:
             pecan.abort(503, detail='vitrage-graph is not ready')
     except oslo_messaging.MessagingTimeout:
         pecan.abort(503, detail='vitrage-graph is not available')
Exemple #26
0
    def get_all(self):

        LOG.info(_LI('returns template list'))

        enforce("template list",
                pecan.request.headers,
                pecan.request.enforcer,
                {})
        try:
            return self._get_templates()
        except Exception as e:
            LOG.exception('failed to get template list %s', e)
            abort(404, str(e))
Exemple #27
0
    def put(self, **kwargs):
        templates = kwargs['templates']
        LOG.info("add template: %s", templates)

        enforce("template add", pecan.request.headers, pecan.request.enforcer,
                {})
        template_type = kwargs['template_type']

        try:
            return self._add(templates, template_type)
        except Exception:
            LOG.exception('Failed to add template.')
            abort(404, 'Failed to add template.')
Exemple #28
0
    def post(self, **kwargs):

        LOG.info('validate template. args: %s', kwargs)

        enforce("template validate", pecan.request.headers,
                pecan.request.enforcer, {})

        templates = kwargs['templates']

        try:
            return self._validate(templates)
        except Exception as e:
            LOG.exception('failed to validate template(s) %s', e)
            abort(404, str(e))
Exemple #29
0
    def get(self, template_uuid):

        LOG.info('get template content')

        enforce("template show", pecan.request.headers, pecan.request.enforcer,
                {})

        try:
            return self._show_template(template_uuid)
        except Exception as e:
            to_unicode = encodeutils.exception_to_unicode(e)
            LOG.exception('failed to show template %s --> %s', template_uuid,
                          to_unicode)
            abort(404, to_unicode)
Exemple #30
0
    def get(self, template_uuid):

        LOG.info(_LI('get template content'))

        enforce("template show",
                pecan.request.headers,
                pecan.request.enforcer,
                {})

        try:
            return self._show_template(template_uuid)
        except Exception as e:
            LOG.exception('failed to show template %s' % template_uuid, e)
            abort(404, str(e))
Exemple #31
0
    def post(self, vitrage_id):
        enforce("list alarms", pecan.request.headers, pecan.request.enforcer,
                {})

        LOG.info(_LI('received list alarms with vitrage id %s') % 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)
        except Exception as e:
            LOG.exception('failed to get alarms %s', e)
            abort(404, str(e))
Exemple #32
0
    def post(self, vitrage_id):
        enforce("list alarms", pecan.request.headers,
                pecan.request.enforcer, {})

        LOG.info(_LI('received list alarms with vitrage id %s') %
                 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)
        except Exception as e:
            LOG.exception('failed to get alarms %s', e)
            abort(404, str(e))
Exemple #33
0
    def post(self, **kwargs):

        LOG.info('validate template. args: %s', kwargs)

        enforce("template validate", pecan.request.headers,
                pecan.request.enforcer, {})

        templates = kwargs['templates']
        template_type = kwargs.get('template_type')

        try:
            return self._validate(templates, template_type)
        except Exception:
            LOG.exception('Failed to validate template(s).')
            abort(404, 'Failed to validate template.')
Exemple #34
0
    def post(self, **kwargs):

        LOG.info(_LI('validate template. args: %s') % kwargs)

        enforce("template validate",
                pecan.request.headers,
                pecan.request.enforcer,
                {})

        templates = kwargs['templates']

        try:
            return self._validate(templates)
        except Exception as e:
            LOG.exception('failed to validate template(s) %s', e)
            abort(404, str(e))
Exemple #35
0
    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, {})
        else:
            enforce("list alarms", pecan.request.headers,
                    pecan.request.enforcer, {})

        LOG.info('returns list alarms with vitrage id %s', vitrage_id)

        try:
            return self._get_alarms(vitrage_id, all_tenants)
        except Exception as e:
            LOG.exception('failed to get alarms %s', e)
            abort(404, str(e))
Exemple #36
0
    def post(self, **kwargs):
        LOG.info('Post event called with args: %s', kwargs)

        enforce("event post", pecan.request.headers, pecan.request.enforcer,
                {})

        prom_event_type = None
        user_agent = pecan.request.headers.get('User-Agent')
        if user_agent and user_agent.startswith("Alertmanager"):
            prom_event_type = PROMETHEUS_EVENT_TYPE

        event_time = kwargs.get('time', datetime.utcnow())
        event_type = kwargs.get('type', prom_event_type)
        details = kwargs.get('details', kwargs)

        self.post_event(event_time, event_type, details)
Exemple #37
0
    def delete(self, **kwargs):
        # for backward computability
        values = kwargs['uuid'] if 'uuid'in kwargs else kwargs['id']
        LOG.info("delete template. values: %s", values)
        uuids = self._to_uuids(values)
        LOG.info("delete template. uuids: %s", uuids)

        enforce("template delete",
                pecan.request.headers,
                pecan.request.enforcer,
                {})
        try:
            return self._delete(uuids)
        except Exception:
            LOG.exception('Failed to delete template.')
            abort(404, 'Failed to delete template.')
Exemple #38
0
    def post(self, depth, graph_type, query, root):
        enforce("get topology", pecan.request.headers,
                pecan.request.enforcer, {})

        LOG.info(_LI('received get topology: depth->%(depth)s '
                     'graph_type->%(graph_type)s root->%(root)s') %
                 {'depth': depth, 'graph_type': graph_type, 'root': root})

        if query:
            query = json.loads(query)

        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)
Exemple #39
0
    def post(self, depth, graph_type, query, root):
        enforce("get topology", pecan.request.headers,
                pecan.request.enforcer, {})

        LOG.info(_LI('received get topology: depth->%(depth)s '
                     'graph_type->%(graph_type)s root->%(root)s') %
                 {'depth': depth, 'graph_type': graph_type, 'root': root})

        if query:
            query = json.loads(query)

        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)