From 162f2cf84a5295badacb82f9f23f7efb008ff22a Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 21 Aug 2026 01:55:14 +0000 Subject: [PATCH] Add config.py --- config.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 config.py diff --git a/config.py b/config.py new file mode 100644 index 0000000..117bd81 --- /dev/null +++ b/config.py @@ -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()