Ejemplo n.º 1
0
def basicData(master):

    plugins_uses = {}
    countPlugins(plugins_uses, master.config.workers)
    countPlugins(plugins_uses, master.config.builders)
    countPlugins(plugins_uses, master.config.schedulers)
    countPlugins(plugins_uses, master.config.services)
    countPlugins(plugins_uses, master.config.change_sources)
    for b in master.config.builders:
        countPlugins(plugins_uses, b.factory.steps)

    # we hash the master's name + various other master dependent variables
    # to get as much as possible an unique id
    # we hash it to not leak private information about the installation such as hostnames and domain names
    installid = hashlib.sha1(
        master.name  # master name contains hostname + master basepath
        + socket.getfqdn()  # we add the fqdn to account for people
        # call their buildbot host 'buildbot' and install it in /var/lib/buildbot
    ).hexdigest()
    return {
        'installid': installid,
        'versions': dict(IndexResource.getEnvironmentVersions()),
        'platform': {
            'machine': platform.machine(),
            'processor': platform.processor(),
            'python_implementation': platform.python_implementation(),
            # xBSD including osx will disclose too much information after [4] like where it was built
            'version': " ".join(platform.version().split(' ')[:4]),
            'distro': get_distro()
        },
        'plugins': plugins_uses,
        'db': master.config.db['db_url'].split("://")[0],
        'mq': master.config.mq['type'],
        'www_plugins': master.config.www['plugins'].keys()
    }
def processwwwindex(config):
    master = yield fakemaster.make_master()
    master_service = WWWService()
    master_service.setServiceParent(master)
    if not config.get('index-file'):
        print(
            "Path to the index.html file is required with option --index-file or -i"
        )
        defer.returnValue(1)
    path = config.get('index-file')
    if not os.path.isfile(path):
        print("Invalid path to index.html")
        defer.returnValue(2)

    main_dir = os.path.dirname(path)

    for name in master_service.apps.names:
        if name != 'base':
            pluginapp = master_service.apps.get(name)
            try:
                os.symlink(pluginapp.static_dir, os.path.join(main_dir, name))
            except OSError:
                pass

    plugins = dict((k, {}) for k in master_service.apps.names if k != "base")

    fakeconfig = {"user": {"anonymous": True}}
    fakeconfig['buildbotURL'] = master.config.buildbotURL
    fakeconfig['title'] = master.config.title
    fakeconfig['titleURL'] = master.config.titleURL
    fakeconfig['multiMaster'] = master.config.multiMaster
    fakeconfig['versions'] = IndexResource.getEnvironmentVersions()
    fakeconfig['plugins'] = plugins
    fakeconfig['auth'] = auth.NoAuth().getConfigDict()
    outputstr = ''
    with open(path) as indexfile:
        template = jinja2.Template(indexfile.read())
        outputstr = template.render(configjson=json.dumps(fakeconfig),
                                    config=fakeconfig)
    with open(path, 'w') as indexfile:
        indexfile.write(outputstr)
    defer.returnValue(0)
Ejemplo n.º 3
0
def processwwwindex(config):
    master = yield fakemaster.make_master()
    master_service = WWWService()
    master_service.setServiceParent(master)
    if not config.get('index-file'):
        print(
            "Path to the index.html file is required with option --index-file or -i")
        defer.returnValue(1)
    path = config.get('index-file')
    if not os.path.isfile(path):
        print("Invalid path to index.html")
        defer.returnValue(2)

    main_dir = os.path.dirname(path)

    for name in master_service.apps.names:
        if name != 'base':
            pluginapp = master_service.apps.get(name)
            try:
                os.symlink(pluginapp.static_dir, os.path.join(main_dir, name))
            except OSError:
                pass

    plugins = dict((k, {}) for k in master_service.apps.names if k != "base")

    fakeconfig = {"user": {"anonymous": True}}
    fakeconfig['buildbotURL'] = master.config.buildbotURL
    fakeconfig['title'] = master.config.title
    fakeconfig['titleURL'] = master.config.titleURL
    fakeconfig['multiMaster'] = master.config.multiMaster
    fakeconfig['versions'] = IndexResource.getEnvironmentVersions()
    fakeconfig['plugins'] = plugins
    fakeconfig['auth'] = auth.NoAuth().getConfigDict()
    outputstr = ''
    with open(path) as indexfile:
        template = jinja2.Template(indexfile.read())
        outputstr = template.render(
            configjson=json.dumps(fakeconfig), config=fakeconfig)
    with open(path, 'w') as indexfile:
        indexfile.write(outputstr)
    defer.returnValue(0)
def basicData(master):

    plugins_uses = {}
    countPlugins(plugins_uses, master.config.workers)
    countPlugins(plugins_uses, master.config.builders)
    countPlugins(plugins_uses, master.config.schedulers)
    countPlugins(plugins_uses, master.config.services)
    countPlugins(plugins_uses, master.config.change_sources)
    for b in master.config.builders:
        countPlugins(plugins_uses, b.factory.steps)

    # we hash the master's name + various other master dependent variables
    # to get as much as possible an unique id
    # we hash it to not leak private information about the installation such as hostnames and domain names
    hashInput = (
        master.name +  # master name contains hostname + master basepath
        socket.getfqdn()  # we add the fqdn to account for people
                          # call their buildbot host 'buildbot'
                          # and install it in /var/lib/buildbot
    )
    hashInput = unicode2bytes(hashInput)
    installid = hashlib.sha1(hashInput).hexdigest()
    return {
        'installid': installid,
        'versions': dict(IndexResource.getEnvironmentVersions()),
        'platform': {
            'platform': platform.platform(),
            'system': platform.system(),
            'machine': platform.machine(),
            'processor': platform.processor(),
            'python_implementation': platform.python_implementation(),
            # xBSD including osx will disclose too much information after [4] like where it was built
            'version': " ".join(platform.version().split(' ')[:4]),
            'distro': get_distro()
        },
        'plugins': plugins_uses,
        'db': master.config.db['db_url'].split("://")[0],
        'mq': master.config.mq['type'],
        'www_plugins': master.config.www['plugins'].keys()
    }