Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE
resource-agents.10370
0024-1251.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0024-1251.patch of Package resource-agents.10370
From 9db7af920168570ca319d4a5a58748c401707eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se> Date: Thu, 18 Oct 2018 10:49:17 +0200 Subject: [PATCH] Dev: ocf.py: Add distro() function --- heartbeat/ocf.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/heartbeat/ocf.py b/heartbeat/ocf.py index 26cca239d..671b49edb 100644 --- a/heartbeat/ocf.py +++ b/heartbeat/ocf.py @@ -206,6 +206,35 @@ def get_parameter(name, default=None): return env.get("OCF_RESKEY_{}".format(name), default) +def distro(): + """ + Return name of distribution/platform. + + If possible, returns "name/version", else + just "name". + """ + import subprocess + import platform + try: + ret = subprocess.check_output(["lsb_release", "-si"]) + if type(ret) != str: + ret = ret.decode() + distro = ret.strip() + ret = subprocess.check_output(["lsb_release", "-sr"]) + if type(ret) != str: + ret = ret.decode() + version = ret.strip() + return "{}/{}".format(distro, version) + except Exception: + if os.path.exists("/etc/debian_version"): + return "Debian" + if os.path.exists("/etc/SuSE-release"): + return "SUSE" + if os.path.exists("/etc/redhat-release"): + return "Redhat" + return platform.system() + + class Parameter(object): def __init__(self, name, shortdesc, longdesc, content_type, unique, required, default): self.name = name
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor