diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-02-26 21:47:50 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-02-26 23:19:07 +0100 |
commit | e27e519bb8cc844da8b4114f5b6c0ea417e43578 (patch) | |
tree | 5cd70553a5f809d87a1b0bc477e28c97379400b4 /source4 | |
parent | 411119db501b131c0632d852129c9f3819cb4190 (diff) | |
download | samba-e27e519bb8cc844da8b4114f5b6c0ea417e43578.tar.gz samba-e27e519bb8cc844da8b4114f5b6c0ea417e43578.tar.bz2 samba-e27e519bb8cc844da8b4114f5b6c0ea417e43578.zip |
provision: Raise proper error when shares are missing rather than AssertionError.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/scripting/python/samba/provision/__init__.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py index 3a69a07177..f9def76710 100644 --- a/source4/scripting/python/samba/provision/__init__.py +++ b/source4/scripting/python/samba/provision/__init__.py @@ -499,7 +499,6 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, netbiosname = lp.get("netbios name") if netbiosname is None: netbiosname = determine_netbios_name(hostname) - assert netbiosname is not None netbiosname = netbiosname.upper() if not valid_netbios_name(netbiosname): raise InvalidNetbiosName(netbiosname) @@ -1645,7 +1644,7 @@ def provision(logger, session_info, credentials, smbconf=None, server_services = None if dns_backend == "SAMBA_INTERNAL": - server_services = [ "+dns" ] + server_services = ["+dns"] # only install a new smb.conf if there isn't one there already if os.path.exists(smbconf): @@ -1779,17 +1778,12 @@ def provision(logger, session_info, credentials, smbconf=None, if serverrole == "domain controller": if paths.netlogon is None: - logger.info("Existing smb.conf does not have a [netlogon] share, but you are configuring a DC.") - logger.info("Please either remove %s or see the template at %s" % - (paths.smbconf, setup_path("provision.smb.conf.dc"))) - assert paths.netlogon is not None + raise MissingShareError("netlogon", paths.smbconf, + setup_path("provision.smb.conf.dc")) if paths.sysvol is None: - logger.info("Existing smb.conf does not have a [sysvol] share, but you" - " are configuring a DC.") - logger.info("Please either remove %s or see the template at %s" % - (paths.smbconf, setup_path("provision.smb.conf.dc"))) - assert paths.sysvol is not None + raise MissingShareError("sysvol", paths.smbconf, + setup_path("provision.smb.conf.dc")) if not os.path.isdir(paths.netlogon): os.makedirs(paths.netlogon, 0755) @@ -1931,3 +1925,12 @@ class InvalidNetbiosName(Exception): def __init__(self, name): super(InvalidNetbiosName, self).__init__( "The name '%r' is not a valid NetBIOS name" % name) + + +class MissingShareError(ProvisioningError): + + def __init__(self, name, smbconf, smbconf_template): + super(MissingShareError, self).__init__( + "Existing smb.conf does not have a [%s] share, but you are " + "configuring a DC. Please either remove %s or see the template " + "at %s" % (name, smbconf, smbconf_template)) |