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

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