!12 [sync] PR-11: add openEuler policy

From: @openeuler-sync-bot
Reviewed-by: @overweight
Signed-off-by: @overweight
This commit is contained in:
openeuler-ci-bot 2021-03-11 09:19:00 +08:00 committed by Gitee
commit c54e0d8863
2 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From 3b76979a51f8b8e65991c00cd4ebab2f23a467a6 Mon Sep 17 00:00:00 2001
From: shixuantong <shixuantong@huawei.com>
Date: Mon, 8 Mar 2021 20:56:05 +0800
Subject: [PATCH] add openEuler policy
this patch is based on sos-4.0, not applicable to the lower version.
---
sos/policies/openEuler.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 sos/policies/openEuler.py
diff --git a/sos/policies/openEuler.py b/sos/policies/openEuler.py
new file mode 100644
index 0000000..ea65ba2
--- /dev/null
+++ b/sos/policies/openEuler.py
@@ -0,0 +1,30 @@
+from __future__ import print_function
+
+from sos.report.plugins import RedHatPlugin
+from sos.policies.redhat import RedHatPolicy, OS_RELEASE
+import os
+
+class OpenEulerPolicy(RedHatPolicy):
+
+ distro = "OpenEuler"
+ vendor = "the openEuler Project"
+ vendor_url = "https://openeuler.org/"
+
+ def __init__(self, sysroot=None, init=None, probe_runtime=True,
+ remote_exec=None):
+ super(OpenEulerPolicy, self).__init__(sysroot=sysroot, init=init,
+ probe_runtime=probe_runtime,
+ remote_exec=remote_exec)
+
+ @classmethod
+ def check(cls, remote=''):
+ """This method checks to see if we are running on OpenEuler. It returns
+ True or False."""
+ if remote:
+ return cls.distro in remote
+ return os.path.isfile('/etc/openEuler-release')
+
+ def openEuler_version(self):
+ pkg = self.pkg_by_name("openEuler-release") or \
+ self.all_pkgs_by_name_regex("openEuler-release-.*")[-1]
+ return int(pkg["version"])
--
1.8.3.1

View File

@ -2,13 +2,14 @@
Name: sos
Version: 4.0
Release: 2
Release: 3
Summary: A set of tools to gather troubleshooting information from a system
License: GPLv2+
URL: https://github.com/sosreport/sos
Source0: https://github.com/sosreport/sos/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch6000: backport-Fix-dict-order-py38-incompatibility.patch
Patch9000: openEuler-add-openEuler-policy.patch
BuildRequires: python3-devel gettext
Requires: libxml2-python3 bzip2 xz python3-rpm tar python3-pexpect
@ -57,6 +58,9 @@ install -m 644 %{name}.conf %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf
%{_mandir}/man5/*
%changelog
* Mon Mar 08 2021 shixuantong <shixuantong@huawei.com> - 4.0-3
- add openEuler policy
* Tue Mar 03 2021 shixuantong <shixuantong@huawei.com> - 4.0-2
- fix unable to read configure file /etc/sos/sos.conf issue