def read_config(paths=None, validate=True): """ Read and validate the admin configuration. :param validate: Validate the configuration. :param validate: bool :param paths: A list of paths to configuration files to read. Reads the standard locations when not specified. :param paths: list :return: A configuration object. :rtype: Config """ if not paths: paths = ['/etc/pulp/admin/admin.conf'] conf_d_dir = '/etc/pulp/admin/conf.d' paths += [ os.path.join(conf_d_dir, i) for i in sorted(os.listdir(conf_d_dir)) ] overrides = os.path.expanduser('~/.pulp/admin.conf') if os.path.exists(overrides): validate_overrides(overrides) paths.append(overrides) config = Config(DEFAULT) config.update(Config(*paths)) if validate: config.validate(SCHEMA) return config
def read_config(path=NODE_CONFIGURATION_PATH, validate=True): """ Get the node configuration object. The node configuration is overridden using values from the pulp consumer.conf and defaulted using server.conf as appropriate. :param path: The optional path to the configuration. :return: The configuration object. :rtype: pulp.common.config.Graph """ config = Config(DEFAULT) config.update(Config(path)) if validate: config.validate(SCHEMA) return config.graph()
def read_config(paths=None, validate=True): """ Read and validate the admin configuration. :param validate: Validate the configuration. :param validate: bool :param paths: A list of paths to configuration files to read. Reads the standard locations when not specified. :param paths: list :return: A configuration object. :rtype: Config """ if not paths: paths = ['/etc/pulp/admin/admin.conf'] conf_d_dir = '/etc/pulp/admin/conf.d' paths += [os.path.join(conf_d_dir, i) for i in sorted(os.listdir(conf_d_dir))] overrides = os.path.expanduser('~/.pulp/admin.conf') if os.path.exists(overrides): paths.append(overrides) config = Config(DEFAULT) config.update(Config(*paths)) if validate: config.validate(SCHEMA) return config