diff options
author | Andrew Bartlett <abartlet@samba.org> | 2010-03-11 14:49:34 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-03-11 15:28:53 +1100 |
commit | 027123199e13cc02ae4edadd8f0dd0f0660e1193 (patch) | |
tree | c6c49eae8fb1bececb74992948ea3463918a1096 /source4/scripting | |
parent | 59545276f2bd6df8ee5e75e96e707fd86ff44350 (diff) | |
download | samba-027123199e13cc02ae4edadd8f0dd0f0660e1193.tar.gz samba-027123199e13cc02ae4edadd8f0dd0f0660e1193.tar.bz2 samba-027123199e13cc02ae4edadd8f0dd0f0660e1193.zip |
s4:provision Improve the handling of provision errors
The backtraces were too confusing for our users, and didn't tell them
what to do to fix the problem. By printing the string (rather than a
backtrace), and including in the error what to do, and what file to
remove, we give them a chance.
Andrew Bartlett
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/python/samba/provision.py | 22 | ||||
-rw-r--r-- | source4/scripting/python/samba/provisionexceptions.py | 6 |
2 files changed, 17 insertions, 11 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index bac234cfac..0a2483790f 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -330,34 +330,36 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, if dnsdomain is None: dnsdomain = lp.get("realm") if dnsdomain is None or dnsdomain == "": - raise ProvisioningError("guess_names: 'realm' not specified in supplied smb.conf!") + raise ProvisioningError("guess_names: 'realm' not specified in supplied %s!", lp.configfile) dnsdomain = dnsdomain.lower() if serverrole is None: serverrole = lp.get("server role") if serverrole is None: - raise ProvisioningError("guess_names: 'server role' not specified in supplied smb.conf!") + raise ProvisioningError("guess_names: 'server role' not specified in supplied %s!" % lp.configfile) serverrole = serverrole.lower() realm = dnsdomain.upper() + if lp.get("realm") == "": + raise ProvisioningError("guess_names: 'realm =' was not specified in supplied %s. Please remove the smb.conf file and let provision generate it" % lp.configfile) + if lp.get("realm").upper() != realm: - raise ProvisioningError("guess_names: Realm '%s' in smb.conf must match chosen realm '%s'!", lp.get("realm").upper(), realm) + raise ProvisioningError("guess_names: 'realm=%s' in %s must match chosen realm '%s'! Please remove the smb.conf file and let provision generate it" % (lp.get("realm").upper(), realm, lp.configfile)) if lp.get("server role").lower() != serverrole: - raise ProvisioningError("guess_names: server role '%s' in smb.conf must match chosen server role '%s'!", lp.get("server role").upper(), serverrole) + raise ProvisioningError("guess_names: 'server role=%s' in %s must match chosen server role '%s'! Please remove the smb.conf file and let provision generate it" % (lp.get("server role").upper(), serverrole, lp.configfile)) if serverrole == "domain controller": if domain is None: + # This will, for better or worse, default to 'WORKGROUP' domain = lp.get("workgroup") - if domain is None: - raise ProvisioningError("guess_names: 'workgroup' not specified in supplied smb.conf!") domain = domain.upper() if lp.get("workgroup").upper() != domain: - raise ProvisioningError("guess_names: Workgroup '%s' in smb.conf must match chosen domain '%s'!", lp.get("workgroup").upper(), domain) + raise ProvisioningError("guess_names: Workgroup '%s' in %s must match chosen domain '%s'! Please remove the %s file and let provision generate it" % (lp.get("workgroup").upper(), domain, lp.configfile)) if domaindn is None: domaindn = "DC=" + dnsdomain.replace(".", ",DC=") @@ -370,11 +372,11 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, raise InvalidNetbiosName(domain) if hostname.upper() == realm: - raise ProvisioningError("guess_names: Realm '%s' must not be equal to hostname '%s'!", realm, hostname) + raise ProvisioningError("guess_names: Realm '%s' must not be equal to hostname '%s'!" % (realm, hostname)) if netbiosname == realm: - raise ProvisioningError("guess_names: Realm '%s' must not be equal to netbios hostname '%s'!", realm, netbiosname) + raise ProvisioningError("guess_names: Realm '%s' must not be equal to netbios hostname '%s'!" % (realm, netbiosname)) if domain == realm: - raise ProvisioningError("guess_names: Realm '%s' must not be equal to short domain name '%s'!", realm, domain) + raise ProvisioningError("guess_names: Realm '%s' must not be equal to short domain name '%s'!" % (realm, domain)) if rootdn is None: rootdn = domaindn diff --git a/source4/scripting/python/samba/provisionexceptions.py b/source4/scripting/python/samba/provisionexceptions.py index 604853fc19..6159a02e95 100644 --- a/source4/scripting/python/samba/provisionexceptions.py +++ b/source4/scripting/python/samba/provisionexceptions.py @@ -25,8 +25,12 @@ class ProvisioningError(Exception): """A generic provision error.""" + def __init__(self, value): + self.value = value + def __str__(self): + return "ProvisioningError: " + self.value -class InvalidNetbiosName(Exception): +class InvalidNetbiosName(ProvisioningError): """A specified name was not a valid NetBIOS name.""" def __init__(self, name): super(InvalidNetbiosName, self).__init__("The name '%r' is not a valid NetBIOS name" % name) |