Skip to content
Open
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
18 changes: 18 additions & 0 deletions servicereportpkg/validate/plugins/spyre.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from servicereportpkg.utils import is_package_installed
from servicereportpkg.check import ConfigurationFileCheck
from servicereportpkg.utils import is_read_write_to_owner_group_users
from servicereportpkg.validate.schemes.schemes import RHELScheme


class Spyre(Plugin, Scheme):
Expand Down Expand Up @@ -59,6 +60,14 @@ def is_applicable(cls):

return Spyre.is_spyre_card_exists()

class SpyreAll(Spyre, Plugin, Scheme):
"""Spyre All configuration checks"""

def __init__(self):
Plugin.__init__(self)
self.name = Spyre.__name__
self.description = Spyre.__doc__

def check_driver_config(self):
"""VFIO Driver configuration"""

Expand Down Expand Up @@ -290,6 +299,14 @@ def check_vfio_access_permission(self):
perm_check.set_status(status)
return perm_check

class SpyreRHEL(Spyre, Plugin, RHELScheme):
"""Spyre sos configuration checks"""

def __init__(self):
Plugin.__init__(self)
self.name = Spyre.__name__
self.description = Spyre.__doc__

def check_sos_package(self):
"""sos package"""

Expand Down Expand Up @@ -319,6 +336,7 @@ def check_sos_config(self):
pattern_logs = re.compile(r'^\s*podman\.logs\s*=\s*true\s*$', re.IGNORECASE)
pattern_all = re.compile(r'^\s*podman\.all\s*=\s*true\s*$', re.IGNORECASE)

in_plugin_options = False
try:
with open(sos_config_file, 'r', encoding="utf-8") as f:
for line in f:
Expand Down
95 changes: 95 additions & 0 deletions sos-plugin/spyre-external.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,99 @@ class SpyreExternal(Plugin, IndependentPlugin):
card_vendor_ids = ["0x1014"]
card_device_ids = ["0x06a7", "0x06a8"]

def get_podman_data(self):

print("Collecting podman data")
# All spyre users must be part of sentient group
groupname = "sentient"
non_root_users = self.exec_cmd("getent group "+ groupname)
if non_root_users['status'] == 0:
users = [u.strip() for u in non_root_users['output'].split(':')[3].split(',') if u.strip()]
for user in users:
# since root user outputs are collected in podman plugin
# skipping here
if not user or user == 'root':
continue
command = "sudo -u "+ user
validate_cmd = self.exec_cmd(f"{command} podman system df")
if validate_cmd['status'] != 0:
print(f"{user} is not valid")
continue

print(f"{user} is valid")
self.add_cmd_tags({
f'{command} podman images': 'podman_list_images',
f'{command} podman ps': 'podman_list_containers'
})

subcmds = [
'info',
'images',
'image trust show',
'images --digests',
'pod ps',
'port --all',
'ps',
'stats --no-stream --all',
'version',
'volume ls',
'system df -v',
]

self.add_cmd_output([f"{command} podman {s}" for s in subcmds],
subdir=f'podman/{user}', tags='podman_commands')

# separately grab ps -s as this can take a *very* long time
if self.get_option('size'):
self.add_cmd_output(f'{command} podman ps -as', subdir=f'podman/{user}', priority=100)

pnets = self.collect_cmd_output(f'{command} podman network ls',
subdir=f'podman/{user}', tags='podman_list_networks')
if pnets['status'] == 0:
nets = [pn.split()[0] for pn in pnets['output'].splitlines()[1:] if pn.strip()]
self.add_cmd_output([
f"{command} podman network inspect {net}" for net in nets
], subdir=f'podman/{user}/networks', tags='podman_network_inspect')

containers = self.collect_cmd_output(f'{command} podman ps -a', subdir=f'podman/{user}')
if containers['status'] == 0:
print("containers['output'].splitlines()[1:] ",containers['output'].splitlines()[1:])
cids = [container.split()[0] for container in containers['output'].splitlines()[1:] if container.strip()]
print("cids: ",cids)
self.add_cmd_output([
f"{command} podman inspect {cid}" for cid in cids
], subdir=f'podman/{user}/containers', tags='podman_container_inspect')
if self.get_option('logs'):
self.add_cmd_output([f"{command} podman logs -t {cid}" for cid in cids],
subdir=f'podman/{user}/containers', priority=50)

images = self.collect_cmd_output(f'{command} podman images --no-trunc', subdir=f'podman/{user}')
if images['status'] == 0:
print("images['output'].splitlines()[1:] ",images['output'].splitlines()[1:])
imageids = [
image.split()[2] if image.split()[0].lower() == 'none' else f"{image.split()[0]}:{image.split()[1]}"
for image in images['output'].splitlines()[1:] if image.strip()
]
print("imageids: ",imageids)
self.add_cmd_output([
f"{command} podman inspect {imageid}" for imageid in imageids
], subdir=f'podman/{user}/images', tags='podman_image_inspect')
self.add_cmd_output(
[f"{command} podman image tree {imageid}" for imageid in imageids],
subdir=f'podman/{user}/images/tree',
tags='podman_image_tree'
)

volumes = self.collect_cmd_output(f'{command} podman volume ls --format "{{{{.Name}}}}"', subdir=f'podman/{user}')
if volumes['status'] == 0:
print("volumes['output'].splitlines()[1:] ",volumes['output'].splitlines())
vols = [v for v in volumes['output'].splitlines() if v.strip()]
print("vols: ",vols)
self.add_cmd_output([
f"{command} podman volume inspect {vol}" for vol in vols
], subdir=f'podman/{user}/volumes', tags='podman_volume_inspect')


def setup(self):
spyre_cards = self.get_spyre_cards()

Expand Down Expand Up @@ -64,6 +157,8 @@ def setup(self):
"/etc/security/limits.d/memlock.conf",
])

self.get_podman_data()

def get_spyre_cards(self):
context = pyudev.Context()
spyre_cards_bus_ids = []
Expand Down