summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-02-26 22:23:27 +0100
committerJelmer Vernooij <jelmer@samba.org>2012-02-26 23:19:07 +0100
commit852418133ee5a8fc629bf8d3e01458eac6a0342d (patch)
tree1905eafca2b07048aa0fc7b8d2368a666f275e4c /source4
parent3bfccdfbc89acf9a88043698ded045042bf4c577 (diff)
downloadsamba-852418133ee5a8fc629bf8d3e01458eac6a0342d.tar.gz
samba-852418133ee5a8fc629bf8d3e01458eac6a0342d.tar.bz2
samba-852418133ee5a8fc629bf8d3e01458eac6a0342d.zip
provision: Simplify make_smbconf a bit.
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/provision/__init__.py33
-rw-r--r--source4/scripting/python/samba/tests/samdb.py4
2 files changed, 19 insertions, 18 deletions
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py
index df00fc09ad..fa686c3137 100644
--- a/source4/scripting/python/samba/provision/__init__.py
+++ b/source4/scripting/python/samba/provision/__init__.py
@@ -586,28 +586,28 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
return names
-def make_smbconf(smbconf, hostname, domain, realm, serverrole,
- targetdir, sid_generator="internal", eadb=False, lp=None,
+def make_smbconf(smbconf, hostname, domain, realm, targetdir,
+ serverrole=None, sid_generator=None, eadb=False, lp=None,
server_services=None):
"""Create a new smb.conf file based on a couple of basic settings.
"""
assert smbconf is not None
+
if hostname is None:
hostname = socket.gethostname().split(".")[0]
- netbiosname = determine_netbios_name(hostname)
- else:
- netbiosname = hostname.upper()
+
+ netbiosname = determine_netbios_name(hostname)
if serverrole is None:
serverrole = "standalone"
- assert serverrole in ("domain controller", "member server", "standalone")
- if serverrole == "domain controller":
- smbconfsuffix = "dc"
- elif serverrole == "member server":
- smbconfsuffix = "member"
- elif serverrole == "standalone":
- smbconfsuffix = "standalone"
+ try:
+ smbconfsuffix = {
+ "domain controller": "dc",
+ "member server": "member",
+ "standalone": "standalone"}[serverrole]
+ except KeyError:
+ raise ValueError("server role %r invalid" % serverrole)
if sid_generator is None:
sid_generator = "internal"
@@ -1658,12 +1658,13 @@ def provision(logger, session_info, credentials, smbconf=None,
f.close()
if data is None or data == "":
make_smbconf(smbconf, hostname, domain, realm,
- serverrole, targetdir, sid_generator, useeadb,
+ targetdir, serverrole=serverrole,
+ sid_generator=sid_generator, eadb=useeadb,
lp=lp, server_services=server_services)
else:
- make_smbconf(smbconf, hostname, domain, realm, serverrole,
- targetdir, sid_generator, useeadb, lp=lp,
- server_services=server_services)
+ make_smbconf(smbconf, hostname, domain, realm, targetdir,
+ serverrole=serverrole, sid_generator=sid_generator,
+ eadb=useeadb, lp=lp, server_services=server_services)
if lp is None:
lp = samba.param.LoadParm()
diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py
index 3df72b0840..a60062d6b6 100644
--- a/source4/scripting/python/samba/tests/samdb.py
+++ b/source4/scripting/python/samba/tests/samdb.py
@@ -53,7 +53,7 @@ class SamDBTestCase(TestCaseInTempDir):
domainsid = security.random_sid()
path = os.path.join(self.tempdir, "samdb.ldb")
session_info = system_session()
-
+
hostname="foo"
domain="EXAMPLE"
dnsdomain="example.com"
@@ -62,7 +62,7 @@ class SamDBTestCase(TestCaseInTempDir):
smbconf = os.path.join(self.tempdir, "smb.conf")
make_smbconf(smbconf, hostname, domain, dnsdomain,
- serverrole, self.tempdir)
+ self.tempdir, serverrole=serverrole)
self.lp = param.LoadParm()
self.lp.load(smbconf)