Beispiel #1
0
    def post(self, depth, graph_type, query, root, all_tenants=0):
        if all_tenants:
            enforce('get topology:all_tenants', pecan.request.headers,
                    pecan.request.enforcer, {})
        else:
            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, all_tenants)
Beispiel #2
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)
Beispiel #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)
Beispiel #4
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)
Beispiel #5
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)
Beispiel #6
0
def build_server(conf):
    app = load_app(conf)
    # Create the WSGI server and start it
    host, port = conf.api.host, conf.api.port

    LOG.info(_LI('Starting server in PID %s') % os.getpid())
    LOG.info(_LI('Configuration:'))
    conf.log_opt_values(LOG, logging.INFO)

    if host == '0.0.0.0':
        LOG.info(_LI(
            'serving on 0.0.0.0:%(port)s, view at http://127.0.0.1:%(port)s')
            % ({'port': port}))
    else:
        LOG.info(_LI('serving on http://%(host)s:%(port)s') % (
            {'host': host, 'port': port}))

    serving.run_simple(host, port,
                       app, processes=conf.api.workers)
Beispiel #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))
Beispiel #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))
Beispiel #9
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))
Beispiel #10
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))
Beispiel #11
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))
Beispiel #12
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))
Beispiel #13
0
def load_app(conf):
    # Build the WSGI app
    cfg_file = None
    cfg_path = conf.api.paste_config
    if not os.path.isabs(cfg_path):
        cfg_file = conf.find_file(cfg_path)
    elif os.path.exists(cfg_path):
        cfg_file = cfg_path

    if not cfg_file:
        raise cfg.ConfigFilesNotFoundError([conf.api.paste_config])
    LOG.info(_LI('Full WSGI config used: %s') % cfg_file)
    return deploy.loadapp("config:" + cfg_file)
Beispiel #14
0
def load_app(conf):
    # Build the WSGI app
    cfg_file = None
    cfg_path = conf.api.paste_config
    if not os.path.isabs(cfg_path):
        cfg_file = conf.find_file(cfg_path)
    elif os.path.exists(cfg_path):
        cfg_file = cfg_path

    if not cfg_file:
        raise cfg.ConfigFilesNotFoundError([conf.api.paste_config])
    LOG.info(_LI('Full WSGI config used: %s') % cfg_file)
    return deploy.loadapp("config:" + cfg_file)
Beispiel #15
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))
Beispiel #16
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))
Beispiel #17
0
def build_server(conf):
    app = load_app(conf)
    # Create the WSGI server and start it
    host, port = conf.api.host, conf.api.port

    LOG.info(_LI('Starting server in PID %s') % os.getpid())
    LOG.info(_LI('Configuration:'))
    conf.log_opt_values(LOG, logging.INFO)

    if host == '0.0.0.0':
        LOG.info(
            _LI('serving on 0.0.0.0:%(port)s, view at http://127.0.0.1:%(port)s'
                ) % ({
                    'port': port
                }))
    else:
        LOG.info(
            _LI('serving on http://%(host)s:%(port)s') % ({
                'host': host,
                'port': port
            }))

    serving.run_simple(host, port, app, processes=conf.api.workers)
Beispiel #18
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))
Beispiel #19
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))
Beispiel #20
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))
Beispiel #21
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))
Beispiel #22
0
 def _lookup(self, id_, *remainder):
     LOG.info(_LI('got lookup %s') % id_)
     return ResourceController(id_), remainder
Beispiel #23
0
 def _lookup(self, id_, *remainder):
     LOG.info(_LI('got lookup %s') % id_)
     return ResourceController(id_), remainder