Coverage for manila/api/views/quota_class_sets.py: 95%
33 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright (c) 2015 Mirantis inc.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
16from manila.api import common
19class ViewBuilder(common.ViewBuilder):
21 _collection_name = "quota_class_set"
22 _detail_version_modifiers = [
23 "add_share_group_quotas",
24 "add_share_replica_quotas",
25 "add_per_share_gigabytes_quotas",
26 "add_share_backup_quotas",
27 "add_encryption_keys_quotas",
28 ]
30 def detail_list(self, request, quota_class_set, quota_class=None):
31 """Detailed view of quota class set."""
32 keys = (
33 'shares',
34 'gigabytes',
35 'snapshots',
36 'snapshot_gigabytes',
37 'share_networks',
38 )
39 view = {key: quota_class_set.get(key) for key in keys}
40 if quota_class:
41 view['id'] = quota_class
42 self.update_versioned_resource_dict(request, view, quota_class_set)
43 return {self._collection_name: view}
45 @common.ViewBuilder.versioned_method("2.40")
46 def add_share_group_quotas(self, context, view, quota_class_set):
47 share_groups = quota_class_set.get('share_groups')
48 share_group_snapshots = quota_class_set.get('share_group_snapshots')
49 if share_groups is not None: 49 ↛ 51line 49 didn't jump to line 51 because the condition on line 49 was always true
50 view['share_groups'] = share_groups
51 if share_group_snapshots is not None: 51 ↛ exitline 51 didn't return from function 'add_share_group_quotas' because the condition on line 51 was always true
52 view['share_group_snapshots'] = share_group_snapshots
54 @common.ViewBuilder.versioned_method("2.53")
55 def add_share_replica_quotas(self, context, view, quota_class_set):
56 view['share_replicas'] = quota_class_set.get('share_replicas')
57 view['replica_gigabytes'] = quota_class_set.get('replica_gigabytes')
59 @common.ViewBuilder.versioned_method("2.62")
60 def add_per_share_gigabytes_quotas(self, context, view, quota_class_set):
61 view['per_share_gigabytes'] = quota_class_set.get(
62 'per_share_gigabytes')
64 @common.ViewBuilder.versioned_method("2.80")
65 def add_share_backup_quotas(self, context, view, quota_class_set):
66 view['backups'] = quota_class_set.get('backups')
67 view['backup_gigabytes'] = quota_class_set.get('backup_gigabytes')
69 @common.ViewBuilder.versioned_method("2.90")
70 def add_encryption_keys_quotas(self, context, view, quota_class_set):
71 view['encryption_keys'] = quota_class_set.get('encryption_keys')