Refactor CLI.py to use database instances for API calls

This commit is contained in:
Théophile Diot 2024-06-25 11:30:00 +01:00
parent e66aea1e14
commit f64b6945e5
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -180,6 +180,15 @@ class CLI(ApiCaller):
self.__logger.error("USE_REDIS is set to yes but REDIS_HOST or REDIS_SENTINEL_HOSTS is not set, disabling redis")
self.__use_redis = False
if Path(sep, "usr", "sbin", "nginx").exists() and self.__integration != "Linux":
return super().__init__(
[
API(
f"http://127.0.0.1:{self.__get_variable('API_HTTP_PORT', '5000')}",
host=self.__get_variable("API_SERVER_NAME", "bwapi"),
)
]
)
super().__init__()
for db_instance in self.__db.get_instances():
self.apis.append(API(f"http://{db_instance['hostname']}:{db_instance['port']}", db_instance["server_name"]))