Skip to content

Commit

Permalink
Use hardcoded default NTP servers, don't remove default servers when …
Browse files Browse the repository at this point in the history
…changing servers
  • Loading branch information
Gerald Elder-Vass committed Mar 19, 2024
1 parent ee123b2 commit db0e7e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 6 additions & 1 deletion XSConsoleConstants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Default NTP domains are <int>.[centos|xenserver].pool.ntp.org
DEFAULT_NTP_DOMAINS = [".centos.pool.ntp.org", ".xenserver.pool.ntp.org"]
CENTOS_NTP_POOL_DOMAIN = "centos.pool.ntp.org"
DEFAULT_NTP_DOMAINS = [CENTOS_NTP_POOL_DOMAIN, "xenserver.pool.ntp.org"]

NUM_DEFAULT_NTP_SERVERS = 4

DEFAULT_NTP_SERVERS = ["%d.%s" % (i, CENTOS_NTP_POOL_DOMAIN) for i in range(NUM_DEFAULT_NTP_SERVERS)]
7 changes: 2 additions & 5 deletions XSConsoleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def UpdateFromNTPConf(self):
self.data['ntp']['method'] = "Manual"

servers = self.data['ntp']['servers']
if len(servers) == 4 and all(
if len(servers) == NUM_DEFAULT_NTP_SERVERS and all(
inDefaultNTPDomains(server)
for server in self.data['ntp']['servers']
):
Expand Down Expand Up @@ -590,10 +590,7 @@ def AddDHCPNTP(self):
def ResetDefaultNTPServers(self):
# Double-check authentication
Auth.Inst().AssertAuthenticated()

Data.Inst().NTPServersSet(
["%d%s" % (i, DEFAULT_NTP_DOMAINS[0]) for i in range(4)]
)
Data.Inst().NTPServersSet(DEFAULT_NTP_SERVERS)

def GetDHClientInterfaces(self):
try:
Expand Down
5 changes: 1 addition & 4 deletions plugins-base/XSFeatureNTP.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def CreateMANUALPane(self):
data.UpdateFromNTPConf()

servers = data.ntp.servers([])
if data.ntp.method("") == "Manual" and len(servers) > 0:
if len(servers) > 0:
choiceDefs.append(
ChoiceDef(
Lang("Remove Server"), lambda: self.HandleManualChoice("REMOVE")
Expand Down Expand Up @@ -302,9 +302,6 @@ def HandleKeyADD(self, inKey):
IPUtils.AssertValidNetworkName(inputValues['name'])

data=Data.Inst()
if data.ntp.method("") == "Default":
data.NTPServersSet([server for server in data.ntp.servers([]) if not inDefaultNTPDomains(server)])

data.RemoveDHCPNTP()

servers = data.ntp.servers([])
Expand Down

0 comments on commit db0e7e9

Please sign in to comment.