How openstack/skyline-apiserver works
Skyline API Server is the backend service for the Skyline OpenStack dashboard. It is an ASGI application started with uvicorn against skyline_apiserver.main:app, and the repo is organized around API handling, OpenStack integration, policy management, and persistent configuration/state.
1. Request entry point and app bootstrap
- skyline_apiserver/main.py and __main__.py are the runtime entry points.
- Startup likely wires together config loading, logging, database setup, security, and route registration before serving HTTP traffic.
- The README shows it is normally run either directly with Uvicorn for development or inside a container in production.
2. HTTP API layer
- All external functionality is exposed under skyline_apiserver/api/v1/.
- Main resource groups are login, policy, setting, extension, prometheus, and contrib.
- api/deps.py is the boundary for shared request dependencies such as auth context, service clients, and request-scoped state.
3. Authentication and request security
- core/security.py and context.py define how identity, authorization, and per-request context are handled.
- The login flow is OpenStack-centric: the service authenticates users through Keystone and then uses that identity for downstream OpenStack requests.
- The FAQ in the README makes clear that Skyline performs some authorization checks itself via the /policy API rather than relying only on downstream services.
4. OpenStack client boundary
- skyline_apiserver/client/openstack/ contains service-specific clients for Keystone, Nova, Neutron, Cinder, Glance, and a generic system client.
- These modules isolate direct OpenStack REST interactions from the API handlers.
- client/utils.py likely holds shared client helpers such as endpoint selection, token handling, and HTTP plumbing.
5. Policy subsystem
- skyline_apiserver/policy/ is a major subsystem and contains a base layer plus per-service policy managers under policy/manager/.
- Managers exist for many OpenStack services: Keystone, Nova, Neutron, Cinder, Glance, Heat, Ironic, Magnum, Manila, Masakari, Octavia, Placement, Trove, Zun, Barbican, and Designate.
- This subsystem is responsible for loading, normalizing, and serving policy rules so the UI can decide whether a user may see or invoke an action.
- cmd/policy_manager.py and the related schemas suggest policy bundles can also be generated or managed as an operational task.
6. Persistent state and migrations
- db/models.py, db/api.py, and db/base.py define the persistence layer.
- Alembic migrations live under db/alembic/, with 000_init.py as the initial schema migration.
- The README indicates both SQLite and MariaDB are supported, so the app is designed to run with either embedded or external relational storage.
7. Configuration model
- config/ contains the runtime configuration system, split into base/default/OpenStack/setting layers.
- The primary config file is etc/skyline.yaml.sample, typically copied to /etc/skyline/skyline.yaml.
- Configuration covers database URL, Keystone URL, default region, endpoint interface type, system user credentials, and Prometheus settings.
- cmd/generate_sample_config.py exists to emit a usable starter config.
8. Prometheus integration
- The API includes a dedicated prometheus resource, which means the service can proxy or surface Prometheus data to the dashboard.
- The README shows optional basic-auth and endpoint settings, so Prometheus is an external integration with configurable credentials rather than a built-in metrics store.
9. API schemas and contract
- schemas/ defines request/response models for each API group.
- This is the main contract boundary between HTTP handlers and business logic, and it supports the generated OpenAPI/Swagger docs.
- cmd/generate_swagger.py and the checked-in swagger.json indicate the API schema is exported as part of the build/release workflow.
10. Packaging, deployment, and operational tooling
- container/, kolla/, devstack/, and playbooks/ show the project is deployed in multiple OpenStack-oriented ways: container image, Kolla Ansible, DevStack, and OpenStack-Ansible.
- etc/gunicorn.py and the Jinja nginx template suggest the service can also be fronted by generated web server config in some deployment modes.
- cmd/generate_nginx.py indicates deployment artifacts are produced from templates rather than hand-maintained.
11. Cross-cutting utility layer
- utils/httpclient.py likely centralizes outbound HTTP behavior.
- utils/roles.py suggests role mapping or implied-role logic used by authorization decisions.
- types/constants.py contains shared constants used across the service.
12. Test and release structure
- Unit tests are organized by subsystem under tests/unit/, mirroring the production package layout.
- releasenotes/ and the spec/ directory show the repo is maintained with OpenStack-style release management and feature/spec tracking.
Overall, the architecture is a thin HTTP API layer backed by a config-driven persistence layer and a substantial OpenStack integration layer. The most important diagram boundaries are: client requests into the ASGI app, policy/login checks against Keystone and service-specific policy data, outbound calls to OpenStack services, and DB-backed state/configuration on the server side.
Main entry points: main.py App startup · v1 API v1 · security.py Security · manager Policy managers
Components 19
Runtime
ASGI entrypoint and HTTP API surface
- App startup · Bootstraps the service and serves the FastAPI app
skyline_apiserver/main.py - Module entry · Module entry for running the server package
skyline_apiserver/__main__.py - API v1 · Versioned API handlers for login, policy, settings, extensions, contrib, and Prometheus
skyline_apiserver/api/v1 - API deps · Shared request-scoped dependencies and injected services
skyline_apiserver/api/deps.py
Core Services
Security, policy, context, and OpenStack integration
- Security · Identity, authorization, and request security helpers
skyline_apiserver/core/security.py - Context · Per-request user and service context
skyline_apiserver/context.py - OpenStack clients · REST clients for Keystone, Nova, Neutron, Cinder, Glance, and system operations
skyline_apiserver/client/openstack - Client utils · Shared outbound HTTP and token/endpoint helpers
skyline_apiserver/client/utils.py - Policy core · Base policy loading and normalization logic
skyline_apiserver/policy/base.py - Policy managers · Per-service policy loaders and rule managers
skyline_apiserver/policy/manager - HTTP utils · Reusable HTTP client helpers for outbound calls
skyline_apiserver/utils/httpclient.py
State & Config
Persistence, runtime settings, and shared contracts
- DB API · Database access helpers and session-facing API
skyline_apiserver/db/api.py - DB models · Persistent entities and schema-backed models
skyline_apiserver/db/models.py - Config · Base, default, OpenStack, and setting configuration layers
skyline_apiserver/config - Schemas · Request and response models for the public API
skyline_apiserver/schemas
Ops & Tooling
Operational commands and generated artifacts
- Policy cmd · Operational policy bundle generation and management
skyline_apiserver/cmd/policy_manager.py - Swagger cmd · Exports the OpenAPI/Swagger document
skyline_apiserver/cmd/generate_swagger.py - Config cmd · Generates starter configuration files
skyline_apiserver/cmd/generate_sample_config.py - Nginx template · Generated web server configuration template
skyline_apiserver/templates/nginx.conf.j2
Connections 24
- Module entry → App startup: launches · Package entry delegates to the ASGI application bootstrap
- App startup → Config: loads · Startup reads runtime configuration
- App startup → Security: wires · Bootstrapping connects auth and request security
- App startup → DB API: initializes · Startup prepares persistence access
- App startup → API v1: serves · The ASGI app exposes versioned routes
- API v1 → API deps: depends on · Handlers use shared request dependencies
- API v1 → Schemas: validates with · Route inputs and outputs use typed schemas
- API v1 → Security: checks · Login and policy endpoints use authn/authz helpers
- API v1 → OpenStack clients: calls · Handlers delegate OpenStack operations to service clients
- API deps → Context: builds · Dependencies assemble request context
- API deps → OpenStack clients: injects · Request-scoped client access is provided here
- Security → Context: stores · Security decisions are reflected in request context
- Security → Policy core: consults · Authorization may consult loaded policy rules
- OpenStack clients → Client utils: uses · Service clients share transport and endpoint helpers
- Client utils → HTTP utils: builds on · Outbound HTTP behavior is centralized
- Policy core → Policy managers: extends · Service-specific managers specialize the policy core
- Policy managers → Config: reads · Policy sources and service settings come from config
- Policy managers → DB API: persists · Policy state can be stored or refreshed via the DB layer
- DB API → DB models: operates on · Database access uses ORM models
- Config cmd → Config: generates · Produces a starter configuration sample
- Policy cmd → Policy managers: operates on · Operational command drives policy bundle management
- Swagger cmd → Schemas: exports · Swagger generation is based on API schemas
- Swagger cmd → API v1: documents · Generated OpenAPI covers the public routes
- Nginx template → App startup: fronts · Deployment template fronts the running service