Merge "Fix openstack quota show without cinder"
This commit is contained in:
@@ -746,21 +746,32 @@ and ``server-group-members`` output for a given quota class."""
|
|||||||
# values if the project or class does not exist. This is expected
|
# values if the project or class does not exist. This is expected
|
||||||
# behavior. However, we have already checked for the presence of the
|
# behavior. However, we have already checked for the presence of the
|
||||||
# project above so it shouldn't be an issue.
|
# 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(
|
compute_quota_info = get_compute_quotas(
|
||||||
self.app,
|
self.app,
|
||||||
project,
|
project,
|
||||||
detail=parsed_args.usage,
|
detail=parsed_args.usage,
|
||||||
default=parsed_args.default,
|
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(
|
volume_quota_info = get_volume_quotas(
|
||||||
self.app,
|
self.app,
|
||||||
project,
|
project,
|
||||||
detail=parsed_args.usage,
|
detail=parsed_args.usage,
|
||||||
default=parsed_args.default,
|
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(
|
network_quota_info = get_network_quotas(
|
||||||
self.app,
|
self.app,
|
||||||
project,
|
project,
|
||||||
@@ -906,12 +917,18 @@ class DeleteQuota(command.Command):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# compute quotas
|
# 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 = self.app.client_manager.compute
|
||||||
compute_client.revert_quota_set(project.id)
|
compute_client.revert_quota_set(project.id)
|
||||||
|
|
||||||
# volume quotas
|
# 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 = self.app.client_manager.sdk_connection.volume
|
||||||
volume_client.revert_quota_set(project.id)
|
volume_client.revert_quota_set(project.id)
|
||||||
|
|
||||||
|
@@ -1041,6 +1041,26 @@ class TestQuotaShow(TestQuota):
|
|||||||
)
|
)
|
||||||
self.assertNotCalled(self.network_client.get_quota_default)
|
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):
|
def test_quota_show__with_compute(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--compute',
|
'--compute',
|
||||||
|
Reference in New Issue
Block a user