From 8bd8a8dfd7d330573740f7610ea28ae291d1e4e2 Mon Sep 17 00:00:00 2001 From: Steve Martinelli Date: Fri, 3 Apr 2015 03:12:27 -0400 Subject: [PATCH] Add support to specify volume quotas per volume type Add a --volume-type option to quota set, this will allow users to set quotas for volume attributes on a per volume-type basis. for example: openstack quota set admin --volume-type myvol --volumes 12 Change-Id: I3ce9cf82a65d4f012b339f0e0dedb752cb132c33 Closes-Bug: 1438377 --- doc/source/command-objects/quota.rst | 5 +++++ openstackclient/common/quota.py | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/source/command-objects/quota.rst b/doc/source/command-objects/quota.rst index 053fb47acc..5ea49f8c52 100644 --- a/doc/source/command-objects/quota.rst +++ b/doc/source/command-objects/quota.rst @@ -30,6 +30,7 @@ Set quotas for project [--gigabytes ] [--snapshots ] [--volumes ] + [--volume-type ] @@ -121,6 +122,10 @@ Set quotas for class New value for the snapshots quota +.. option:: --volume-type + + Set quotas for a specific + quota show ---------- diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py index dde4a9acb6..ea1dc38f58 100644 --- a/openstackclient/common/quota.py +++ b/openstackclient/common/quota.py @@ -82,6 +82,11 @@ class SetQuota(command.Command): type=int, help='New value for the %s quota' % v, ) + parser.add_argument( + '--volume-type', + metavar='', + help='Set quotas for a specific ', + ) return parser def take_action(self, parsed_args): @@ -97,8 +102,11 @@ class SetQuota(command.Command): volume_kwargs = {} for k, v in VOLUME_QUOTAS.items(): - if v in parsed_args: - volume_kwargs[k] = getattr(parsed_args, v, None) + value = getattr(parsed_args, v, None) + if value is not None: + if parsed_args.volume_type: + k = k + '_%s' % parsed_args.volume_type + volume_kwargs[k] = value if compute_kwargs == {} and volume_kwargs == {}: sys.stderr.write("No quotas updated")