未验证 提交 72202b84 编写于 作者: P Praveen K Pandey

Merge branch 'sysctl_v2' of https://github.com/clebergnu/avocado into clebergnu-sysctl_v2

Signed-off-by: Praveen K Pandey praveen@linux.vnet.ibm.com
# 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 LICENSE for more details.
#
# This code was inspired in the autotest project,
#
# client/base_utils.py
#
# Copyright: IBM, 2019
# Red Hat Inc. 2019
# Authors : Praveen K Pandey <praveen@linux.vnet.ibm.com>
# Cleber Rosa <crosa@redhat.com>
"""
Linux OS utilities
"""
import os
from . import genio
def get_proc_sys(key):
"""
Read values from /proc/sys
:param key: A location under /proc/sys
:return: The single-line sysctl value as a string.
"""
path = os.path.join('/proc/sys/%s', key)
return genio.read_one_line(path)
def set_proc_sys(key, value):
"""
Set values on /proc/sys
:param key: A location under /proc/sys
:param value: If not None, a value to write into the sysctl.
:return: The single-line sysctl value as a string.
"""
path = os.path.join('/proc/sys/%s', key)
genio.write_one_line(path, value)
return get_proc_sys(key)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册