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("

View File

@ -194,26 +194,122 @@ def list_opts():
('FC-ZONE-MANAGER',
itertools.chain(
cinder_zonemanager_drivers_brocade_brcdfczonedriver.brcd_opts,
cinder_zonemanager_fczonemanager.zone_manager_opts,
cinder_zonemanager_drivers_cisco_ciscofczonedriver.cisco_opts,
cinder_zonemanager_fczonemanager.zone_manager_opts,
)),
('DEFAULT',
itertools.chain(
cinder_api_common.api_common_opts,
[cinder_api_middleware_auth.use_forwarded_for_opt],
[cinder_api_middleware_sizelimit.max_request_body_size_opt],
cinder_api_views_versions.versions_opts,
cinder_backup_api.backup_api_opts,
cinder_backup_chunkeddriver.chunkedbackup_service_opts,
cinder_backup_driver.service_opts,
cinder_backup_drivers_ceph.service_opts,
cinder_backup_drivers_glusterfs.glusterfsbackup_service_opts,
cinder_backup_drivers_google.gcsbackup_service_opts,
cinder_backup_drivers_nfs.nfsbackup_service_opts,
cinder_backup_drivers_posix.posixbackup_service_opts,
cinder_backup_drivers_swift.swiftbackup_service_opts,
cinder_backup_drivers_tsm.tsm_opts,
cinder_backup_manager.backup_manager_opts,
[cinder_cmd_volume.cluster_opt],
cinder_common_config.core_opts,
cinder_common_config.global_opts,
cinder.compute.compute_opts,
cinder_compute_nova.nova_opts,
cinder_context.context_opts,
cinder_db_api.db_opts,
[cinder_db_base.db_driver_opt],
cinder_exception.exc_log_opts,
cinder_image_glance.glance_opts,
cinder_image_glance.glance_core_properties_opts,
cinder_image_imageutils.image_helper_opts,
cinder_message_api.messages_opts,
cinder_quota.quota_opts,
cinder_scheduler_driver.scheduler_driver_opts,
cinder_scheduler_hostmanager.host_manager_opts,
[cinder_scheduler_manager.scheduler_driver_opt],
[cinder_scheduler_scheduleroptions.
scheduler_json_config_location_opt],
cinder_scheduler_weights_capacity.capacity_weight_opts,
cinder_scheduler_weights_volumenumber.
volume_number_weight_opts,
cinder_service.service_opts,
cinder_sshutils.ssh_opts,
cinder_transfer_api.volume_transfer_opts,
[cinder_volume_api.allow_force_upload_opt],
[cinder_volume_api.volume_host_opt],
[cinder_volume_api.volume_same_az_opt],
[cinder_volume_api.az_cache_time_opt],
cinder_volume_driver.volume_opts,
cinder_volume_driver.iser_opts,
cinder_volume_drivers_blockdevice.volume_opts,
cinder_volume_drivers_blockbridge.blockbridge_opts,
cinder_volume_drivers_cloudbyte_options.
cloudbyte_add_qosgroup_opts,
cinder_volume_drivers_cloudbyte_options.
cloudbyte_create_volume_opts,
cinder_volume_drivers_cloudbyte_options.
cloudbyte_connection_opts,
cinder_volume_drivers_cloudbyte_options.
cloudbyte_update_volume_opts,
cinder_volume_drivers_coho.coho_opts,
cinder_volume_drivers_coprhd_common.volume_opts,
cinder_volume_drivers_coprhd_scaleio.scaleio_opts,
cinder_volume_drivers_datera.d_opts,
cinder_volume_drivers_dell_dellstoragecentercommon.
common_opts,
cinder_volume_drivers_disco_disco.disco_opts,
cinder_volume_drivers_dothill_dothillcommon.common_opts,
cinder_volume_drivers_dothill_dothillcommon.iscsi_opts,
cinder_volume_drivers_drbdmanagedrv.drbd_opts,
cinder_volume_drivers_emc_emcvmaxcommon.emc_opts,
cinder_volume_drivers_emc_scaleio.scaleio_opts,
cinder_volume_drivers_emc_vnx_common.EMC_VNX_OPTS,
cinder_volume_drivers_emc_xtremio.XTREMIO_OPTS,
cinder_volume_drivers_eqlx.eqlx_opts,
cinder_volume_drivers_falconstor_fsscommon.FSS_OPTS,
cinder_volume_drivers_fujitsu_eternusdxcommon.
FJ_ETERNUS_DX_OPT_opts,
cinder_volume_drivers_fusionstorage_dsware.volume_opts,
cinder_volume_drivers_glusterfs.volume_opts,
cinder_volume_drivers_hgst.hgst_opts,
cinder_volume_drivers_hitachi_hbsdcommon.volume_opts,
cinder_volume_drivers_hitachi_hbsdfc.volume_opts,
cinder_volume_drivers_hitachi_hbsdhorcm.volume_opts,
cinder_volume_drivers_hitachi_hbsdiscsi.volume_opts,
cinder_volume_drivers_hitachi_hnasiscsi.iSCSI_OPTS,
cinder_volume_drivers_hitachi_hnasnfs.NFS_OPTS,
cinder_volume_drivers_hitachi_hnasutils.drivers_common_opts,
cinder_volume_drivers_hpe_hpe3parcommon.hpe3par_opts,
cinder_volume_drivers_hpe_hpelefthandiscsi.hpelefthand_opts,
cinder_volume_drivers_hpe_hpexpopts.FC_VOLUME_OPTS,
cinder_volume_drivers_hpe_hpexpopts.COMMON_VOLUME_OPTS,
cinder_volume_drivers_hpe_hpexpopts.HORCM_VOLUME_OPTS,
cinder_volume_drivers_huawei_huaweidriver.huawei_opts,
cinder_volume_drivers_ibm_flashsystemcommon.flashsystem_opts,
cinder_volume_drivers_ibm_flashsystemfc.flashsystem_fc_opts,
cinder_volume_drivers_ibm_flashsystemiscsi.
flashsystem_iscsi_opts,
cinder_volume_drivers_ibm_gpfs.gpfs_opts,
cinder_volume_drivers_ibm_ibmstorage.driver_opts,
cinder_volume_drivers_ibm_storwize_svc_storwizesvccommon.
storwize_svc_opts,
cinder_volume_drivers_ibm_storwize_svc_storwizesvcfc.
storwize_svc_fc_opts,
cinder_volume_drivers_ibm_storwize_svc_storwizesvciscsi.
storwize_svc_iscsi_opts,
cinder_volume_drivers_infortrend_raidcmd_cli_commoncli.
infortrend_esds_opts,
cinder_volume_drivers_infortrend_raidcmd_cli_commoncli.
infortrend_esds_extra_opts,
cinder_api_common.api_common_opts,
cinder_backup_drivers_ceph.service_opts,
cinder_volume_drivers_smbfs.volume_opts,
cinder_backup_chunkeddriver.chunkedbackup_service_opts,
cinder_volume_drivers_san_san.san_opts,
cinder_volume_drivers_hitachi_hnasnfs.NFS_OPTS,
cinder_wsgi_eventletserver.socket_opts,
cinder_sshutils.ssh_opts,
cinder_volume_drivers_kaminario_kaminariocommon.
kaminario1_opts,
cinder_volume_drivers_lenovo_lenovocommon.common_opts,
cinder_volume_drivers_lenovo_lenovocommon.iscsi_opts,
cinder_volume_drivers_lvm.volume_opts,
cinder_volume_drivers_netapp_options.netapp_proxy_opts,
cinder_volume_drivers_netapp_options.netapp_connection_opts,
cinder_volume_drivers_netapp_options.netapp_transport_opts,
@ -226,137 +322,41 @@ def list_opts():
cinder_volume_drivers_netapp_options.netapp_nfs_extra_opts,
cinder_volume_drivers_netapp_options.netapp_san_opts,
cinder_volume_drivers_netapp_options.netapp_replication_opts,
cinder_volume_drivers_ibm_storwize_svc_storwizesvciscsi.
storwize_svc_iscsi_opts,
cinder_compute_nova.nova_opts,
cinder_volume_drivers_coprhd_scaleio.scaleio_opts,
cinder_backup_drivers_tsm.tsm_opts,
cinder_volume_drivers_fujitsu_eternusdxcommon.
FJ_ETERNUS_DX_OPT_opts,
cinder_volume_drivers_ibm_gpfs.gpfs_opts,
cinder_volume_drivers_zte_zteks.zte_opts,
cinder_volume_drivers_violin_v7000common.violin_opts,
cinder_volume_drivers_nexenta_options.NEXENTA_CONNECTION_OPTS,
cinder_volume_drivers_nexenta_options.NEXENTA_ISCSI_OPTS,
cinder_volume_drivers_nexenta_options.NEXENTA_DATASET_OPTS,
cinder_volume_drivers_nexenta_options.NEXENTA_NFS_OPTS,
cinder_volume_drivers_nexenta_options.NEXENTA_RRMGR_OPTS,
cinder_volume_drivers_nexenta_options.NEXENTA_EDGE_OPTS,
cinder_exception.exc_log_opts,
cinder_common_config.core_opts,
cinder_common_config.global_opts,
cinder_scheduler_weights_capacity.capacity_weight_opts,
cinder_volume_drivers_sheepdog.sheepdog_opts,
[cinder_api_middleware_sizelimit.max_request_body_size_opt],
cinder_volume_drivers_solidfire.sf_opts,
cinder_volume_drivers_coprhd_common.volume_opts,
cinder_backup_drivers_swift.swiftbackup_service_opts,
cinder_volume_drivers_cloudbyte_options.
cloudbyte_add_qosgroup_opts,
cinder_volume_drivers_cloudbyte_options.
cloudbyte_create_volume_opts,
cinder_volume_drivers_cloudbyte_options.
cloudbyte_connection_opts,
cinder_volume_drivers_cloudbyte_options.
cloudbyte_update_volume_opts,
cinder_service.service_opts,
cinder.compute.compute_opts,
cinder_volume_drivers_drbdmanagedrv.drbd_opts,
cinder_volume_drivers_dothill_dothillcommon.common_opts,
cinder_volume_drivers_dothill_dothillcommon.iscsi_opts,
cinder_volume_drivers_glusterfs.volume_opts,
cinder_volume_drivers_pure.PURE_OPTS,
cinder_context.context_opts,
cinder_scheduler_driver.scheduler_driver_opts,
cinder_volume_drivers_ibm_ibmstorage.driver_opts,
cinder_volume_drivers_vmware_vmdk.vmdk_opts,
cinder_volume_drivers_lenovo_lenovocommon.common_opts,
cinder_volume_drivers_lenovo_lenovocommon.iscsi_opts,
cinder_backup_drivers_posix.posixbackup_service_opts,
cinder_volume_drivers_emc_scaleio.scaleio_opts,
[cinder_db_base.db_driver_opt],
cinder_volume_drivers_eqlx.eqlx_opts,
cinder_transfer_api.volume_transfer_opts,
cinder_db_api.db_opts,
cinder_scheduler_weights_volumenumber.
volume_number_weight_opts,
cinder_volume_drivers_coho.coho_opts,
cinder_volume_drivers_scality.volume_opts,
cinder_volume_drivers_xio.XIO_OPTS,
cinder_volume_drivers_ibm_storwize_svc_storwizesvcfc.
storwize_svc_fc_opts,
cinder_volume_drivers_falconstor_fsscommon.FSS_OPTS,
cinder_volume_drivers_zfssa_zfssaiscsi.ZFSSA_OPTS,
cinder_volume_driver.volume_opts,
cinder_volume_driver.iser_opts,
cinder_api_views_versions.versions_opts,
cinder_volume_drivers_nfs.nfs_opts,
cinder_volume_drivers_nimble.nimble_opts,
cinder_volume_drivers_windows_windows.windows_opts,
cinder_volume_drivers_emc_vnx_common.EMC_VNX_OPTS,
cinder_volume_drivers_san_hp_hpmsacommon.common_opts,
cinder_volume_drivers_san_hp_hpmsacommon.iscsi_opts,
cinder_image_glance.glance_opts,
cinder_image_glance.glance_core_properties_opts,
cinder_volume_drivers_hpe_hpelefthandiscsi.hpelefthand_opts,
cinder_volume_drivers_lvm.volume_opts,
cinder_volume_drivers_emc_emcvmaxcommon.emc_opts,
cinder_volume_drivers_prophetstor_options.DPL_OPTS,
cinder_volume_drivers_pure.PURE_OPTS,
cinder_volume_drivers_quobyte.volume_opts,
cinder_volume_drivers_rbd.RBD_OPTS,
cinder_volume_drivers_remotefs.nas_opts,
cinder_volume_drivers_remotefs.volume_opts,
cinder_volume_drivers_emc_xtremio.XTREMIO_OPTS,
cinder_backup_drivers_google.gcsbackup_service_opts,
[cinder_api_middleware_auth.use_forwarded_for_opt],
cinder_volume_drivers_hitachi_hbsdcommon.volume_opts,
cinder_volume_drivers_hitachi_hnasiscsi.iSCSI_OPTS,
cinder_volume_drivers_rbd.RBD_OPTS,
cinder_volume_drivers_tintri.tintri_opts,
cinder_backup_api.backup_api_opts,
cinder_volume_drivers_hitachi_hbsdhorcm.volume_opts,
cinder_backup_manager.backup_manager_opts,
cinder_volume_drivers_ibm_storwize_svc_storwizesvccommon.
storwize_svc_opts,
cinder_volume_drivers_hitachi_hbsdfc.volume_opts,
cinder_quota.quota_opts,
cinder_volume_drivers_huawei_huaweidriver.huawei_opts,
cinder_volume_drivers_san_hp_hpmsacommon.common_opts,
cinder_volume_drivers_san_hp_hpmsacommon.iscsi_opts,
cinder_volume_drivers_san_san.san_opts,
cinder_volume_drivers_scality.volume_opts,
cinder_volume_drivers_sheepdog.sheepdog_opts,
cinder_volume_drivers_smbfs.volume_opts,
cinder_volume_drivers_solidfire.sf_opts,
cinder_volume_drivers_synology_synologycommon.cinder_opts,
cinder_volume_drivers_dell_dellstoragecentercommon.
common_opts,
cinder_scheduler_hostmanager.host_manager_opts,
[cinder_scheduler_manager.scheduler_driver_opt],
cinder_backup_drivers_nfs.nfsbackup_service_opts,
cinder_volume_drivers_blockbridge.blockbridge_opts,
[cinder_scheduler_scheduleroptions.
scheduler_json_config_location_opt],
cinder_volume_drivers_zfssa_zfssanfs.ZFSSA_OPTS,
cinder_volume_drivers_fusionstorage_dsware.volume_opts,
cinder_volume_drivers_kaminario_kaminariocommon.
kaminario1_opts,
cinder_volume_drivers_disco_disco.disco_opts,
cinder_volume_drivers_hgst.hgst_opts,
cinder_message_api.messages_opts,
cinder_image_imageutils.image_helper_opts,
cinder_backup_drivers_glusterfs.glusterfsbackup_service_opts,
cinder_volume_drivers_ibm_flashsystemfc.flashsystem_fc_opts,
cinder_volume_drivers_prophetstor_options.DPL_OPTS,
cinder_volume_drivers_hpe_hpexpopts.FC_VOLUME_OPTS,
cinder_volume_drivers_hpe_hpexpopts.COMMON_VOLUME_OPTS,
cinder_volume_drivers_hpe_hpexpopts.HORCM_VOLUME_OPTS,
cinder_volume_drivers_hitachi_hbsdiscsi.volume_opts,
cinder_volume_manager.volume_manager_opts,
cinder_volume_drivers_ibm_flashsystemiscsi.
flashsystem_iscsi_opts,
cinder_volume_drivers_tegile.tegile_opts,
cinder_volume_drivers_ibm_flashsystemcommon.flashsystem_opts,
[cinder_volume_api.allow_force_upload_opt],
[cinder_volume_api.volume_host_opt],
[cinder_volume_api.volume_same_az_opt],
[cinder_volume_api.az_cache_time_opt],
cinder_volume_drivers_hpe_hpe3parcommon.hpe3par_opts,
cinder_volume_drivers_datera.d_opts,
cinder_volume_drivers_zadara.zadara_opts,
cinder_volume_drivers_blockdevice.volume_opts,
cinder_volume_drivers_quobyte.volume_opts,
cinder_volume_drivers_tintri.tintri_opts,
cinder_volume_drivers_violin_v7000common.violin_opts,
cinder_volume_drivers_vmware_vmdk.vmdk_opts,
cinder_volume_drivers_vzstorage.vzstorage_opts,
cinder_volume_drivers_nfs.nfs_opts,
cinder_volume_drivers_windows_windows.windows_opts,
cinder_volume_drivers_xio.XIO_OPTS,
cinder_volume_drivers_zadara.zadara_opts,
cinder_volume_drivers_zfssa_zfssaiscsi.ZFSSA_OPTS,
cinder_volume_drivers_zfssa_zfssanfs.ZFSSA_OPTS,
cinder_volume_drivers_zte_zteks.zte_opts,
cinder_volume_manager.volume_manager_opts,
cinder_wsgi_eventletserver.socket_opts,
)),
('CISCO_FABRIC_EXAMPLE',
itertools.chain(