Blame SOURCES/0005-lvmdbusd-Move-get_error_msg-to-utils.patch

337b9c
From 4e34edd6e4e52328dd77b6a55aeadd9b0454c743 Mon Sep 17 00:00:00 2001
337b9c
From: Tony Asleson <tasleson@redhat.com>
337b9c
Date: Tue, 29 Nov 2022 10:00:39 -0600
337b9c
Subject: [PATCH 2/3] lvmdbusd: Move get_error_msg to utils
337b9c
337b9c
Moving this so we can re-use outside of lvm_shell_proxy.
337b9c
337b9c
(cherry picked from commit 8f60c494515ddccb20e4afb804edb6b9599e65c0)
337b9c
---
337b9c
 daemons/lvmdbusd/lvm_shell_proxy.py.in | 23 +++--------------------
337b9c
 daemons/lvmdbusd/utils.py              | 17 +++++++++++++++++
337b9c
 2 files changed, 20 insertions(+), 20 deletions(-)
337b9c
337b9c
diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in
337b9c
index ac6d51e65..37d73218b 100755
337b9c
--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in
337b9c
+++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in
337b9c
@@ -28,7 +28,7 @@ except ImportError:
337b9c
 
337b9c
 import lvmdbusd.cfg as cfg
337b9c
 from lvmdbusd.utils import log_debug, log_error, add_no_notify, make_non_block,\
337b9c
-			read_decoded, extract_stack_trace, LvmBug
337b9c
+			read_decoded, extract_stack_trace, LvmBug, get_error_msg
337b9c
 
337b9c
 SHELL_PROMPT = "lvm> "
337b9c
 
337b9c
@@ -191,24 +191,7 @@ class LVMShellProxy(object):
337b9c
 	def get_last_log(self):
337b9c
 		self._write_cmd('lastlog\n')
337b9c
 		report_json = self._read_response()[1]
337b9c
-		return LVMShellProxy.get_error_msg(report_json)
337b9c
-
337b9c
-	@staticmethod
337b9c
-	def get_error_msg(report_json):
337b9c
-		# Get the error message from the returned JSON
337b9c
-		if 'log' in report_json:
337b9c
-			error_msg = ""
337b9c
-			# Walk the entire log array and build an error string
337b9c
-			for log_entry in report_json['log']:
337b9c
-				if log_entry['log_type'] == "error":
337b9c
-					if error_msg:
337b9c
-						error_msg += ', ' + log_entry['log_message']
337b9c
-					else:
337b9c
-						error_msg = log_entry['log_message']
337b9c
-
337b9c
-			return error_msg
337b9c
-
337b9c
-		return None
337b9c
+		return get_error_msg(report_json)
337b9c
 
337b9c
 	def call_lvm(self, argv, debug=False):
337b9c
 		rc = 1
337b9c
@@ -245,7 +228,7 @@ class LVMShellProxy(object):
337b9c
 				# report json too.
337b9c
 				error_msg = self.get_last_log()
337b9c
 				if error_msg is None:
337b9c
-					error_msg = LVMShellProxy.get_error_msg(report_json)
337b9c
+					error_msg = get_error_msg(report_json)
337b9c
 					if error_msg is None:
337b9c
 						error_msg = 'No error reason provided! (missing "log" section)'
337b9c
 
337b9c
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
337b9c
index 5aecb1fff..0b81591b2 100644
337b9c
--- a/daemons/lvmdbusd/utils.py
337b9c
+++ b/daemons/lvmdbusd/utils.py
337b9c
@@ -859,3 +859,20 @@ class LvmDebugData:
337b9c
 		self._close_fd()
337b9c
 		# In case lvm_complete doesn't get called.
337b9c
 		self._remove_file()
337b9c
+
337b9c
+
337b9c
+def get_error_msg(report_json):
337b9c
+	# Get the error message from the returned JSON
337b9c
+	if 'log' in report_json:
337b9c
+		error_msg = ""
337b9c
+		# Walk the entire log array and build an error string
337b9c
+		for log_entry in report_json['log']:
337b9c
+			if log_entry['log_type'] == "error":
337b9c
+				if error_msg:
337b9c
+					error_msg += ', ' + log_entry['log_message']
337b9c
+				else:
337b9c
+					error_msg = log_entry['log_message']
337b9c
+
337b9c
+		return error_msg
337b9c
+
337b9c
+	return None
337b9c
-- 
337b9c
2.39.1
337b9c