예제 #1
0
def load_config(filepath=None):
    config_cls = CIMConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'cim')
    config_cls.validate()
    return config_cls
예제 #2
0
def load_config(filename=None):
    config_cls = StatsConfig()
    if filename:
        config_cls.load_dict(read_config(filename))
    else:
        read(config_cls, CONFIG_BASENAME)
    config_cls.validate()
    return config_cls
예제 #3
0
def load_ad_ldap_config(name='ad_ldap', filepath=None):
    config = ADLDAPConfig()
    if filepath:
        config.load_dict(read_config(filepath))
    else:
        read(config, name)
    config.validate()
    return config
예제 #4
0
파일: config.py 프로젝트: chrnux/cerebrum
def load_config(filepath=None):
    config_cls = CIMConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'cim')
    config_cls.validate()
    return config_cls
예제 #5
0
def load_ad_ldap_config(name='ad_ldap', filepath=None):
    config = ADLDAPConfig()
    if filepath:
        config.load_dict(read_config(filepath))
    else:
        read(config, name)
    config.validate()
    return config
예제 #6
0
파일: scim.py 프로젝트: chrnux/cerebrum
 def load_config(cls):
     from Cerebrum.config.loader import read
     config = EventConfig()
     read(config, 'scim-event')
     config.validate()
     cls.issuer = config.issuer
     cls.url = config.urltemplate
     cls.keytemplate = config.keytemplate
예제 #7
0
def load_config(filepath=None):
    config_cls = ExchangeConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'exchange')
    config_cls.validate()
    return config_cls
예제 #8
0
 def load_config(cls):
     from Cerebrum.config.loader import read
     config = EventConfig()
     read(config, 'scim-event')
     config.validate()
     cls.issuer = config.issuer
     cls.url = config.urltemplate
     cls.keytemplate = config.keytemplate
예제 #9
0
def load_config(filepath=None):
    """ Loads and validates the GPG data configuration. """
    config_cls = GPGDataConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'gpg_data')
    config_cls.validate()
    return config_cls
예제 #10
0
def load_config(filepath=None):
    """Load config for this consumer."""
    config_cls = FPEConsumerConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'consumer_affiliations')
    config_cls.validate()
    return config_cls
예제 #11
0
def load_config(filepath=None):
    """Load config for this consumer."""
    config_cls = SAPConsumerConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'consumer_sap')
    config_cls.validate()
    return config_cls
def load_config(filepath=None):
    """Load config for this consumer."""
    config_cls = FPEConsumerConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'consumer_enforce_forward_policy')
    config_cls.validate()
    return config_cls
예제 #13
0
def _load_partial_config(cls, root_name, filepath):
    """ Try to load a given config into a config class `cls`. """
    config = cls()
    if filepath:
        config.load_dict(read_config(filepath))
    else:
        read(config, root_name)
    config.validate()
    return config
def load_config(filepath=None):
    """Load config for this consumer."""
    config_cls = FPEConsumerConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'consumer_enforce_forward_policy')
    config_cls.validate()
    return config_cls
예제 #15
0
파일: config.py 프로젝트: unioslo/cerebrum
def _load_partial_config(cls, root_name, filepath):
    """ Try to load a given config into a config class `cls`. """
    config = cls()
    if filepath:
        config.load_dict(read_config(filepath))
    else:
        read(config, root_name)
    config.validate()
    return config
예제 #16
0
파일: config.py 프로젝트: unioslo/cerebrum
def load_config(filepath=None):
    """ Loads and validates the GPG data configuration. """
    config_cls = GPGDataConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'gpg_data')
    config_cls.validate()
    return config_cls
예제 #17
0
파일: config.py 프로젝트: unioslo/cerebrum
def load_config(filepath=None):
    """
    """
    config_cls = PasswordNotifierConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'password_notifier')
    config_cls.validate()
    return config_cls
예제 #18
0
def load_config(filepath=None):
    """
    """
    config_cls = PasswordNotifierConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'password_notifier')
    config_cls.validate()
    return config_cls
예제 #19
0
def load_config(filepath=None):
    """
    """
    config_cls = PasswordGeneratorConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'password_generator')
    config_cls.validate()
    return config_cls
예제 #20
0
def load_config(filepath=None):
    """
    """
    config_cls = PasswordGeneratorConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'password_generator')
    config_cls.validate()
    return config_cls
예제 #21
0
def load_config(filepath=None):
    u"""Load the config in filepath.

    defaults to event_publisher.json"""
    config_cls = AMQPClientPublisherConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    else:
        read(config_cls, 'event_publisher')
    config_cls.validate()
    return config_cls
예제 #22
0
def load_amqp_client_config(celery_task, filepath=None):
    """
    Loads the Cerebrum.config for the AMQPClient

    defaults to sys.prefix/etc/config/`celery_task`.json
    """
    config = AMQPClientPublisherConfig()
    if filepath:
        config.load_dict(read_config(filepath))
    else:
        read(config, celery_task)
    config.validate()
    return config
예제 #23
0
def get_config(config_file=None, namespace=DEFAULT_TEMPLATES_CONFIG):
    """ Autoload a TemplatesConfig config file.

    :param str config_file:
        Read the logging configuration from this file.
    :param str namespace:
        If no `config_file` is given, look for a config with this basename in
        the configuration directory.

    :return TemplatesConfig:
        Returns a configuration object.
    """
    templates_config = TemplatesConfig()

    if config_file:
        templates_config.load_dict(loader.read_config(config_file))
    else:
        loader.read(templates_config, root_ns=namespace)
    return templates_config
예제 #24
0
def get_config(config_file=None, namespace=DEFAULT_LOGGING_CONFIG):
    """ Autoload a LoggingEnvironment config file.

    :param str config_file:
        Read the logging configuration from this file.
    :param str namespace:
        If no `config_file` is given, look for a config with this basename in
        the configuration directory.

    :return LoggingEnvironment:
        Returns a configuration object.
    """
    config = LoggingEnvironment()

    if config_file:
        config.load_dict(loader.read_config(config_file))
    else:
        loader.read(config, root_ns=namespace)
    return config
예제 #25
0
파일: config.py 프로젝트: unioslo/cerebrum
def get_config(config_file=None, namespace=DEFAULT_TEMPLATES_CONFIG):
    """ Autoload a TemplatesConfig config file.

    :param str config_file:
        Read the logging configuration from this file.
    :param str namespace:
        If no `config_file` is given, look for a config with this basename in
        the configuration directory.

    :return TemplatesConfig:
        Returns a configuration object.
    """
    templates_config = TemplatesConfig()

    if config_file:
        templates_config.load_dict(loader.read_config(config_file))
    else:
        loader.read(templates_config, root_ns=namespace)
    return templates_config
예제 #26
0
파일: config.py 프로젝트: chrnux/cerebrum
def load_config(filepath=None, consumer_name=None):
    u"""Load config.

    Load config from filepath or the config associated with consumer_name.

    Defaults to consumer_config.json

    :type filepath: str
    :param filepath: The filepath to load

    :type consumer_name: str
    :param consumer_name: Load <consumer_name>.json"""
    config_cls = AMQPClientConsumerConfig()
    if filepath:
        config_cls.load_dict(read_config(filepath))
    elif consumer_name:
        read(config_cls, consumer_name)
    else:
        read(config_cls, 'consumer_config')
    config_cls.validate()
    return config_cls
예제 #27
0
def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('-c', '--commit', action='store_true',
                        default=False, help="Do commit the changes to db")
    parser.add_argument('--config', action='store', default=None,
                        help='Config file')
    parser.add_argument('types', action='store', nargs='+',
                        help='The types to create (see config)')
    args = parser.parse_args()

    if args.config:
        conf = CreateOuGroupConfig(read_config(args.config))
    else:
        conf = read(CreateOuGroupConfig(), 'create-ougroups')

    configs = {}
    for t in conf.types:
        configs[t.name] = t

    db = Factory.get('Database')(client_encoding='UTF-8')
    db.cl_init(change_program="create-ougroups")
    co = Factory.get('Constants')(db)

    for tp in args.types:
        if tp in configs:
            logger.info('Setting up groups for rule %s', tp)
            conf = configs[tp]
            aff, status = parse_aff(conf.aff, co)
            source = co.AuthoritativeSystem(conf.source)
            roots = conf.root
            recursion = co.VirtualGroupOURecursion(conf.recursion)
            members = co.VirtualGroupOUMembership(conf.members)
            perspective = co.OUPerspective(conf.perspective)
            spreads = map(co.Spread, conf.spreads)
            for root in roots:
                logger.info('Setting up root %s', root)
                setup_types(db, root, recursion, aff, status, source, members,
                            perspective, conf.nametemplate,
                            conf.descriptiontemplate, spreads, co)
            logger.info('Done setting up %s', tp)
        else:
            sys.exit(1)
    if args.commit:
        logger.info('Committing')
        db.commit()
    else:
        logger.info('Doing rollback')
        db.rollback()