diff --git a/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_iscsi.py b/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_iscsi.py index bb036ae53ba..21c7652211b 100644 --- a/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_iscsi.py +++ b/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_iscsi.py @@ -90,7 +90,7 @@ class HNASiSCSIDriverTest(test.TestCase): 'iscsi_ip': '172.17.39.132', 'iscsi_port': '3260', 'port': '22', - 'volume_type': 'default', + 'pool_name': 'default', 'label': 'svc_0', 'evs': '1', 'tgt': { @@ -103,7 +103,7 @@ class HNASiSCSIDriverTest(test.TestCase): 'iscsi_ip': '172.17.39.133', 'iscsi_port': '3260', 'port': '22', - 'volume_type': 'silver', + 'pool_name': 'silver', 'label': 'svc_1', 'evs': '2', 'tgt': { diff --git a/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_nfs.py b/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_nfs.py index 1fdd3ebe32e..792ae631af1 100644 --- a/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_nfs.py +++ b/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_nfs.py @@ -100,7 +100,7 @@ class HNASNFSDriverTest(test.TestCase): 'services': { 'default': { 'hdp': '172.24.49.21:/fs-cinder', - 'volume_type': 'default', + 'pool_name': 'default', 'label': 'svc_0', 'ctl': '1', 'export': { diff --git a/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_utils.py b/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_utils.py index 094d075e1f6..099523774b3 100644 --- a/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_utils.py +++ b/cinder/tests/unit/volume/drivers/hitachi/test_hitachi_hnas_utils.py @@ -54,11 +54,11 @@ config_from_cinder_conf = { 'services': { 'default': { 'label': u'svc_0', - 'volume_type': 'default', + 'pool_name': 'default', 'hdp': 'easy-stack'}, 'FS-CinderDev1': { 'label': u'svc_1', - 'volume_type': 'FS-CinderDev1', + 'pool_name': 'FS-CinderDev1', 'hdp': 'silver'}}, 'password': 'supervisor'} @@ -137,9 +137,9 @@ parsed_xml = {'username': 'supervisor', 'password': 'supervisor', 'cluster_admin_ip0': None, 'ssh_private_key': '/home/ubuntu/.ssh/id_rsa', 'services': { - 'default': {'hdp': 'easy-stack', 'volume_type': 'default', + 'default': {'hdp': 'easy-stack', 'pool_name': 'default', 'label': 'svc_0'}, - 'silver': {'hdp': 'FS-CinderDev1', 'volume_type': 'silver', + 'silver': {'hdp': 'FS-CinderDev1', 'pool_name': 'silver', 'label': 'svc_1'}}, 'mgmt_ip0': '172.24.44.15'} @@ -165,10 +165,10 @@ class HNASUtilsTest(test.TestCase): self.override_config('hnas_username', 'supervisor') self.override_config('hnas_password', 'supervisor') self.override_config('hnas_mgmt_ip0', '172.24.44.15') - self.override_config('hnas_svc0_volume_type', 'default') + self.override_config('hnas_svc0_pool_name', 'default') self.override_config('hnas_svc0_hdp', 'easy-stack') self.override_config('hnas_svc0_iscsi_ip', '172.24.49.21') - self.override_config('hnas_svc1_volume_type', 'FS-CinderDev1') + self.override_config('hnas_svc1_pool_name', 'FS-CinderDev1') self.override_config('hnas_svc1_hdp', 'silver') self.override_config('hnas_svc1_iscsi_ip', '172.24.49.32') @@ -318,7 +318,7 @@ class HNASUtilsTest(test.TestCase): self.assertIsNone(out) @ddt.data('hnas_username', 'hnas_password', - 'hnas_mgmt_ip0', 'hnas_svc0_iscsi_ip', 'hnas_svc0_volume_type', + 'hnas_mgmt_ip0', 'hnas_svc0_iscsi_ip', 'hnas_svc0_pool_name', 'hnas_svc0_hdp', ) def test_init_invalid_conf_parameters(self, attr_name): self.override_config(attr_name, None) diff --git a/cinder/volume/drivers/hitachi/hnas_iscsi.py b/cinder/volume/drivers/hitachi/hnas_iscsi.py index d8c10ac9560..4dc789b7a62 100644 --- a/cinder/volume/drivers/hitachi/hnas_iscsi.py +++ b/cinder/volume/drivers/hitachi/hnas_iscsi.py @@ -341,8 +341,6 @@ class HNASISCSIDriver(driver.ISCSIDriver): """ pool_from_vol_type = hnas_utils.get_pool(self.config, volume) - pool_from_host = utils.extract_host(volume.host, level='pool') - if (pool_from_vol_type == 'default' and 'default' not in self.config['services']): msg = (_("Failed to manage existing volume %(volume)s because the " @@ -350,7 +348,8 @@ class HNASISCSIDriver(driver.ISCSIDriver): "service_label configured in its extra-specs and there " "is no pool configured with hnas_svcX_volume_type as " "'default' in cinder.conf.") % - {'volume': volume.id, 'vol_type': volume.volume_type['id']}) + {'volume': volume.id, + 'vol_type': getattr(volume.volume_type, 'id', None)}) LOG.error(msg) raise exception.ManageExistingVolumeTypeMismatch(reason=msg) @@ -364,6 +363,8 @@ class HNASISCSIDriver(driver.ISCSIDriver): LOG.error(msg) raise exception.ManageExistingVolumeTypeMismatch(reason=msg) + pool_from_host = utils.extract_host(volume.host, level='pool') + if pool_from_host != pool_from_vol_type: msg = (_("Failed to manage existing volume because the pool " "%(pool)s of the volume type chosen does not match the " @@ -417,8 +418,8 @@ class HNASISCSIDriver(driver.ISCSIDriver): for svc in service_list: svc = self.config['services'][svc] pool = {} - pool['pool_name'] = svc['volume_type'] - pool['service_label'] = svc['volume_type'] + pool['pool_name'] = svc['pool_name'] + pool['service_label'] = svc['pool_name'] pool['fs'] = svc['hdp'] self.pools.append(pool) diff --git a/cinder/volume/drivers/hitachi/hnas_nfs.py b/cinder/volume/drivers/hitachi/hnas_nfs.py index 84c2c2331be..51652d77b5c 100644 --- a/cinder/volume/drivers/hitachi/hnas_nfs.py +++ b/cinder/volume/drivers/hitachi/hnas_nfs.py @@ -367,8 +367,8 @@ class HNASNFSDriver(nfs.NfsDriver): for svc in service_list: svc = self.config['services'][svc] pool = {} - pool['pool_name'] = svc['volume_type'] - pool['service_label'] = svc['volume_type'] + pool['pool_name'] = svc['pool_name'] + pool['service_label'] = svc['pool_name'] pool['fs'] = svc['hdp'] self.pools.append(pool) @@ -572,10 +572,13 @@ class HNASNFSDriver(nfs.NfsDriver): if (pool_from_vol_type == 'default' and 'default' not in self.config['services']): - msg = (_("Failed to manage existing volume because the chosen " - "volume type does not have a service_label configured in " - "its extra-specs and there is no pool configured with " - "hnas_svcX_volume_type as 'default' in cinder.conf.")) + msg = (_("Failed to manage existing volume %(volume)s because the " + "chosen volume type %(vol_type)s does not have a " + "service_label configured in its extra-specs and there " + "is no pool configured with hnas_svcX_volume_type as " + "'default' in cinder.conf.") % + {'volume': volume.id, + 'vol_type': getattr(volume.volume_type, 'id', None)}) LOG.error(msg) raise exception.ManageExistingVolumeTypeMismatch(reason=msg) diff --git a/cinder/volume/drivers/hitachi/hnas_utils.py b/cinder/volume/drivers/hitachi/hnas_utils.py index f6355fb58a0..0778478a728 100644 --- a/cinder/volume/drivers/hitachi/hnas_utils.py +++ b/cinder/volume/drivers/hitachi/hnas_utils.py @@ -60,20 +60,24 @@ drivers_common_opts = [ default=None, help='The IP of the HNAS cluster admin. ' 'Required only for HNAS multi-cluster setups.'), - cfg.StrOpt('hnas_svc0_volume_type', - help='Service 0 volume type'), + cfg.StrOpt('hnas_svc0_pool_name', + help='Service 0 pool name', + deprecated_name='hnas_svc0_volume_type'), cfg.StrOpt('hnas_svc0_hdp', help='Service 0 HDP'), - cfg.StrOpt('hnas_svc1_volume_type', - help='Service 1 volume type'), + cfg.StrOpt('hnas_svc1_pool_name', + help='Service 1 pool name', + deprecated_name='hnas_svc1_volume_type'), cfg.StrOpt('hnas_svc1_hdp', help='Service 1 HDP'), - cfg.StrOpt('hnas_svc2_volume_type', - help='Service 2 volume type'), + cfg.StrOpt('hnas_svc2_pool_name', + help='Service 2 pool name', + deprecated_name='hnas_svc2_volume_type'), cfg.StrOpt('hnas_svc2_hdp', help='Service 2 HDP'), - cfg.StrOpt('hnas_svc3_volume_type', - help='Service 3 volume type'), + cfg.StrOpt('hnas_svc3_pool_name', + help='Service 3 pool name:', + deprecated_name='hnas_svc3_volume_type'), cfg.StrOpt('hnas_svc3_hdp', help='Service 3 HDP') ] @@ -82,11 +86,11 @@ CONF = cfg.CONF CONF.register_opts(drivers_common_opts) -def _check_conf_params(config, vol_type, dv_type, idx): +def _check_conf_params(config, pool_name, dv_type, idx): """Validates if the configuration on cinder.conf is complete. :param config: Dictionary with the driver configurations - :param vol_type: The volume type of the current pool + :param pool_name: The name of the current pool :param dv_type: The type of the driver (NFS or iSCSI) :param idx: Index of the current pool """ @@ -113,7 +117,7 @@ def _check_conf_params(config, vol_type, dv_type, idx): LOG.error(msg) raise exception.InvalidParameterValue(err=msg) - if config['services'][vol_type]['hdp'] is None: + if config['services'][pool_name]['hdp'] is None: msg = (_("The config parameter hnas_svc%(idx)s_hdp is " "not set in the cinder.conf. Note that you need to " "have at least one pool configured.") % @@ -121,9 +125,9 @@ def _check_conf_params(config, vol_type, dv_type, idx): LOG.error(msg) raise exception.InvalidParameterValue(err=msg) - if config['services'][vol_type]['volume_type'] is None: + if config['services'][pool_name]['pool_name'] is None: msg = (_("The config parameter " - "hnas_svc%(idx)s_volume_type is not set " + "hnas_svc%(idx)s_pool_name is not set " "in the cinder.conf. Note that you need to " "have at least one pool configured.") % {'idx': idx}) @@ -131,7 +135,7 @@ def _check_conf_params(config, vol_type, dv_type, idx): raise exception.InvalidParameterValue(err=msg) if (dv_type == 'iscsi' and - config['services'][vol_type]['iscsi_ip'] is None): + config['services'][pool_name]['iscsi_ip'] is None): msg = (_("The config parameter " "hnas_svc%(idx)s_iscsi_ip is not set " "in the cinder.conf. Note that you need to " @@ -241,7 +245,11 @@ def read_xml_config(xml_config_file, svc_params, optional_params): # none optional for arg in svc_params: service[arg] = _xml_read(root, svc + '/' + arg, 'check') - config['services'][service['volume_type']] = service + + # Backward compatibility with volume_type + service.setdefault('pool_name', service.pop('volume_type', None)) + + config['services'][service['pool_name']] = service config['fs'][service['hdp']] = service['hdp'] # at least one service required! @@ -312,28 +320,28 @@ def read_cinder_conf(config_opts, dv_type): # It's possible to have up to 4 pools configured. for i in range(0, 4): idx = six.text_type(i) - svc_vol_type = (config_opts.safe_get( - 'hnas_svc%(idx)s_volume_type' % {'idx': idx})) + svc_pool_name = (config_opts.safe_get( + 'hnas_svc%(idx)s_pool_name' % {'idx': idx})) svc_hdp = (config_opts.safe_get( 'hnas_svc%(idx)s_hdp' % {'idx': idx})) # It's mandatory to have at least 1 pool configured (svc_0) - if (idx == '0' or svc_vol_type is not None or + if (idx == '0' or svc_pool_name is not None or svc_hdp is not None): - config['services'][svc_vol_type] = {} + config['services'][svc_pool_name] = {} config['fs'][svc_hdp] = svc_hdp - config['services'][svc_vol_type]['hdp'] = svc_hdp - config['services'][svc_vol_type]['volume_type'] = svc_vol_type + config['services'][svc_pool_name]['hdp'] = svc_hdp + config['services'][svc_pool_name]['pool_name'] = svc_pool_name if dv_type == 'iscsi': svc_ip = (config_opts.safe_get( 'hnas_svc%(idx)s_iscsi_ip' % {'idx': idx})) - config['services'][svc_vol_type]['iscsi_ip'] = svc_ip + config['services'][svc_pool_name]['iscsi_ip'] = svc_ip - config['services'][svc_vol_type]['label'] = ( + config['services'][svc_pool_name]['label'] = ( 'svc_%(idx)s' % {'idx': idx}) # Checking to ensure that the pools configurations are complete - _check_conf_params(config, svc_vol_type, dv_type, idx) + _check_conf_params(config, svc_pool_name, dv_type, idx) return config diff --git a/releasenotes/notes/hnas-deprecated-svc-volume-type-77768f27946aadf4.yaml b/releasenotes/notes/hnas-deprecated-svc-volume-type-77768f27946aadf4.yaml new file mode 100644 index 00000000000..43d8160b8e8 --- /dev/null +++ b/releasenotes/notes/hnas-deprecated-svc-volume-type-77768f27946aadf4.yaml @@ -0,0 +1,4 @@ +--- +deprecations: + - Deprecated the configuration option ``hnas_svcX_volume_type``. Use option + ``hnas_svcX_pool_name`` to indicate the name of the services (pools).