diff --git a/tubearchivist/config/management/commands/ta_connection.py b/tubearchivist/config/management/commands/ta_connection.py index 4e0f59aa..94b5e0dc 100644 --- a/tubearchivist/config/management/commands/ta_connection.py +++ b/tubearchivist/config/management/commands/ta_connection.py @@ -3,12 +3,12 @@ Functionality: - check that all connections are working """ -from os import environ from time import sleep import requests from django.core.management.base import BaseCommand, CommandError from home.src.es.connect import ElasticWrap +from home.src.ta.settings import EnvironmentSettings from home.src.ta.ta_redis import RedisArchivist TOPIC = """ @@ -156,10 +156,8 @@ class Command(BaseCommand): " 🗙 path.repo env var not found. " + "set the following env var to the ES container:\n" + " path.repo=" - + environ.get( - "ES_SNAPSHOT_DIR", "/usr/share/elasticsearch/data/snapshot" - ), + + EnvironmentSettings.ES_SNAPSHOT_DIR ) - self.stdout.write(self.style.ERROR(f"{message}")) + self.stdout.write(self.style.ERROR(message)) sleep(60) raise CommandError(message) diff --git a/tubearchivist/home/src/es/snapshot.py b/tubearchivist/home/src/es/snapshot.py index d77f0761..0cff51e6 100644 --- a/tubearchivist/home/src/es/snapshot.py +++ b/tubearchivist/home/src/es/snapshot.py @@ -4,7 +4,6 @@ functionality: """ from datetime import datetime -from os import environ from time import sleep from zoneinfo import ZoneInfo @@ -20,9 +19,7 @@ class ElasticSnapshot: REPO_SETTINGS = { "compress": "true", "chunk_size": "1g", - "location": environ.get( - "ES_SNAPSHOT_DIR", "/usr/share/elasticsearch/data/snapshot" - ), + "location": EnvironmentSettings.ES_SNAPSHOT_DIR, } POLICY = "ta_daily" diff --git a/tubearchivist/home/src/ta/settings.py b/tubearchivist/home/src/ta/settings.py index db609c76..16f36994 100644 --- a/tubearchivist/home/src/ta/settings.py +++ b/tubearchivist/home/src/ta/settings.py @@ -37,6 +37,11 @@ class EnvironmentSettings: ES_URL: str = str(environ.get("ES_URL")) ES_PASS: str = str(environ.get("ELASTIC_PASSWORD")) ES_USER: str = str(environ.get("ELASTIC_USER", "elastic")) + ES_SNAPSHOT_DIR: str = str( + environ.get( + "ES_SNAPSHOT_DIR", "/usr/share/elasticsearch/data/snapshot" + ) + ) ES_DISABLE_VERIFY_SSL: bool = bool(environ.get("ES_DISABLE_VERIFY_SSL")) def print_generic(self): @@ -78,6 +83,7 @@ class EnvironmentSettings: ES_URL: {self.ES_URL} ES_PASS: ***** ES_USER: {self.ES_USER} + ES_SNAPSHOT_DIR: {self.ES_SNAPSHOT_DIR} ES_DISABLE_VERIFY_SSL: {self.ES_DISABLE_VERIFY_SSL}""" )