1 Star 0 Fork 105

王策/anaconda

forked from src-openEuler/anaconda 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ntp-servers-improve-007-Add-support-for-generating-a-summary-of-the-NTP-servers.patch 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
eaglegai 提交于 2020-12-04 17:45 . improve ntp servers to fix unkown error
From 716db242314b710b881c073d290b6d1ad8670d36 Mon Sep 17 00:00:00 2001
From: Vendula Poncova <vponcova@redhat.com>
Date: Mon, 6 Jul 2020 14:19:46 +0200
Subject: [PATCH] Add support for generating a summary of the NTP servers
Call the functions get_ntp_server_summary and get_ntp_servers_summary to
generate a string with a summary of the specified NTP servers and their
states.
---
pyanaconda/ntp.py | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/pyanaconda/ntp.py b/pyanaconda/ntp.py
index 637d31f63e..eed4b34307 100644
--- a/pyanaconda/ntp.py
+++ b/pyanaconda/ntp.py
@@ -60,6 +60,41 @@ class NTPconfigError(Exception):
pass
+def get_ntp_server_summary(server, states):
+ """Generate a summary of an NTP server and its status.
+
+ :param server: an NTP server
+ :type server: an instance of TimeSourceData
+ :param states: a cache of NTP server states
+ :type states: an instance of NTPServerStatusCache
+ :return: a string with a summary
+ """
+ return "{} ({})".format(
+ server.hostname,
+ states.get_status_description(server)
+ )
+
+
+def get_ntp_servers_summary(servers, states):
+ """Generate a summary of NTP servers and their states.
+
+ :param servers: a list of NTP servers
+ :type servers: a list of TimeSourceData
+ :param states: a cache of NTP server states
+ :type states: an instance of NTPServerStatusCache
+ :return: a string with a summary
+ """
+ summary = _("NTP servers:")
+
+ for server in servers:
+ summary += "\n" + get_ntp_server_summary(server, states)
+
+ if not servers:
+ summary += " " + _("not configured")
+
+ return summary
+
+
def ntp_server_working(server_hostname):
"""Tries to do an NTP request to the server (timeout may take some time).
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangce1988/anaconda.git
git@gitee.com:wangce1988/anaconda.git
wangce1988
anaconda
anaconda
master

搜索帮助