summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-06-13 15:32:41 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-06-13 18:19:03 +0200
commitd9d0d54475c1bf78ce1c45f139097cd30029ccaa (patch)
tree3d0002fba6f8bc30cdd31de4d35ebce0c69b4b72 /source4/scripting
parent3552ad3ab13a97c28925713dcea01d1e01df8868 (diff)
downloadsamba-d9d0d54475c1bf78ce1c45f139097cd30029ccaa.tar.gz
samba-d9d0d54475c1bf78ce1c45f139097cd30029ccaa.tar.bz2
samba-d9d0d54475c1bf78ce1c45f139097cd30029ccaa.zip
upgradeprovision: Use logging infrastructure.
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/bin/upgradeprovision27
-rwxr-xr-xsource4/scripting/python/samba/upgradehelpers.py12
2 files changed, 21 insertions, 18 deletions
diff --git a/source4/scripting/bin/upgradeprovision b/source4/scripting/bin/upgradeprovision
index 4ab4c007ed..b7582d00fe 100755
--- a/source4/scripting/bin/upgradeprovision
+++ b/source4/scripting/bin/upgradeprovision
@@ -22,9 +22,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import shutil
+import logging
import optparse
import os
+import shutil
import sys
import tempfile
# Allow to run from s4 source directory (without installing samba)
@@ -120,22 +121,22 @@ parser.add_option("--full", help="Perform full upgrade of the samdb (schema, con
opts = parser.parse_args()[0]
-whatToLog = define_what_to_log(opts)
+handler = logging.StreamHandler(sys.stdout)
+upgrade_logger = logging.getLogger("upgradeprovision")
+upgrade_logger.addHandler(handler)
-def messageprovision(text):
- """Print a message if quiet is not set
+provision_logger = logging.getLogger("provision")
+provision_logger.addHandler(handler)
- :param text: Message to print """
- if opts.debugprovision or opts.debugall:
- print text
+whatToLog = define_what_to_log(opts)
-def message(what,text):
+def message(what, text):
"""Print a message if this message type has been selected to be printed
:param what: Category of the message
:param text: Message to print """
if (whatToLog & what) or what <= 0:
- print text
+ upgrade_logger.info("%s", text)
if len(sys.argv) == 1:
opts.interactive = True
@@ -199,10 +200,10 @@ def sanitychecks(credentials,session_info,names,paths):
sam_ldb = Ldb(paths.samdb, session_info=session, credentials=creds,lp=lp,options=["modules:samba_dsdb"])
sam_ldb.set_session_info(session)
- res = sam_ldb.search(expression="objectClass=ntdsdsa",base=str(names.configdn),
- scope=SCOPE_SUBTREE,attrs=["dn"],controls=["search_options:1:2"])
+ res = sam_ldb.search(expression="objectClass=ntdsdsa", base=str(names.configdn),
+ scope=SCOPE_SUBTREE, attrs=["dn"], controls=["search_options:1:2"])
if len(res) == 0:
- print "No DC found, your provision is most probalby hardly broken !"
+ print "No DC found, your provision is most probably hardly broken !"
return False
elif len(res) != 1:
print "Found %d domain controllers, for the moment upgradeprovision is not able to handle upgrade on \
@@ -945,7 +946,7 @@ if __name__ == '__main__':
# With all this information let's create a fresh new provision used as reference
message(SIMPLE, "Creating a reference provision")
provisiondir = tempfile.mkdtemp(dir=paths.private_dir, prefix="referenceprovision")
- newprovision(names, setup_dir, creds, session, smbconf, provisiondir, messageprovision)
+ newprovision(names, setup_dir, creds, session, smbconf, provisiondir, provision_logger)
# Get file paths of this new provision
newpaths = get_paths(param, targetdir=provisiondir)
populate_backlink(newpaths, creds, session,names.schemadn)
diff --git a/source4/scripting/python/samba/upgradehelpers.py b/source4/scripting/python/samba/upgradehelpers.py
index a9efa9ed5a..5bd83873b3 100755
--- a/source4/scripting/python/samba/upgradehelpers.py
+++ b/source4/scripting/python/samba/upgradehelpers.py
@@ -54,11 +54,11 @@ def get_paths(param, targetdir=None, smbconf=None):
smbconf = param.default_path()
if not os.path.exists(smbconf):
- raise ProvisioningError("Unable to find smb.conf ...")
+ raise ProvisioningError("Unable to find smb.conf")
lp = param.LoadParm()
lp.load(smbconf)
- paths = provision_paths_from_lp(lp,lp.get("realm"))
+ paths = provision_paths_from_lp(lp, lp.get("realm"))
return paths
@@ -71,7 +71,8 @@ def find_provision_key_parameters(param, credentials, session_info, paths,
:param session_info: Session object
:param paths: A list of path to provision object
:param smbconf: Path to the smb.conf file
- :return: A list of key provision parameters"""
+ :return: A list of key provision parameters
+ """
lp = param.LoadParm()
lp.load(paths.smbconf)
@@ -80,14 +81,15 @@ def find_provision_key_parameters(param, credentials, session_info, paths,
# NT domain, kerberos realm, root dn, domain dn, domain dns name
names.domain = string.upper(lp.get("workgroup"))
names.realm = lp.get("realm")
- basedn = "DC=" + names.realm.replace(".",",DC=")
+ basedn = "DC=" + names.realm.replace(".", ",DC=")
names.dnsdomain = names.realm
names.realm = string.upper(names.realm)
# netbiosname
secrets_ldb = Ldb(paths.secrets, session_info=session_info,
credentials=credentials,lp=lp, options=["modules:samba_secrets"])
# Get the netbiosname first (could be obtained from smb.conf in theory)
- res = secrets_ldb.search(expression="(flatname=%s)"%names.domain,base="CN=Primary Domains", scope=SCOPE_SUBTREE, attrs=["sAMAccountName"])
+ res = secrets_ldb.search(expression="(flatname=%s)" % names.domain,
+ base="CN=Primary Domains", scope=SCOPE_SUBTREE, attrs=["sAMAccountName"])
names.netbiosname = str(res[0]["sAMAccountName"]).replace("$","")
names.smbconf = smbconf