diff --git a/cinder/config/generate_cinder_opts.py b/cinder/config/generate_cinder_opts.py index a7f819f0742..60c9fafbbe4 100644 --- a/cinder/config/generate_cinder_opts.py +++ b/cinder/config/generate_cinder_opts.py @@ -17,13 +17,15 @@ import os import subprocess import textwrap +OrderedDict = collections.OrderedDict + BASEDIR = os.path.split(os.path.realpath(__file__))[0] + "/../../" if __name__ == "__main__": os.chdir(BASEDIR) opt_file = open("cinder/opts.py", 'w') - opt_dict = collections.OrderedDict() + opt_dict = OrderedDict() dir_trees_list = [] REGISTER_OPTS_STR = "CONF.register_opts(" REGISTER_OPT_STR = "CONF.register_opt(" @@ -62,12 +64,14 @@ if __name__ == "__main__": cmd_opts = common_string % REGISTER_OPTS_STR output_opts = subprocess.check_output( # nosec : command is hardcoded - '{}'.format(cmd_opts), shell=True) + '{}'.format(cmd_opts), shell=True, + universal_newlines=True) dir_trees_list = output_opts.split() cmd_opt = common_string % REGISTER_OPT_STR output_opt = subprocess.check_output( # nosec : command is hardcoded - '{}'.format(cmd_opt), shell=True) + '{}'.format(cmd_opt), shell=True, + universal_newlines=True) temp_list = output_opt.split() for item in temp_list: @@ -127,7 +131,7 @@ if __name__ == "__main__": flag = False - registered_opts_dict = {'DEFAULT': [], } + registered_opts_dict = OrderedDict([('DEFAULT', [])]) def _write_item(opts): list_name = opts[-3:] @@ -207,6 +211,9 @@ if __name__ == "__main__": " return [\n") opt_file.write(setup_str) + registered_opts_dict = OrderedDict(sorted(registered_opts_dict.items(), + key = lambda x: x[0])) + for key in registered_opts_dict: section_start_str = (" ('" + key + "',\n" " itertools.chain(\n") diff --git a/cinder/opts.py b/cinder/opts.py index 2cbb2a21571..8e9dd58b9db 100644 --- a/cinder/opts.py +++ b/cinder/opts.py @@ -204,11 +204,23 @@ from cinder.zonemanager import fc_zone_manager as \ def list_opts(): return [ - ('FC-ZONE-MANAGER', + ('BACKEND', itertools.chain( - cinder_zonemanager_drivers_brocade_brcdfczonedriver.brcd_opts, - cinder_zonemanager_drivers_cisco_ciscofczonedriver.cisco_opts, - cinder_zonemanager_fczonemanager.zone_manager_opts, + [cinder_cmd_volume.host_opt], + )), + ('BRCD_FABRIC_EXAMPLE', + itertools.chain( + cinder_zonemanager_drivers_brocade_brcdfabricopts. + brcd_zone_opts, + )), + ('CISCO_FABRIC_EXAMPLE', + itertools.chain( + cinder_zonemanager_drivers_cisco_ciscofabricopts. + cisco_zone_opts, + )), + ('COORDINATION', + itertools.chain( + cinder_coordination.coordination_opts, )), ('DEFAULT', itertools.chain( @@ -366,26 +378,14 @@ def list_opts(): cinder_volume_manager.volume_manager_opts, cinder_wsgi_eventletserver.socket_opts, )), - ('CISCO_FABRIC_EXAMPLE', + ('FC-ZONE-MANAGER', itertools.chain( - cinder_zonemanager_drivers_cisco_ciscofabricopts. - cisco_zone_opts, - )), - ('BRCD_FABRIC_EXAMPLE', - itertools.chain( - cinder_zonemanager_drivers_brocade_brcdfabricopts. - brcd_zone_opts, - )), - ('COORDINATION', - itertools.chain( - cinder_coordination.coordination_opts, + cinder_zonemanager_drivers_brocade_brcdfczonedriver.brcd_opts, + cinder_zonemanager_drivers_cisco_ciscofczonedriver.cisco_opts, + cinder_zonemanager_fczonemanager.zone_manager_opts, )), ('KEY_MANAGER', itertools.chain( cinder_keymgr_confkeymgr.key_mgr_opts, )), - ('BACKEND', - itertools.chain( - [cinder_cmd_volume.host_opt], - )), ]