示例#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)
示例#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)
示例#3
0
文件: rca.py 项目: Idandos/vitrage
    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)
示例#4
0
文件: webhook.py 项目: eilatc/vitrage
 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))
示例#5
0
文件: alarm.py 项目: wookiist/vitrage
    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)
示例#6
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:
            LOG.exception('Failed to load JSON.')
            abort(404, "Failed to show alarm.")
示例#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))
示例#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))
示例#9
0
文件: rca.py 项目: pczerkas/vitrage
    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)
示例#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.')
示例#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)
示例#12
0
文件: webhook.py 项目: eilatc/vitrage
    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))
示例#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))
示例#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.')
示例#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))
示例#16
0
文件: webhook.py 项目: eilatc/vitrage
    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))
示例#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))
示例#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')
示例#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)
示例#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)
示例#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.')
示例#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))
示例#23
0
文件: resource.py 项目: aweyl/vitrage
    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))
示例#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)
示例#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')
示例#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))
示例#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.')
示例#28
0
文件: template.py 项目: aweyl/vitrage
    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))
示例#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)
示例#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))
示例#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))
示例#32
0
文件: alarms.py 项目: Idandos/vitrage
    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))
示例#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.')
示例#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))
示例#35
0
文件: alarm.py 项目: aweyl/vitrage
    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))
示例#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)
示例#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.')
示例#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)
示例#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)