From cfe0d9c38a9843a27c9fac9a5344ce00e4f2eeae Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 07 2019 09:37:50 +0000 Subject: import sos-collector-1.6-4.el8 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7414830 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/sos-collector-1.6.tar.gz diff --git a/.sos-collector.metadata b/.sos-collector.metadata new file mode 100644 index 0000000..812d89a --- /dev/null +++ b/.sos-collector.metadata @@ -0,0 +1 @@ +61b7d707fb053f08678488c59c7d6826c4ae9d94 SOURCES/sos-collector-1.6.tar.gz diff --git a/SOURCES/sos-collector-local-pexpect.patch b/SOURCES/sos-collector-local-pexpect.patch new file mode 100644 index 0000000..75bdf92 --- /dev/null +++ b/SOURCES/sos-collector-local-pexpect.patch @@ -0,0 +1,79 @@ +diff --git a/soscollector/sosnode.py b/soscollector/sosnode.py +index 44d21c4..7fdb524 100644 +--- a/soscollector/sosnode.py ++++ b/soscollector/sosnode.py +@@ -26,7 +26,6 @@ import six + from distutils.version import LooseVersion + from pipes import quote + from soscollector.exceptions import * +-from subprocess import Popen, PIPE + + + class SosNode(): +@@ -308,7 +307,7 @@ class SosNode(): + sudo or su - as appropriate and to input the password + force_local - force a command to run locally. Mainly used for scp. + ''' +- if not self.control_socket_exists: ++ if not self.control_socket_exists and not self.local: + self.log_debug('Control socket does not exist, attempting to ' + 're-create') + try: +@@ -333,42 +332,21 @@ class SosNode(): + get_pty = True + if not self.local and not force_local: + cmd = "%s %s" % (self.ssh_cmd, quote(cmd)) +- res = pexpect.spawn(cmd, encoding='utf-8') +- if need_root: +- if self.config['need_sudo']: +- res.sendline(self.config['sudo_pw']) +- if self.config['become_root']: +- res.sendline(self.config['root_password']) +- output = res.expect([pexpect.EOF, pexpect.TIMEOUT], +- timeout=timeout) +- if output == 0: +- out = res.before +- res.close() +- rc = res.exitstatus +- return {'status': rc, 'stdout': out} +- elif output == 1: +- raise CommandTimeoutException(cmd) +- else: +- try: +- proc = Popen(shlex.split(cmd), shell=get_pty, stdin=PIPE, +- stdout=PIPE, stderr=PIPE) +- if self.config['become_root'] and need_root: +- stdout, stderr = proc.communicate( +- input=self.config['root_password'] + '\n' +- ) +- elif self.config['need_sudo'] and need_root: +- stdout, stderr = proc.communicate( +- input=self.config['sudo_pw'] + '\n' +- ) +- else: +- stdout, stderr = proc.communicate() +- proc.wait() +- rc = proc.returncode +- return {'status': rc, 'stdout': stdout or stderr} +- except Exception as err: +- self.log_error("Exception while running command %s: %s" +- % (cmd, err)) +- raise ++ res = pexpect.spawn(cmd, encoding='utf-8') ++ if need_root: ++ if self.config['need_sudo']: ++ res.sendline(self.config['sudo_pw']) ++ if self.config['become_root']: ++ res.sendline(self.config['root_password']) ++ output = res.expect([pexpect.EOF, pexpect.TIMEOUT], ++ timeout=timeout) ++ if output == 0: ++ out = res.before ++ res.close() ++ rc = res.exitstatus ++ return {'status': rc, 'stdout': out} ++ elif output == 1: ++ raise CommandTimeoutException(cmd) + + def sosreport(self): + '''Run a sosreport on the node, then collect it''' diff --git a/SOURCES/sos-collector-non-root-quote.patch b/SOURCES/sos-collector-non-root-quote.patch new file mode 100644 index 0000000..e5b89c1 --- /dev/null +++ b/SOURCES/sos-collector-non-root-quote.patch @@ -0,0 +1,26 @@ +From b69d2f8decf044d5ee4c97a580bc36bb1735b1c7 Mon Sep 17 00:00:00 2001 +From: Jake Hunsaker +Date: Fri, 21 Dec 2018 15:47:27 -0500 +Subject: [PATCH] [sosnode] Fix quoting for non-root su commands + +Signed-off-by: Jake Hunsaker +--- + soscollector/sosnode.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/soscollector/sosnode.py b/soscollector/sosnode.py +index 7fdb524..cfdb1e0 100644 +--- a/soscollector/sosnode.py ++++ b/soscollector/sosnode.py +@@ -154,7 +154,7 @@ class SosNode(): + here we prefix the command with the correct bits + ''' + if self.config['become_root']: +- return "su -c '%s'" % cmd ++ return "su -c %s" % quote(cmd) + if self.config['need_sudo']: + return "sudo -S %s" % cmd + return cmd +-- +2.14.5 + diff --git a/SOURCES/sos-collector-sat-support.patch b/SOURCES/sos-collector-sat-support.patch new file mode 100644 index 0000000..93d85a6 --- /dev/null +++ b/SOURCES/sos-collector-sat-support.patch @@ -0,0 +1,70 @@ +From 096ce477d314d47aa805fae585dc5aac17810d8f Mon Sep 17 00:00:00 2001 +From: Jake Hunsaker +Date: Fri, 28 Dec 2018 14:21:40 -0500 +Subject: [PATCH] [satellite] Add satellite a supported environment + +Adds a profile for Satellite 6. While not technically a cluster, Sat 6 +does have capsule servers that can be deployed concurrently to help with +load and distribution, so it still fits in with sos-collector's goal. + +Many thanks to Paul Dudley from Red Hat for assistance in providing a +test environment for this work and identifying the need. + +Signed-off-by: Jake Hunsaker +--- + soscollector/clusters/satellite.py | 43 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 43 insertions(+) + create mode 100644 soscollector/clusters/satellite.py + +diff --git a/soscollector/clusters/satellite.py b/soscollector/clusters/satellite.py +new file mode 100644 +index 0000000..ccdfefb +--- /dev/null ++++ b/soscollector/clusters/satellite.py +@@ -0,0 +1,43 @@ ++# Copyright Red Hat 2018, Jake Hunsaker ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License along ++# with this program; if not, write to the Free Software Foundation, Inc., ++# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ ++from pipes import quote ++from soscollector.clusters import Cluster ++ ++ ++class satellite(Cluster): ++ """Red Hat Satellite 6""" ++ ++ packages = ('satellite', 'satellite-installer') ++ ++ def _psql_cmd(self, query): ++ _cmd = "su postgres -c %s" ++ _dbcmd = "psql foreman -c %s" ++ return _cmd % quote(_dbcmd % quote(query)) ++ ++ def get_nodes(self): ++ cmd = self._psql_cmd('select name from smart_proxies') ++ res = self.exec_master_cmd(cmd, need_root=True) ++ if res['status'] == 0: ++ idx = 2 ++ if 'could not change' in res['stdout']: ++ idx = 3 ++ nodes = [n.strip() for n in res['stdout'].splitlines()[idx:-1]] ++ return nodes ++ ++ def set_node_label(self, node): ++ if node.address == self.master.address: ++ return 'satellite' ++ return 'capsule' +-- +2.14.5 + diff --git a/SPECS/sos-collector.spec b/SPECS/sos-collector.spec new file mode 100644 index 0000000..b76ef3e --- /dev/null +++ b/SPECS/sos-collector.spec @@ -0,0 +1,87 @@ +Summary: Capture sosreports from multiple nodes simultaneously +Name: sos-collector +Version: 1.6 +Release: 4%{?dist} +Source0: http://people.redhat.com/jhunsake/sos-collector/%{name}-%{version}.tar.gz +License: GPLv2 +BuildArch: noarch +Url: https://github.com/sosreport/sos-collector +Requires: sos >= 3.0 +Obsoletes: clustersos < 1.2.2-2 +Provides: clustersos = %{version}-%{release} + +Patch0: sos-collector-local-pexpect.patch +Patch1: sos-collector-non-root-quote.patch +Patch2: sos-collector-sat-support.patch + +%if 0%{?rhel} == 7 +BuildRequires: python-devel +BuildRequires: python-setuptools +Requires: python2-futures +Requires: python-six +Requires: pexpect +%else +BuildRequires: python3-devel +BuildRequires: python3-six +BuildRequires: python3-pexpect +Requires: python3-six +Requires: python3-pexpect +%endif + + +%description +sos-collector is a utility designed to capture sosreports from multiple nodes +at once and collect them into a single archive. If the nodes are part of +a cluster, profiles can be used to configure how the sosreport command +is run on the nodes. + +%prep +%setup -q +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 + +%build +%if 0%{?rhel} == 7 +%py2_build +%else +%py3_build +%endif + +%install +mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1 +install -p -m644 man/en/sos-collector.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/ +%if 0%{?rhel} == 7 +%py2_install +%else +%py3_install +%endif + + + +%check +%if 0%{?rhel} == 7 +%{__python2} setup.py test +%else +%{__python3} setup.py test +%endif + +%files +%{_bindir}/sos-collector +%if 0%{?rhel} == 7 +%{python2_sitelib}/* +%else +%{python3_sitelib}/* +%endif +%{_mandir}/man1/* + +%license LICENSE + +%changelog +* Tue Jan 08 2019 Jake Hunsaker - 1.6-4 +- Adds support for Satellite deployments +- Fixes quoting for non-root local commands + +* Thu Dec 20 2018 Jake Hunsaker - 1.6-3 +- Initial RHEL 8 release based on upstream 1.6 +- Drops paramiko dependency in favor of OpenSSH ControlPersist