From 8ce40940300e0e37191251a8a26bb8a4b5fcd604 Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Jun 30 2016 14:38:28 +0000 Subject: Move normalize_hostname to where it is expected Commit 3d71c43504ea7837ea14bb9dd4a469c07337293f broke ipa-client-install by importing normalize_hostname from the wrong module. Move the function. https://fedorahosted.org/freeipa/ticket/5976 Reviewed-By: Martin Basti --- diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index 3fe9c5f..0bb5a53 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -44,7 +44,7 @@ from ipalib import x509 from ipalib import output from ipalib.request import context from ipalib.util import (normalize_sshpubkey, validate_sshpubkey_no_options, - convert_sshpubkey_post, validate_hostname) + convert_sshpubkey_post, validate_hostname, normalize_hostname) from ipapython.ipautil import ipa_generate_password, CheckedIPAddress from ipapython.dnsutil import DNSName from ipapython.ssh import SSHPublicKey @@ -267,14 +267,6 @@ def validate_ipaddr(ugettext, ipaddr): return None -def normalize_hostname(hostname): - """Use common fqdn form without the trailing dot""" - if hostname.endswith(u'.'): - hostname = hostname[:-1] - hostname = hostname.lower() - return hostname - - def _hostname_validator(ugettext, value): try: validate_hostname(value) diff --git a/ipalib/util.py b/ipalib/util.py index 7a99149..6caf396 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -844,3 +844,11 @@ def detect_dns_zone_realm_type(api, domain): def has_managed_topology(api): domainlevel = api.Command['domainlevel_get']().get('result', DOMAIN_LEVEL_0) return domainlevel > DOMAIN_LEVEL_0 + + +def normalize_hostname(hostname): + """Use common fqdn form without the trailing dot""" + if hostname.endswith(u'.'): + hostname = hostname[:-1] + hostname = hostname.lower() + return hostname