コード例 #1
0
    def _get_rows(self, content):
        """
        Yields:
            a list per row of the following form:

            .. code:: python

                [
                    <name.arch>,
                    <[epoch:]version-release>,
                    <repo or @installed-from-repo>
                ]
        """
        start = self._find_start(content)
        if start == len(content):
            raise SkipComponent()

        # join hanging wrapped lines together into a single line.
        # see https://bugzilla.redhat.com/show_bug.cgi?id=584525
        cur = []
        for line in content[start:]:
            if not cur:
                cur.append(line.strip())
            elif line.startswith(" "):
                cur.append(line.strip())
            else:
                yield " ".join(cur).split()
                cur = [line.strip()]

        if cur:
            yield " ".join(cur).split()
コード例 #2
0
    def __init__(self, rpms, sat_server):
        self.full = None
        self.version = None
        self.release = None
        self.major = None
        self.minor = None

        if sat_server:
            raise SkipComponent('Not a Satellite Capsule machine')
        # For Capsule, ONLY 6.2 and newer are supported
        sat62_pkg = rpms.get_max('satellite-capsule')
        if sat62_pkg:
            self.full = sat62_pkg.package
            self.version = sat62_pkg.version
            self.release = sat62_pkg.release
            self.major, self.minor = _parse_sat_version(self.version)
        else:
            raise SkipComponent(
                "Not a Satellite Capsule machine or unable to determine the version"
            )
コード例 #3
0
 def __init__(self, local, shared):
     super(HttpdV, self).__init__()
     rhel_ver = shared[redhat_release].major
     self.data = shared[HV].data if HV in shared else None
     if rhel_ver == 6:
         ps = shared[PsAuxww]
         if ps.fuzzy_match('httpd.worker'):
             self.data = shared[HWV].data if HWV in shared else None
         elif ps.fuzzy_match('httpd.event'):
             self.data = shared[HEV].data if HEV in shared else None
     if self.data is None:
         raise SkipComponent("Unable to get the valid `httpd -V` command")
コード例 #4
0
 def __init__(self, rel, ps, hv, hev, hwv):
     deprecated(HttpdV, "Use the `HttpdV` parser in `insights.parsers.httpd_V`.")
     super(HttpdV, self).__init__()
     rhel_ver = rel.major
     self.data = hv.data if hv else None
     if rhel_ver == 6:
         if ps.fuzzy_match('httpd.worker'):
             self.data = hwv.data if hwv else None
         elif ps.fuzzy_match('httpd.event'):
             self.data = hev.data if hev else None
     if self.data is None:
         raise SkipComponent("Unable to get the valid `httpd -V` command")
コード例 #5
0
    def __init__(self, rpms, sat6_ver):
        self.full = None
        self.version = None
        self.release = None
        self.major = None
        self.minor = None

        # For Satellite 6.1, if satellite_version/version.rb is available:
        if sat6_ver:
            # no 'release' in this case, but more accurate
            self.full = sat6_ver.full
            self.version = sat6_ver.version
            self.major = sat6_ver.major
            self.minor = sat6_ver.minor
        else:
            # For Satellite 6.2 and newer, check the satellite package directly
            sat62_pkg = rpms.get_max('satellite')
            if sat62_pkg:
                self.full = sat62_pkg.package
                self.version = sat62_pkg.version
                self.release = sat62_pkg.release
                self.major, self.minor = _parse_sat_version(self.version)
            else:
                # For Satellite 6.0/6.1, check the version of:
                # - foreman, candlepin and katello
                fman = rpms.get_max('foreman')
                cndp = rpms.get_max('candlepin')
                ktlo = rpms.get_max('katello')
                if fman and cndp and ktlo:
                    for sat_ver, map_ver in sat6_ver_map.items():
                        if all(
                                pkg.version.startswith(mv) for pkg, mv in zip(
                                    [fman, cndp, ktlo], map_ver)):
                            # no 'release' in this situation
                            self.major, self.minor = _parse_sat_version(
                                sat_ver)
                            self.full = self.version = sat_ver
                else:
                    # For Satellite 5.x
                    sat5_pkg = rpms.get_max(
                        'satellite-schema') or rpms.get_max(
                            'rhn-satellite-schema')
                    if sat5_pkg:
                        self.full = sat5_pkg.package
                        self.version = sat5_pkg.version
                        self.release = sat5_pkg.release
                        self.major, self.minor = _parse_sat_version(
                            self.version)
        if not self.full:
            raise SkipComponent(
                "Not a Satellite machine or unable to determine Satellite version"
            )
コード例 #6
0
    def __init__(self, mi_all, mi_each):
        self.retpoline_y = set()
        self.retpoline_n = set()
        if mi_all:
            self.update(mi_all)
            self.retpoline_y = mi_all.retpoline_y
            self.retpoline_n = mi_all.retpoline_n
        else:
            for m in mi_each:
                name = m.module_name
                self[name] = m
                self.retpoline_y.add(name) if m.get(
                    'retpoline') == 'Y' else None
                self.retpoline_n.add(name) if m.get(
                    'retpoline') == 'N' else None

        if len(self) == 0:
            raise SkipComponent("No Parsed Contents")
コード例 #7
0
ファイル: grub_conf.py プロジェクト: yadneshk/insights-core
    def __init__(self, grub_bles, sys_firmware):
        self.version = self._version = 2
        self.is_efi = self._efi = '/sys/firmware/efi' in sys_firmware if sys_firmware else False
        self.entries = []
        self.boot_entries = []
        self.is_kdump_iommu_enabled = False
        for ble in grub_bles:
            self.entries.append(ble.entry)
            self.boot_entries.append(
                BootEntry({
                    'name': ble.title,
                    'cmdline': ble.cmdline
                }))
            self.is_kdump_iommu_enabled = self.is_kdump_iommu_enabled or ble.is_kdump_iommu_enabled
        self.kernel_initrds = get_kernel_initrds(self.entries)

        if not self.entries:
            raise SkipComponent()
コード例 #8
0
    def __init__(self, rpms):
        self.full = None
        self.version = None
        self.release = None
        self.major = None
        self.minor = None

        # For Capsule, ONLY 6.2 and newer are supported
        sat62_pkg = rpms.get_max('satellite-capsule')
        # foreman package should not be there on Capsule Server
        if sat62_pkg and 'foreman' not in rpms:
            self.full = sat62_pkg.package
            self.version = sat62_pkg.version
            self.release = sat62_pkg.release
            self.major, self.minor = _parse_sat_version(self.version)
        else:
            raise SkipComponent(
                "Not a Satellite Capsule machine or unable to determine the version"
            )
コード例 #9
0
    def __init__(self, hostname, insts, lssap):
        hn = hostname.hostname
        fqdn = hostname.fqdn
        data = {}
        self.local_instances = []
        self.business_instances = []
        self.function_instances = []
        self.all_instances = []
        self._types = set()
        if insts:
            self._types = insts.types
            self.all_instances = insts.instances
            for inst in insts.data:
                k = inst['InstanceName']
                if (hn == inst['Hostname'].split('.')[0]
                        or fqdn == inst['FullQualifiedHostname']
                        or fqdn == inst['Hostname']):
                    self.local_instances.append(k)
                data[k] = SAPInstances(k, inst['Hostname'], inst['SID'],
                                       inst['InstanceType'],
                                       inst['SystemNumber'],
                                       inst['FullQualifiedHostname'],
                                       inst['SapVersionInfo'])
        elif lssap:
            for inst in lssap.data:
                k = inst['Instance']
                t = k.rstrip('1234567890')
                self.all_instances.append(k)
                self._types.add(t)
                self.local_instances.append(
                    k) if hn == inst['SAPLOCALHOST'].split('.')[0] else None
                data[k] = SAPInstances(k, inst['SAPLOCALHOST'], inst['SID'], t,
                                       inst['Nr'], None, inst['Version'])
        if not data:
            raise SkipComponent('No SAP instance.')

        self.update(data)

        for i in self.all_instances:
            (self.function_instances if i.startswith(FUNC_TYPES) else
             self.business_instances).append(i)
コード例 #10
0
    def __init__(self, grub_bles, grubenv, sys_firmware):
        self.version = self._version = 2
        self.is_efi = self._efi = '/sys/firmware/efi' in sys_firmware if sys_firmware else False
        self.entries = []
        self.boot_entries = []
        self.is_kdump_iommu_enabled = False

        for ble in grub_bles:
            # Make a copy of the ble entry, so that no write
            # backs occur below when expanding variables.
            self.entries.append(ble.entry.copy())
            self.boot_entries.append(BootEntry({'name': ble.title, 'cmdline': ble.cmdline,
                                                'version': ble.entry.get('version')}))
            self.is_kdump_iommu_enabled = self.is_kdump_iommu_enabled or ble.is_kdump_iommu_enabled

        # If grub_bles and grubenv expand the $kernelopts,
        # $tuned_params, and $tuned_initrd variables.
        if grub_bles and grubenv:
            for entry in self.entries:
                entry_options = entry.get('options', "")
                if "$kernelopts" in entry_options or "$tuned_params" in entry_options:
                    entry['options'] = re.sub("\\$kernelopts", grubenv.kernelopts,
                                              entry['options']).strip()
                    entry['options'] = re.sub("\\$tuned_params", grubenv.tuned_params,
                                              entry['options']).strip()

                if "$tuned_initrd" in entry.get('initrd', "") and grubenv.get('tuned_initrd'):
                    entry['initrd'] = re.sub("\\$tuned_initrd", grubenv.get('tuned_initrd', ""),
                                             entry['initrd']).strip()

            for entry in self.boot_entries:
                entry_options = entry.get('cmdline', "")
                if "$kernelopts" in entry_options or "$tuned_params" in entry_options:
                    entry['cmdline'] = re.sub("\\$kernelopts", grubenv.kernelopts, entry['cmdline']).strip()
                    entry['cmdline'] = re.sub("\\$tuned_params", grubenv.tuned_params, entry['cmdline']).strip()

        self.kernel_initrds = get_kernel_initrds(self.entries)

        if not self.entries:
            raise SkipComponent()
コード例 #11
0
def uptime(ut):
    """
    .. warning::
       This combiner method is deprecated, please use
       :py:class:`insights.parsers.uptime.Uptime` instead.

    Check uptime to get the uptime information.

    Returns:
        insights.combiners.uptime.Uptime: A named tuple with `currtime`,
        `updays`, `uphhmm`, `users`, `loadavg` and `uptime` components.

    Raises:
        SkipComponent: If no data is available or if ``loadavg`` is not available.
    """
    deprecated(uptime, "Use the `Uptime` parser instead.")

    if ut.loadavg:
        return Uptime(ut.currtime, ut.updays, ut.uphhmm, ut.users, ut.loadavg,
                      ut.uptime)

    raise SkipComponent("Unable to get uptime information.")
コード例 #12
0
def yum_updates(_broker):
    """
    This datasource provides a list of available updates on the system.
    It uses the yum python library installed locally, and collects list of
    available package updates, along with advisory info where applicable.

    Sample data returned::

        {
          "releasever": "8",
          "basearch": "x86_64",
          "update_list": {
            "NetworkManager-1:1.22.8-4.el8.x86_64": {
              "available_updates": [
                {
                  "package": "NetworkManager-1:1.22.8-5.el8_2.x86_64",
                  "repository": "rhel-8-for-x86_64-baseos-rpms",
                  "basearch": "x86_64",
                  "releasever": "8",
                  "erratum": "RHSA-2020:3011"
                }
              ]
            }
          },
          "metadata_time": "2021-01-01T09:39:45Z"
        }

    Returns:
        list: List of available updates
    Raises:
        SkipComponent: Raised on systems different than RHEL 7
    """

    if not _broker.get(IsRhel7):
        raise SkipComponent("Yum updates currently only works on RHEL 7")

    with UpdatesManager() as umgr:
        umgr.load()

        response = {
            "releasever": umgr.releasever,
            "basearch": umgr.basearch,
            "update_list": {},
        }

        data = {'package_list': umgr.installed_packages()}
        updates = {}
        for pkg in data["package_list"]:
            (nevra, updates_list) = umgr.updates(pkg)
            updates[nevra] = updates_list
            for (nevra, update_list) in updates.items():
                if update_list:
                    out_list = []
                    for pkg in umgr.sorted_pkgs(update_list):
                        pkg_dict = {
                            "package": umgr.pkg_nevra(pkg),
                            "repository": umgr.pkg_repo(pkg),
                            "basearch": response["basearch"],
                            "releasever": response["releasever"],
                        }
                        erratum = umgr.advisory(pkg)
                        if erratum:
                            pkg_dict["erratum"] = erratum
                        out_list.append(pkg_dict)
                    response["update_list"][nevra] = {"available_updates": out_list}

        ts = umgr.last_update()
        if ts:
            response["metadata_time"] = time.strftime("%FT%TZ", time.gmtime(ts))
    return DatasourceProvider(content=json.dumps(response), relative_path='insights_commands/yum_updates_list')