From be8326b7ccb0c8ca7eadb1424ed3bb29387174b0 Mon Sep 17 00:00:00 2001 From: Victoria Martinez de la Cruz Date: Tue, 17 Aug 2021 18:20:42 +0000 Subject: [PATCH] Add share groups/share group snaps to quota class Share groups and share group snapshots can be now updated through the quota class API This change adds this option to the manilaclient CLI Closes-Bug: #1871252 Change-Id: If2faf8a88a0a0e39d7fd0554bc3e530e18c3e922 --- manilaclient/tests/unit/v2/test_shell.py | 9 +++++- manilaclient/v2/quota_classes.py | 28 ++++++++++++++++--- manilaclient/v2/shell.py | 27 +++++++++++++++++- ...hare-group-snapshots-20ec1dfcc0a7e81c.yaml | 8 ++++++ 4 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/bug-1871252-update-default-quotas-via-quota-class-share-groups-share-group-snapshots-20ec1dfcc0a7e81c.yaml diff --git a/manilaclient/tests/unit/v2/test_shell.py b/manilaclient/tests/unit/v2/test_shell.py index 3c6e82a52..e6af7b50a 100644 --- a/manilaclient/tests/unit/v2/test_shell.py +++ b/manilaclient/tests/unit/v2/test_shell.py @@ -3185,7 +3185,14 @@ class ShellTest(test_utils.TestCase): '--snapshots': 5, '--gigabytes': 5, '--snapshot-gigabytes': 5, - '--share-networks': 5}) + '--share-networks': 5}, + {'--shares': 5, + '--snapshots': 5, + '--gigabytes': 5, + '--snapshot-gigabytes': 5, + '--share-networks': 5, + '--share-groups': 5, + '--share-group-snapshots': 5}) def test_quota_class_update(self, data): cmd = 'quota-class-update test' expected = dict() diff --git a/manilaclient/v2/quota_classes.py b/manilaclient/v2/quota_classes.py index a3d33d1c1..4ccd04f35 100644 --- a/manilaclient/v2/quota_classes.py +++ b/manilaclient/v2/quota_classes.py @@ -55,6 +55,7 @@ class QuotaClassSetManager(base.ManagerWithFind): snapshots=None, snapshot_gigabytes=None, share_networks=None, share_replicas=None, replica_gigabytes=None, per_share_gigabytes=None, + share_groups=None, share_group_snapshots=None, resource_path=RESOURCE_PATH): body = { 'quota_class_set': { @@ -67,6 +68,8 @@ class QuotaClassSetManager(base.ManagerWithFind): "share_replicas": share_replicas, "replica_gigabytes": replica_gigabytes, 'per_share_gigabytes': per_share_gigabytes, + 'share_groups': share_groups, + 'share_group_snapshots': share_group_snapshots, } } @@ -88,7 +91,7 @@ class QuotaClassSetManager(base.ManagerWithFind): snapshots=snapshots, snapshot_gigabytes=snapshot_gigabytes, share_networks=share_networks, resource_path=RESOURCE_PATH_LEGACY) - @api_versions.wraps("2.7", "2.52") # noqa + @api_versions.wraps("2.7", "2.39") # noqa def update(self, class_name, shares=None, gigabytes=None, # noqa snapshots=None, snapshot_gigabytes=None, share_networks=None): return self._do_update( @@ -96,25 +99,42 @@ class QuotaClassSetManager(base.ManagerWithFind): snapshots=snapshots, snapshot_gigabytes=snapshot_gigabytes, share_networks=share_networks, resource_path=RESOURCE_PATH) + @api_versions.wraps("2.40", "2.52") # noqa + def update(self, class_name, shares=None, gigabytes=None, # noqa + snapshots=None, snapshot_gigabytes=None, share_networks=None, + share_groups=None, share_group_snapshots=None): + return self._do_update( + class_name, shares=shares, gigabytes=gigabytes, + snapshots=snapshots, snapshot_gigabytes=snapshot_gigabytes, + share_networks=share_networks, share_groups=share_groups, + share_group_snapshots=share_group_snapshots, + resource_path=RESOURCE_PATH) + @api_versions.wraps(REPLICA_QUOTAS_MICROVERSION, "2.61") # noqa def update(self, class_name, shares=None, gigabytes=None, # noqa snapshots=None, snapshot_gigabytes=None, share_networks=None, + share_groups=None, share_group_snapshots=None, share_replicas=None, replica_gigabytes=None): return self._do_update( class_name, shares=shares, gigabytes=gigabytes, snapshots=snapshots, snapshot_gigabytes=snapshot_gigabytes, - share_networks=share_networks, share_replicas=share_replicas, - replica_gigabytes=replica_gigabytes, resource_path=RESOURCE_PATH) + share_networks=share_networks, share_groups=share_groups, + share_group_snapshots=share_group_snapshots, + share_replicas=share_replicas, replica_gigabytes=replica_gigabytes, + resource_path=RESOURCE_PATH) @api_versions.wraps("2.62") # noqa def update(self, class_name, shares=None, gigabytes=None, # noqa snapshots=None, snapshot_gigabytes=None, share_networks=None, + share_groups=None, share_group_snapshots=None, share_replicas=None, replica_gigabytes=None, per_share_gigabytes=None): return self._do_update( class_name, shares=shares, gigabytes=gigabytes, snapshots=snapshots, snapshot_gigabytes=snapshot_gigabytes, - share_networks=share_networks, share_replicas=share_replicas, + share_networks=share_networks, share_groups=share_groups, + share_group_snapshots=share_group_snapshots, + share_replicas=share_replicas, replica_gigabytes=replica_gigabytes, per_share_gigabytes=per_share_gigabytes, resource_path=RESOURCE_PATH) diff --git a/manilaclient/v2/shell.py b/manilaclient/v2/shell.py index 169c0cb89..5147c87fe 100644 --- a/manilaclient/v2/shell.py +++ b/manilaclient/v2/shell.py @@ -458,7 +458,9 @@ _quota_resources = [ 'share_networks', 'share_replicas', 'replica_gigabytes', - 'per_share_gigabytes' + 'per_share_gigabytes', + 'share_groups', + 'share_group_snapshots' ] @@ -772,6 +774,24 @@ def do_quota_class_show(cs, args): default=None, action='single_alias', help='New value for the "share_networks" quota.') +@cliutils.arg( + '--share-groups', + '--share_groups', # alias + metavar='', + type=int, + default=None, + action='single_alias', + help='New value for the "share_groups" quota. Available only for ' + 'microversion >= 2.40') +@cliutils.arg( + '--share-group-snapshots', + '--share_group_snapshots', + metavar='', + type=int, + default=None, + action='single_alias', + help='New value for the "share_group_snapshots" quota. Available only for ' + 'microversion >= 2.40') @cliutils.arg( '--share-replicas', '--share_replicas', # alias @@ -802,6 +822,11 @@ def do_quota_class_show(cs, args): 'microversion >= 2.62') def do_quota_class_update(cs, args): """Update the quotas for a quota class (Admin only).""" + if args.share_groups is not None or args.share_group_snapshots is not None: + if cs.api_version < api_versions.APIVersion("2.40"): + raise exceptions.CommandError( + "'share groups' quotas are available only starting with " + "'2.40' API microversion.") if args.share_replicas is not None or args.replica_gigabytes is not None: if cs.api_version < api_versions.APIVersion("2.53"): raise exceptions.CommandError( diff --git a/releasenotes/notes/bug-1871252-update-default-quotas-via-quota-class-share-groups-share-group-snapshots-20ec1dfcc0a7e81c.yaml b/releasenotes/notes/bug-1871252-update-default-quotas-via-quota-class-share-groups-share-group-snapshots-20ec1dfcc0a7e81c.yaml new file mode 100644 index 000000000..fe906bd6e --- /dev/null +++ b/releasenotes/notes/bug-1871252-update-default-quotas-via-quota-class-share-groups-share-group-snapshots-20ec1dfcc0a7e81c.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Share group and share group snapshots quotas have been available in manila + since API 2.40. With this change, we added the possibility for users to update + share group and share group snapshots quotas via the quota class API to the + manilaclient CLI. For more details, please refer to + `Launchpad bug 1871252 `_.