Skip to content

Commit

Permalink
Merge pull request #53 from lukemartinlogan/master
Browse files Browse the repository at this point in the history
Fixed issue with generating resource graph containing no local storage
  • Loading branch information
lukemartinlogan authored Jan 28, 2025
2 parents 44a814a + bbab838 commit 44133ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
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

0 comments on commit 44133ad

Please sign in to comment.