From 179c2e3771942f435d9857da8ae38d41d5cc5ea3 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 17 Oct 2024 20:57:45 +0900 Subject: [PATCH] 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 --- openstack_dashboard/api/cinder.py | 6 +++--- .../dashboards/admin/group_types/panel.py | 5 ++++- openstack_dashboard/dashboards/admin/info/tabs.py | 4 +++- .../dashboards/admin/snapshots/panel.py | 4 +++- .../dashboards/admin/volume_types/panel.py | 4 +++- .../dashboards/admin/volumes/panel.py | 4 +++- .../dashboards/project/backups/panel.py | 4 +++- .../dashboards/project/snapshots/panel.py | 4 +++- .../dashboards/project/snapshots/tests.py | 2 +- .../launch-instance-model.service.js | 14 ++++++++++++-- .../launch-instance-model.service.spec.js | 4 ++++ .../dashboards/project/vg_snapshots/panel.py | 5 ++++- .../dashboards/project/volume_groups/panel.py | 5 ++++- .../dashboards/project/volumes/panel.py | 4 +++- .../core/images/actions/create-volume.service.js | 6 +++++- 15 files changed, 58 insertions(+), 17 deletions(-) diff --git a/openstack_dashboard/api/cinder.py b/openstack_dashboard/api/cinder.py index 5cde7d2823..7d023a2134 100644 --- a/openstack_dashboard/api/cinder.py +++ b/openstack_dashboard/api/cinder.py @@ -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') ) diff --git a/openstack_dashboard/dashboards/admin/group_types/panel.py b/openstack_dashboard/dashboards/admin/group_types/panel.py index cdbdbab00c..6e778ed68f 100644 --- a/openstack_dashboard/dashboards/admin/group_types/panel.py +++ b/openstack_dashboard/dashboards/admin/group_types/panel.py @@ -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"),) diff --git a/openstack_dashboard/dashboards/admin/info/tabs.py b/openstack_dashboard/dashboards/admin/info/tabs.py index 5c065876fa..c1d11be644 100644 --- a/openstack_dashboard/dashboards/admin/info/tabs.py +++ b/openstack_dashboard/dashboards/admin/info/tabs.py @@ -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'), ) diff --git a/openstack_dashboard/dashboards/admin/snapshots/panel.py b/openstack_dashboard/dashboards/admin/snapshots/panel.py index bfc2b2f4bf..ec07d04a0f 100644 --- a/openstack_dashboard/dashboards/admin/snapshots/panel.py +++ b/openstack_dashboard/dashboards/admin/snapshots/panel.py @@ -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"),) diff --git a/openstack_dashboard/dashboards/admin/volume_types/panel.py b/openstack_dashboard/dashboards/admin/volume_types/panel.py index c13c0b0a3d..ebd0453299 100644 --- a/openstack_dashboard/dashboards/admin/volume_types/panel.py +++ b/openstack_dashboard/dashboards/admin/volume_types/panel.py @@ -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"),) diff --git a/openstack_dashboard/dashboards/admin/volumes/panel.py b/openstack_dashboard/dashboards/admin/volumes/panel.py index d8892eda0c..208842616a 100644 --- a/openstack_dashboard/dashboards/admin/volumes/panel.py +++ b/openstack_dashboard/dashboards/admin/volumes/panel.py @@ -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"),) diff --git a/openstack_dashboard/dashboards/project/backups/panel.py b/openstack_dashboard/dashboards/project/backups/panel.py index 9ab64e88a8..56ac7f4748 100644 --- a/openstack_dashboard/dashboards/project/backups/panel.py +++ b/openstack_dashboard/dashboards/project/backups/panel.py @@ -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"),) diff --git a/openstack_dashboard/dashboards/project/snapshots/panel.py b/openstack_dashboard/dashboards/project/snapshots/panel.py index 1818a9ee13..47d2d26cd9 100644 --- a/openstack_dashboard/dashboards/project/snapshots/panel.py +++ b/openstack_dashboard/dashboards/project/snapshots/panel.py @@ -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"),) diff --git a/openstack_dashboard/dashboards/project/snapshots/tests.py b/openstack_dashboard/dashboards/project/snapshots/tests.py index 56d7234481..334c34b1fe 100644 --- a/openstack_dashboard/dashboards/project/snapshots/tests.py +++ b/openstack_dashboard/dashboards/project/snapshots/tests.py @@ -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) diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js index 0c22a9a65c..b735909208 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js @@ -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; diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js index 52f1f2e767..568dc20b65 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js @@ -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(); } diff --git a/openstack_dashboard/dashboards/project/vg_snapshots/panel.py b/openstack_dashboard/dashboards/project/vg_snapshots/panel.py index f204eba42b..3ea05e3e51 100644 --- a/openstack_dashboard/dashboards/project/vg_snapshots/panel.py +++ b/openstack_dashboard/dashboards/project/vg_snapshots/panel.py @@ -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"),) diff --git a/openstack_dashboard/dashboards/project/volume_groups/panel.py b/openstack_dashboard/dashboards/project/volume_groups/panel.py index 83880a811f..b57f0f77a6 100644 --- a/openstack_dashboard/dashboards/project/volume_groups/panel.py +++ b/openstack_dashboard/dashboards/project/volume_groups/panel.py @@ -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"),) diff --git a/openstack_dashboard/dashboards/project/volumes/panel.py b/openstack_dashboard/dashboards/project/volumes/panel.py index 84af9ef6dd..c07aa184d7 100644 --- a/openstack_dashboard/dashboards/project/volumes/panel.py +++ b/openstack_dashboard/dashboards/project/volumes/panel.py @@ -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"),) diff --git a/openstack_dashboard/static/app/core/images/actions/create-volume.service.js b/openstack_dashboard/static/app/core/images/actions/create-volume.service.js index 1a41b68f66..c6ad911a53 100644 --- a/openstack_dashboard/static/app/core/images/actions/create-volume.service.js +++ b/openstack_dashboard/static/app/core/images/actions/create-volume.service.js @@ -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;