Beispiel #1
0
    def process(self):
        skip_check = os.getenv('LEAPP_SKIP_CHECK_SIGNED_PACKAGES')
        if skip_check:
            self.produce(
                CheckResult(
                    severity='Warning',
                    result='Not Applicable',
                    summary='Skipped signed packages check',
                    details=
                    'Signed packages check skipped via LEAPP_SKIP_CHECK_SIGNED_PACKAGES env var'
                ))
            return

        unsigned_pkgs = next(self.consume(InstalledUnsignedRPM),
                             InstalledUnsignedRPM())

        if len(unsigned_pkgs.items):
            # FIXME: To avoid problems during tests, this is being reported as WARNING by now
            self.produce(
                CheckResult(
                    severity='Warning',
                    result='Fail',
                    summary=
                    'Packages not signed by Red Hat found in the system',
                    details=(
                        'Following packages were not signed by Red Hat:\n    {}'
                        .format('\n    '.join(
                            [pkg.name for pkg in unsigned_pkgs.items]))),
                    solutions=(
                        'Consider removing those packages from'
                        ' the system. Such packages could have negative impact'
                        ' on the whole upgrade process.')))
Beispiel #2
0
 def produce_info(self, result, summary, details, solution=None):
     self.produce(
         CheckResult(severity='Info',
                     result=result,
                     summary=summary,
                     details=details,
                     solutions=solution))
Beispiel #3
0
    def process(self):
        os_data_file = '/etc/os-release'
        os_data = {}

        try:
            with open(os_data_file) as f:
                os_data = dict(l.strip().split('=', 1) for l in f.readlines()
                               if '=' in l)
        except IOError as e:
            self.produce(
                CheckResult(severity='Error',
                            result='Fail',
                            summary='Error while collecting system OS facts',
                            details=str(e),
                            solutions=None))
            return

        self.produce(
            OSReleaseFacts(id=os_data.get('ID', '').strip('"'),
                           name=os_data.get('NAME', '').strip('"'),
                           pretty_name=os_data.get('PRETTY_NAME',
                                                   '').strip('"'),
                           version=os_data.get('VERSION', '').strip('"'),
                           version_id=os_data.get('VERSION_ID', '').strip('"'),
                           variant=os_data.get('VARIANT', '').strip('"')
                           or None,
                           variant_id=os_data.get('VARIANT_ID', '').strip('"')
                           or None))
Beispiel #4
0
    def process(self):
        ''' based on a decision maker Actor, it disables firewall services '''
        self.log.info("Starting to get decision on FirewallD.")
        for decision in self.consume(FirewallDecisionM):
            if decision.disable_choice == 'Y':
                self.log.info("Disabling Firewall.")
                for facts in self.consume(SystemFacts):
                    if facts.firewalls.iptables.enabled:
                        self.log.info("- IPTables.")
                        self.disable_iptables()
                        break
                    elif facts.firewalls.firewalld.enabled:
                        self.log.info("- FirewallD.")
                        self.disable_firewalld()
                        break
                    else:
                        continue

                self.log.info("Firewalls are disabled.")
                self.produce(
                    CheckResult(
                        severity='Info',
                        result='Pass',
                        summary='Firewalls are disabled',
                        details=
                        'FirewallD and/or IPTables services are disabled.',
                        solutions=None))
                return
            elif decision.disable_choice == 'N':
                self.log.info(
                    "Interrupting the upgrade process due the current user choice to take care for Firewall manually."
                )
                return
            elif decision.disable_choice == 'S':
                self.log.info("Skipping - all should be disabled.")
                return
        else:
            self.log.info(
                "Interrupting: There was nothing to consume regarding the Firewall decision."
            )
            self.produce(
                CheckResult(severity='Error',
                            result='Fail',
                            summary='No message to consume',
                            details='No decision message to consume.',
                            solutions=None))
            return
Beispiel #5
0
    def process(self):
        skip_check = os.getenv('LEAPP_SKIP_CHECK_OS_RELEASE')
        if skip_check:
            self.produce(
                CheckResult(
                    severity='Warning',
                    result='Not Applicable',
                    summary='Skipped OS release check',
                    details=
                    'OS release check skipped via LEAPP_SKIP_CHECK_OS_RELEASE env var',
                    solutions=None))
            return

        min_supported_version = {'rhel': '7.6'}

        for facts in self.consume(OSReleaseFacts):
            if facts.id not in min_supported_version.keys():
                self.produce(
                    CheckResult(
                        severity='Error',
                        result='Fail',
                        summary='Unsupported OS id',
                        details='Supported OS ids for upgrade process: ' +
                        ','.join(min_supported_version.keys()),
                        solutions=None))
                return

            min_version = [
                int(x) for x in min_supported_version[facts.id].split('.')
            ]
            os_version = [int(x) for x in facts.version_id.split('.')]

            for current, minimal in zip(os_version, min_version):
                if current > minimal:
                    break

                if current < minimal:
                    self.produce(
                        CheckResult(
                            severity='Error',
                            result='Fail',
                            summary='Unsupported OS version',
                            details=
                            'Minimal supported OS version for upgrade process: '
                            + min_supported_version[facts.id],
                            solutions=None))
                    return
Beispiel #6
0
 def process(self):
     if platform.machine() != 'x86_64':
         self.produce(
             CheckResult(
                 severity='Error',
                 result='Fail',
                 summary='Unsupported arch',
                 details=
                 'Upgrade process is only supported on x86_64 systems',
                 solutions='There is no current solution for this problem'))
Beispiel #7
0
 def process(self):
     self.log.info("Starting to get FirewallD decision.")
     for facts in self.consume(SystemFacts):
         # FIXME: checked only whether services are disabled. But in case
         # + there is another service/proces/... that starts firewalls during
         # + boot we will not catch it in this way. Shouldn't we check and
         # + print warning message in case the firewalls are active but
         # + services are disabled? To reflect possible risk, e.g. that user
         # + will not be able to connect to the upgraded system through ssh.
         # + Fix it later.
         if facts.firewalls.firewalld.enabled or facts.firewalls.iptables.enabled:
             answer = self.request_answers(self.dialogs[0]).get(
                 'continue_fw', False)
             self.produce(
                 FirewallDecisionM(disable_choice='Y' if answer else 'N'))
             if not answer:
                 self.produce(
                     CheckResult(
                         severity='Error',
                         result='Fail',
                         summary=
                         'Firewall interrupts upgrade process request',
                         details='SA user chose to interrupt the upgrade.',
                         solutions=None))
             return
         else:
             # FIXME: See the fixme above
             self.log.info("Firewall is disabled. Nothing to decide.")
             self.produce(FirewallDecisionM(disable_choice='S'))
             self.produce(
                 CheckResult(severity='Info',
                             result='Pass',
                             summary='Firewall disabled',
                             details='Firewall service is disabled.',
                             solutions=None))
             return
     else:
         self.log.info(
             "No message to consume for the Firewall decision. Quitting..")
     return
Beispiel #8
0
    def process(self):
        error_detected = detect_config_error('/etc/default/grub')
        if error_detected:
            self.produce(
                CheckResult(
                    severity='Info',
                    result='Fixed',
                    summary='Syntax error detected in grub configuration.',
                    details=
                    'Syntax error was detected in GRUB_CMDLINE_LINUX value of grub configuration. '
                    'This error is causing booting and other issues. '
                    'Error is automatically fixed by add_upgrade_boot_entry actor.'
                ))

        self.produce(GrubConfigError(error_detected=error_detected))
Beispiel #9
0
 def process(self):
     for storage_info in self.consume(StorageInfo):
         for blk in storage_info.lsblk:
             if blk.tp == 'crypt':
                 self.produce(
                     CheckResult(
                         severity='Error',
                         result='Fail',
                         summary='LUKS encrypted partition detected',
                         details=
                         'Upgrading system with encrypted partitions is not supported',
                         solutions=
                         'If the encrypted partition is not system one and the system '
                         'is not depending on it, you can remove/blacklist it from '
                         'the system'))
                 break
Beispiel #10
0
 def process(self):
     for fact in self.consume(SystemFacts):
         for active_module in fact.kernel_modules:
             if active_module.filename == 'btrfs':
                 self.produce(
                     CheckResult(
                         severity='Error',
                         result='Fail',
                         summary='Btrfs removed on next major version',
                         details=
                         'The Btrfs file system was introduced as Technology Preview with the initial release '
                         'of Red Hat Enterprise Linux 6 and Red Hat Enterprise Linux 7. As of versions 6.6 and '
                         '7.4 this technology has been deprecated and will be removed in next major version',
                         solutions=
                         'Please consider migrating your Btrfs mount point(s) to a different filesystem '
                         'before next upgrade attempt. If no Btrfs filesystem is in use, please unload '
                         'btrfs kernel module running "# rmmod btrfs"'))
                 break