⛲
OpenSt­ack 源码­分析之 Magnum
  • 前言
  • 整体结构
  • contrib
  • doc
  • etc
  • magnum
    • api
      • controllers
        • v1
        • base.py
        • link.py
        • root.py
      • middleware
        • auth_token.py
        • parsable_error.py
      • app.py
      • auth.py
      • config.py
      • hooks.py
    • cloud
      • nova_driver.py
    • cmd
      • api.py
      • conductor.py
      • db_manage.py
      • template_manage.py
    • common
      • pythonk8sclient
        • client
        • templates
        • README.rst
      • clients.py
      • config.py
      • context.py
      • docker_utils.py
      • exception.py
      • k8s_manifest.py
      • magnum_keystoneclient.py
      • paths.py
      • policy.py
      • rpc.py
      • rpc_service.py
      • safe_utils.py
      • service.py
      • short_id.py
      • urlfetch.py
      • utils.py
      • yamlutils.py
    • conductor
      • handlers
        • common
        • bay_conductor.py
        • conductor_listener.py
        • docker_conductor.py
        • kube.py
      • tasks
        • heat_tasks.py
        • init.py
      • api.py
      • bay_lock.py
      • config.py
      • template_definition.py
    • db
      • sqlalchemy
        • alembic
        • alembic.ini
        • api.py
        • migration.py
        • models.py
      • api.py
      • migration.py
    • locale
      • magnum-log-critical.pot
      • magnum-log-error.pot
      • magnum-log-info.pot
      • magnum-log-warning.pot
      • magnum.pot
    • objects
      • base.py
      • bay.py
      • baylock.py
      • baymodel.py
      • container.py
      • fields.py
      • node.py
      • pod.py
      • replicationcontroller.py
      • service.py
      • utils.py
      • init.py
    • openstack
      • common
        • _i18n.py
        • cliutils.py
        • eventlet_backdoor.py
        • local.py
        • loopingcall.py
        • periodic_task.py
        • service.py
        • systemd.py
        • threadgroup.py
        • utils.py
        • versionutils.py
    • public
      • css
        • style.css
    • templates
      • docker-swarm
        • fragments
        • COPYING
        • README.md
        • swarm.yaml
        • swarmnode.yaml
      • heat-kubernetes
        • elements
        • fragments
        • COPYING
        • kubecluster-coreos.yaml
        • kubecluster-fedora-ironic.yaml
        • kubecluster.yaml
        • kubeminion.yaml
        • kubenode-coreos.yaml
        • kubenode-fedora-ironic.yaml
        • README.md
    • tests
      • contrib
        • post_test_hook.sh
      • functional
        • test_magnum_python_client.py
        • test_templates.py
      • unit
        • api
        • common
        • conductor
        • db
        • objects
      • base.py
      • config.py
      • conf_fixture.py
      • fakes.py
      • utils.py
    • base.py
    • config.py
    • i18n.py
    • MANIFEST.in
    • opts.py
    • version.py
  • specs
  • tools
  • 架构
Powered by GitBook
On this page

Was this helpful?

  1. magnum
  2. api

app.py

主要的 PeCan APP 配置,包括注册 API 的选项,提供初始化参数等。

API_SERVICE_OPTS = [
    cfg.IntOpt('port',
               default=9511,
               help='The port for the magnum API server'),
    cfg.StrOpt('host',
               default='127.0.0.1',
               help='The listen IP for the magnum API server'),
    cfg.IntOpt('max_limit',
               default=1000,
               help='The maximum number of items returned in a single '
                    'response from a collection resource.')
]

setup_app 方法返回一个 WSGi 应用对象,是响应 API 请求的入口。

def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    app_conf = dict(config.app)

    app = pecan.make_app(
        app_conf.pop('root'),
        logging=getattr(config, 'logging', {}),
        wrap_app=middleware.ParsableErrorMiddleware,
        **app_conf
    )

    return auth.install(app, CONF, config.app.acl_public_routes)

从 config.py 中读取配置信息,然后直接启动添加 ACL 规则后的应用。

Previousparsable_error.pyNextauth.py

Last updated 5 years ago

Was this helpful?