Example #1
0
def make_sync(classes, sync_type, mock=False):
    """Make an instantiated sync."""
    sync_class = BaseSync.get_class(classes=classes, sync_type=sync_type)
    sync = sync_class(db=db, logger=logger)
    adconf.SYNCS[sync_type]['mock'] = mock
    adconf.SYNCS[sync_type]['sync_type'] = sync_type
    sync.configure(adconf.SYNCS[sync_type])
    return sync
Example #2
0
        elif opt == '--dump-cerebrum-data':
            dump_cerebrum_data = True
        else:
            print "Unknown option: %s" % opt
            usage(1)

    if not sync_type:
        print "Need to specify what sync type to perform"
        usage(1)

    # Make use of config file settings, if not set otherwise by arguments
    for key, value in adconf.SYNCS[sync_type].iteritems():
        if key not in configuration:
            configuration[key] = value

    sync_class = BaseSync.get_class(classes=sync_classes, sync_type=sync_type)
    logger.debug2("Using sync classes: %s" % ', '.join(repr(c) for c in
                                                      type.mro(sync_class)))
    sync = sync_class(db=db, logger=logger)
    sync.configure(configuration)

    # If debugging instead of syncing:
    if dump_cerebrum_data:
        # TODO: How to avoid fetching the get-dc call at init? Maybe it
        # shouldn't be started somewhere else?
        sync.fetch_cerebrum_data()
        sync.calculate_ad_values()
        sync.server.close()
        atrnames = sorted(sync.config['attributes'])
        for entname in sorted(sync.entities):
            ent = sync.entities[entname]