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 commitde88853de2) (cherry picked from commit63f78be109)
This commit is contained in:
committed by
Stephen Finucane
parent
bc1930c20e
commit
798832536c
@@ -733,21 +733,32 @@ and ``server-group-members`` output for a given quota class."""
|
||||
# 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,
|
||||
@@ -880,12 +891,18 @@ class DeleteQuota(command.Command):
|
||||
)
|
||||
|
||||
# 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.sdk_connection.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)
|
||||
|
||||
|
||||
@@ -1018,6 +1018,26 @@ class TestQuotaShow(TestQuota):
|
||||
)
|
||||
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_sdk_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',
|
||||
|
||||
Reference in New Issue
Block a user