diff options
author | Martin Basti <mbasti@redhat.com> | 2016-06-13 20:02:21 +0200 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2016-06-17 15:22:24 +0200 |
commit | 2157ea0e6d0d762bdc71022ddd55045406c4b300 (patch) | |
tree | 312c488152c3d417f230906fb2476c4885bc17f7 /ipalib | |
parent | 88a0952f26f9d1e2ee9d02126b27f3075dbad46a (diff) | |
download | freeipa-2157ea0e6d0d762bdc71022ddd55045406c4b300.tar.gz freeipa-2157ea0e6d0d762bdc71022ddd55045406c4b300.tar.xz freeipa-2157ea0e6d0d762bdc71022ddd55045406c4b300.zip |
DNS Locations: dnsserver-* commands
New commands for manipulation with DNS server configuration were added:
* dnsserver-show
* dnsserver-mod
* dnsserver-find
https://fedorahosted.org/bind-dyndb-ldap/wiki/Design/PerServerConfigInLDAP
https://fedorahosted.org/freeipa/ticket/2008
Reviewed-By: Petr Spacek <pspacek@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/constants.py | 1 | ||||
-rw-r--r-- | ipalib/util.py | 53 |
2 files changed, 54 insertions, 0 deletions
diff --git a/ipalib/constants.py b/ipalib/constants.py index 05ba1adbb..bcddb5b97 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -123,6 +123,7 @@ DEFAULT_CONFIG = ( ('container_caacl', DN(('cn', 'caacls'), ('cn', 'ca'))), ('container_locations', DN(('cn', 'locations'), ('cn', 'etc'))), ('container_ca', DN(('cn', 'cas'), ('cn', 'ca'))), + ('container_dnsservers', DN(('cn', 'servers'), ('cn', 'dns'))), # Ports, hosts, and URIs: ('xmlrpc_uri', 'http://localhost:8888/ipa/xml'), diff --git a/ipalib/util.py b/ipalib/util.py index 4b5f11509..68d11fc6c 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -898,3 +898,56 @@ class classproperty(object): def getter(self, fget): self.fget = fget return self + + +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) + except ValueError as e: + return _('invalid domain-name: %s') % unicode(e) + + return None + + +def ipaddr_validator(ugettext, ipaddr, ip_version=None): + try: + ip = netaddr.IPAddress(str(ipaddr), flags=netaddr.INET_PTON) + + if ip_version is not None: + if ip.version != ip_version: + return _( + 'invalid IP address version (is %(value)d, must be ' + '%(required_value)d)!') % dict( + value=ip.version, + required_value=ip_version + ) + except (netaddr.AddrFormatError, ValueError): + return _('invalid IP address format') + return None + + +def validate_bind_forwarder(ugettext, forwarder): + ip_address, sep, port = forwarder.partition(u' port ') + + ip_address_validation = ipaddr_validator(ugettext, ip_address) + + if ip_address_validation is not None: + return ip_address_validation + + if sep: + try: + port = int(port) + if port < 0 or port > 65535: + raise ValueError() + except ValueError: + return _('%(port)s is not a valid port' % dict(port=port)) + + return None |