Ask Your Question

Python module for *writing* openstack style config files?

asked 2014-09-19 10:15:19 -0500

larsks gravatar image

updated 2014-09-19 10:15:49 -0500

Is there a Python module that can write OpenStack-style INI configuration files?

The OpenStack project using an INI-style configuration file format parsed by the oslo.config module. There are a few things that make it incompatible with the standard INI parsing and generating tools, such as ConfigParser or iniparse:

  • The DEFAULT section is not meant to be treated specially.

  • Options can take multiple values by listing them multiple times in the config file. That is, the result of:

    option_foo = value1
    option_foo = value2


    option_foo = ['value1', 'value2']

The oslo.config.cfg module has a parser that will read these files without a problem. I wanted to write something similar to crudini (which itself does not currently handle multi-valued options) that would read a data soruce for configuration values and then generate an appropriate configuration file.

While I can certainly write one myself, I'm curious if there is a solution out there already.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-09-21 15:34:54 -0500

updated 2014-09-21 15:35:29 -0500

Note the crudini CLI interface is designed to be compat with multi valued options (through the new --list option in version 0.4), though supporing that would require updating iniparse or equivalent. I think the handling of [DEFAULT] is done appropriately by crudini as is.

Please consider updating crudini rather than duplicating any work in a separate project. Any patches are very welcome.

edit flag offensive delete link more


This is actually a completely different use case from crudini (specifically, pulling ini configuration from etcd using that to generate config files). But if I either find a generator that meets my needs or -- unlikely -- write my own, I'll be sure to pass it your way.

larsks gravatar imagelarsks ( 2014-09-21 21:28:39 -0500 )edit

answered 2014-09-19 10:48:18 -0500

oslo itself can generate it. You can look at the following file

edit flag offensive delete link more


That doesn't appear to do quite what I want. That extracts information from option definitions and generates a sample configuration with default values. I am looking for something which requires only a oslo.config.cfg.ConfigParser and generates output from that.

larsks gravatar imagelarsks ( 2014-09-19 10:54:24 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2014-09-19 10:15:19 -0500

Seen: 283 times

Last updated: Sep 21 '14