Skip to content

Commit

Permalink
Merge branch 'master' into paulway_improve_topological_sort
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWay authored Jan 18, 2023
2 parents 9ec1ca6 + 16d145c commit 2574f19
Show file tree
Hide file tree
Showing 6 changed files with 358 additions and 37 deletions.
29 changes: 20 additions & 9 deletions insights/combiners/rhel_for_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
* :py:class:`insights.parsers.systemd.unitfiles.ListUnits`
* :py:class:`insights.parsers.redhat_release.RedhatRelease`
"""
from insights.core.exceptions import SkipComponent
from insights.core.plugins import combiner
from insights.parsers.cmdline import CmdLine
from insights.parsers.installed_rpms import InstalledRpms
from insights.parsers.systemd.unitfiles import ListUnits
from insights.parsers.redhat_release import RedhatRelease
from insights.parsers.rpm_ostree_status import RpmOstreeStatus


@combiner(InstalledRpms, CmdLine, ListUnits, RedhatRelease)
@combiner(ListUnits, optional=[RpmOstreeStatus, InstalledRpms, CmdLine, RedhatRelease])
class RhelForEdge(object):
"""Combiner for checking if the system is an edge computing system. Edge
computing as well as the Red Hat CoreOS packages are managed via rpm-ostree.
Expand Down Expand Up @@ -58,13 +60,22 @@ class RhelForEdge(object):
"""

def __init__(self, rpms, cmdline, units, redhatrelease):
def __init__(self, units, rpmostreestatus, rpms, cmdline, redhatrelease):
self.is_edge = False
self.is_automated = False

if ('rpm-ostree' in rpms and 'yum' not in rpms) and \
('ostree' in cmdline) and \
("red hat enterprise linux release" in redhatrelease.raw.lower()):
self.is_edge = True
if units.is_running("rhcd.service"):
self.is_automated = True
if rpmostreestatus:
origin = rpmostreestatus.query.deployments.origin
origin_check = [item.value.endswith("edge") for item in origin]
if origin_check and all(origin_check):
self.is_edge = True
if units.is_running("rhcd.service"):
self.is_automated = True
elif rpms and cmdline and redhatrelease:
if ('rpm-ostree' in rpms and 'yum' not in rpms) and \
('ostree' in cmdline) and \
("red hat enterprise linux release" in redhatrelease.raw.lower()):
self.is_edge = True
if units.is_running("rhcd.service"):
self.is_automated = True
else:
raise SkipComponent("Unable to determine if this system is created from an edge image.")
37 changes: 19 additions & 18 deletions insights/parsers/installed_rpms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
-----------------------------------------------------------
"""

from collections import defaultdict
import json
import re
from collections import defaultdict

import six
import warnings

from ..util import rsplit
from .. import parser, get_active_lines, CommandParser
from .rpm_vercmp import rpm_version_compare
from insights import ContainerParser, parser, CommandParser
from insights.core.exceptions import SkipComponent
from insights.parsers.rpm_vercmp import rpm_version_compare
from insights.specs import Specs
from insights import ContainerParser
from insights.util import rsplit


# This list of architectures is taken from PDC (Product Definition Center):
# https://pdc.fedoraproject.org/rest_api/v1/arches/
Expand Down Expand Up @@ -253,24 +253,25 @@ def __init__(self, *args, **kwargs):

def parse_content(self, content):
packages = defaultdict(list)
for line in get_active_lines(content, comment_char='COMMAND>'):
if content and (not content[0].strip() or "COMMAND>" in content[0]):
content = content[1:]
if not content:
raise SkipComponent("The content of rpm command is empty!")
if content and '"name":' in content[0]:
rpm_init_method = InstalledRpm.from_json
else:
rpm_init_method = InstalledRpm.from_line
for line in content:
if not line.strip():
continue
if line.startswith('error:') or line.startswith('warning:'):
self.errors.append(line)
else:
try:
# Try to parse from JSON input
rpm = InstalledRpm.from_json(line)
rpm = rpm_init_method(line)
packages[rpm.name].append(rpm)
except Exception:
# If that fails, try to parse from line input
if line.strip():
try:
rpm = InstalledRpm.from_line(line)
packages[rpm.name].append(rpm)
except Exception:
# Both ways failed
self.unparsed.append(line)
# Don't want defaultdict's behavior after parsing is complete
self.unparsed.append(line)
self.packages = dict(packages)

@property
Expand Down
3 changes: 2 additions & 1 deletion insights/specs/datasources/sys_fs_cgroup_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ def sys_fs_cgroup_uniq_memory_swappiness(broker):
data_list = []
for value, count in data.items():
data_list.append("{0} {1}".format(value, count))
return DatasourceProvider(content="\n".join(data_list), relative_path='insights_commands/sys_fs_cgroup_uniq_memory_swappiness')

return DatasourceProvider(content="\n".join(data_list), relative_path='insights_commands/sys_fs_cgroup_uniq_memory_swappiness')
2 changes: 2 additions & 0 deletions insights/specs/insights_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class InsightsArchiveSpecs(Specs):
aws_instance_id_pkcs7 = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_aws_instance_id_pkcs7")
awx_manage_check_license = simple_file("insights_commands/awx-manage_check_license")
awx_manage_print_settings = simple_file("insights_commands/awx-manage_print_settings_INSIGHTS_TRACKING_STATE_SYSTEM_UUID_INSTALL_UUID_TOWER_URL_BASE_AWX_CLEANUP_PATHS_AWX_PROOT_BASE_PATH_LOG_AGGREGATOR_ENABLED_LOG_AGGREGATOR_LEVEL_--format_json")
azure_instance_id = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_azure_instance_id")
azure_instance_type = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_azure_instance_type")
azure_instance_plan = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_azure_instance_plan")
bios_uuid = simple_file("insights_commands/dmidecode_-s_system-uuid")
Expand Down Expand Up @@ -76,6 +77,7 @@ class InsightsArchiveSpecs(Specs):
firewall_cmd_list_all_zones = simple_file("insights_commands/firewall-cmd_--list-all-zones")
fw_devices = simple_file("insights_commands/fwupdagent_get-devices")
fw_security = simple_file("insights_commands/fwupdagent_security_--force")
gcp_instance_type = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_gcp_instance_type")
gcp_license_codes = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_gcp_license_codes")
getcert_list = simple_file("insights_commands/getcert_list")
getconf_page_size = simple_file("insights_commands/getconf_PAGE_SIZE")
Expand Down
Loading

0 comments on commit 2574f19

Please sign in to comment.