Exemplo n.º 1
0
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
Exemplo n.º 2
0
def node_configuration(path=NODE_CONFIGURATION_PATH):
    """
    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
    """
    cfg = Config(path)
    cfg.validate(NODE_SCHEMA)
    return cfg.graph()
Exemplo n.º 3
0
def node_configuration(path=NODE_CONFIGURATION_PATH):
    """
    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
    """
    cfg = Config(path)
    cfg.validate(NODE_SCHEMA)
    return cfg.graph()
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
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()
Exemplo n.º 6
0
def read_config(paths=None, validate=True):
    """
    Read and validate the consumer 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/consumer/consumer.conf']
        overrides = os.path.expanduser('~/.pulp/consumer.conf')
        if os.path.exists(overrides):
            paths.append(overrides)
    config = Config(*paths)
    if validate:
        config.validate(SCHEMA)
    return config
Exemplo n.º 7
0
def read_config(paths=None, validate=True):
    """
    Read and validate the consumer 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/consumer/consumer.conf']
        overrides = os.path.expanduser('~/.pulp/consumer.conf')
        if os.path.exists(overrides):
            paths.append(overrides)
    config = Config(*paths)
    if validate:
        config.validate(SCHEMA)
    return config
Exemplo n.º 8
0
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