加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ntp-servers-improve-005-Use-the-structure-for-time-sources-in-network-py.patch 2.77 KB
一键复制 编辑 原始数据 按行查看 历史
eaglegai 提交于 2020-12-04 17:45 . improve ntp servers to fix unkown error
From 4635e846a98182901777ab6de492020082f313cb Mon Sep 17 00:00:00 2001
From: Vendula Poncova <vponcova@redhat.com>
Date: Fri, 3 Jul 2020 12:12:33 +0200
Subject: [PATCH] Use the structure for time sources in network.py
Modify network.py to work with TimeSourceData instead of strings.
---
pyanaconda/network.py | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index f8e9b19a15..bce57354b1 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -16,14 +16,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import gi
-gi.require_version("NM", "1.0")
-
-from gi.repository import NM
-
import shutil
-from pyanaconda.core import util, constants
import socket
import itertools
import os
@@ -34,17 +27,24 @@
from dasbus.typing import get_native
+from pyanaconda.anaconda_loggers import get_module_logger
+from pyanaconda.core import util, constants
from pyanaconda.core.i18n import _
from pyanaconda.core.kernel import kernel_arguments
from pyanaconda.core.regexes import HOSTNAME_PATTERN_WITHOUT_ANCHORS, \
IPV6_ADDRESS_IN_DRACUT_IP_OPTION
from pyanaconda.core.configuration.anaconda import conf
+from pyanaconda.core.constants import TIME_SOURCE_SERVER
from pyanaconda.modules.common.constants.services import NETWORK, TIMEZONE, STORAGE
from pyanaconda.modules.common.constants.objects import FCOE
from pyanaconda.modules.common.task import sync_run_task
from pyanaconda.modules.common.structures.network import NetworkDeviceInfo
+from pyanaconda.modules.common.structures.timezone import TimeSourceData
+
+import gi
+gi.require_version("NM", "1.0")
+from gi.repository import NM
-from pyanaconda.anaconda_loggers import get_module_logger
log = get_module_logger(__name__)
DEFAULT_HOSTNAME = "localhost.localdomain"
@@ -347,9 +347,20 @@ def _set_ntp_servers_from_dhcp():
hostnames.append(hostname)
# check if some NTP servers were specified from kickstart
- if not timezone_proxy.NTPServers and conf.target.is_hardware:
+ if not timezone_proxy.TimeSources and conf.target.is_hardware:
# no NTP servers were specified, add those from DHCP
- timezone_proxy.SetNTPServers(hostnames)
+ servers = []
+
+ for hostname in hostnames:
+ server = TimeSourceData()
+ server.type = TIME_SOURCE_SERVER
+ server.hostname = hostname
+ server.options = ["iburst"]
+ servers.append(server)
+
+ timezone_proxy.SetTimeSources(
+ TimeSourceData.to_structure_list(servers)
+ )
def wait_for_connected_NM(timeout=constants.NETWORK_CONNECTION_TIMEOUT, only_connecting=False):
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化