Remove NTP server role while upgrading

Remove NTP server role from config.py.
Remove uneccesary variables and replaced untrack_file with restore_file.
Update typo in manpages and messages printed while installing.

Resolves: https://pagure.io/freeipa/issue/7024
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Tibor Dudlák 2018-03-23 15:32:14 +01:00 committed by Rob Crittenden
parent ece56ea69a
commit dba87a47a7
6 changed files with 34 additions and 31 deletions

View File

@ -116,7 +116,7 @@ Configure chronyd to use this NTP server. This option can be used multiple times
Configure chronyd to use this NTP server pool.
.TP
\fB\-N\fR, \fB\-\-no\-ntp\fR
Do not configure NTP client (chornyd).
Do not configure NTP client (chronyd).
.TP
\fB\-\-force\-chrony\fR
Stop and disable any time&date synchronization services besides chronyd.

View File

@ -90,7 +90,7 @@ Configure chronyd to use this NTP server. This option can be used multiple times
Configure chronyd to use this NTP server pool.
.TP
\fB\-N\fR, \fB\-\-no\-ntp\fR
Do not configure NTP client (chornyd).
Do not configure NTP client (chronyd).
.TP
\fB\-\-force\-chrony\fR
Stop and disable any time&date synchronization services besides chronyd.

View File

@ -48,7 +48,7 @@ Configure chronyd to use this NTP server. This option can be used multiple times
Configure chronyd to use this NTP server pool.
.TP
\fB\-N\fR, \fB\-\-no\-ntp\fR
Do not configure NTP client (chornyd).
Do not configure NTP client (chronyd).
.TP
\fB\-\-force\-chrony\fR
Stop and disable any time&date synchronization services besides chronyd.

View File

@ -2347,9 +2347,9 @@ def update_ipa_nssdb():
def sync_time(options, fstore, statestore, force):
"""
Will disable any other time synchronization service if there is
--force-chrony option set, and configure chrony with given ntp(chrony)
server and/or pool using Augeas in configure_chrony method.
Will disable any other time synchronization service if the --force-chrony
option set, and configure chrony with given ntp(chrony) server and/or pool
using Augeas in configure_chrony method.
If there is no option --ntp-server set IPADiscovery will try to find ntp
server in DNS records.
"""
@ -2372,18 +2372,19 @@ def sync_time(options, fstore, statestore, force):
if ntp_servers:
if timeconf.configure_chrony(ntp_servers, options.ntp_pool,
fstore, statestore):
print("Done Configuring chrony.")
print("Done configuring chrony.")
else:
print("Warning: IPA Server was unable to sync time with chrony!")
print(" Time synchronization is required for IPA Server "
print("Warning: IPA was unable to sync time with chrony!")
print(" Time synchronization is required for IPA "
"to work correctly")
logger.warning(
"Unable to sync time with chrony server, assuming the time "
"is in sync. Please check that 123 UDP port is opened, "
"and any time server is on network.")
else:
print("Warning: chrony not configured, using default configuration.")
logger.warning("No SRV records of NTP servers found nor NTP server "
print("Warning: Skipping chrony configuration. "
"The default configuration will be used.")
logger.warning("No SRV records of NTP servers found and no NTP server "
"address was provided. Skipping chrony configuration, "
"default configuration will be used")
@ -3477,7 +3478,7 @@ class ClientInstallInterface(hostname_.HostNameInstallInterface,
None, False,
deprecated=True,
description="Stop and disable any time&date synchronization services "
"besides ntpd.\n"
"besides ntpd. "
"This option has been obsoleted by --force-chrony",
)
force_ntpd = enroll_only(force_ntpd)

View File

@ -29,6 +29,7 @@ from ipapython import dnsutil
from ipapython.dn import DN
from ipaplatform.constants import constants
from ipaplatform.paths import paths
from ipaserver import servroles
from ipaserver.install import installutils
from ipaserver.install import dsinstance
from ipaserver.install import httpinstance
@ -1608,24 +1609,31 @@ def ntpd_cleanup(fqdn, fstore):
except Exception as e:
logger.info("Service ntpd was not disabled or stopped")
ntpd_files = [paths.NTP_CONF, paths.NTP_STEP_TICKERS, paths.SYSCONFIG_NTPD]
for ntpd_file in ntpd_files:
for ntpd_file in [paths.NTP_CONF, paths.NTP_STEP_TICKERS,
paths.SYSCONFIG_NTPD]:
try:
fstore.untrack_file(ntpd_file)
os.remove(ntpd_file)
except IOError:
logger.warning(
"No access to the %s, file could not be deleted.", ntpd_file)
fstore.restore_file(ntpd_file)
except ValueError as e:
logger.warning("Error: %s", e)
logger.warning(e)
connection = api.Backend.ldap2
try:
connection.delete_entry(DN(('cn', 'NTP'), ('cn', fqdn),
api.env.container_masters))
api.Backend.ldap2.delete_entry(DN(('cn', 'NTP'), ('cn', fqdn),
api.env.container_masters))
except ipalib.errors.NotFound:
logger.warning("Warning: NTP service entry was not found in LDAP.")
ntp_role_instance = servroles.ServiceBasedRole(
u"ntp_server_server",
u"NTP server",
component_services=['NTP']
)
updated_role_instances = tuple()
for role_instance in servroles.role_instances:
if role_instance is not ntp_role_instance:
updated_role_instances += tuple([role_instance])
servroles.role_instances = updated_role_instances
sysupgrade.set_upgrade_state('ntpd', 'ntpd_cleaned', True)

View File

@ -243,12 +243,6 @@ class config(LDAPObject):
doc=_('IPA servers configured as certificate authority'),
flags={'virtual_attribute', 'no_create', 'no_update'}
),
Str(
'ntp_server_server*',
label=_('IPA NTP servers'),
doc=_('IPA servers with enabled NTP'),
flags={'virtual_attribute', 'no_create', 'no_update'}
),
Str(
'ca_renewal_master_server?',
label=_('IPA CA renewal master'),
@ -548,7 +542,7 @@ class config_mod(LDAPUpdate):
def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
self.obj.show_servroles_attributes(
entry_attrs, "CA server", "IPA master", "NTP server", **options)
entry_attrs, "CA server", "IPA master", **options)
return dn
@ -558,5 +552,5 @@ class config_show(LDAPRetrieve):
def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
self.obj.show_servroles_attributes(
entry_attrs, "CA server", "IPA master", "NTP server", **options)
entry_attrs, "CA server", "IPA master", **options)
return dn