]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move LoggerFile to teuthology.util
authorZack Cerza <zack@redhat.com>
Thu, 11 Jul 2024 16:05:48 +0000 (10:05 -0600)
committerZack Cerza <zack@redhat.com>
Thu, 11 Jul 2024 16:05:48 +0000 (10:05 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/task/ansible.py
teuthology/task/cephmetrics.py
teuthology/util/loggerfile.py [new file with mode: 0644]

index d27137d12c0769aeeb9aa0fbd83612bb5c1696ef..29d1170d1ac14f898af6fe8a77f520ed7760a8fe 100644 (file)
@@ -14,30 +14,12 @@ from teuthology import repo_utils
 from teuthology.config import config as teuth_config
 from teuthology.exceptions import CommandFailedError, AnsibleFailedError
 from teuthology.job_status import set_status
-
 from teuthology.task import Task
+from teuthology.util.loggerfile import LoggerFile
 
 log = logging.getLogger(__name__)
 
 
-class LoggerFile(object):
-    """
-    A thin wrapper around a logging.Logger instance that provides a file-like
-    interface.
-
-    Used by Ansible.execute_playbook() when it calls pexpect.run()
-    """
-    def __init__(self, logger, level):
-        self.logger = logger
-        self.level = level
-
-    def write(self, string):
-        self.logger.log(self.level, string.decode('utf-8', 'ignore'))
-
-    def flush(self):
-        pass
-
-
 class FailureAnalyzer:
     def analyze(self, failure_log):
         failure_obj = yaml.safe_load(failure_log)
index fee4ad6b679339fceb8861f36fab08277a1adc96..813d266addda55b5912e90334bb180674911ff38 100644 (file)
@@ -5,8 +5,9 @@ import time
 
 from teuthology.config import config as teuth_config
 from teuthology.exceptions import CommandFailedError
+from teuthology.task.ansible import Ansible
+from teuthology.util.loggerfile import LoggerFile
 
-from teuthology.task.ansible import Ansible, LoggerFile
 
 log = logging.getLogger(__name__)
 
diff --git a/teuthology/util/loggerfile.py b/teuthology/util/loggerfile.py
new file mode 100644 (file)
index 0000000..3dd7862
--- /dev/null
@@ -0,0 +1,19 @@
+import logging
+
+class LoggerFile(object):
+    """
+    A thin wrapper around a logging.Logger instance that provides a file-like
+    interface.
+
+    Used by Ansible.execute_playbook() when it calls pexpect.run()
+    """
+    def __init__(self, logger: logging.Logger, level: int):
+        self.logger = logger
+        self.level = level
+
+    def write(self, string):
+        self.logger.log(self.level, string.decode('utf-8', 'ignore'))
+
+    def flush(self):
+        pass
+