View | Details | Raw Unified | Return to bug 39162
Collapse All | Expand All

(-)modules/univention/s4connector/s4/dns.py (-3 / +15 lines)
 Lines 574-579    Link Here 
574
	return c
574
	return c
575
575
576
def __pack_sRVrecord(object, dnsRecords):
576
def __pack_sRVrecord(object, dnsRecords):
577
	ttl = object['attributes'].get('dNSTTL', [None])[0]
577
	for srvRecord in object['attributes'].get('sRVRecord', []):
578
	for srvRecord in object['attributes'].get('sRVRecord', []):
578
		srvRecord=univention.s4connector.s4.compatible_modstring(srvRecord)
579
		srvRecord=univention.s4connector.s4.compatible_modstring(srvRecord)
579
		srv=srvRecord.split(' ')
580
		srv=srvRecord.split(' ')
 Lines 581-591    Link Here 
581
		weight=int(srv[1])
582
		weight=int(srv[1])
582
		port=int(srv[2])
583
		port=int(srv[2])
583
		target=__remove_dot(srv[3])
584
		target=__remove_dot(srv[3])
584
		s=SRVRecord(target, port, priority, weight)
585
		if ttl:
586
			s=SRVRecord(target, port, priority, weight, ttl=int(ttl))
587
		else:
588
			s=SRVRecord(target, port, priority, weight)
585
		dnsRecords.append(ndr_pack(s))
589
		dnsRecords.append(ndr_pack(s))
586
590
587
def __unpack_sRVrecord(object):
591
def __unpack_sRVrecord(object):
588
	srv=[]
592
	srv=[]
593
	ttl=0
589
	dnsRecords=object['attributes'].get('dnsRecord', [])
594
	dnsRecords=object['attributes'].get('dnsRecord', [])
590
	for dnsRecord in dnsRecords:
595
	for dnsRecord in dnsRecords:
591
		dnsRecord=dnsRecord.encode('latin1')
596
		dnsRecord=dnsRecord.encode('latin1')
 Lines 592-598    Link Here 
592
		ndrRecord=ndr_unpack(dnsp.DnssrvRpcRecord, dnsRecord)
597
		ndrRecord=ndr_unpack(dnsp.DnssrvRpcRecord, dnsRecord)
593
		if ndrRecord.wType == dnsp.DNS_TYPE_SRV:
598
		if ndrRecord.wType == dnsp.DNS_TYPE_SRV:
594
			srv.append([str(ndrRecord.data.wPriority), str(ndrRecord.data.wWeight), str(ndrRecord.data.wPort), __append_dot(ndrRecord.data.nameTarget)])
599
			srv.append([str(ndrRecord.data.wPriority), str(ndrRecord.data.wWeight), str(ndrRecord.data.wPort), __append_dot(ndrRecord.data.nameTarget)])
595
	return srv
600
			if ndrRecord.dwTtlSeconds:
601
				ttl=max(ttl, ndrRecord.dwTtlSeconds)
602
	return (srv, ttl)
596
603
597
def __pack_ptrRecord(object, dnsRecords):
604
def __pack_ptrRecord(object, dnsRecords):
598
	for ptr in object['attributes'].get('pTRRecord', []):
605
	for ptr in object['attributes'].get('pTRRecord', []):
 Lines 1031-1037    Link Here 
1031
	relativeDomainName = object['attributes']['relativeDomainName'][0]
1038
	relativeDomainName = object['attributes']['relativeDomainName'][0]
1032
1039
1033
	# unpack the host record
1040
	# unpack the host record
1034
	srv=__unpack_sRVrecord(object)
1041
	srv, ttl=__unpack_sRVrecord(object)
1042
	ud.debug(ud.LDAP, ud.INFO, 'ucs_srv_record_create: DEBUG got  ttl: %s' % ttl)
1035
1043
1036
	# ucr set connector/s4/mapping/dns/srv_record/_ldap._tcp.test.local/location='100 0 389 foobar.test.local. 100 0 389 foobar2.test.local.'
1044
	# ucr set connector/s4/mapping/dns/srv_record/_ldap._tcp.test.local/location='100 0 389 foobar.test.local. 100 0 389 foobar2.test.local.'
1037
	ucr_locations = s4connector.configRegistry.get('connector/s4/mapping/dns/srv_record/%s.%s/location' % (relativeDomainName.lower(),zoneName.lower()))
1045
	ucr_locations = s4connector.configRegistry.get('connector/s4/mapping/dns/srv_record/%s.%s/location' % (relativeDomainName.lower(),zoneName.lower()))
 Lines 1055-1060    Link Here 
1055
			newRecord['location'].sort()
1063
			newRecord['location'].sort()
1056
			if srv != newRecord['location']:
1064
			if srv != newRecord['location']:
1057
				newRecord['location']=srv
1065
				newRecord['location']=srv
1066
				if ttl:
1067
					newRecord['zonettl']=[ str(ttl) ]
1058
				newRecord.modify()
1068
				newRecord.modify()
1059
			else:
1069
			else:
1060
				ud.debug(ud.LDAP, ud.INFO, 'ucs_srv_record_create: do not modify host record')
1070
				ud.debug(ud.LDAP, ud.INFO, 'ucs_srv_record_create: do not modify host record')
 Lines 1080-1085    Link Here 
1080
		ud.debug(ud.LDAP, ud.INFO, msg)
1090
		ud.debug(ud.LDAP, ud.INFO, msg)
1081
		newRecord['name']=parts
1091
		newRecord['name']=parts
1082
		newRecord['location']=srv
1092
		newRecord['location']=srv
1093
		if ttl:
1094
			newRecord['zonettl']=[ str(ttl) ]
1083
		newRecord.create()
1095
		newRecord.create()
1084
	
1096
	
1085
1097

Return to bug 39162