Make sure to set default_volume_type when only one storage backend

if there is only one backend, the default_volume_type will not be set.
Then error "default volume type can not be found" will raise when
creating volume from image panel in horizon.

Closes-Bug: 1826259
Change-Id: Ia9c6d30418b41bc15de7a34bec60b3bdae8324d7
Signed-off-by: zhangkunpeng <zhang.kunpeng@99cloud.net>
This commit is contained in:
zhangkunpeng 2019-07-24 11:12:19 +08:00
parent 524c62c426
commit fc2423a511
1 changed files with 12 additions and 11 deletions

View File

@ -103,17 +103,18 @@ class CinderHelm(openstack.OpenstackBaseHelm):
},
}
# If there are more CEPH backends, we default to the volume type
# associated with the primary CEPH tier, which currently has the name
# set to 'ceph-store'.
if len(backends) > 1:
default = next(
(b.name for b in backends
if b.name ==
constants.SB_DEFAULT_NAMES[constants.SB_TYPE_CEPH]), None)
if default:
conf_cinder['DEFAULT']['default_volume_type'] = \
default.encode('utf8', 'strict')
# Always set the default_volume_type to the volume type associated with the
# primary Ceph backend/tier which is available on all StarlingX platform
# configurations. This will guarantee that any Cinder API requests for
# this value will be fulfilled as part of determining a safe volume type to
# use during volume creation. This can be overrides by the user when/if
# additional backends are added to the platform.
default = next(
(b.name for b in backends
if b.name == constants.SB_DEFAULT_NAMES[constants.SB_TYPE_CEPH]), None)
if default:
conf_cinder['DEFAULT']['default_volume_type'] = \
default.encode('utf8', 'strict')
return conf_cinder