Coverage for manila/policies/share_snapshot_instance.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Licensed under the Apache License, Version 2.0 (the "License"); you may 

2# not use this file except in compliance with the License. You may obtain 

3# a copy of the License at 

4# 

5# http://www.apache.org/licenses/LICENSE-2.0 

6# 

7# Unless required by applicable law or agreed to in writing, software 

8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

10# License for the specific language governing permissions and limitations 

11# under the License. 

12 

13from oslo_log import versionutils 

14from oslo_policy import policy 

15 

16from manila.policies import base 

17 

18 

19BASE_POLICY_NAME = 'share_snapshot_instance:%s' 

20 

21DEPRECATED_REASON = """ 

22The share snapshot instance API now supports scope and default roles. 

23""" 

24 

25deprecated_snapshot_instance_show = policy.DeprecatedRule( 

26 name=BASE_POLICY_NAME % 'show', 

27 check_str=base.RULE_ADMIN_API, 

28 deprecated_reason=DEPRECATED_REASON, 

29 deprecated_since=versionutils.deprecated.WALLABY 

30) 

31deprecated_snapshot_instance_index = policy.DeprecatedRule( 

32 name=BASE_POLICY_NAME % 'index', 

33 check_str=base.RULE_ADMIN_API, 

34 deprecated_reason=DEPRECATED_REASON, 

35 deprecated_since=versionutils.deprecated.WALLABY 

36) 

37deprecated_snapshot_instance_detail = policy.DeprecatedRule( 

38 name=BASE_POLICY_NAME % 'detail', 

39 check_str=base.RULE_ADMIN_API, 

40 deprecated_reason=DEPRECATED_REASON, 

41 deprecated_since=versionutils.deprecated.WALLABY 

42) 

43deprecated_snapshot_instance_reset_status = policy.DeprecatedRule( 

44 name=BASE_POLICY_NAME % 'reset_status', 

45 check_str=base.RULE_ADMIN_API, 

46 deprecated_reason=DEPRECATED_REASON, 

47 deprecated_since=versionutils.deprecated.WALLABY 

48) 

49 

50 

51share_snapshot_instance_policies = [ 

52 policy.DocumentedRuleDefault( 

53 name=BASE_POLICY_NAME % 'show', 

54 check_str=base.ADMIN, 

55 scope_types=['project'], 

56 description="Get share snapshot instance.", 

57 operations=[ 

58 { 

59 'method': 'GET', 

60 'path': '/snapshot-instances/{snapshot_instance_id}', 

61 } 

62 ], 

63 deprecated_rule=deprecated_snapshot_instance_show 

64 ), 

65 policy.DocumentedRuleDefault( 

66 name=BASE_POLICY_NAME % 'index', 

67 check_str=base.ADMIN, 

68 scope_types=['project'], 

69 description="Get all share snapshot instances.", 

70 operations=[ 

71 { 

72 'method': 'GET', 

73 'path': '/snapshot-instances?{query}', 

74 }, 

75 ], 

76 deprecated_rule=deprecated_snapshot_instance_index 

77 ), 

78 policy.DocumentedRuleDefault( 

79 name=BASE_POLICY_NAME % 'detail', 

80 check_str=base.ADMIN, 

81 scope_types=['project'], 

82 description="Get details of share snapshot instances.", 

83 operations=[ 

84 { 

85 'method': 'GET', 

86 'path': '/snapshot-instances/detail?{query}', 

87 }, 

88 ], 

89 deprecated_rule=deprecated_snapshot_instance_detail 

90 ), 

91 policy.DocumentedRuleDefault( 

92 name=BASE_POLICY_NAME % 'reset_status', 

93 check_str=base.ADMIN, 

94 scope_types=['project'], 

95 description="Reset share snapshot instance's status.", 

96 operations=[ 

97 { 

98 'method': 'POST', 

99 'path': '/snapshot-instances/{snapshot_instance_id}/action', 

100 } 

101 ], 

102 deprecated_rule=deprecated_snapshot_instance_reset_status 

103 ), 

104] 

105 

106 

107def list_rules(): 

108 return share_snapshot_instance_policies