diff options
author | Martin Basti <mbasti@redhat.com> | 2016-09-12 14:38:12 +0200 |
---|---|---|
committer | David Kupka <dkupka@redhat.com> | 2016-09-14 15:30:55 +0200 |
commit | 1c96ff7a6c7e1733a6492f9b3c93265f5bc8ff5b (patch) | |
tree | 685ead7e0d0e8ffa9c0167e5d10bd514326d86d4 /ipalib | |
parent | 271a4f098230112ee0e3ea3ffb3a509977ee7330 (diff) | |
download | freeipa-1c96ff7a6c7e1733a6492f9b3c93265f5bc8ff5b.tar.gz freeipa-1c96ff7a6c7e1733a6492f9b3c93265f5bc8ff5b.tar.xz freeipa-1c96ff7a6c7e1733a6492f9b3c93265f5bc8ff5b.zip |
Abstract procedures for IP address warnings
Originaly there should be only two occurencees of this warning, one for
server, one for client. But obviously is not possible with current
installers to achive this goal, so I have to extract code to not mess
with 5 times copy and paste.
https://fedorahosted.org/freeipa/ticket/5814
Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/util.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/ipalib/util.py b/ipalib/util.py index 805774006..785dd5fd4 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -21,7 +21,10 @@ Various utility functions. """ -from __future__ import absolute_import +from __future__ import ( + absolute_import, + print_function, +) import os import socket @@ -29,6 +32,7 @@ import re import decimal import dns import encodings +import sys from weakref import WeakKeyDictionary import netaddr @@ -45,6 +49,7 @@ from ipapython.ssh import SSHPublicKey from ipapython.dn import DN, RDN from ipapython.dnsutil import DNSName from ipapython.dnsutil import resolve_ip_addresses +from ipapython.ipa_log_manager import root_logger if six.PY3: unicode = str @@ -994,3 +999,23 @@ def check_principal_realm_in_trust_namespace(api_instance, *keys): name='krbprincipalname', error=_('realm or UPN suffix overlaps with trusted domain ' 'namespace')) + + +def network_ip_address_warning(addr_list): + for ip in addr_list: + if ip.is_network_addr(): + root_logger.warning("IP address %s might be network address", ip) + # fixme: once when loggers will be fixed, we can remove this + # print + print("WARNING: IP address {} might be network address".format(ip), + file=sys.stderr) + + +def broadcast_ip_address_warning(addr_list): + for ip in addr_list: + if ip.is_broadcast_addr(): + root_logger.warning("IP address %s might be broadcast address", ip) + # fixme: once when loggers will be fixed, we can remove this + # print + print("WARNING: IP address {} might be broadcast address".format( + ip), file=sys.stderr) |