move hostname validation from DNS to hosts

Validator is no more used in dns plugin

Part of ticket:
IPA should allow internationalized domain names
https://fedorahosted.org/freeipa/ticket/3169

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Martin Basti 2014-03-20 09:47:20 +01:00 committed by Martin Kosek
parent dafd162ae5
commit 0827b95d0a

View File

@ -34,13 +34,12 @@ from ipalib.plugins.service import (split_principal, validate_certificate,
set_kerberos_attrs)
from ipalib.plugins.dns import (dns_container_exists, _record_types,
add_records_for_host_validation, add_records_for_host,
_hostname_validator, get_reverse_zone)
from ipalib.plugins.dns import get_reverse_zone
get_reverse_zone)
from ipalib import _, ngettext
from ipalib import x509
from ipalib.request import context
from ipalib.util import (normalize_sshpubkey, validate_sshpubkey_no_options,
convert_sshpubkey_post)
convert_sshpubkey_post, validate_hostname)
from ipapython.ipautil import ipa_generate_password, CheckedIPAddress
from ipapython.dnsutil import DNSName
from ipapython.ssh import SSHPublicKey
@ -215,6 +214,15 @@ def normalize_hostname(hostname):
hostname = hostname.lower()
return hostname
def _hostname_validator(ugettext, value):
try:
validate_hostname(value)
except ValueError, e:
return _('invalid domain-name: %s') \
% unicode(e)
return None
class host(LDAPObject):
"""
Host object.