import openstack from openstack.connection import Connection from watcher_visio.settings import OPENSTACK_CLOUD, OPENSTACK_REGION_NAME def check_openstack() -> dict: """ Lightweight check that OpenStack is reachable (connection only). Returns {"status": "ok"} or {"status": "error", "message": "..."}. """ try: conn = openstack.connect(cloud=OPENSTACK_CLOUD, region_name=OPENSTACK_REGION_NAME) if conn is None: return {"status": "error", "message": "No connection"} return {"status": "ok"} except Exception as e: return {"status": "error", "message": str(e) or "Connection failed"} def get_connection() -> Connection: connection = openstack.connect(cloud=OPENSTACK_CLOUD, region_name=OPENSTACK_REGION_NAME) return connection