Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with generating resource graph containing no local storage #53

Merged
merged 6 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions jarvis_util/introspect/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ class PyLsblk(Exec):
rota: whether or not the device is rotational
host: the host this record corresponds to
"""

columns = [
'parent', 'device', 'size', 'mount', 'model', 'tran',
'rota', 'dev_type', 'host'
]
def __init__(self, exec_info):
cmd = 'pylsblk'
super().__init__(cmd, exec_info.mod(collect_output=True))
Expand All @@ -222,9 +225,21 @@ def wait(self):
for dev in lsblk_data:
if dev['tran'] == 'pcie':
dev['tran'] = 'nvme'
dev['dev_type'] = self.GetDevType(dev)
dev['host'] = host
total.append(dev)
self.df = sdf.SmallDf(rows=total)
self.df = sdf.SmallDf(rows=total, columns=self.columns)

def GetDevType(self, dev):
if dev['tran'] == 'sata':
if dev['rota']:
return str(StorageDeviceType.HDD)
else:
return str(StorageDeviceType.SSD)
elif dev['tran'] == 'nvme':
return str(StorageDeviceType.NVME)
elif dev['tran'] == 'dimm':
return str(StorageDeviceType.PMEM)


class Blkid(Exec):
Expand Down Expand Up @@ -502,28 +517,31 @@ def modify(self, exec_info):
"""

def introspect_fs(self, exec_info, sudo=False):
lsblk = PyLsblk(exec_info.mod(hide_output=True))
lsblk = PyLsblk(exec_info.mod(hide_output=True))
blkid = Blkid(exec_info.mod(hide_output=True))
list_fs = ListFses(exec_info.mod(hide_output=True))
fs = sdf.merge([lsblk.df, blkid.df],
on=['device', 'host'],
how='outer')
how='outer')
fs[:, 'shared'] = False
fs = sdf.merge([fs, list_fs.df],
on=['device', 'host'],
how='outer')
fs['mount'] = fs['fs_mount']
print(fs)
fs = self._find_common_mounts(fs, exec_info)
fs = self._label_user_mounts(fs)
fs = fs.drop_columns([
'used', 'use%', 'fs_mount', 'partuuid', 'fs_size',
'partlabel', 'label', 'host'])
self.fs = fs
print(self.fs)
return self.fs

def _find_common_mounts(self, fs, exec_info):
"""
Finds mount point points common across all hosts
"""
"""
io_groups = fs.groupby(['mount', 'device'])
common = []
for name, group in io_groups.groups.items():
Expand Down
3 changes: 3 additions & 0 deletions jarvis_util/util/small_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ def merge(self, other, on=None):
for row in rows:
if '$#matched' in row:
del row['$#matched']
for col in self.columns:
if col not in row:
row[col] = None
return SmallDf(rows=rows)

def _find_unmatched(self, orig_rows):
Expand Down
Loading