diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-08-03 12:44:46 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2011-08-04 08:18:18 +0200 |
commit | eb0454d45c68d455fff29816caf73b23eeb04dcd (patch) | |
tree | a822394b3d6492a2f5a24a4030183c5e69f235a6 /install | |
parent | 9150187ab95f272de4e3c8bc1a1fe2acf08328f8 (diff) | |
download | freeipa-eb0454d45c68d455fff29816caf73b23eeb04dcd.tar.gz freeipa-eb0454d45c68d455fff29816caf73b23eeb04dcd.tar.xz freeipa-eb0454d45c68d455fff29816caf73b23eeb04dcd.zip |
Improve error message in ipactl
If a hostname configured in /etc/ipa/default.conf is changed and
is different from the one stored in LDAP in cn=ipa,cn=etc,$SUFFIX
ipactl gives an unintelligible error.
This patch improves the error message and also offers a list of
configured master so that the hostname setting in IPA configuration
can be easily fixed.
https://fedorahosted.org/freeipa/ticket/1558
Diffstat (limited to 'install')
-rwxr-xr-x | install/tools/ipactl | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/install/tools/ipactl b/install/tools/ipactl index a9445170f..f43c2e329 100755 --- a/install/tools/ipactl +++ b/install/tools/ipactl @@ -25,6 +25,7 @@ try: from ipapython import sysrestore from ipapython import config from ipalib import api, errors + from ipalib.dn import DN import logging import ldap import ldap.sasl @@ -88,6 +89,25 @@ def get_config(): # LSB status code 3: program is not running raise IpactlError("Failed to get list of services to probe status:\n" + "Directory Server is stopped", 3) + except ldap.NO_SUCH_OBJECT: + masters_list = [] + dn = str(DN('cn=masters,cn=ipa,cn=etc,%s' % api.env.basedn)) + attrs = ['cn'] + try: + entries = con.search_s(dn, + ldap.SCOPE_ONELEVEL, + attrlist=attrs,) + except Exception, e: + masters_list.append("No master found because of error: %s" % str(e)) + else: + for dn,master_entry in entries: + masters_list.append(master_entry.get('cn', [None])[0]) + + masters = "\n".join(masters_list) + + raise IpactlError("Failed to get list of services to probe status!\n" + "Configured hostname '%s' does not match any master server in LDAP:\n%s" + % (api.env.host, masters)) except Exception, e: raise IpactlError("Unknown error when retrieving list of services from LDAP: " + str(e)) @@ -296,7 +316,8 @@ def main(): api.finalize() if '.' not in api.env.host: - raise IpactlError("Invalid hostname, must be fully-qualified") + raise IpactlError("Invalid hostname '%s' in IPA configuration!\n" + "The hostname must be fully-qualified" % api.env.host) if args[0].lower() == "start": ipa_start() |