SHA256
1
0
forked from pool/salt
salt/fix-inspector-module-export-function-bsc-1097531-481.patch

69 lines
2.8 KiB
Diff

From 554b13dec6a9770b7fbf287b3bf9af91a2cdabde Mon Sep 17 00:00:00 2001
From: Victor Zhestkov <vzhestkov@suse.com>
Date: Fri, 28 Jan 2022 16:44:25 +0300
Subject: [PATCH] Fix inspector module export function (bsc#1097531)
(#481)
---
salt/modules/inspectlib/fsdb.py | 8 ++++----
salt/modules/inspectlib/query.py | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/salt/modules/inspectlib/fsdb.py b/salt/modules/inspectlib/fsdb.py
index 489fde5684..b834b8f678 100644
--- a/salt/modules/inspectlib/fsdb.py
+++ b/salt/modules/inspectlib/fsdb.py
@@ -137,7 +137,7 @@ class CsvDB:
return self._tables.keys()
def _load_table(self, table_name):
- with gzip.open(os.path.join(self.db_path, table_name), "rb") as table:
+ with gzip.open(os.path.join(self.db_path, table_name), "rt") as table:
return OrderedDict(
[tuple(elm.split(":")) for elm in next(csv.reader(table))]
)
@@ -184,7 +184,7 @@ class CsvDB:
"""
get_type = lambda item: str(type(item)).split("'")[1]
if not os.path.exists(os.path.join(self.db_path, obj._TABLE)):
- with gzip.open(os.path.join(self.db_path, obj._TABLE), "wb") as table_file:
+ with gzip.open(os.path.join(self.db_path, obj._TABLE), "wt") as table_file:
csv.writer(table_file).writerow(
[
"{col}:{type}".format(col=elm[0], type=get_type(elm[1]))
@@ -212,7 +212,7 @@ class CsvDB:
db_obj = self.get(obj.__class__, eq=fields)
if db_obj and distinct:
raise Exception("Object already in the database.")
- with gzip.open(os.path.join(self.db_path, obj._TABLE), "a") as table:
+ with gzip.open(os.path.join(self.db_path, obj._TABLE), "at") as table:
csv.writer(table).writerow(self._validate_object(obj))
def update(self, obj, matches=None, mt=None, lt=None, eq=None):
@@ -318,7 +318,7 @@ class CsvDB:
:return:
"""
objects = []
- with gzip.open(os.path.join(self.db_path, obj._TABLE), "rb") as table:
+ with gzip.open(os.path.join(self.db_path, obj._TABLE), "rt") as table:
header = None
for data in csv.reader(table):
if not header:
diff --git a/salt/modules/inspectlib/query.py b/salt/modules/inspectlib/query.py
index 079cc29172..8027176a13 100644
--- a/salt/modules/inspectlib/query.py
+++ b/salt/modules/inspectlib/query.py
@@ -74,7 +74,7 @@ class SysInfo:
for dev, dev_data in salt.utils.fsutils._blkid().items():
dev = self._get_disk_size(dev)
device = dev.pop("device")
- dev["type"] = dev_data["type"]
+ dev["type"] = dev_data.get("type", "UNKNOWN")
data[device] = dev
return data
--
2.34.1