Skip to content

Commit

Permalink
[atomic] Remove atomic policy
Browse files Browse the repository at this point in the history
RHEL Atomic Host is RHEL7 only, and we since
we don't ship sos 4.* in RHEL 7, we can drop
this policy.

Signed-off-by: Jose Castillo <[email protected]>
  • Loading branch information
jcastill committed Dec 18, 2023
1 parent 2cd3a16 commit b292ef5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 88 deletions.
80 changes: 2 additions & 78 deletions sos/policies/distros/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
import re

from sos.report.plugins import RedHatPlugin
from sos.presets.redhat import (RHEL_PRESETS, ATOMIC_PRESETS, RHV, RHEL,
CB, RHOSP, RHOCP, RH_CFME, RH_SATELLITE,
ATOMIC)
from sos.presets.redhat import (RHEL_PRESETS, RHV, RHEL, CB, RHOSP,
RHOCP, RH_CFME, RH_SATELLITE)
from sos.policies.distros import LinuxPolicy, ENV_HOST_SYSROOT
from sos.policies.package_managers.rpm import RpmPackageManager
from sos.policies.package_managers.flatpak import FlatpakPackageManager
Expand All @@ -32,7 +31,6 @@

OS_RELEASE = "/etc/os-release"
RHEL_RELEASE_STR = "Red Hat Enterprise Linux"
ATOMIC_RELEASE_STR = "Atomic"


class RedHatPolicy(LinuxPolicy):
Expand Down Expand Up @@ -434,74 +432,6 @@ class CentOsPolicy(RHELPolicy):
vendor_urls = [('Community Website', 'https://www.centos.org/')]


class RedHatAtomicPolicy(RHELPolicy):
distro = "Red Hat Atomic Host"
msg = _("""\
This command will collect diagnostic and configuration \
information from this %(distro)s system.
An archive containing the collected information will be \
generated in %(tmpdir)s and may be provided to a %(vendor)s \
support representative.
""" + disclaimer_text + "%(vendor_text)s\n")

containerzed = True
container_runtime = 'docker'
container_image = 'registry.access.redhat.com/rhel7/support-tools'
sos_path_strip = '/host'
container_version_command = 'rpm -q sos'

def __init__(self, sysroot=None, init=None, probe_runtime=True,
remote_exec=None):
super(RedHatAtomicPolicy, self).__init__(sysroot=sysroot, init=init,
probe_runtime=probe_runtime,
remote_exec=remote_exec)
self.register_presets(ATOMIC_PRESETS)

@classmethod
def check(cls, remote=''):

if remote:
return cls.distro in remote

atomic = False
if ENV_HOST_SYSROOT not in os.environ:
return atomic
host_release = os.environ[ENV_HOST_SYSROOT] + OS_RELEASE
if not os.path.exists(host_release):
return False
try:
with open(host_release, 'r') as afile:
for line in afile.read().splitlines():
atomic |= ATOMIC_RELEASE_STR in line
except IOError:
pass
return atomic

def probe_preset(self):
if self.pkg_by_name('atomic-openshift'):
return self.find_preset(RHOCP)

return self.find_preset(ATOMIC)

def create_sos_container(self, image=None, auth=None, force_pull=False):
_cmd = ("{runtime} run -di --name {name} --privileged --ipc=host"
" --net=host --pid=host -e HOST=/host -e NAME={name} -e "
"IMAGE={image} {pull} -v /run:/run -v /var/log:/var/log -v "
"/etc/machine-id:/etc/machine-id -v "
"/etc/localtime:/etc/localtime -v /:/host {auth} {image}")
_image = image or self.container_image
_pull = '--pull=always' if force_pull else ''
return _cmd.format(runtime=self.container_runtime,
name=self.sos_container_name,
image=_image,
pull=_pull,
auth=auth or '')

def set_cleanup_cmd(self):
return 'docker rm --force sos-collector-tmp'


class RedHatCoreOSPolicy(RHELPolicy):
"""
Red Hat CoreOS is a containerized host built upon Red Hat Enterprise Linux
Expand Down Expand Up @@ -587,12 +517,6 @@ def set_cleanup_cmd(self):
return 'podman rm --force %s' % self.sos_container_name


class CentOsAtomicPolicy(RedHatAtomicPolicy):
distro = "CentOS Atomic Host"
vendor = "CentOS"
vendor_urls = [('Community Website', 'https://www.centos.org/')]


class FedoraPolicy(RedHatPolicy):
"""
The policy for Fedora based systems, regardless of spin/edition. This
Expand Down
10 changes: 0 additions & 10 deletions sos/presets/redhat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,4 @@
}


ATOMIC = "atomic"
ATOMIC_RELEASE_STR = "Atomic"
ATOMIC_DESC = "Red Hat Enterprise Linux Atomic Host"

ATOMIC_PRESETS = {
ATOMIC: PresetDefaults(name=ATOMIC, desc=ATOMIC_DESC, note=NOTE_TIME,
opts=_opts_verify)
}


# vim: set et ts=4 sw=4 :

0 comments on commit b292ef5

Please sign in to comment.