diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-02-26 20:38:50 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-02-26 20:52:05 +0100 |
commit | 16a4fa97046e0db460882c70a5c3c241daf55223 (patch) | |
tree | d39677476dd149dd3cc559527ca5f8ce873c00ac /source4 | |
parent | d09764e180f0fef076b014fb446a4247f7cf0d29 (diff) | |
download | samba-16a4fa97046e0db460882c70a5c3c241daf55223.tar.gz samba-16a4fa97046e0db460882c70a5c3c241daf55223.tar.bz2 samba-16a4fa97046e0db460882c70a5c3c241daf55223.zip |
provision: Factor out determination of new netbios name.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/scripting/python/samba/provision/__init__.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py index 42da903302..f28fe5b4f9 100644 --- a/source4/scripting/python/samba/provision/__init__.py +++ b/source4/scripting/python/samba/provision/__init__.py @@ -480,6 +480,18 @@ def provision_paths_from_lp(lp, dnsdomain): return paths +def determine_netbios_name(hostname): + """Determine a netbios name from a hostname.""" + netbiosname = hostname + # remove forbidden chars + newnbname = "" + for x in netbiosname: + if x.isalnum() or x in VALID_NETBIOS_CHARS: + newnbname = "%s%c" % (newnbname, x) + # force the length to be <16 + return newnbname[0:15].upper() + + def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, serverrole=None, rootdn=None, domaindn=None, configdn=None, schemadn=None, serverdn=None, sitename=None): @@ -490,14 +502,7 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, netbiosname = lp.get("netbios name") if netbiosname is None: - netbiosname = hostname - # remove forbidden chars - newnbname = "" - for x in netbiosname: - if x.isalnum() or x in VALID_NETBIOS_CHARS: - newnbname = "%s%c" % (newnbname, x) - # force the length to be <16 - netbiosname = newnbname[0:15] + netbiosname = determine_netbios_name(hostname) assert netbiosname is not None netbiosname = netbiosname.upper() if not valid_netbios_name(netbiosname): |