Exemplo n.º 1
0
    def process(self):
        service_name = 'leapp_resume.service'
        service_templ_fpath = self.get_file_path(service_name)
        shutil.copyfile(service_templ_fpath,
                        os.path.join('/etc/systemd/system/', service_name))

        service_path = '/etc/systemd/system/{}'.format(service_name)
        symlink_path = '/etc/systemd/system/default.target.wants/{}'.format(
            service_name)

        try:
            os.symlink(service_path, symlink_path)
        except OSError as e:
            self.report_error(
                'Could not create a symlink to enable {}'.format(service_name),
                details=str(e))
            return

        self.produce(
            FinalReport(
                severity='Info',
                result='Pass',
                summary='Leapp resume systemd service enabled',
                details=
                '{} enabled as oneshot systemd service to resume Leapp execution '
                'after reboot'.format(service_name)))
Exemplo n.º 2
0
 def process(self):
     for decision in self.consume(SelinuxRelabelDecision):
         if decision.set_relabel:
             try:
                 with open('/.autorelabel', 'w'):
                     pass
             except OSError as e:
                 self.produce(FinalReport(
                     severity='Error',
                     result='Fail',
                     summary='Could not schedule SElinux for relabelling',
                     details=e,))
                 self.log.critical('Could not schedule SElinux for relabelling: %s' % e)
Exemplo n.º 3
0
 def process(self):
     for decision in self.consume(SelinuxPermissiveDecision):
         if decision.set_permissive:
             success, err_msg = selinux_set_permissive()
             if not success:
                 self.produce(
                     FinalReport(
                         severity='Error',
                         result='Fail',
                         summary=
                         'Could not set SElinux into permissive mode',
                         details=err_msg,
                     ))
                 self.log.critical(
                     'Could not set SElinux into permissive mode: %s' %
                     err_msg)
Exemplo n.º 4
0
    def process(self):
        service_name = 'leapp_resume.service'
        if os.path.isfile('/etc/systemd/system/{}'.format(service_name)):
            subprocess.call(['systemctl', 'disable', service_name])
            try:
                os.unlink('/etc/systemd/system/{}'.format(service_name))
                os.unlink('/etc/systemd/system/default.target.wants/{}'.format(
                    service_name))
            except OSError as e:
                if e.errno != errno.ENOENT:
                    raise

        self.produce(
            FinalReport(
                severity='Info',
                result='Pass',
                summary='"{}" service deleted'.format(service_name),
                details='"{}" was taking care of resuming upgrade process '
                'after the first reboot'.format(service_name)))