]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
config: allow reading teuthology config from env var location
authorJohn Mulligan <phlogistonjohn@asynchrono.us>
Fri, 9 Aug 2024 14:15:15 +0000 (10:15 -0400)
committerJohn Mulligan <phlogistonjohn@asynchrono.us>
Fri, 9 Aug 2024 14:15:15 +0000 (10:15 -0400)
Allow changing the default "user" location of the teuthology
configuration yaml using the (optional) TEUTHOLOGY_CONFIG environment
variable. This change aids my effort to run a customized local
teuthology environment.

Signed-off-by: John Mulligan <phlogistonjohn@asynchrono.us>
teuthology/config.py

index 30204aa466a4bea4f99aacbc236f5b8f053a277b..893a042d475dbe8e663a031a5722db43f0815b50 100644 (file)
@@ -137,7 +137,6 @@ class TeuthologyConfig(YamlConfig):
     objects. Currently it serves as a convenient interface to
     ~/.teuthology.yaml and nothing else.
     """
-    yaml_path = os.path.join(os.path.expanduser('~/.teuthology.yaml'))
     _defaults = {
         'archive_base': '/home/teuthworker/archive',
         'archive_upload': None,
@@ -285,10 +284,13 @@ def set_config_attr(obj):
 
 
 def _get_config_path():
+    config_path = os.environ.get('TEUTHOLOGY_CONFIG', '~/.teuthology.yaml')
+    config_path = os.path.join(os.path.expanduser(config_path))
     system_config_path = '/etc/teuthology.yaml'
-    if not os.path.exists(TeuthologyConfig.yaml_path) and \
-            os.path.exists(system_config_path):
-        return system_config_path
-    return TeuthologyConfig.yaml_path
+    for path in (config_path, system_config_path):
+        if os.path.exists(path):
+            return path
+    return None
+
 
 config = TeuthologyConfig(yaml_path=_get_config_path())