Downstream Fix for Genconfig

This patch adds the opts.py file to the tree as a fix for deployers
that package cinder. The opts.py file is no longer being deleted right
away by generate_sample.sh after the cinder.sample.conf is being
generated.

This patch also introduces a pep8 check to make sure that the opts.py
file is up to date, so that it will catch when new opts get added to
Cinder without the opts.py being updated.

To support the ability to keep and check the opts file a number
of changes were needed in the check_uptodate.sh script as well as
the generate_sample.sh script:
    - check_uptodate now takes --checkopts instead of --checkonly
      When checkopts is used the opts.py file is generated using the
      current code and the generated file is compared to the existing
      file.  The check fails if there are differences.
    - generate_sample now has the --nosamplefile option.
      When this option is used, only the opts.py file is generated.
      The oslo-config-generator code is skipped so no sample file
      is created.
    - generate_sample also has some coding style consistency changes.
    - Added the 'genopts' option to tox so users can generate
      a fresh opts.py without a sample file when necessary.

Closes-Bug: 1501820
Co-Author: Jay Bryant <jsbryant@us.ibm.com>

Change-Id: I1f5494ebb19d5f4e8c651cbeef0acad07ad96829
This commit is contained in:
Kendall Nelson 2015-10-07 08:53:38 -05:00
parent 72984f6ec8
commit 2f9e4163f4
5 changed files with 520 additions and 68 deletions

View File

@ -14,6 +14,7 @@
import os
import subprocess
import textwrap
if __name__ == "__main__":
opt_file = open("cinder/opts.py", 'a')
@ -22,7 +23,23 @@ if __name__ == "__main__":
REGISTER_OPTS_STR = "CONF.register_opts("
REGISTER_OPT_STR = "CONF.register_opt("
opt_file.write("import copy\n")
license_str = textwrap.dedent(
"""
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.\n
""")
opt_file.write(license_str)
opt_file.write("import itertools\n\n")
targetdir = os.environ['TARGETDIR']
@ -47,10 +64,18 @@ if __name__ == "__main__":
flag = False
def _check_import(aline):
if len(aline) > 79:
new_lines = aline.partition(' as ')
return new_lines
else:
return [aline]
for atree in dir_trees_list:
if atree in ["cinder/config/generate_cinder_opts.py",
"cinder/hacking/checks.py"]:
"cinder/hacking/checks.py",
"cinder/volume/configuration.py", ]:
continue
dirs_list = atree.split('/')
@ -69,11 +94,18 @@ if __name__ == "__main__":
import_name += dir[:-3].replace("_", "")
import_module = (import_module[:-1] + " import " +
dir[:-3] + " as " + import_name)
opt_file.write(import_module + "\n")
lines = _check_import(import_module)
if len(lines) > 1:
opt_file.write(lines[0] + lines[1] + "\\\n")
opt_file.write(" " + lines[2] + "\n")
else:
opt_file.write(lines[0] + "\n")
else:
import_name = import_name[:-1].replace('/', '.')
init_import = atree[:-12].replace('/', '.')
opt_file.write("import " + init_import + "\n")
flag = True
if flag is False:
opt_dict[import_name] = atree
@ -93,9 +125,21 @@ if __name__ == "__main__":
def _write_item(opts):
list_name = opts[-3:]
if list_name.lower() == "opt":
opt_file.write(" [" + opts.strip("\n") + "],\n")
line_to_write = " [" + opts.strip("\n") + "],\n"
opt_line = _check_line_length(line_to_write)
if len(opt_line) > 1:
opt_file.write(opt_line[0] + opt_line[1] + "\n")
opt_file.write(" " + opt_line[2])
else:
opt_file.write(opt_line[0])
else:
opt_file.write(" " + opts.strip("\n") + ",\n")
line_to_write = " " + opts.strip("\n") + ",\n"
opt_line = _check_line_length(line_to_write)
if len(opt_line) > 1:
opt_file.write(opt_line[0] + opt_line[1] + "\n")
opt_file.write(" " + opt_line[2])
else:
opt_file.write(opt_line[0])
def _retrieve_name(aline):
if REGISTER_OPT_STR in aline:
@ -104,6 +148,20 @@ if __name__ == "__main__":
str_to_replace = REGISTER_OPTS_STR
return aline.replace(str_to_replace, "")
def _check_line_length(aline):
if len(aline) > 79:
temp = aline.split(".")
lines_to_write = []
for section in temp:
lines_to_write.append(section)
lines_to_write.append('.')
return lines_to_write
else:
return [aline]
for key in opt_dict:
fd = os.open(opt_dict[key], os.O_RDONLY)
afile = os.fdopen(fd, "r")
@ -167,64 +225,65 @@ if __name__ == "__main__":
registered_opts_dict['DEFAULT'].append(line)
opt_dict[key] = registered_opts_dict
list_str = ("def list_opts():\n"
list_str = ("\n\n"
"def list_opts():\n"
" return [\n"
" ('DEFAULT',\n"
" itertools.chain(\n")
" itertools.chain(\n")
opt_file.write(list_str)
for item in registered_opts_dict["DEFAULT"]:
_write_item(item)
profiler_str = (" )),\n"
" ('profiler',\n"
" itertools.chain(\n")
profiler_str = (" )),\n"
" ('profiler',\n"
" itertools.chain(\n")
opt_file.write(profiler_str)
for item in registered_opts_dict["profiler"]:
_write_item(item)
backend_str = (" )),\n"
" ('backend',\n"
" itertools.chain(\n")
backend_str = (" )),\n"
" ('backend',\n"
" itertools.chain(\n")
opt_file.write(backend_str)
for item in registered_opts_dict["backend"]:
_write_item(item)
cisco_str = (" )),\n"
" ('CISCO_FABRIC_EXAMPLE',\n"
" itertools.chain(\n")
cisco_str = (" )),\n"
" ('CISCO_FABRIC_EXAMPLE',\n"
" itertools.chain(\n")
opt_file.write(cisco_str)
for item in registered_opts_dict["CISCO_FABRIC_EXAMPLE"]:
_write_item(item)
brcd_str = (" )),\n"
" ('BRCD_FABRIC_EXAMPLE',\n"
" itertools.chain(\n")
brcd_str = (" )),\n"
" ('BRCD_FABRIC_EXAMPLE',\n"
" itertools.chain(\n")
opt_file.write(brcd_str)
for item in registered_opts_dict["BRCD_FABRIC_EXAMPLE"]:
_write_item(item)
keymgr_str = (" )),\n"
" ('keymgr',\n"
" itertools.chain(\n")
keymgr_str = (" )),\n"
" ('keymgr',\n"
" itertools.chain(\n")
opt_file.write(keymgr_str)
for item in registered_opts_dict["keymgr"]:
_write_item(item)
fczm_str = (" )),\n"
" ('fc-zone-manager',\n"
" itertools.chain(\n")
fczm_str = (" )),\n"
" ('fc-zone-manager',\n"
" itertools.chain(\n")
opt_file.write(fczm_str)
for item in registered_opts_dict["fc-zone-manager"]:
_write_item(item)
closing_str = (" )),\n"
"]\n\n\n")
closing_str = (" )),\n"
" ]\n")
opt_file.write(closing_str)
opt_file.close()

338
cinder/opts.py Normal file
View File

@ -0,0 +1,338 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import itertools
from cinder.api import common as cinder_api_common
from cinder.api.middleware import auth as cinder_api_middleware_auth
from cinder.api.middleware import sizelimit as cinder_api_middleware_sizelimit
from cinder.api.v2 import volumes as cinder_api_v2_volumes
from cinder.api.views import versions as cinder_api_views_versions
from cinder.backup import chunkeddriver as cinder_backup_chunkeddriver
from cinder.backup import driver as cinder_backup_driver
from cinder.backup.drivers import ceph as cinder_backup_drivers_ceph
from cinder.backup.drivers import glusterfs as cinder_backup_drivers_glusterfs
from cinder.backup.drivers import nfs as cinder_backup_drivers_nfs
from cinder.backup.drivers import posix as cinder_backup_drivers_posix
from cinder.backup.drivers import swift as cinder_backup_drivers_swift
from cinder.backup.drivers import tsm as cinder_backup_drivers_tsm
from cinder.backup import manager as cinder_backup_manager
from cinder.cmd import all as cinder_cmd_all
from cinder.cmd import volume as cinder_cmd_volume
from cinder.common import config as cinder_common_config
import cinder.compute
from cinder.compute import nova as cinder_compute_nova
from cinder import context as cinder_context
from cinder.db import api as cinder_db_api
from cinder.db import base as cinder_db_base
from cinder import exception as cinder_exception
from cinder.image import glance as cinder_image_glance
from cinder.image import image_utils as cinder_image_imageutils
import cinder.keymgr
from cinder.keymgr import conf_key_mgr as cinder_keymgr_confkeymgr
from cinder.keymgr import key_mgr as cinder_keymgr_keymgr
from cinder import quota as cinder_quota
from cinder.scheduler import driver as cinder_scheduler_driver
from cinder.scheduler import host_manager as cinder_scheduler_hostmanager
from cinder.scheduler import manager as cinder_scheduler_manager
from cinder.scheduler import scheduler_options as \
cinder_scheduler_scheduleroptions
from cinder.scheduler.weights import capacity as \
cinder_scheduler_weights_capacity
from cinder.scheduler.weights import volume_number as \
cinder_scheduler_weights_volumenumber
from cinder import service as cinder_service
from cinder import ssh_utils as cinder_sshutils
from cinder import test as cinder_test
from cinder.transfer import api as cinder_transfer_api
from cinder.volume import api as cinder_volume_api
from cinder.volume import driver as cinder_volume_driver
from cinder.volume.drivers import block_device as \
cinder_volume_drivers_blockdevice
from cinder.volume.drivers import blockbridge as \
cinder_volume_drivers_blockbridge
from cinder.volume.drivers.cloudbyte import options as \
cinder_volume_drivers_cloudbyte_options
from cinder.volume.drivers import datera as cinder_volume_drivers_datera
from cinder.volume.drivers.dell import dell_storagecenter_common as \
cinder_volume_drivers_dell_dellstoragecentercommon
from cinder.volume.drivers.dothill import dothill_common as \
cinder_volume_drivers_dothill_dothillcommon
from cinder.volume.drivers import drbdmanagedrv as \
cinder_volume_drivers_drbdmanagedrv
from cinder.volume.drivers.emc import emc_vmax_common as \
cinder_volume_drivers_emc_emcvmaxcommon
from cinder.volume.drivers.emc import emc_vnx_cli as \
cinder_volume_drivers_emc_emcvnxcli
from cinder.volume.drivers.emc import scaleio as \
cinder_volume_drivers_emc_scaleio
from cinder.volume.drivers.emc import xtremio as \
cinder_volume_drivers_emc_xtremio
from cinder.volume.drivers import eqlx as cinder_volume_drivers_eqlx
from cinder.volume.drivers import glusterfs as cinder_volume_drivers_glusterfs
from cinder.volume.drivers import hgst as cinder_volume_drivers_hgst
from cinder.volume.drivers.hitachi import hbsd_common as \
cinder_volume_drivers_hitachi_hbsdcommon
from cinder.volume.drivers.hitachi import hbsd_fc as \
cinder_volume_drivers_hitachi_hbsdfc
from cinder.volume.drivers.hitachi import hbsd_horcm as \
cinder_volume_drivers_hitachi_hbsdhorcm
from cinder.volume.drivers.hitachi import hbsd_iscsi as \
cinder_volume_drivers_hitachi_hbsdiscsi
from cinder.volume.drivers.hitachi import hnas_iscsi as \
cinder_volume_drivers_hitachi_hnasiscsi
from cinder.volume.drivers.hitachi import hnas_nfs as \
cinder_volume_drivers_hitachi_hnasnfs
from cinder.volume.drivers.hpe import hpe_3par_common as \
cinder_volume_drivers_hpe_hpe3parcommon
from cinder.volume.drivers.huawei import huawei_driver as \
cinder_volume_drivers_huawei_huaweidriver
from cinder.volume.drivers.ibm import flashsystem_common as \
cinder_volume_drivers_ibm_flashsystemcommon
from cinder.volume.drivers.ibm import flashsystem_fc as \
cinder_volume_drivers_ibm_flashsystemfc
from cinder.volume.drivers.ibm import flashsystem_iscsi as \
cinder_volume_drivers_ibm_flashsystemiscsi
from cinder.volume.drivers.ibm import gpfs as cinder_volume_drivers_ibm_gpfs
from cinder.volume.drivers.ibm import ibmnas as \
cinder_volume_drivers_ibm_ibmnas
import cinder.volume.drivers.ibm.storwize_svc
from cinder.volume.drivers.ibm import xiv_ds8k as \
cinder_volume_drivers_ibm_xivds8k
from cinder.volume.drivers.infortrend.eonstor_ds_cli import common_cli as \
cinder_volume_drivers_infortrend_eonstor_ds_cli_commoncli
from cinder.volume.drivers.lenovo import lenovo_common as \
cinder_volume_drivers_lenovo_lenovocommon
from cinder.volume.drivers import lvm as cinder_volume_drivers_lvm
from cinder.volume.drivers.netapp import options as \
cinder_volume_drivers_netapp_options
from cinder.volume.drivers import nfs as cinder_volume_drivers_nfs
from cinder.volume.drivers import nimble as cinder_volume_drivers_nimble
from cinder.volume.drivers.prophetstor import options as \
cinder_volume_drivers_prophetstor_options
from cinder.volume.drivers import pure as cinder_volume_drivers_pure
from cinder.volume.drivers import quobyte as cinder_volume_drivers_quobyte
from cinder.volume.drivers import rbd as cinder_volume_drivers_rbd
from cinder.volume.drivers import remotefs as cinder_volume_drivers_remotefs
from cinder.volume.drivers.san.hp import hp_lefthand_rest_proxy as \
cinder_volume_drivers_san_hp_hplefthandrestproxy
from cinder.volume.drivers.san.hp import hp_xp_opts as \
cinder_volume_drivers_san_hp_hpxpopts
from cinder.volume.drivers.san.hp import hpmsa_common as \
cinder_volume_drivers_san_hp_hpmsacommon
from cinder.volume.drivers.san import san as cinder_volume_drivers_san_san
from cinder.volume.drivers import scality as cinder_volume_drivers_scality
from cinder.volume.drivers import sheepdog as cinder_volume_drivers_sheepdog
from cinder.volume.drivers import smbfs as cinder_volume_drivers_smbfs
from cinder.volume.drivers import solidfire as cinder_volume_drivers_solidfire
from cinder.volume.drivers import srb as cinder_volume_drivers_srb
from cinder.volume.drivers import tintri as cinder_volume_drivers_tintri
from cinder.volume.drivers.violin import v6000_common as \
cinder_volume_drivers_violin_v6000common
from cinder.volume.drivers.violin import v7000_common as \
cinder_volume_drivers_violin_v7000common
from cinder.volume.drivers.vmware import vmdk as \
cinder_volume_drivers_vmware_vmdk
from cinder.volume.drivers import vzstorage as cinder_volume_drivers_vzstorage
from cinder.volume.drivers.windows import windows as \
cinder_volume_drivers_windows_windows
from cinder.volume.drivers import xio as cinder_volume_drivers_xio
from cinder.volume.drivers.zfssa import zfssaiscsi as \
cinder_volume_drivers_zfssa_zfssaiscsi
from cinder.volume.drivers.zfssa import zfssanfs as \
cinder_volume_drivers_zfssa_zfssanfs
from cinder.volume import manager as cinder_volume_manager
from cinder.wsgi import eventlet_server as cinder_wsgi_eventletserver
from cinder.zonemanager.drivers.brocade import brcd_fabric_opts as \
cinder_zonemanager_drivers_brocade_brcdfabricopts
from cinder.zonemanager.drivers.brocade import brcd_fc_zone_driver as \
cinder_zonemanager_drivers_brocade_brcdfczonedriver
from cinder.zonemanager.drivers.cisco import cisco_fabric_opts as \
cinder_zonemanager_drivers_cisco_ciscofabricopts
from cinder.zonemanager.drivers.cisco import cisco_fc_zone_driver as \
cinder_zonemanager_drivers_cisco_ciscofczonedriver
from cinder.zonemanager import fc_zone_manager as \
cinder_zonemanager_fczonemanager
def list_opts():
return [
('DEFAULT',
itertools.chain(
cinder_backup_driver.service_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_volume_drivers_violin_v7000common.violin_opts,
cinder_sshutils.ssh_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,
cinder_volume_drivers_netapp_options.netapp_basicauth_opts,
cinder_volume_drivers_netapp_options.netapp_cluster_opts,
cinder_volume_drivers_netapp_options.netapp_7mode_opts,
cinder_volume_drivers_netapp_options.netapp_provisioning_opts,
cinder_volume_drivers_netapp_options.netapp_img_cache_opts,
cinder_volume_drivers_netapp_options.netapp_eseries_opts,
cinder_volume_drivers_netapp_options.netapp_nfs_extra_opts,
cinder_volume_drivers_netapp_options.netapp_san_opts,
cinder_backup_drivers_glusterfs.glusterfsbackup_service_opts,
cinder_backup_drivers_tsm.tsm_opts,
cinder_volume_drivers_san_hp_hpxpopts.FC_VOLUME_OPTS,
cinder_volume_drivers_san_hp_hpxpopts.COMMON_VOLUME_OPTS,
cinder_volume_drivers_san_hp_hpxpopts.HORCM_VOLUME_OPTS,
cinder_test.test_opts,
cinder.volume.drivers.ibm.storwize_svc.storwize_svc_opts,
cinder_backup_manager.backup_manager_opts,
cinder_exception.exc_log_opts,
cinder_common_config.global_opts,
cinder_scheduler_weights_capacity.capacity_weight_opts,
cinder_volume_drivers_sheepdog.sheepdog_opts,
cinder_volume_drivers_ibm_gpfs.gpfs_opts,
[cinder_api_middleware_sizelimit.max_request_body_size_opt],
cinder_volume_drivers_solidfire.sf_opts,
cinder_volume_drivers_ibm_ibmnas.platform_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_scality.volume_opts,
cinder_volume_drivers_emc_emcvnxcli.loc_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_xio.XIO_OPTS,
cinder_volume_drivers_zfssa_zfssaiscsi.ZFSSA_OPTS,
cinder_wsgi_eventletserver.socket_opts,
cinder_wsgi_eventletserver.eventlet_opts,
cinder_volume_driver.volume_opts,
cinder_volume_driver.iser_opts,
cinder_api_views_versions.versions_opts,
cinder_volume_drivers_nimble.nimble_opts,
cinder_volume_drivers_windows_windows.windows_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_lvm.volume_opts,
cinder_volume_drivers_emc_emcvmaxcommon.emc_opts,
cinder_volume_drivers_remotefs.nas_opts,
cinder_volume_drivers_remotefs.volume_opts,
cinder_volume_drivers_violin_v6000common.violin_opts,
cinder_volume_drivers_srb.srb_opts,
cinder_volume_drivers_emc_xtremio.XTREMIO_OPTS,
[cinder_api_middleware_auth.use_forwarded_for_opt],
cinder_volume_drivers_hitachi_hbsdcommon.volume_opts,
cinder_volume_drivers_infortrend_eonstor_ds_cli_commoncli.
infortrend_esds_opts,
cinder_volume_drivers_infortrend_eonstor_ds_cli_commoncli.
infortrend_esds_extra_opts,
cinder_volume_drivers_hitachi_hnasiscsi.iSCSI_OPTS,
cinder_volume_drivers_rbd.rbd_opts,
cinder_volume_drivers_tintri.tintri_opts,
cinder_volume_drivers_hitachi_hbsdhorcm.volume_opts,
cinder_volume_drivers_san_hp_hplefthandrestproxy.
hplefthand_opts,
cinder_volume_drivers_hitachi_hbsdfc.volume_opts,
cinder_quota.quota_opts,
cinder_volume_drivers_huawei_huaweidriver.huawei_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_hgst.hgst_opts,
cinder_image_imageutils.image_helper_opts,
cinder_compute_nova.nova_opts,
cinder_volume_drivers_ibm_flashsystemfc.flashsystem_fc_opts,
cinder_volume_drivers_prophetstor_options.DPL_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_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_ibm_xivds8k.xiv_ds8k_opts,
cinder_volume_drivers_hpe_hpe3parcommon.hpe3par_opts,
cinder_volume_drivers_datera.d_opts,
cinder_volume_drivers_blockdevice.volume_opts,
[cinder_api_v2_volumes.query_volume_filters_opt],
cinder_volume_drivers_quobyte.volume_opts,
cinder_volume_drivers_vzstorage.vzstorage_opts,
cinder_volume_drivers_nfs.nfs_opts,
)),
('profiler',
itertools.chain(
cinder_service.profiler_opts,
)),
('backend',
itertools.chain(
[cinder_cmd_volume.host_opt],
[cinder_cmd_all.volume_cmd.host_opt],
)),
('CISCO_FABRIC_EXAMPLE',
itertools.chain(
cinder_zonemanager_drivers_cisco_ciscofabricopts.
cisco_zone_opts,
)),
('BRCD_FABRIC_EXAMPLE',
itertools.chain(
cinder_zonemanager_drivers_brocade_brcdfabricopts.
brcd_zone_opts,
)),
('keymgr',
itertools.chain(
cinder_keymgr_keymgr.encryption_opts,
cinder.keymgr.keymgr_opts,
cinder_keymgr_confkeymgr.key_mgr_opts,
)),
('fc-zone-manager',
itertools.chain(
cinder_zonemanager_fczonemanager.zone_manager_opts,
cinder_zonemanager_drivers_brocade_brcdfczonedriver.brcd_opts,
cinder_zonemanager_drivers_cisco_ciscofczonedriver.cisco_opts,
)),
]

View File

@ -1,26 +1,57 @@
#!/usr/bin/env bash
CHECKONLY=0
if [ "$1" == "--checkonly" ]; then
CHECKONLY=1
CHECKOPTS=0
if [ "$1" == "--checkopts" ]; then
CHECKOPTS=1
fi
PROJECT_NAME=${PROJECT_NAME:-cinder}
CFGFILE_NAME=${PROJECT_NAME}.conf.sample
TEMPDIR=`mktemp -d /tmp/${PROJECT_NAME}.XXXXXX`
trap "rm -rf $TEMPDIR" EXIT
tools/config/generate_sample.sh from_tox
if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then
CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME}
elif [ -e cinder/opts.py]; then
echo -en "\n\nWARNING: Found cinder/opts.py file. \n"
echo -en "Check for generate_cinder_opts.py failure.\n\n"
exit 1
if [ $CHECKOPTS -eq 1 ]; then
if [ ! -e cinder/opts.py ]; then
echo -en "\n\n#################################################"
echo -en "\nERROR: cinder/opts.py file is missing."
echo -en "\n#################################################\n"
exit 1
else
mv cinder/opts.py cinder/opts.py.orig
tox -e genopts &> /dev/null
if [ $? -ne 0 ]; then
echo -en "\n\n#################################################"
echo -en "\nERROR: Non-zero exit from generate_cinder_opts.py."
echo -en "\n See output above for details.\n"
echo -en "#################################################\n"
mv cinder/opts.py.orig cinder/opts.py
exit 1
else
diff cinder/opts.py.orig cinder/opts.py
if [ $? -ne 0 ]; then
echo -en "\n\n########################################################"
echo -en "\nERROR: Configuration options change detected."
echo -en "\n A new cinder/opts.py file must be generated."
echo -en "\n Run 'tox -e genopts' from the base directory"
echo -en "\n and add the result to your commit."
echo -en "\n########################################################\n\n"
rm cinder/opts.py
mv cinder/opts.py.orig cinder/opts.py
exit 1
else
rm cinder/opts.py.orig
fi
fi
fi
else
echo "${0##*/}: Can't find config file."
exit 1
tox -e genconfig &> /dev/null
if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then
CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME}
rm -f $CFGFILE
else
echo -en "\n\n####################################################"
echo -en "\n${0##*/}: Can't find config file."
echo -en "\n####################################################\n\n"
exit 1
fi
fi

View File

@ -12,6 +12,13 @@
BASEDIR=${BASEDIR:-`pwd`}
NOSAMPLE=0
if [ ! -z ${2} ] ; then
if [ "${2}" == "--nosamplefile" ]; then
NOSAMPLE=1
fi
fi
print_error ()
{
echo -en "\n\n##########################################################"
@ -31,11 +38,9 @@ if [ ${1} != "from_tox" ] ; then
exit 1
fi
if ! [ -d $BASEDIR ]
then
if ! [ -d $BASEDIR ] ; then
echo "${0##*/}: missing project base directory" >&2 ; exit 1
elif [[ $BASEDIR != /* ]]
then
elif [[ $BASEDIR != /* ]] ; then
BASEDIR=$(cd "$BASEDIR" && pwd)
fi
@ -51,34 +56,47 @@ find $TARGETDIR -type f -name "*.pyc" -delete
export TARGETDIR=$TARGETDIR
export BASEDIRESC=$BASEDIRESC
if [ -e $TARGETDIR/opts.py ] ; then
mv $TARGETDIR/opts.py $TARGETDIR/opts.py.bak
fi
python cinder/config/generate_cinder_opts.py
if [ $? -ne 0 ]
then
if [ $? -ne 0 ] ; then
echo -en "\n\n#################################################"
echo -en "\nERROR: Non-zero exit from generate_cinder_opts.py."
echo -en "\n See output above for details.\n"
echo -en "#################################################\n"
if [ -e $TARGETDIR/opts.py.bak ] ; then
mv $TARGETDIR/opts.py.bak $TARGETDIR/opts.py
fi
exit 1
fi
oslo-config-generator --config-file=cinder/config/cinder-config-generator.conf
if [ $NOSAMPLE -eq 0 ] ; then
oslo-config-generator --config-file=cinder/config/cinder-config-generator.conf
if [ $? -ne 0 ]
then
echo -en "\n\n#################################################"
echo -en "\nERROR: Non-zero exit from oslo-config-generator."
echo -en "\n See output above for details.\n"
echo -en "#################################################\n"
exit 1
fi
if [ ! -s ./etc/cinder/cinder.conf.sample ] ; then
echo -en "\n\n#########################################################"
echo -en "\nERROR: etc/cinder/cinder.sample.conf not created properly."
echo -en "\n See above output for details.\n"
echo -en "###########################################################\n"
exit 1
fi
diff $TARGETDIR/opts.py $TARGETDIR/opts.py.bak &> /dev/null
if [ $? -ne 0 ] ; then
mv $TARGETDIR/opts.py.bak $TARGETDIR/opts.py
else
rm -f $TARGETDIR/opts.py.bak
fi
rm -f cinder/opts.py
rm -f cinder/opts.pyc
if [ $? -ne 0 ] ; then
echo -en "\n\n#################################################"
echo -en "\nERROR: Non-zero exit from oslo-config-generator."
echo -en "\n See output above for details.\n"
echo -en "#################################################\n"
exit 1
fi
if [ ! -s ./etc/cinder/cinder.conf.sample ] ; then
echo -en "\n\n#########################################################"
echo -en "\nERROR: etc/cinder/cinder.sample.conf not created properly."
echo -en "\n See above output for details.\n"
echo -en "###########################################################\n"
exit 1
fi
else
rm -f $TARGETDIR/opts.py.bak
fi

View File

@ -58,6 +58,7 @@ commands =
flake8 {posargs} . cinder/common
# Check that .po and .pot files are valid:
bash -c "find cinder -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null"
{toxinidir}/tools/config/check_uptodate.sh --checkopts
{toxinidir}/tools/config/check_uptodate.sh
{toxinidir}/tools/check_exec.py {toxinidir}/cinder
@ -93,6 +94,11 @@ sitepackages = False
envdir = {toxworkdir}/venv
commands = {toxinidir}/tools/config/generate_sample.sh from_tox
[testenv:genopts]
sitepackages = False
envdir = {toxworkdir}/venv
commands = {toxinidir}/tools/config/generate_sample.sh from_tox --nosamplefile
[testenv:venv]
commands = {posargs}