File: Fix_openstack_quota_show_without_cinder.patch

package info (click to toggle)
python-openstackclient 8.2.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,952 kB
  • sloc: python: 132,001; makefile: 140; sh: 22
file content (106 lines) | stat: -rw-r--r-- 4,286 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Description: 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.
 .
 [1] https://bugs.debian.org/1109288
Author: Svein-Erik Skjelbred <svein-erik@skjelbred.com>
Date: Mon, 29 Sep 2025 14:59:03 +0200
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>
Forwarded: https://review.opendev.org/c/openstack/python-openstackclient/+/962838
Bug-Debian: https://bugs.debian.org/1109288

diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py
index f706a59..41c57e6 100644
--- a/openstackclient/common/quota.py
+++ b/openstackclient/common/quota.py
@@ -746,21 +746,32 @@
         # values if the project or class does not exist. This is expected
         # behavior. However, we have already checked for the presence of the
         # project above so it shouldn't be an issue.
-        if parsed_args.service in {'all', 'compute'}:
+        if parsed_args.service == 'compute' or (
+            parsed_args.service == 'all'
+            and self.app.client_manager.is_compute_endpoint_enabled()
+        ):
             compute_quota_info = get_compute_quotas(
                 self.app,
                 project,
                 detail=parsed_args.usage,
                 default=parsed_args.default,
             )
-        if parsed_args.service in {'all', 'volume'}:
+
+        if parsed_args.service == 'volume' or (
+            parsed_args.service == 'all'
+            and self.app.client_manager.is_volume_endpoint_enabled()
+        ):
             volume_quota_info = get_volume_quotas(
                 self.app,
                 project,
                 detail=parsed_args.usage,
                 default=parsed_args.default,
             )
-        if parsed_args.service in {'all', 'network'}:
+
+        if parsed_args.service == 'network' or (
+            parsed_args.service == 'all'
+            and self.app.client_manager.is_network_endpoint_enabled()
+        ):
             network_quota_info = get_network_quotas(
                 self.app,
                 project,
@@ -906,12 +917,18 @@
         )
 
         # compute quotas
-        if parsed_args.service in {'all', 'compute'}:
+        if parsed_args.service == 'compute' or (
+            parsed_args.service == 'all'
+            and self.app.client_manager.is_compute_endpoint_enabled()
+        ):
             compute_client = self.app.client_manager.compute
             compute_client.revert_quota_set(project.id)
 
         # volume quotas
-        if parsed_args.service in {'all', 'volume'}:
+        if parsed_args.service == 'volume' or (
+            parsed_args.service == 'all'
+            and self.app.client_manager.is_volume_endpoint_enabled()
+        ):
             volume_client = self.app.client_manager.sdk_connection.volume
             volume_client.revert_quota_set(project.id)
 
diff --git a/openstackclient/tests/unit/common/test_quota.py b/openstackclient/tests/unit/common/test_quota.py
index 53df4da..a2418d0 100644
--- a/openstackclient/tests/unit/common/test_quota.py
+++ b/openstackclient/tests/unit/common/test_quota.py
@@ -1041,6 +1041,26 @@
         )
         self.assertNotCalled(self.network_client.get_quota_default)
 
+    def test_quota_show__missing_services(self):
+        self.app.client_manager.compute_endpoint_enabled = False
+        self.app.client_manager.volume_endpoint_enabled = False
+        self.app.client_manager.network_endpoint_enabled = False
+
+        arglist = [
+            self.projects[0].name,
+        ]
+        verifylist = [
+            ('service', 'all'),
+            ('project', self.projects[0].name),
+        ]
+        parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+        self.cmd.take_action(parsed_args)
+
+        self.compute_client.get_quota_set.assert_not_called()
+        self.volume_sdk_client.get_quota_set.assert_not_called()
+        self.network_client.get_quota.assert_not_called()
+
     def test_quota_show__with_compute(self):
         arglist = [
             '--compute',