From 0c2dc137b9d6de061d2fe42dec56ed274e0591c2 Mon Sep 17 00:00:00 2001 From: Robert Church Date: Mon, 9 Apr 2018 19:45:24 -0500 Subject: [PATCH] Set cinder default_volume_type via service parameters Service Parameter support added for setting cinder.conf parameter DEFAULT/default_volume_type. Changes include: - Added service parameter cinder/DEFAULT/default_volume_type with checks to verify that the provided value is a currently defined volume type and multiple values are not provided. The cinder API is queried to get a list of acceptable values. - The service parameter is not required to be present. It is optional, but we maintain behavior from past releases which sets the default volume type to 'ceph' if the ceph backend in present. - If the ceph backend is present and the service parameter is present, the service parameter takes precedence. - The cinder.pp manifest is updated to provide a service_parameter runtime class that applies the cinder.conf changes for SAN backend sections and the DEFAULT section. - puppet-cinder is updated to remove the default_volume_type from the cinder::api class. This allows us to set the parameter as part of a targeted runtime class and during the ::openstack::cinder main class. To upstream this we should create cinder::default_volume_type class (like the cinder::backends class) to enable setting this as needed. Change-Id: I64e61cdc28efd327f34fa74bb2bea645458f6d6e --- .../src/modules/openstack/manifests/cinder.pp | 41 ++++- .../api/controllers/v1/service_parameter.py | 43 ++++- .../sysinv/sysinv/sysinv/common/constants.py | 3 + .../sysinv/sysinv/sysinv/common/exception.py | 4 + .../sysinv/sysinv/common/service_parameter.py | 50 ++++++ .../sysinv/sysinv/sysinv/conductor/manager.py | 8 +- .../sysinv/sysinv/conductor/openstack.py | 16 +- .../sysinv/sysinv/sysinv/conductor/rpcapi.py | 12 ++ .../sysinv/sysinv/sysinv/db/sqlalchemy/api.py | 2 + sysinv/sysinv/sysinv/sysinv/puppet/cinder.py | 157 ++++++++++++------ 10 files changed, 273 insertions(+), 63 deletions(-) diff --git a/puppet-manifests/src/modules/openstack/manifests/cinder.pp b/puppet-manifests/src/modules/openstack/manifests/cinder.pp index 35e2bd7080..b42313134d 100644 --- a/puppet-manifests/src/modules/openstack/manifests/cinder.pp +++ b/puppet-manifests/src/modules/openstack/manifests/cinder.pp @@ -103,6 +103,7 @@ class openstack::cinder::params ( } } + # Called from controller manifest class openstack::cinder inherits ::openstack::cinder::params { @@ -191,6 +192,7 @@ class openstack::cinder include ::cinder::ceilometer include ::cinder::glance + include ::openstack::cinder::config include ::openstack::cinder::backends # TODO(mpeters): move to puppet module formal parameters @@ -215,6 +217,21 @@ class openstack::cinder } } + +class openstack::cinder::config::default( + $config_params +) inherits ::openstack::cinder::params { + # Realize any service parameter provided DEFAULT section params of cinder.conf + create_resources('cinder_config', hiera_hash('openstack::cinder::config::default::config_params', {})) +} + + +class openstack::cinder::config + inherits ::openstack::cinder::params { + include ::openstack::cinder::config::default +} + + class openstack::cinder::backends::san inherits ::openstack::cinder::params { include ::openstack::cinder::emc_vnx @@ -222,6 +239,7 @@ class openstack::cinder::backends::san include ::openstack::cinder::hpelefthand } + class openstack::cinder::backends inherits ::openstack::cinder::params { @@ -240,6 +258,7 @@ class openstack::cinder::backends include openstack::cinder::backends::san } + class openstack::cinder::lvm::filesystem::drbd ( $device = '/dev/drbd4', $lv_name = 'cinder-lv', @@ -569,6 +588,7 @@ define openstack::cinder::api::backend( } } + class openstack::cinder::api::backends( $ceph_type_configs = {} ) inherits ::openstack::cinder::params { @@ -591,9 +611,8 @@ class openstack::cinder::api::backends( # Called from the controller manifest -class openstack::cinder::api( - $default_volume_type = $::os_service_default -) inherits ::openstack::cinder::params { +class openstack::cinder::api + inherits ::openstack::cinder::params { include ::platform::params $api_workers = $::platform::params::eng_workers @@ -615,8 +634,7 @@ class openstack::cinder::api( bind_host => $api_host, service_workers => $api_workers, sync_db => $::platform::params::init_database, - enabled => str2bool($enable_cinder_service), - default_volume_type => $default_volume_type + enabled => str2bool($enable_cinder_service) } if $::openstack::cinder::params::configure_endpoint { @@ -634,6 +652,7 @@ class openstack::cinder::api( } } + class openstack::cinder::pre { include ::openstack::cinder::params $enabled = str2bool($::openstack::cinder::params::enable_cinder_service) @@ -645,6 +664,7 @@ class openstack::cinder::pre { } } + class openstack::cinder::post inherits openstack::cinder::params { @@ -714,6 +734,7 @@ class openstack::cinder::reload { platform::sm::restart {'cinder-api': } } + # Called for runtime changes class openstack::cinder::runtime inherits ::openstack::cinder::params { @@ -726,6 +747,7 @@ class openstack::cinder::runtime } } + # Called for runtime changes on region class openstack::cinder::endpoint::runtime { if str2bool($::is_controller_active) { @@ -733,13 +755,18 @@ class openstack::cinder::endpoint::runtime { } } -# Called for SAN backend runtime changes => cinder.conf only changes -class openstack::cinder::backends::san::runtime + +# Called for service_parameter runtime changes: +# - Currently cinder.conf only changes +# - external SAN backend sections +# - default section changes +class openstack::cinder::service_param::runtime inherits ::openstack::cinder::params { class { '::cinder::backends': enabled_backends => $enabled_backends } + include ::openstack::cinder::config::default include ::openstack::cinder::backends::san class { '::openstack::cinder::reload': diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py index 067abf1e46..452865c9b0 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py @@ -696,9 +696,44 @@ class ServiceParameterController(rest.RestController): constants.SERVICE_PARAM_SECTION_IDENTITY_LDAP)) raise wsme.exc.ClientSideError(msg) + @staticmethod + def _service_parameter_apply_semantic_check_cinder_default(): + """Semantic checks for the Cinder Service Type: DEFAULT parameters """ + try: + volume_type = pecan.request.dbapi.service_parameter_get_one( + service=constants.SERVICE_TYPE_CINDER, + section=constants.SERVICE_PARAM_SECTION_CINDER_DEFAULT, + name=constants.SERVICE_PARAM_CINDER_DEFAULT_VOLUME_TYPE) + except exception.MultipleResults: + msg = (_('Unable to apply service parameters. Multiple parameters ' + 'found for %s/%s/%s. Ensure only one parameter is ' + 'provided.') % ( + constants.SERVICE_TYPE_CINDER, + constants.SERVICE_PARAM_SECTION_CINDER_DEFAULT, + constants.SERVICE_PARAM_CINDER_DEFAULT_VOLUME_TYPE)) + raise wsme.exc.ClientSideError(msg) + except exception.NotFound: + # not required to be set + volume_type = None + + if volume_type: + try: + volume_types = pecan.request.rpcapi.get_cinder_volume_type_names( + pecan.request.context) + except rpc_common.RemoteError as e: + raise wsme.exc.ClientSideError(str(e.value)) + + if volume_type.value not in volume_types: + msg = (_('Unable to apply service parameters. Cannot set "%s" ' + 'to value "%s". This is not a valid cinder volume ' + 'type. Acceptable values are: [%s].') % ( + constants.SERVICE_PARAM_CINDER_DEFAULT_VOLUME_TYPE, + volume_type.value, ','.join(volume_types))) + raise wsme.exc.ClientSideError(msg) + @staticmethod def _service_parameter_apply_semantic_check_cinder_emc_vnx(): - """Semantic checks for the Cinder Service Type """ + """Semantic checks for the Cinder Service Type: EMC VNX backend """ feature_enabled = pecan.request.dbapi.service_parameter_get_one( service=constants.SERVICE_TYPE_CINDER, section=constants.SERVICE_PARAM_SECTION_CINDER_EMC_VNX, @@ -925,11 +960,13 @@ class ServiceParameterController(rest.RestController): if not StorageBackendConfig.is_service_enabled(pecan.request.dbapi, constants.SB_SVC_CINDER, filter_shared=True): - msg = _("Cannot apply Cinder SAN configuration. Cinder is " - "not currently enabled on either the %s or %s backends." + msg = _("Cannot apply Cinder configuration. Cinder is not " + "currently enabled on either the %s or %s backends." % (constants.SB_TYPE_LVM, constants.SB_TYPE_CEPH)) raise wsme.exc.ClientSideError(msg) + self._service_parameter_apply_semantic_check_cinder_default() + self._service_parameter_apply_semantic_check_cinder_emc_vnx() self._emc_vnx_ip_addresses_reservation() diff --git a/sysinv/sysinv/sysinv/sysinv/common/constants.py b/sysinv/sysinv/sysinv/sysinv/common/constants.py index 045bc2807f..34d4da727a 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/constants.py +++ b/sysinv/sysinv/sysinv/sysinv/common/constants.py @@ -769,6 +769,9 @@ SERVICE_PARAM_SECTION_IDENTITY_IDENTITY = 'identity' SERVICE_PARAM_SECTION_IDENTITY_LDAP = 'ldap' SERVICE_PARAM_SECTION_IDENTITY_CONFIG = 'config' +SERVICE_PARAM_SECTION_CINDER_DEFAULT = 'DEFAULT' +SERVICE_PARAM_CINDER_DEFAULT_VOLUME_TYPE = 'default_volume_type' + SERVICE_PARAM_SECTION_CINDER_EMC_VNX = 'emc_vnx' SERVICE_PARAM_CINDER_EMC_VNX_ENABLED = 'enabled' SERVICE_PARAM_SECTION_CINDER_EMC_VNX_STATE = 'emc_vnx.state' diff --git a/sysinv/sysinv/sysinv/sysinv/common/exception.py b/sysinv/sysinv/sysinv/sysinv/common/exception.py index 49edc6aef4..16f1429a97 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/exception.py +++ b/sysinv/sysinv/sysinv/sysinv/common/exception.py @@ -673,6 +673,10 @@ class NotFound(SysinvException): code = 404 +class MultipleResults(SysinvException): + message = _("More than one result found.") + + class DiskNotFound(NotFound): message = _("No disk with id %(disk_id)s") diff --git a/sysinv/sysinv/sysinv/sysinv/common/service_parameter.py b/sysinv/sysinv/sysinv/sysinv/common/service_parameter.py index f0fa5dbfb7..2194e0514d 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/service_parameter.py +++ b/sysinv/sysinv/sysinv/sysinv/common/service_parameter.py @@ -1094,6 +1094,48 @@ NETWORK_DEFAULT_PARAMETER_DATA_FORMAT = { } +# +# Cinder DEFAULT service parameters +# + +CINDER_DEFAULT_PARAMETER_MANDATORY = [ +] + +CINDER_DEFAULT_PARAMETER_PROTECTED = [] + +# If the lists: +# +# * CINDER_DEFAULT_PARAMETER_PROTECTED +# * CINDER_DEFAULT_PARAMETER_REQUIRED +# * CINDER_DEFAULT_PARAMETER_OPTIONAL +# +# are changed, we must update the +# SP_CINDER_DEFAULT_ALL_SUPPORTTED_PARAMS list in +# packstack/plugins/cinder_250.py. + +CINDER_DEFAULT_PARAMETER_REQUIRED = [] + +CINDER_DEFAULT_PARAMETER_OPTIONAL = ( + CINDER_DEFAULT_PARAMETER_REQUIRED + + CINDER_DEFAULT_PARAMETER_PROTECTED + [ + 'default_volume_type' + ] +) + +CINDER_DEFAULT_PARAMETER_VALIDATOR = { + # Mandatory parameters + # Required parameters + # Optional parameters + 'default_volume_type': _validate_not_empty +} + +CINDER_DEFAULT_PARAMETER_RESOURCE = { + # Mandatory parameters + # Required parameters + # Optional parameters + 'default_volume_type': None +} + CINDER_EMC_VNX_SAN_IP = 'san_ip' CINDER_EMC_VNX_SAN_SECONDARY_IP = 'san_secondary_ip' CINDER_EMC_VNX_DATA_SAN_IP = 'data_san_ip' @@ -1440,6 +1482,14 @@ SERVICE_VALUE_PROTECTION_MASK = "****" SERVICE_PARAMETER_SCHEMA = { constants.SERVICE_TYPE_CINDER: { + constants.SERVICE_PARAM_SECTION_CINDER_DEFAULT: { + SERVICE_PARAM_MANDATORY: CINDER_DEFAULT_PARAMETER_MANDATORY, + SERVICE_PARAM_PROTECTED: CINDER_DEFAULT_PARAMETER_PROTECTED, + SERVICE_PARAM_OPTIONAL: CINDER_DEFAULT_PARAMETER_OPTIONAL, + SERVICE_PARAM_VALIDATOR: CINDER_DEFAULT_PARAMETER_VALIDATOR, + SERVICE_PARAM_RESOURCE: CINDER_DEFAULT_PARAMETER_RESOURCE, + }, + constants.SERVICE_PARAM_SECTION_CINDER_EMC_VNX: { SERVICE_PARAM_MANDATORY: CINDER_EMC_VNX_PARAMETER_MANDATORY, SERVICE_PARAM_PROTECTED: CINDER_EMC_VNX_PARAMETER_PROTECTED, diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py index 088f7aad2a..f43be02e79 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py @@ -4967,6 +4967,12 @@ class ConductorManager(service.PeriodicService): return None + def get_cinder_volume_type_names(self, context): + """Get the names of all currently defined cinder volume types.""" + + volume_types_list = self._openstack.get_cinder_volume_types() + return [t.name for t in volume_types_list] + def _ipv_replace_disk(self, pv_id): """Handle replacement of the disk this physical volume is attached to. """ @@ -6553,7 +6559,7 @@ class ConductorManager(service.PeriodicService): config_dict = { "personalities": personalities, - "classes": ['openstack::cinder::backends::san::runtime'], + "classes": ['openstack::cinder::service_param::runtime'], "host_uuids": [ctrl.uuid for ctrl in valid_ctrls], } self._config_apply_runtime_manifest(context, config_uuid, config_dict) diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/openstack.py b/sysinv/sysinv/sysinv/sysinv/conductor/openstack.py index 0ff1d4771a..d42ab1b811 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/openstack.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/openstack.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2017 Wind River Systems, Inc. +# Copyright (c) 2013-2018 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -764,6 +764,20 @@ class OpenStackOperator(object): return service_list + def get_cinder_volume_types(self): + """Obtain the current list of volume types.""" + volume_types_list = [] + + if StorageBackendConfig.is_service_enabled(self.dbapi, + constants.SB_SVC_CINDER, + filter_shared=True): + try: + volume_types_list = self._get_cinderclient().volume_types.list() + except Exception as e: + LOG.error("get_cinder_volume_types: Failed to access Cinder client: %s" % e) + + return volume_types_list + def cinder_prepare_db_for_volume_restore(self, context): """ Make sure that Cinder's database is in the state required to restore all diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py b/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py index 6a6e0101a7..9d64fc34cd 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py @@ -656,9 +656,21 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy): self.make_msg('get_ceph_pools_df_stats')) def get_cinder_lvm_usage(self, context): + """Get the usage information for the LVM pools. + + :param context: request context. + """ return self.call(context, self.make_msg('get_cinder_lvm_usage')) + def get_cinder_volume_type_names(self, context): + """Get the names of all currently defined cinder volume types. + + :param context: request context. + """ + return self.call(context, + self.make_msg('get_cinder_volume_type_names')) + def kill_ceph_storage_monitor(self, context): """Stop the ceph storage monitor. pmon will not restart it. This should only be used in an diff --git a/sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/api.py b/sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/api.py index 6d2e506c90..325ed8de29 100755 --- a/sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/api.py +++ b/sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/api.py @@ -6382,6 +6382,8 @@ class Connection(api.Connection): result = query.one() except NoResultFound: raise exception.NotFound() + except MultipleResultsFound: + raise exception.MultipleResults() return result diff --git a/sysinv/sysinv/sysinv/sysinv/puppet/cinder.py b/sysinv/sysinv/sysinv/sysinv/puppet/cinder.py index 011f938d80..2d6c2cf080 100644 --- a/sysinv/sysinv/sysinv/sysinv/puppet/cinder.py +++ b/sysinv/sysinv/sysinv/sysinv/puppet/cinder.py @@ -13,7 +13,16 @@ from . import openstack LOG = logging.getLogger(__name__) -SP_CINDER_EMC_VNX = 'emc_vnx' +# This section is for [DEFAULT] config params that may need to be applied +SP_CINDER_DEFAULT = constants.SERVICE_PARAM_SECTION_CINDER_DEFAULT +SP_CINDER_DEFAULT_PREFIX = 'openstack::cinder::config::default' +SP_CINDER_DEFAULT_ALL_SUPPORTED_PARAMS = [ + constants.SERVICE_PARAM_CINDER_DEFAULT_VOLUME_TYPE + # Hardcoded params: params we always want set +] + +# This section is for [emc_vnx] config params that may need to be applied +SP_CINDER_EMC_VNX = constants.SERVICE_PARAM_SECTION_CINDER_EMC_VNX SP_CINDER_EMC_VNX_PREFIX = 'openstack::cinder::emc_vnx' # The entries in CINDER_EMC_VNX_PARAMETER_REQUIRED_ON_FEATURE_ENABLED, @@ -42,19 +51,20 @@ SP_CINDER_EMC_VNX_ALL_BLACKLIST_PARAMS = [ 'control_network', 'data_network', 'data_san_ip', ] - -SP_CINDER_HPE3PAR = 'hpe3par' +# This section is for [hpe3par] config params that may need to be applied +SP_CINDER_HPE3PAR = constants.SERVICE_PARAM_SECTION_CINDER_HPE3PAR SP_CINDER_HPE3PAR_PREFIX = 'openstack::cinder::hpe3par' SP_CINDER_HPE3PAR_ALL_SUPPORTED_PARAMS = [ 'hpe3par_api_url', 'hpe3par_username', 'hpe3par_password', 'hpe3par_cpg', 'hpe3par_cpg_snap', 'hpe3par_snapshot_expiration', 'hpe3par_debug', 'hpe3par_iscsi_ips', 'hpe3par_iscsi_chap_enabled', - 'san_login', 'san_password', 'san_ip' + 'san_login', 'san_password', 'san_ip', # Hardcoded params 'volume_backend_name', 'volume_driver' ] -SP_CINDER_HPELEFTHAND = 'hpelefthand' +# This section is for [hpelefthand] config params that may need to be applied +SP_CINDER_HPELEFTHAND = constants.SERVICE_PARAM_SECTION_CINDER_HPELEFTHAND SP_CINDER_HPELEFTHAND_PREFIX = 'openstack::cinder::hpelefthand' SP_CINDER_HPELEFTHAND_ALL_SUPPORTED_PARAMS = [ 'hpelefthand_api_url', 'hpelefthand_username', 'hpelefthand_password', @@ -71,29 +81,36 @@ SP_PROVIDED_PARAMS_LIST_KEY = 'provided_params_list' SP_ABSENT_PARAMS_LIST_KEY = 'absent_params_list' -def sp_default_param_process(config, section, section_map, name, value): +# +# common section processing calls +# + + +def sp_common_param_process(config, section, section_map, name, value): if SP_PROVIDED_PARAMS_LIST_KEY not in section_map: section_map[SP_PROVIDED_PARAMS_LIST_KEY] = {} section_map[SP_PROVIDED_PARAMS_LIST_KEY][name] = value -def sp_default_post_process(config, section, section_map, - is_service_enabled, enabled_backends): +def sp_common_post_process(config, section, section_map, is_service_enabled, + enabled_backends, is_a_feature=True): if section_map: provided_params = section_map.get(SP_PROVIDED_PARAMS_LIST_KEY, {}) absent_params = section_map.get(SP_ABSENT_PARAMS_LIST_KEY, []) conf_name = section_map.get(SP_CONF_NAME_KEY) + '::config_params' - feature_enabled_conf = section_map.get(SP_CONF_NAME_KEY) + '::feature_enabled' - # Convert "enabled" service param to 'feature_enabled' param - config[feature_enabled_conf] = provided_params.get('enabled', 'false').lower() - if 'enabled' in provided_params: - del provided_params['enabled'] + if is_a_feature: + feature_enabled_conf = section_map.get(SP_CONF_NAME_KEY) + '::feature_enabled' - # Inform Cinder to support this storage backend as well - if config[feature_enabled_conf] == 'true': - enabled_backends.append(section) + # Convert "enabled" service param to 'feature_enabled' param + config[feature_enabled_conf] = provided_params.get('enabled', 'false').lower() + if 'enabled' in provided_params: + del provided_params['enabled'] + + # Inform Cinder to support this storage backend as well + if config[feature_enabled_conf] == 'true': + enabled_backends.append(section) # Reformat the params data structure to match with puppet config # resource. This will make puppet code very simple. For example @@ -110,7 +127,7 @@ def sp_default_post_process(config, section, section_map, # emc_vnx/san_secondary_ip: # ensure: absent # - # With this format, Puppet only need to do this: + # With this format, Puppet only needs to do this: # create_resources('cinder_config', hiera_hash( # '', {})) @@ -125,8 +142,46 @@ def sp_default_post_process(config, section, section_map, provided_params_puppet_format[section + '/' + param] = { 'ensure': 'absent' } + config[conf_name] = provided_params_puppet_format +# +# Section specific post processing calls: DEFAULT, emc_vnx, hpe3par, hpelefthand +# + + +def sp_default_post_process(config, section, section_map, + is_service_enabled, enabled_backends): + + provided_params = section_map.get(SP_PROVIDED_PARAMS_LIST_KEY, {}) + + if not is_service_enabled: + # If the service is not enabled and there are some provided params then + # just remove all of these params as they should not be in cinder.conf + section_map[SP_PROVIDED_PARAMS_LIST_KEY] = {} + provided_params = section_map[SP_PROVIDED_PARAMS_LIST_KEY] + else: + # Special Handling: + + # SERVICE_PARAM_CINDER_DEFAULT_VOLUME_TYPE: + # Ceph tiers: Since we may have multiple ceph backends, prioritize the + # primary backend to maintain existing behavior if a default volume + # type is not set + param = constants.SERVICE_PARAM_CINDER_DEFAULT_VOLUME_TYPE + if param not in provided_params: + if constants.CINDER_BACKEND_CEPH in enabled_backends: + provided_params[param] = constants.CINDER_BACKEND_CEPH + + # Now make sure the parameters which are not in the provided_params list are + # removed out of cinder.conf + absent_params = section_map[SP_ABSENT_PARAMS_LIST_KEY] = [] + for param in SP_CINDER_DEFAULT_ALL_SUPPORTED_PARAMS: + if param not in provided_params: + absent_params.append(param) + + sp_common_post_process(config, section, section_map, is_service_enabled, + enabled_backends, is_a_feature=False) + def sp_emc_vnx_post_process(config, section, section_map, is_service_enabled, enabled_backends): @@ -176,15 +231,15 @@ def sp_emc_vnx_post_process(config, section, section_map, section_map[SP_PROVIDED_PARAMS_LIST_KEY] = {} provided_params = section_map[SP_PROVIDED_PARAMS_LIST_KEY] - # Now make sure the parameters which are not in provided_params list - # then they should be removed out of cinder.conf + # Now make sure the parameters which are not in the provided_params list are + # removed out of cinder.conf absent_params = section_map[SP_ABSENT_PARAMS_LIST_KEY] = [] for param in SP_CINDER_EMC_VNX_ALL_SUPPORTED_PARAMS: if param not in provided_params: absent_params.append(param) - sp_default_post_process(config, section, section_map, - is_service_enabled, enabled_backends) + sp_common_post_process(config, section, section_map, is_service_enabled, + enabled_backends) def sp_hpe3par_post_process(config, section, section_map, @@ -205,15 +260,15 @@ def sp_hpe3par_post_process(config, section, section_map, section_map[SP_PROVIDED_PARAMS_LIST_KEY] = {} provided_params = section_map[SP_PROVIDED_PARAMS_LIST_KEY] - # Now make sure the parameters which are not in provided_params list - # then they should be removed out of cinder.conf + # Now make sure the parameters which are not in the provided_params list are + # removed out of cinder.conf absent_params = section_map[SP_ABSENT_PARAMS_LIST_KEY] = [] for param in SP_CINDER_HPE3PAR_ALL_SUPPORTED_PARAMS: if param not in provided_params: absent_params.append(param) - sp_default_post_process(config, section, section_map, - is_service_enabled, enabled_backends) + sp_common_post_process(config, section, section_map, is_service_enabled, + enabled_backends) def sp_hpelefthand_post_process(config, section, section_map, @@ -234,37 +289,45 @@ def sp_hpelefthand_post_process(config, section, section_map, section_map[SP_PROVIDED_PARAMS_LIST_KEY] = {} provided_params = section_map[SP_PROVIDED_PARAMS_LIST_KEY] - # Now make sure the parameters which are not in provided_params list - # then they should be removed out of cinder.conf + # Now make sure the parameters which are not in the provided_params list are + # removed out of cinder.conf absent_params = section_map[SP_ABSENT_PARAMS_LIST_KEY] = [] for param in SP_CINDER_HPELEFTHAND_ALL_SUPPORTED_PARAMS: if param not in provided_params: absent_params.append(param) - sp_default_post_process(config, section, section_map, - is_service_enabled, enabled_backends) + sp_common_post_process(config, section, section_map, is_service_enabled, + enabled_backends) +# For each section provided is: +# SP_CONF_NAME_KEY : The hieradata path for this section +# SP_PARAM_PROCESS_KEY: This function is invoked for every service param +# belonging to the section +# SP_POST_PROCESS_KEY : This function is invoked after each individual service +# param in the section is processed SP_CINDER_SECTION_MAPPING = { + SP_CINDER_DEFAULT: { + SP_CONF_NAME_KEY: SP_CINDER_DEFAULT_PREFIX, + SP_PARAM_PROCESS_KEY: sp_common_param_process, + SP_POST_PROCESS_KEY: sp_default_post_process, + }, + SP_CINDER_EMC_VNX: { SP_CONF_NAME_KEY: SP_CINDER_EMC_VNX_PREFIX, - # This function is invoked for every service param - # belong to Emc VNX SAN - SP_PARAM_PROCESS_KEY: sp_default_param_process, - # This function is invoked one after each individual service param - # is processed + SP_PARAM_PROCESS_KEY: sp_common_param_process, SP_POST_PROCESS_KEY: sp_emc_vnx_post_process, }, SP_CINDER_HPE3PAR: { SP_CONF_NAME_KEY: SP_CINDER_HPE3PAR_PREFIX, - SP_PARAM_PROCESS_KEY: sp_default_param_process, + SP_PARAM_PROCESS_KEY: sp_common_param_process, SP_POST_PROCESS_KEY: sp_hpe3par_post_process, }, SP_CINDER_HPELEFTHAND: { SP_CONF_NAME_KEY: SP_CINDER_HPELEFTHAND_PREFIX, - SP_PARAM_PROCESS_KEY: sp_default_param_process, + SP_PARAM_PROCESS_KEY: sp_common_param_process, SP_POST_PROCESS_KEY: sp_hpelefthand_post_process, }, } @@ -477,19 +540,6 @@ class CinderPuppet(openstack.OpenstackBasePuppet): ceph_type_configs, }) - # TODO(rchurch): Since setting the default volume type can only be done - # via the config file (no cinder cli support), defining this should be - # migrated to a cinder service parameter to easily cover multiple - # backend scenarios with custom volume types. - - # Ceph tiers: Since we may have multiple ceph backends, then prioritize - # the primary backend to maintain existing behavior. - if constants.CINDER_BACKEND_CEPH in enabled_backends: - config.update({ - 'openstack::cinder::api::default_volume_type': - constants.CINDER_BACKEND_CEPH - }) - return config def get_secure_system_config(self): @@ -648,16 +698,21 @@ class CinderPuppet(openstack.OpenstackBasePuppet): if service_parameters is None: return {} + # DEFAULT section may or may not be present therefore reset param list + SP_CINDER_SECTION_MAPPING[ + SP_CINDER_DEFAULT][SP_PROVIDED_PARAMS_LIST_KEY] = {} + + # Eval all currently provided parameters for s in service_parameters: if s.section in SP_CINDER_SECTION_MAPPING: SP_CINDER_SECTION_MAPPING[s.section].get( - SP_PARAM_PROCESS_KEY, sp_default_param_process)( + SP_PARAM_PROCESS_KEY, sp_common_param_process)( config, s.section, SP_CINDER_SECTION_MAPPING[s.section], s.name, s.value) for section, sp_section_map in SP_CINDER_SECTION_MAPPING.items(): - sp_section_map.get(SP_POST_PROCESS_KEY, sp_default_post_process)( + sp_section_map.get(SP_POST_PROCESS_KEY, sp_common_post_process)( config, section, sp_section_map, is_service_enabled, enabled_backends)