cinder: Use 'block-storage' service type to detect cinder

The official service type name for cinder is not volume (or volumevN)
but block-storage. Use the block-storage type to detect availability
of cinder, in addition to legacy volume/volumev3 service type.

'block-store' is also a valid alias and should be added as well.

Closes-Bug: #2084794
Change-Id: Ifbeaba033c6dae0fa704a2be568b2f4e2cb7426a
This commit is contained in:
Takashi Kajinami 2024-10-17 20:57:45 +09:00 committed by Tatiana Ovchinnikova
parent 5d3bea0ae3
commit 179c2e3771
15 changed files with 58 additions and 17 deletions

View File

@ -214,8 +214,7 @@ def _find_cinder_url(request, version=None):
version = base.Version(version) version = base.Version(version)
# We support only cinder v3. # We support only cinder v3.
# FIXME: 'block-storage' is also a valid service_type for cinder candidates = ['block-storage', 'block-store', 'volumev3', 'volume']
candidates = ['volumev3', 'volume']
for service_name in candidates: for service_name in candidates:
try: try:
@ -1050,7 +1049,8 @@ def message_list(request, search_opts=None):
def is_volume_service_enabled(request): def is_volume_service_enabled(request):
return bool( return bool(
# FIXME: 'block-storage' is also a valid service_type for cinder base.is_service_enabled(request, 'block-storage') or
base.is_service_enabled(request, 'block-store') or
base.is_service_enabled(request, 'volumev3') or base.is_service_enabled(request, 'volumev3') or
base.is_service_enabled(request, 'volume') base.is_service_enabled(request, 'volume')
) )

View File

@ -19,6 +19,9 @@ class GroupTypes(horizon.Panel):
name = _("Group Types") name = _("Group Types")
slug = 'group_types' slug = 'group_types'
permissions = ( permissions = (
('openstack.services.volume', 'openstack.services.volumev3'), ('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'),
) )
policy_rules = (("volume", "group:group_types_manage"),) policy_rules = (("volume", "group:group_types_manage"),)

View File

@ -77,7 +77,9 @@ class CinderServicesTab(tabs.TableTab):
slug = tables.CinderServicesTable.Meta.name slug = tables.CinderServicesTable.Meta.name
template_name = constants.INFO_DETAIL_TEMPLATE_NAME template_name = constants.INFO_DETAIL_TEMPLATE_NAME
permissions = ( permissions = (
('openstack.services.volume', ('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'), 'openstack.services.volumev3'),
) )

View File

@ -21,7 +21,9 @@ class Snapshots(horizon.Panel):
name = _("Snapshots") name = _("Snapshots")
slug = 'snapshots' slug = 'snapshots'
permissions = ( permissions = (
('openstack.services.volume', ('openstack.services/block-storage',
'openstack.services/block-store',
'openstack.services.volume',
'openstack.services.volumev3'), 'openstack.services.volumev3'),
) )
policy_rules = (("volume", "context_is_admin"),) policy_rules = (("volume", "context_is_admin"),)

View File

@ -21,7 +21,9 @@ class VolumeTypes(horizon.Panel):
name = _("Volume Types") name = _("Volume Types")
slug = 'volume_types' slug = 'volume_types'
permissions = ( permissions = (
('openstack.services.volume', ('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'), 'openstack.services.volumev3'),
) )
policy_rules = (("volume", "volume_extension:types_manage"),) policy_rules = (("volume", "volume_extension:types_manage"),)

View File

@ -19,7 +19,9 @@ class Volumes(horizon.Panel):
name = _("Volumes") name = _("Volumes")
slug = "volumes" slug = "volumes"
permissions = ( permissions = (
('openstack.services.volume', ('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'), 'openstack.services.volumev3'),
) )
policy_rules = (("volume", "context_is_admin"),) policy_rules = (("volume", "context_is_admin"),)

View File

@ -23,7 +23,9 @@ class Backups(horizon.Panel):
name = _("Backups") name = _("Backups")
slug = 'backups' slug = 'backups'
permissions = ( permissions = (
('openstack.services.volume', ('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'), 'openstack.services.volumev3'),
) )
policy_rules = (("volume", "backup:get_all"),) policy_rules = (("volume", "backup:get_all"),)

View File

@ -21,7 +21,9 @@ class Snapshots(horizon.Panel):
name = _("Snapshots") name = _("Snapshots")
slug = 'snapshots' slug = 'snapshots'
permissions = ( permissions = (
('openstack.services.volume', ('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'), 'openstack.services.volumev3'),
) )
policy_rules = (("volume", "volume:get_all_snapshots"),) policy_rules = (("volume", "volume:get_all_snapshots"),)

View File

@ -55,7 +55,7 @@ class VolumeSnapshotsViewTests(test.TestCase):
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_is_service_enabled, 2, self.mock_is_service_enabled, 2,
mock.call(test.IsHttpRequest(), 'volumev3')) mock.call(test.IsHttpRequest(), 'block-storage'))
self.mock_volume_snapshot_list_paged.assert_called_once_with( self.mock_volume_snapshot_list_paged.assert_called_once_with(
test.IsHttpRequest(), marker=marker, sort_dir=sort_dir, test.IsHttpRequest(), marker=marker, sort_dir=sort_dir,
paginate=True) paginate=True)

View File

@ -610,9 +610,19 @@
var volumeDeferred = $q.defer(); var volumeDeferred = $q.defer();
var volumeSnapshotDeferred = $q.defer(); var volumeSnapshotDeferred = $q.defer();
var absoluteLimitsDeferred = $q.defer(); var absoluteLimitsDeferred = $q.defer();
serviceCatalog
.ifTypeEnabled('block-storage')
.then(onVolumeServiceEnabled, onCheckBlockStore);
function onCheckBlockStore() {
serviceCatalog
.ifTypeEnabled('block-store')
.then(onVolumeServiceEnabled, onCheckVolumeV3);
}
function onCheckVolumeV3() {
serviceCatalog serviceCatalog
.ifTypeEnabled('volumev3') .ifTypeEnabled('volumev3')
.then(onVolumeServiceEnabled, resolvePromises); .then(onVolumeServiceEnabled, resolvePromises);
}
function onVolumeServiceEnabled() { function onVolumeServiceEnabled() {
model.volumeBootable = true; model.volumeBootable = true;
model.allowCreateVolumeFromImage = true; model.allowCreateVolumeFromImage = true;

View File

@ -239,6 +239,10 @@
deferred.resolve(); deferred.resolve();
} else if (theType === 'volumev3' && cinderEnabled) { } else if (theType === 'volumev3' && cinderEnabled) {
deferred.resolve(); deferred.resolve();
} else if (theType === 'block-storage' && cinderEnabled) {
deferred.resolve();
} else if (theType === 'block-store' && cinderEnabled) {
deferred.resolve();
} else { } else {
deferred.reject(); deferred.reject();
} }

View File

@ -28,7 +28,10 @@ class GroupSnapshots(horizon.Panel):
name = _("Group Snapshots") name = _("Group Snapshots")
slug = 'vg_snapshots' slug = 'vg_snapshots'
permissions = ( permissions = (
('openstack.services.volume', 'openstack.services.volumev3'), ('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'),
) )
policy_rules = (("volume", "group:get_all_group_snapshots"),) policy_rules = (("volume", "group:get_all_group_snapshots"),)

View File

@ -28,7 +28,10 @@ class VolumeGroups(horizon.Panel):
name = _("Groups") name = _("Groups")
slug = 'volume_groups' slug = 'volume_groups'
permissions = ( permissions = (
('openstack.services.volume', 'openstack.services.volumev3'), ('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'),
) )
policy_rules = (("volume", "group:get_all"),) policy_rules = (("volume", "group:get_all"),)

View File

@ -21,7 +21,9 @@ class Volumes(horizon.Panel):
name = _("Volumes") name = _("Volumes")
slug = 'volumes' slug = 'volumes'
permissions = ( permissions = (
('openstack.services.volume', ('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'), 'openstack.services.volumev3'),
) )
policy_rules = (("volume", "volume:get_all"),) policy_rules = (("volume", "volume:get_all"),)

View File

@ -72,7 +72,11 @@
function initAction() { function initAction() {
createVolumePromise = policy.ifAllowed({rules: [['volume', 'volume:create']]}); createVolumePromise = policy.ifAllowed({rules: [['volume', 'volume:create']]});
if (serviceCatalog.ifTypeEnabled('volumev3')) { if (serviceCatalog.ifTypeEnabled('block-storage')) {
volumeServiceEnabledPromise = true;
} else if (serviceCatalog.ifTypeEnabled('block-store')) {
volumeServiceEnabledPromise = true;
} else if (serviceCatalog.ifTypeEnabled('volumev3')) {
volumeServiceEnabledPromise = true; volumeServiceEnabledPromise = true;
} else { } else {
volumeServiceEnabledPromise = false; volumeServiceEnabledPromise = false;