Skip to content

Commit 3dd779b

Browse files
committed
CP-309762 Update ntp-dhcp server file path
xsconsole can set ntp to Use DHCP NTP Servers or Use Default NTP Servers, Provide NTP Servers Manually. This is so-called dhcp default and manual mode. When switching from other modes to DHCP, the DHCP-provided NTP servers should be added to the Chrony sources. Conversely, they should be removed when switching away from DHCP. When upgrade dom0 chrony version to 4, the chrony-dhcp server file changes from `/var/lib/dhclient/chrony.servers.$interface` to `/run/chrony-dhcp/$interface.sources`, the same with XS9. Signed-off-by: Changlei Li <[email protected]>
1 parent 3af1114 commit 3dd779b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

XSConsoleData.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ def AddDHCPNTP(self):
602602
for interface in interfaces:
603603
ntpServer = self.GetDHCPNTPServer(interface)
604604

605-
with open("/var/lib/dhclient/chrony.servers.%s" % interface, "w") as chronyFile:
606-
chronyFile.write("%s iburst prefer\n" % ntpServer)
605+
with open("/run/chrony-dhcp/%s.sources" % interface, "w") as chronyFile:
606+
chronyFile.write("server %s iburst prefer\n" % ntpServer)
607607

608608
# Ensure chrony is enabled
609609
self.EnableService("chronyd")
@@ -655,7 +655,7 @@ def RemoveDHCPNTP(self):
655655
newPermissions = oldPermissions & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
656656
os.chmod("/etc/dhcp/dhclient.d/chrony.sh", newPermissions)
657657

658-
getstatusoutput("rm -f /var/lib/dhclient/chrony.servers.*")
658+
getstatusoutput("rm -f /run/chrony-dhcp/*.sources")
659659

660660
def SetTimeManually(self, date):
661661
# Double-check authentication

0 commit comments

Comments
 (0)