quota: Trivial style fixups
Change-Id: I4522b54676033dced2b47477238ceb551e11d04a Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
b62021260c
commit
1ff839da76
@ -313,12 +313,14 @@ class ListQuota(command.Lister):
|
|||||||
# NOTE(slaweq): there is no detailed quotas info for some resources
|
# NOTE(slaweq): there is no detailed quotas info for some resources
|
||||||
# and it shouldn't be displayed here
|
# and it shouldn't be displayed here
|
||||||
if isinstance(values, dict):
|
if isinstance(values, dict):
|
||||||
result.append({
|
result.append(
|
||||||
'resource': resource,
|
{
|
||||||
'in_use': values.get('in_use'),
|
'resource': resource,
|
||||||
'reserved': values.get('reserved'),
|
'in_use': values.get('in_use'),
|
||||||
'limit': values.get('limit'),
|
'reserved': values.get('reserved'),
|
||||||
})
|
'limit': values.get('limit'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
columns = (
|
columns = (
|
||||||
'resource',
|
'resource',
|
||||||
@ -375,8 +377,9 @@ class ListQuota(command.Lister):
|
|||||||
data = compute_client.quotas.get(p)
|
data = compute_client.quotas.get(p)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if (
|
if (
|
||||||
type(ex).__name__ == 'NotFound' or
|
type(ex).__name__ == 'NotFound'
|
||||||
ex.http_status >= 400 and ex.http_status <= 499
|
or ex.http_status >= 400
|
||||||
|
and ex.http_status <= 499
|
||||||
):
|
):
|
||||||
# Project not found, move on to next one
|
# Project not found, move on to next one
|
||||||
LOG.warning("Project %s not found: %s" % (p, ex))
|
LOG.warning("Project %s not found: %s" % (p, ex))
|
||||||
@ -537,7 +540,7 @@ class ListQuota(command.Lister):
|
|||||||
'Security Groups',
|
'Security Groups',
|
||||||
'Security Group Rules',
|
'Security Group Rules',
|
||||||
'Subnets',
|
'Subnets',
|
||||||
'Subnet Pools'
|
'Subnet Pools',
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -554,10 +557,13 @@ class SetQuota(common.NetDetectionMixin, command.Command):
|
|||||||
def _build_options_list(self):
|
def _build_options_list(self):
|
||||||
help_fmt = _('New value for the %s quota')
|
help_fmt = _('New value for the %s quota')
|
||||||
# Compute and volume quota options are always the same
|
# Compute and volume quota options are always the same
|
||||||
rets = [(k, v, help_fmt % v) for k, v in itertools.chain(
|
rets = [
|
||||||
COMPUTE_QUOTAS.items(),
|
(k, v, help_fmt % v)
|
||||||
VOLUME_QUOTAS.items(),
|
for k, v in itertools.chain(
|
||||||
)]
|
COMPUTE_QUOTAS.items(),
|
||||||
|
VOLUME_QUOTAS.items(),
|
||||||
|
)
|
||||||
|
]
|
||||||
# For docs build, we want to produce helps for both neutron and
|
# For docs build, we want to produce helps for both neutron and
|
||||||
# nova-network options. They overlap, so we have to figure out which
|
# nova-network options. They overlap, so we have to figure out which
|
||||||
# need to be tagged as specific to one network type or the other.
|
# need to be tagged as specific to one network type or the other.
|
||||||
@ -574,10 +580,12 @@ class SetQuota(common.NetDetectionMixin, command.Command):
|
|||||||
rets.append((k, v, _help))
|
rets.append((k, v, _help))
|
||||||
elif self.is_neutron:
|
elif self.is_neutron:
|
||||||
rets.extend(
|
rets.extend(
|
||||||
[(k, v, help_fmt % v) for k, v in NETWORK_QUOTAS.items()])
|
[(k, v, help_fmt % v) for k, v in NETWORK_QUOTAS.items()]
|
||||||
|
)
|
||||||
elif self.is_nova_network:
|
elif self.is_nova_network:
|
||||||
rets.extend(
|
rets.extend(
|
||||||
[(k, v, help_fmt % v) for k, v in NOVA_NETWORK_QUOTAS.items()])
|
[(k, v, help_fmt % v) for k, v in NOVA_NETWORK_QUOTAS.items()]
|
||||||
|
)
|
||||||
return rets
|
return rets
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
@ -656,8 +664,7 @@ class SetQuota(common.NetDetectionMixin, command.Command):
|
|||||||
for k, v in VOLUME_QUOTAS.items():
|
for k, v in VOLUME_QUOTAS.items():
|
||||||
value = getattr(parsed_args, k, None)
|
value = getattr(parsed_args, k, None)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
if (parsed_args.volume_type and
|
if parsed_args.volume_type and k in IMPACT_VOLUME_TYPE_QUOTAS:
|
||||||
k in IMPACT_VOLUME_TYPE_QUOTAS):
|
|
||||||
k = k + '_%s' % parsed_args.volume_type
|
k = k + '_%s' % parsed_args.volume_type
|
||||||
volume_kwargs[k] = value
|
volume_kwargs[k] = value
|
||||||
|
|
||||||
@ -682,35 +689,34 @@ class SetQuota(common.NetDetectionMixin, command.Command):
|
|||||||
if compute_kwargs:
|
if compute_kwargs:
|
||||||
compute_client.quota_classes.update(
|
compute_client.quota_classes.update(
|
||||||
parsed_args.project,
|
parsed_args.project,
|
||||||
**compute_kwargs)
|
**compute_kwargs,
|
||||||
|
)
|
||||||
if volume_kwargs:
|
if volume_kwargs:
|
||||||
volume_client.quota_classes.update(
|
volume_client.quota_classes.update(
|
||||||
parsed_args.project,
|
parsed_args.project,
|
||||||
**volume_kwargs)
|
**volume_kwargs,
|
||||||
|
)
|
||||||
if network_kwargs:
|
if network_kwargs:
|
||||||
sys.stderr.write("Network quotas are ignored since quota class"
|
sys.stderr.write(
|
||||||
" is not supported.")
|
"Network quotas are ignored since quota classes are not "
|
||||||
|
"supported."
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
project = utils.find_resource(
|
project = utils.find_resource(
|
||||||
identity_client.projects,
|
identity_client.projects,
|
||||||
parsed_args.project,
|
parsed_args.project,
|
||||||
).id
|
).id
|
||||||
|
|
||||||
if compute_kwargs:
|
if compute_kwargs:
|
||||||
compute_client.quotas.update(
|
compute_client.quotas.update(project, **compute_kwargs)
|
||||||
project,
|
|
||||||
**compute_kwargs)
|
|
||||||
if volume_kwargs:
|
if volume_kwargs:
|
||||||
volume_client.quotas.update(
|
volume_client.quotas.update(project, **volume_kwargs)
|
||||||
project,
|
|
||||||
**volume_kwargs)
|
|
||||||
if (
|
if (
|
||||||
network_kwargs and
|
network_kwargs
|
||||||
self.app.client_manager.is_network_endpoint_enabled()
|
and self.app.client_manager.is_network_endpoint_enabled()
|
||||||
):
|
):
|
||||||
network_client = self.app.client_manager.network
|
network_client = self.app.client_manager.network
|
||||||
network_client.update_quota(
|
network_client.update_quota(project, **network_kwargs)
|
||||||
project,
|
|
||||||
**network_kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowQuota(command.Lister):
|
class ShowQuota(command.Lister):
|
||||||
@ -877,13 +883,9 @@ class ShowQuota(command.Lister):
|
|||||||
del info['location']
|
del info['location']
|
||||||
|
|
||||||
if not parsed_args.usage:
|
if not parsed_args.usage:
|
||||||
result = [
|
result = [{'resource': k, 'limit': v} for k, v in info.items()]
|
||||||
{'resource': k, 'limit': v} for k, v in info.items()
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
result = [
|
result = [{'resource': k, **v} for k, v in info.items()]
|
||||||
{'resource': k, **v} for k, v in info.items()
|
|
||||||
]
|
|
||||||
|
|
||||||
columns = (
|
columns = (
|
||||||
'resource',
|
'resource',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user