Re: [Freeipa-devel] [PATCH] 096 Fix ipa-dns-install incorrect warning

2011-07-19 Thread Martin Kosek
On Mon, 2011-07-18 at 13:49 +0200, Jan Cholasta wrote:
 On 18.7.2011 12:56, Martin Kosek wrote:
  ipa-dns-install incorrectly warns about non-local IP addresses
  when installing without --ip-address parameter.
 
  https://fedorahosted.org/freeipa/ticket/1486
 
 
 IMO the warning message should be removed from parse_ip_address 
 altogether, as the local IP address check is done in 
 CheckedIPAddress.__init__. This makes both parse_ip_address and 
 verify_ip_address unnecessary, because all they do is call 
 CheckedIPAddress, so calls to them should be replaced with calls to 
 CheckedIPAddress directly.
 
 I've made a patch that does all of this and also removes some redundant 
 IP address checks from ipa-server-install, see attachment.
 
 Honza
 

I agree. This will clean up the mess around CheckedIPAddress.

Pushed to master.

Martin

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 096 Fix ipa-dns-install incorrect warning

2011-07-18 Thread Martin Kosek
ipa-dns-install incorrectly warns about non-local IP addresses
when installing without --ip-address parameter.

https://fedorahosted.org/freeipa/ticket/1486

From befac1fc7221cddae0fbda67c4a72297b5377906 Mon Sep 17 00:00:00 2001
From: Martin Kosek mko...@redhat.com
Date: Mon, 18 Jul 2011 12:54:03 +0200
Subject: [PATCH] Fix ipa-dns-install incorrect warning

ipa-dns-install incorrectly warns about non-local IP addresses
when installing without --ip-address parameter.

https://fedorahosted.org/freeipa/ticket/1486
---
 install/tools/ipa-dns-install |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/install/tools/ipa-dns-install b/install/tools/ipa-dns-install
index 7c83dc8694ffec94299979b163818794db57ccf5..56edccadeebd2ece7db9415ebf0aac69eb64ba29 100755
--- a/install/tools/ipa-dns-install
+++ b/install/tools/ipa-dns-install
@@ -112,7 +112,7 @@ def main():
 ip = options.ip_address
 else:
 hostaddr = resolve_host(api.env.host)
-ip = hostaddr and ipautil.CheckedIPAddress(hostaddr)
+ip = hostaddr and parse_ip_address(hostaddr)
 
 try:
 verify_ip_address(ip)
-- 
1.7.6

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 096 Fix ipa-dns-install incorrect warning

2011-07-18 Thread Jan Cholasta

On 18.7.2011 12:56, Martin Kosek wrote:

ipa-dns-install incorrectly warns about non-local IP addresses
when installing without --ip-address parameter.

https://fedorahosted.org/freeipa/ticket/1486



IMO the warning message should be removed from parse_ip_address 
altogether, as the local IP address check is done in 
CheckedIPAddress.__init__. This makes both parse_ip_address and 
verify_ip_address unnecessary, because all they do is call 
CheckedIPAddress, so calls to them should be replaced with calls to 
CheckedIPAddress directly.


I've made a patch that does all of this and also removes some redundant 
IP address checks from ipa-server-install, see attachment.


Honza

--
Jan Cholasta
From 947708b36bdf6979e11850217a98738f01f896f0 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Mon, 18 Jul 2011 13:36:47 +0200
Subject: [PATCH] Clean up of IP address checks in install scripts.

Fixes ipa-dns-install incorrect warning.

ticket 1486
---
 install/tools/ipa-dns-install |   12 +---
 install/tools/ipa-replica-install |4 ++--
 install/tools/ipa-server-install  |   22 --
 ipaserver/install/installutils.py |   13 ++---
 4 files changed, 13 insertions(+), 38 deletions(-)

diff --git a/install/tools/ipa-dns-install b/install/tools/ipa-dns-install
index cc091dd..917cb1c 100755
--- a/install/tools/ipa-dns-install
+++ b/install/tools/ipa-dns-install
@@ -109,13 +109,11 @@ def main():
 ip = options.ip_address
 else:
 hostaddr = resolve_host(api.env.host)
-ip = hostaddr and ipautil.CheckedIPAddress(hostaddr)
-
-try:
-verify_ip_address(ip)
-except Exception, e:
-print Error: Invalid IP Address %s: %s % (ip, e)
-ip = None
+try:
+ip = hostaddr and ipautil.CheckedIPAddress(hostaddr, match_local=True)
+except Exception, e:
+print Error: Invalid IP Address %s: %s % (ip, e)
+ip = None
 
 if not ip:
 if options.unattended:
diff --git a/install/tools/ipa-replica-install b/install/tools/ipa-replica-install
index d499754..6531421 100755
--- a/install/tools/ipa-replica-install
+++ b/install/tools/ipa-replica-install
@@ -186,7 +186,7 @@ def install_bind(config, options):
 ip_address = resolve_host(config.host_name)
 if not ip_address:
 sys.exit(Unable to resolve IP address for host name)
-ip = installutils.parse_ip_address(ip_address)
+ip = ipautil.CheckedIPAddress(ip_address, match_local=True)
 ip_address = str(ip)
 
 if options.reverse_zone:
@@ -225,7 +225,7 @@ def install_dns_records(config, options):
 ip_address = resolve_host(config.host_name)
 if not ip_address:
 sys.exit(Unable to resolve IP address for host name)
-ip = installutils.parse_ip_address(ip_address)
+ip = ipautil.CheckedIPAddress(ip_address, match_local=True)
 ip_address = str(ip)
 reverse_zone = bindinstance.find_reverse_zone(ip)
 
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index 35b16da..186b904 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -603,20 +603,11 @@ def main():
 if hostaddr is not None:
 ip = CheckedIPAddress(hostaddr, match_local=True)
 else:
-if not options.ip_address:
-print Unable to resolve IP address for host name
 ip = options.ip_address
-if ip is None and options.unattended:
-sys.exit(Unable to resolve IP address for host name)
-
-if ip:
-try:
-verify_ip_address(ip)
-except Exception, e:
-print Error: Invalid IP Address %s: %s % (ip, e)
-if options.unattended:
-sys.exit(1)
-ip = None
+if ip is None:
+print Unable to resolve IP address for host name
+if options.unattended:
+sys.exit(1)
 
 if options.ip_address:
 if options.ip_address != ip and not options.setup_dns:
@@ -626,11 +617,6 @@ def main():
 return 1
 
 ip = options.ip_address
-try:
-verify_ip_address(ip)
-except Exception, e:
-print Error: Invalid IP Address %s: %s % (ip, e)
-sys.exit(1)
 
 if ip is None:
 ip = read_ip_address(host_name, fstore)
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 68fce7e..0cdc906 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -164,15 +164,6 @@ def verify_fqdn(host_name,no_host_dns=False):
 else:
 print Warning: Hostname (%s) not found in DNS % host_name
 
-def parse_ip_address(addr, match_local=True, parse_netmask=True):
-ip = ipautil.CheckedIPAddress(addr, match_local=match_local, parse_netmask=parse_netmask)
-if match_local and not ip.is_local():
-print Warning: No network interface matches IP address %s % addr
-return ip
-
-def