Sort options in cinder.conf by module name

Up until now generate_cinder_opts put the options in a (more or less)
random order into the generated config file. This makes e.g. diffing
config files of different cinder releases pretty hard.  This commit
ensures that the options are ordered by the name of the module which
they were defined in. (i.e. it will keep options defined in the same
module (e.g. a volume driver) grouped together)

The reasons for doing the change here, instead of e.g. sorting the
options in oslo-config-generator are:

1. Other projects that maintain their opts.py file manually are already
keeping the options specifically ordered in some way. Sorting them in
oslo-config-generator will likely break that manually sorted order.

2. Sorting it here in cinder will ensure that all the options of e.g. a
specific driver will be kepts together. It basically sorts the options
by the driver name (or more specifically by the name of the module
they're defined in).  Sorting in the config-generator will really sort
all options of a section e.g.  [DEFAULT] alphabetically, which might
result in options that logically belong together split across the entire
file.

Change-Id: Id7169a045928ee7bedafec35905e5710f2fd5146
This commit is contained in:
Ralf Haferkamp
2016-09-02 09:08:49 +02:00
parent a99e98663e
commit 6632875d56
2 changed files with 130 additions and 129 deletions

View File

@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import collections
import os
import subprocess
import textwrap
@@ -22,7 +23,7 @@ BASEDIR = os.path.split(os.path.realpath(__file__))[0] + "/../../"
if __name__ == "__main__":
os.chdir(BASEDIR)
opt_file = open("cinder/opts.py", 'w')
opt_dict = {}
opt_dict = collections.OrderedDict()
dir_trees_list = []
REGISTER_OPTS_STR = "CONF.register_opts("
REGISTER_OPT_STR = "CONF.register_opt("