[SCM] build.samba.org - branch master updated

Jelmer Vernooij jelmer at samba.org
Fri Nov 19 13:32:07 MST 2010


The branch, master has been updated
       via  795dac9 Support arguments in admin.py.
       via  53f8095 Remove unnecessary umask code.
      from  7af2d22 Add Tree database table.

http://gitweb.samba.org/?p=build-farm.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 795dac9d7ce2a0a7c94e21397e8d8427f646f6b2
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Nov 19 21:29:51 2010 +0100

    Support arguments in admin.py.

commit 53f8095d8c116c7c6810e4e96523ddf9b627900f
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Nov 19 21:00:38 2010 +0100

    Remove unnecessary umask code.

-----------------------------------------------------------------------

Summary of changes:
 admin.py           |   83 ++++++++++++++++++++++++++++------------------------
 buildfarm/sqldb.py |   10 ++----
 2 files changed, 48 insertions(+), 45 deletions(-)


Changeset truncated at 500 lines:

diff --git a/admin.py b/admin.py
index e191235..4dd2b98 100755
--- a/admin.py
+++ b/admin.py
@@ -30,12 +30,10 @@ from email.MIMEText import MIMEText
 
 buildfarm = StormCachingBuildFarm()
 
-db = buildfarm.hostdb
-
 def update_rsyncd_secrets():
     temp_rsyncd_secrets = os.path.join(os.path.dirname(__file__), "../rsyncd.secrets.new")
     f = open(temp_rsyncd_secrets, "w")
-    f.writelines(db.create_rsync_secrets())
+    f.writelines(buildfarm.hostdb.create_rsync_secrets())
     f.close()
 
     os.rename(temp_rsyncd_secrets, "../rsyncd.secrets")
@@ -43,7 +41,7 @@ def update_rsyncd_secrets():
 def update_hosts_list():
     temp_hosts_list_file = os.path.join(os.path.dirname(__file__), "web", "hosts.list.new")
     f = open(temp_hosts_list_file, "w")
-    f.writelines(db.create_hosts_list())
+    f.writelines(buildfarm.hostdb.create_hosts_list())
     f.close()
 
     os.rename(temp_hosts_list_file, os.path.join(os.path.dirname(__file__), "web/hosts.list"))
@@ -53,9 +51,12 @@ dry_run = False
 print "Samba Build farm management tool"
 print "================================"
 
-if len(sys.argv) > 1:
-    op = sys.argv[1]
-else:
+args = sys.argv[1:]
+
+try:
+    op = args.pop(0)
+except IndexError:
+    print "Initialize the buildfarm:       init"
     print "Add Machine to build farm:      add"
     print "Remove Machine from build farm: remove"
     print "Modify build farm account:      modify"
@@ -67,21 +68,25 @@ else:
     if op == "":
         op = "add"
 
-if op == "remove":
-    hostname = raw_input("Please enter hostname to delete: ")
-    try:
-        db.deletehost(hostname)
-    except hostdb.NoSuchHost, e:
-        print "No such host '%s'" % e.name
-        sys.exit(1)
-    else:
-        db.commit()
-        update_rsyncd_secrets()
-        update_hosts_list()
+if op == "init":
+    buildfarm.commit()
+elif op == "remove":
+    if not args:
+        args = [raw_input("Please enter hostname to delete: ")]
+    for hostname in args:
+        try:
+            buildfarm.hostdb.deletehost(hostname)
+        except hostdb.NoSuchHost, e:
+            print "No such host '%s'" % e.name
+            sys.exit(1)
+        else:
+            buildfarm.hostdb.commit()
+            update_rsyncd_secrets()
+            update_hosts_list()
 elif op == "modify":
     hostname = raw_input("Please enter hostname to modify: ")
     try:
-        host = db[hostname]
+        host = buildfarm.hostdb[hostname]
     except hostdb.NoSuchHost, e:
         print "No such host '%s'" % e.name
         sys.exit(1)
@@ -94,12 +99,12 @@ elif op == "modify":
     if mod_op == "platform":
         platform = raw_input("Enter new platform: ")
         host.update_platform(platform)
-        db.commit()
+        buildfarm.commit()
     elif mod_op == "owner":
         owner = raw_input("Enter new owner's name: ")
         owner_email = raw_input("Enter new owner's e-mail address: ")
         host.update_owner(owner, owner_email.decode("utf-8"))
-        db.commit()
+        buildfarm.commit()
     else:
         print "Unknown subcommand %s" % mod_op
         sys.exit(1)
@@ -108,7 +113,7 @@ elif op == "modify":
 elif op == "add":
     hostname = raw_input("Machine hostname: ")
     try:
-        db[hostname]
+        buildfarm.hostdb[hostname]
     except hostdb.NoSuchHost, e:
         pass
     else:
@@ -129,7 +134,7 @@ elif op == "add":
         line = raw_input("")
 
     try:
-        db.createhost(hostname, platform.decode("utf-8"),
+        buildfarm.hostdb.createhost(hostname, platform.decode("utf-8"),
             owner.decode("utf-8"), owner_email.decode("utf-8"),
             password.decode("utf-8"),
             "".join(permission).decode("utf-8", "replace"))
@@ -137,7 +142,7 @@ elif op == "add":
         print "A host with the name %s already exists." % e.name
         sys.exit(1)
     else:
-        db.commit()
+        buildfarm.commit()
 
     body = """
 Welcome to the Samba.org build farm.  
@@ -190,21 +195,23 @@ Thanks, your friendly Samba build farm administrator <build at samba.org>""" % owne
         update_rsyncd_secrets()
         update_hosts_list()
 elif op == "info":
-    hostname = raw_input("Hostname: ")
-    try:
-        host = db[hostname]
-    except hostdb.NoSuchHost, e:
-        print "No such host '%s'" % e.name
-        sys.exit(1)
-    if host.fqdn:
-        opt_fqdn = " (%s)" % host.fqdn
-    else:
-        opt_fqdn = ""
-    print "Host: %s%s" % (host.name, opt_fqdn)
-    print "Platform: %s" % host.platform
-    print "Owner: %s <%s>" % host.owner
+    if not args:
+        args = [raw_input("Hostname: ")]
+    for hostname in args:
+        try:
+            host = buildfarm.hostdb[hostname]
+        except hostdb.NoSuchHost, e:
+            print "No such host '%s'" % e.name
+            sys.exit(1)
+        if host.fqdn:
+            opt_fqdn = " (%s)" % host.fqdn
+        else:
+            opt_fqdn = ""
+        print "Host: %s%s" % (host.name, opt_fqdn)
+        print "Platform: %s" % host.platform
+        print "Owner: %s <%s>" % host.owner
 elif op == "list":
-    for host in db.host_ages():
+    for host in buildfarm.hostdb.host_ages():
         if host.last_update:
             age = time.time() - host.last_update
         else:
diff --git a/buildfarm/sqldb.py b/buildfarm/sqldb.py
index e20bbbc..9c55fc6 100644
--- a/buildfarm/sqldb.py
+++ b/buildfarm/sqldb.py
@@ -229,13 +229,9 @@ class StormCachingBuildFarm(BuildFarm):
         if self.store is not None:
             return self.store
         db_path = os.path.join(self.path, "db", "hostdb.sqlite")
-        umask = os.umask(0664)
-        try:
-            db = create_database("sqlite:%s?timeout=%f" % (db_path, self.timeout))
-            self.store = Store(db)
-            setup_schema(self.store)
-        finally:
-            os.umask(umask)
+        db = create_database("sqlite:%s?timeout=%f" % (db_path, self.timeout))
+        self.store = Store(db)
+        setup_schema(self.store)
         return self.store
 
     def _open_hostdb(self):


-- 
build.samba.org


More information about the samba-cvs mailing list