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)
# We support only cinder v3.
# FIXME: 'block-storage' is also a valid service_type for cinder
candidates = ['volumev3', 'volume']
candidates = ['block-storage', 'block-store', 'volumev3', 'volume']
for service_name in candidates:
try:
@ -1050,7 +1049,8 @@ def message_list(request, search_opts=None):
def is_volume_service_enabled(request):
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, 'volume')
)

View File

@ -19,6 +19,9 @@ class GroupTypes(horizon.Panel):
name = _("Group Types")
slug = 'group_types'
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"),)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,9 @@ class Snapshots(horizon.Panel):
name = _("Snapshots")
slug = 'snapshots'
permissions = (
('openstack.services.volume',
('openstack.services.block-storage',
'openstack.services.block-store',
'openstack.services.volume',
'openstack.services.volumev3'),
)
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.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(
test.IsHttpRequest(), marker=marker, sort_dir=sort_dir,
paginate=True)

View File

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

View File

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

View File

@ -28,7 +28,10 @@ class GroupSnapshots(horizon.Panel):
name = _("Group Snapshots")
slug = 'vg_snapshots'
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"),)

View File

@ -28,7 +28,10 @@ class VolumeGroups(horizon.Panel):
name = _("Groups")
slug = 'volume_groups'
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"),)

View File

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

View File

@ -72,7 +72,11 @@
function initAction() {
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;
} else {
volumeServiceEnabledPromise = false;