mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
DNS Locations: generate NTP records
Move NTP records to centralized record generator https://fedorahosted.org/freeipa/ticket/2008 Reviewed-By: Petr Spacek <pspacek@redhat.com>
This commit is contained in:
@@ -44,6 +44,11 @@ IPA_DEFAULT_ADTRUST_SRV_REC = (
|
|||||||
(DNSName(u'_kerberos._udp.dc._msdcs'), 88),
|
(DNSName(u'_kerberos._udp.dc._msdcs'), 88),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IPA_DEFAULT_NTP_SRV_REC = (
|
||||||
|
# srv record name, port
|
||||||
|
(DNSName("_ntp._udp"), 123),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class IPADomainIsNotManagedByIPAError(Exception):
|
class IPADomainIsNotManagedByIPAError(Exception):
|
||||||
pass
|
pass
|
||||||
@@ -180,6 +185,14 @@ class IPASystemRecords(object):
|
|||||||
weight=server['weight']
|
weight=server['weight']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if 'NTP server' in eff_roles:
|
||||||
|
self.__add_srv_records(
|
||||||
|
zone_obj,
|
||||||
|
hostname_abs,
|
||||||
|
IPA_DEFAULT_NTP_SRV_REC,
|
||||||
|
weight=server['weight']
|
||||||
|
)
|
||||||
|
|
||||||
def _get_location_dns_records_for_server(
|
def _get_location_dns_records_for_server(
|
||||||
self, zone_obj, hostname, locations,
|
self, zone_obj, hostname, locations,
|
||||||
roles=None, include_master_role=True):
|
roles=None, include_master_role=True):
|
||||||
@@ -217,6 +230,16 @@ class IPASystemRecords(object):
|
|||||||
location=location
|
location=location
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if 'NTP server' in eff_roles:
|
||||||
|
self.__add_srv_records(
|
||||||
|
zone_obj,
|
||||||
|
hostname_abs,
|
||||||
|
IPA_DEFAULT_NTP_SRV_REC,
|
||||||
|
weight=server['weight'],
|
||||||
|
priority=priority,
|
||||||
|
location=location
|
||||||
|
)
|
||||||
|
|
||||||
return zone_obj
|
return zone_obj
|
||||||
|
|
||||||
def __prepare_records_update_dict(self, node):
|
def __prepare_records_update_dict(self, node):
|
||||||
@@ -332,7 +355,8 @@ class IPASystemRecords(object):
|
|||||||
names_requiring_cname_templates = set(
|
names_requiring_cname_templates = set(
|
||||||
rec[0].derelativize(self.domain_abs) for rec in (
|
rec[0].derelativize(self.domain_abs) for rec in (
|
||||||
IPA_DEFAULT_MASTER_SRV_REC +
|
IPA_DEFAULT_MASTER_SRV_REC +
|
||||||
IPA_DEFAULT_ADTRUST_SRV_REC
|
IPA_DEFAULT_ADTRUST_SRV_REC +
|
||||||
|
IPA_DEFAULT_NTP_SRV_REC
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -405,6 +429,7 @@ class IPASystemRecords(object):
|
|||||||
for records in (
|
for records in (
|
||||||
IPA_DEFAULT_MASTER_SRV_REC,
|
IPA_DEFAULT_MASTER_SRV_REC,
|
||||||
IPA_DEFAULT_ADTRUST_SRV_REC,
|
IPA_DEFAULT_ADTRUST_SRV_REC,
|
||||||
|
IPA_DEFAULT_NTP_SRV_REC
|
||||||
):
|
):
|
||||||
for name, _port in records:
|
for name, _port in records:
|
||||||
loc_records.append(
|
loc_records.append(
|
||||||
|
|||||||
@@ -859,21 +859,6 @@ class BindInstance(service.Service):
|
|||||||
def __add_master_records(self, fqdn, addrs):
|
def __add_master_records(self, fqdn, addrs):
|
||||||
host, zone = fqdn.split(".", 1)
|
host, zone = fqdn.split(".", 1)
|
||||||
|
|
||||||
if normalize_zone(zone) == normalize_zone(self.domain):
|
|
||||||
host_in_rr = host
|
|
||||||
else:
|
|
||||||
host_in_rr = normalize_zone(fqdn)
|
|
||||||
|
|
||||||
srv_records = ()
|
|
||||||
if self.ntp:
|
|
||||||
srv_records += (
|
|
||||||
("_ntp._udp", "0 100 123 %s" % host_in_rr),
|
|
||||||
)
|
|
||||||
|
|
||||||
for (rname, rdata) in srv_records:
|
|
||||||
add_rr(self.domain, rname, "SRV", rdata, self.dns_backup,
|
|
||||||
api=self.api)
|
|
||||||
|
|
||||||
if not dns_zone_exists(zone, self.api):
|
if not dns_zone_exists(zone, self.api):
|
||||||
# check if master hostname is resolvable
|
# check if master hostname is resolvable
|
||||||
try:
|
try:
|
||||||
@@ -1097,13 +1082,6 @@ class BindInstance(service.Service):
|
|||||||
self.fqdn = fqdn
|
self.fqdn = fqdn
|
||||||
self.domain = domain_name
|
self.domain = domain_name
|
||||||
|
|
||||||
resource_records = (
|
|
||||||
("_ntp._udp", "SRV", "0 100 123 %s" % self.host_in_rr),
|
|
||||||
)
|
|
||||||
|
|
||||||
for (record, type, rdata) in resource_records:
|
|
||||||
del_rr(self.domain, record, type, rdata, api=self.api)
|
|
||||||
|
|
||||||
areclist = get_fwd_rr(zone, host, api=self.api)
|
areclist = get_fwd_rr(zone, host, api=self.api)
|
||||||
for rdata in areclist:
|
for rdata in areclist:
|
||||||
del_fwd_rr(zone, host, rdata, api=self.api)
|
del_fwd_rr(zone, host, rdata, api=self.api)
|
||||||
|
|||||||
Reference in New Issue
Block a user