Add config.py
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""Configuration for the billing API, loaded from environment / .env file."""
|
||||
from functools import lru_cache
|
||||
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
# OpenStack endpoints
|
||||
keystone_auth_url: str = "https://internal.3engine.rootxwire.com:5000"
|
||||
cloudkitty_url: str = "https://internal.3engine.rootxwire.com:8889"
|
||||
|
||||
# Keystone credentials (needs visibility over all projects' rating data,
|
||||
# i.e. admin or a reader role on the service project)
|
||||
os_username: str = "admin"
|
||||
os_password: str = ""
|
||||
os_project_name: str = "admin"
|
||||
os_user_domain: str = "Default"
|
||||
os_project_domain: str = "Default"
|
||||
|
||||
# Cluster uses self-signed certs on internal endpoints
|
||||
verify_ssl: bool = False
|
||||
|
||||
# CloudKitty stores period boundaries in the cluster-local tz (+05:30)
|
||||
billing_tz: str = "Asia/Kolkata"
|
||||
|
||||
http_timeout: float = 30.0
|
||||
# Cache the Keystone token this long (tokens are valid ~1h by default)
|
||||
token_ttl_seconds: int = 2700
|
||||
|
||||
# Optional endpoint overrides. Empty = use the Keystone catalog's
|
||||
# public URLs (correct when running outside the cluster network).
|
||||
nova_url: str = ""
|
||||
cinder_url: str = ""
|
||||
neutron_url: str = ""
|
||||
|
||||
# SMTP for emailing tenant reports. Leave smtp_host empty to disable;
|
||||
# the /send endpoint then returns the report for manual sharing instead.
|
||||
smtp_host: str = ""
|
||||
smtp_port: int = 587
|
||||
smtp_user: str = ""
|
||||
smtp_password: str = ""
|
||||
smtp_from: str = "billing@connectvm.com"
|
||||
smtp_tls: bool = True
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
env_prefix = "BILLING_"
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
Reference in New Issue
Block a user