X Tutup
Skip to content

Commit 7988325

Browse files
thomasgoirandstephenfin
authored andcommitted
Fix openstack quota show without cinder
Per this Debian bug [1], 'openstack quota show --default' fails when cinder is NOT installed. This is also true of other services. Conflicts: openstackclient/common/quota.py NOTE(stephenfin): Conflicts are due to the absence of change I43d9ede39d36cc29301f94fa462b9b9d9441807c which repurposed the compute client attribute for the SDK client. We also need to update the new test to reflect this old naming scheme. [1] https://bugs.debian.org/1109288 Change-Id: I361da44b9f1d09ba3a454632d41e2110a3815395 Signed-off-by: Svein-Erik Skjelbred <svein-erik@skjelbred.com> Signed-off-by: Thomas Goirand <zigo@debian.org> Signed-off-by: Stephen Finucane <stephenfin@redhat.com> (cherry picked from commit de88853) (cherry picked from commit 63f78be)
1 parent bc1930c commit 7988325

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

openstackclient/common/quota.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -733,21 +733,32 @@ def take_action(self, parsed_args):
733733
# values if the project or class does not exist. This is expected
734734
# behavior. However, we have already checked for the presence of the
735735
# project above so it shouldn't be an issue.
736-
if parsed_args.service in {'all', 'compute'}:
736+
if parsed_args.service == 'compute' or (
737+
parsed_args.service == 'all'
738+
and self.app.client_manager.is_compute_endpoint_enabled()
739+
):
737740
compute_quota_info = get_compute_quotas(
738741
self.app,
739742
project,
740743
detail=parsed_args.usage,
741744
default=parsed_args.default,
742745
)
743-
if parsed_args.service in {'all', 'volume'}:
746+
747+
if parsed_args.service == 'volume' or (
748+
parsed_args.service == 'all'
749+
and self.app.client_manager.is_volume_endpoint_enabled()
750+
):
744751
volume_quota_info = get_volume_quotas(
745752
self.app,
746753
project,
747754
detail=parsed_args.usage,
748755
default=parsed_args.default,
749756
)
750-
if parsed_args.service in {'all', 'network'}:
757+
758+
if parsed_args.service == 'network' or (
759+
parsed_args.service == 'all'
760+
and self.app.client_manager.is_network_endpoint_enabled()
761+
):
751762
network_quota_info = get_network_quotas(
752763
self.app,
753764
project,
@@ -880,12 +891,18 @@ def take_action(self, parsed_args):
880891
)
881892

882893
# compute quotas
883-
if parsed_args.service in {'all', 'compute'}:
894+
if parsed_args.service == 'compute' or (
895+
parsed_args.service == 'all'
896+
and self.app.client_manager.is_compute_endpoint_enabled()
897+
):
884898
compute_client = self.app.client_manager.sdk_connection.compute
885899
compute_client.revert_quota_set(project.id)
886900

887901
# volume quotas
888-
if parsed_args.service in {'all', 'volume'}:
902+
if parsed_args.service == 'volume' or (
903+
parsed_args.service == 'all'
904+
and self.app.client_manager.is_volume_endpoint_enabled()
905+
):
889906
volume_client = self.app.client_manager.sdk_connection.volume
890907
volume_client.revert_quota_set(project.id)
891908

openstackclient/tests/unit/common/test_quota.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,26 @@ def test_quota_show(self):
10181018
)
10191019
self.assertNotCalled(self.network_client.get_quota_default)
10201020

1021+
def test_quota_show__missing_services(self):
1022+
self.app.client_manager.compute_endpoint_enabled = False
1023+
self.app.client_manager.volume_endpoint_enabled = False
1024+
self.app.client_manager.network_endpoint_enabled = False
1025+
1026+
arglist = [
1027+
self.projects[0].name,
1028+
]
1029+
verifylist = [
1030+
('service', 'all'),
1031+
('project', self.projects[0].name),
1032+
]
1033+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1034+
1035+
self.cmd.take_action(parsed_args)
1036+
1037+
self.compute_sdk_client.get_quota_set.assert_not_called()
1038+
self.volume_sdk_client.get_quota_set.assert_not_called()
1039+
self.network_client.get_quota.assert_not_called()
1040+
10211041
def test_quota_show__with_compute(self):
10221042
arglist = [
10231043
'--compute',

0 commit comments

Comments
 (0)
X Tutup