Ejemplo n.º 1
0
def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-m',
        '--multi',
        action='store_true',
        help='If specified, produce multi-master format and interpret the '
        '"master" argument as a glob expression of masters to match.')
    parser.add_argument(
        'master',
        help='The path of the master to dump. If "*" is provided, produce a '
        'multi-master-format output list of all master configs.')
    parser.add_argument('output',
                        type=argparse.FileType('w'),
                        default=sys.stdout)

    args = parser.parse_args(argv)

    if args.multi:
        data = dump_all_masters(args.master)
    else:
        data = master_cfg_utils.LoadConfig(args.master)['BuildmasterConfig']

    json.dump(data,
              args.output,
              cls=BuildbotJSONEncoder,
              indent=4,
              sort_keys=True)
    return 0
Ejemplo n.º 2
0
def execute(options):
    if options.list_masters:
        masterpairs = master_cfg_utils.GetMasters()
        master_cfg_utils.PrettyPrintMasters(masterpairs)
        return 0

    if options.master_dir:
        config = master_cfg_utils.LoadConfig(options.master_dir,
                                             options.master_cfg)
    else:
        path = master_cfg_utils.ChooseMaster(options.mastername)
        if not path:
            return 2

        config = master_cfg_utils.LoadConfig(path,
                                             config_file=options.master_cfg)

    if not config:
        return 2

    mastername = config['BuildmasterConfig']['properties']['mastername']
    builders = config['BuildmasterConfig']['builders']
    options.build_properties.update(config['BuildmasterConfig'].get(
        'properties', {}))

    if options.list_builders:
        master_cfg_utils.PrettyPrintBuilders(builders, mastername)
        return 0

    if options.test_config:
        for builder in builders:
            # We need to provide a slavename, so just pick the first one
            # the builder has.
            builder['slavename'] = builder['slavenames'][0]
            execute_builder(builder, mastername, options)
        return 0

    my_builder = master_cfg_utils.ChooseBuilder(builders, options.spec)
    return execute_builder(my_builder, mastername, options)
Ejemplo n.º 3
0
def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument('master')
    parser.add_argument('output',
                        type=argparse.FileType('w'),
                        default=sys.stdout)

    args = parser.parse_args(argv)

    result = master_cfg_utils.LoadConfig(args.master)
    json.dump(result['BuildmasterConfig'],
              args.output,
              cls=BuildbotJSONEncoder,
              indent=4)
    return 0
def get_topology_info(master_dir):
    config = master_cfg_utils.LoadConfig(master_dir)['BuildmasterConfig']

    triggers = {}
    for s in config['schedulers']:
        if isinstance(s, schedulers.triggerable.Triggerable):
            triggers[s.name] = s.builderNames

    builders = collections.defaultdict(dict)
    for b in config['builders']:
        # Add the slaves to the builder entry.
        builders[b['name']]['slaves'] = b['slavenames']

        # Find trigger steps, see which scheduler they trigger, and flatten that to
        # the list of builders triggered by this builder.
        builder_trigger = set()
        for step in b['factory'].steps:
            if step[0] == steps.trigger.Trigger:
                for scheduler in step[1]['schedulerNames']:
                    builder_trigger |= set(triggers[scheduler])
        builders[b['name']]['triggers'] = list(builder_trigger)

    return builders