Ported master.cfg.
diff --git a/buildbot/osuosl/master/master.cfg b/buildbot/osuosl/master/master.cfg
index ff92e91..0fbf754 100644
--- a/buildbot/osuosl/master/master.cfg
+++ b/buildbot/osuosl/master/master.cfg
@@ -3,124 +3,117 @@
 
 # Extend paths to allow loading zorg and config modules.
 import os, sys
-path = os.path.join(os.environ.get('HOME'), 'zorg', 'buildbot', 'osuosl', 'master')
+# All the configuration files are under the directory
+# where master.cfg file is.
+cfg_path = os.path.abspath(os.path.dirname(__file__))
+if cfg_path not in sys.path:
+  sys.path.append(cfg_path)
+# Zorg is 3 levels up.
+path = os.path.abspath(
+         os.path.join(cfg_path, '..', '..', '..')
+       )
 if path not in sys.path:
   sys.path.append(path)
-path = os.path.join(os.environ.get('HOME'), 'zorg')
-if path not in sys.path:
-  sys.path.append(path)
+
+##print(">>> sys.path={}}".format(sys.path)) # TODO: Remove this later.
 
 # This is the dictionary that the buildmaster pays attention to. We also use
 # a shorter alias to save typing.
 c = BuildmasterConfig = {}
+c['buildbotNetUsageData'] = None
 
 import config
 
+## TODO: Figure out what to do with the reloading.
 # Reload stuff automatically.
 #
 # FIXME: Find better way.
-reload(config.slaves)
-reload(config.builders)
-reload(config.status)
-reload(config)
+#reload(config.workers)
+#reload(config.builders)
+#reload(config.status)
+#reload(config)
 
-####### BUILDSLAVES
+####### Workers
 
-c['slaves'] = config.slaves.get_build_slaves()
-c['slavePortnum'] = 9990
+c['workers'] = config.workers.get_all()
+
+c['protocols'] = {'pb': {'port': 9990}}
 
 ####### CHANGESOURCES
 
-from buildbot.changes.pb import PBChangeSource
-from zorg.buildbot.changes.llvmgitpoller import LLVMPoller as llvmgitpoller
+##from buildbot.changes.pb import PBChangeSource
+from zorg.buildbot.changes.llvmgitpoller import LLVMPoller
+from zorg.buildbot.process.buildrequest import collapseRequests
 
-llvm_projects = [
-    "llvm",
-    "cfe",
-    "clang-tests-external",
-    "clang-tools-extra",
-    "polly",
-    "compiler-rt",
-    "flang",
-    "libc",
-    "libcxx",
-    "libcxxabi",
-    "libunwind",
-    "lld",
-    "lldb",
-    "mlir",
-    "openmp",
-    "lnt",
-    "test-suite"]
-
-c['change_source'] = [PBChangeSource()]
+c['change_source'] = []
+# TODO: Do we want to support a push mode for the changes? Probably not.
+#c['change_source'].append(PBChangeSource())
 c['change_source'].append(
-    llvmgitpoller(projects=llvm_projects,
-                  repourl='http://git.lab.llvm.org/llvm/llvm-project.git',
-                  workdir='gitpoller-workdir',
-                  pollinterval=120))
+    LLVMPoller(repourl='https://github.com/llvm/llvm-project.git',
+               workdir='gitpoller-workdir',
+               pollinterval=120))
 
-####### RESOURCE USAGE
-
-# Number of build records to maintain per builder.
-c['buildHorizon'] = 200
-
-# Number of logs to maintain per builder.
-c['logHorizon'] = 200
-
-# Number of events (connect, disconnect, etc.) to maintain.
-c['eventHorizon'] = 100
-
-# Number of builds to cache in memory.
-c['buildCacheSize'] = 200
-
-# Do not compress logs to reduce server load.
-# We have a designated build master with large enough HDD.
-c['logCompressionLimit'] = False
+c['collapseRequests'] = collapseRequests
 
 ####### BUILDERS
 
-c['builders'] = builders = list(config.builders.get_builders())
+from buildbot.plugins import util
 
-####### STATUS TARGETS
-
-# Schedule builds and email for all non-experimental and non-LNT builders.
-# The LNT performance buildbots have a very long delay and commonly fail
-# late and if they fail, all of them fail together. As the same failures
-# are are normally also catched by the faster non-LNT bots, there is no need
-# to warn everybody about failures in the performance bots. Tobias Grosser
-# will keep track of such.
-standard_builders = [b['name'] for b in builders
-                     if not b['category'].endswith('.exp') and
-                        not b['category'].endswith('.on-demand') and
-                        # List of builders to keep quite
-                        not b['name'].startswith('perf-x86_64') and
-                        not b['name'] == 'sanitizer_x86_64-freebsd' and
-                        not b['name'] == 'clang-native-arm-lnt-perf' and
-                        not b['name'] == 'sanitizer_x86_64-freebsd']
-
-# TODO: Fix buildbot.status.words.IRC to accept a list of builders to report
-# instead of defining categories to report. Otherwise we could report more
-# than requested.
-standard_categories = [b['category'] for b in builders
-                       if not b['category'].endswith('.exp') and
-                          not b['category'].endswith('.on-demand') and
-                          not b['name'].startswith('perf-x86_64')]
-
-c['status'] = config.status.get_status_targets(standard_builders,
-                                               standard_categories)
+c['builders'] = builders = [
+  util.BuilderConfig(**b) for b in config.builders.all
+]
 
 ####### SCHEDULERS
 
 c['schedulers'] = config.schedulers.getSingleBranchSchedulers(
                                         c['builders'])
+c['schedulers'].extend(config.schedulers.getForceSchedulers(
+                                        c['builders']))
+
+####### BUILDBOT SERVICES
+
+# 'services' is a list of BuildbotService items like reporter targets. The
+# status of each build will be pushed to these targets. buildbot/reporters/*.py
+# has a variety to choose from, like IRC bots.
+
+# Configure MailNotifier, IRC, buildbot.reporters.github.GitHubStatusPush, buildbot.reporters.github.GitHubCommentPush
+c['services'] = config.status.getReporters()
 
 ####### PROJECT IDENTITY
 
-c['title'] = "LLVM"
-c['titleURL'] = "http://llvm.org/"
-c['buildbotURL'] = "http://lab.llvm.org:8011/"
+c['title'] = config.options.get('Buildbot', 'title')
+c['titleURL'] = config.options.get('Buildbot', 'title_url')
+c['buildbotURL'] = config.options.get('Buildbot', 'my_url')
+
+# minimalistic config to activate new web UI
+c['www'] = dict(port=8011,
+                plugins=dict(waterfall_view={}, console_view={}, grid_view={}), # TODO: badges
+                default_page='console',
+                auth=config.auth.getAuth(),
+                authz=config.auth.getAuthz(),
+                #logRotateLength=
+                #maxRotatedFiles=
+                #versions=
+            )
 
 ####### DB URL
 
-c['db_url'] = "postgresql://localhost/buildmasterdb"
+c['db'] = {
+    'db_url' : config.options.get('Database', 'db_url'),
+}
+
+####### RESOURCE USAGE
+
+from datetime import timedelta
+
+# TODO: Figure out the "changeHorizon" value for our usage.
+#c["changeHorizon"] = 300
+
+# configure a janitor which will delete all logs older than one month,
+# and will run on sundays at noon
+# TODO: Recheck the setting for the production bot.
+c['configurators'] = [util.JanitorConfigurator(
+    logHorizon=timedelta(weeks=4), # Roughly once a month.
+    hour=12,
+    dayOfWeek=6
+)]