From 96ac9e7f7c2502f64f7ebae77fbca18ce2b6fdb9 Mon Sep 17 00:00:00 2001 From: jeff200902 Date: Mon, 13 Jul 2020 09:52:11 +0000 Subject: [PATCH] hoperun-openeuler-sos-policy --- sos/policies/openEuler.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 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..de58f92 --- /dev/null +++ b/sos/policies/openEuler.py @@ -0,0 +1,36 @@ +# Copyright (C) Huawei, Inc. 2020 + +# This file is part of the sos project: https://github.com/sosreport/sos +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# version 2 of the GNU General Public License. +# +# See the LICENSE file in the source distribution for further information. + +# This enables the use of with syntax in python 2.5 (e.g. jython) +from __future__ import print_function + +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): + super(OpenEulerPolicy, self).__init__(sysroot=sysroot) + + @classmethod + def check(cls): + """This method checks to see if we are running on OpenEuler. It returns + True or False.""" + 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"]) -- 2.23.0