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

11 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 = 'service:%s' 

20 

21DEPRECATED_REASON = """ 

22The service API now supports scope and default roles. 

23""" 

24 

25deprecated_service_index = policy.DeprecatedRule( 

26 name=BASE_POLICY_NAME % 'index', 

27 check_str=base.RULE_ADMIN_API, 

28 deprecated_reason=DEPRECATED_REASON, 

29 deprecated_since=versionutils.deprecated.WALLABY 

30) 

31deprecated_service_update = policy.DeprecatedRule( 

32 name=BASE_POLICY_NAME % 'update', 

33 check_str=base.RULE_ADMIN_API, 

34 deprecated_reason=DEPRECATED_REASON, 

35 deprecated_since=versionutils.deprecated.WALLABY 

36) 

37deprecated_service_ensure = policy.DeprecatedRule( 

38 name=BASE_POLICY_NAME % 'ensure_shares', 

39 check_str=base.RULE_ADMIN_API, 

40 deprecated_reason=DEPRECATED_REASON, 

41 deprecated_since='2024.2/Dalmatian' 

42) 

43 

44 

45service_policies = [ 

46 policy.DocumentedRuleDefault( 

47 name=BASE_POLICY_NAME % 'index', 

48 check_str=base.ADMIN, 

49 scope_types=['project'], 

50 description="Return a list of all running services.", 

51 operations=[ 

52 { 

53 'method': 'GET', 

54 'path': '/os-services?{query}', 

55 }, 

56 { 

57 'method': 'GET', 

58 'path': '/services?{query}', 

59 } 

60 ], 

61 deprecated_rule=deprecated_service_index 

62 ), 

63 policy.DocumentedRuleDefault( 

64 name=BASE_POLICY_NAME % 'update', 

65 check_str=base.ADMIN, 

66 scope_types=['project'], 

67 description="Enable/Disable scheduling for a service.", 

68 operations=[ 

69 { 

70 'method': 'PUT', 

71 'path': '/os-services/disable', 

72 }, 

73 { 

74 'method': 'PUT', 

75 'path': '/os-services/enable', 

76 }, 

77 { 

78 'method': 'PUT', 

79 'path': '/services/disable', 

80 }, 

81 { 

82 'method': 'PUT', 

83 'path': '/services/enable', 

84 }, 

85 ], 

86 deprecated_rule=deprecated_service_update 

87 ), 

88 policy.DocumentedRuleDefault( 

89 name=BASE_POLICY_NAME % 'ensure_shares', 

90 check_str=base.ADMIN, 

91 scope_types=['project'], 

92 description="Run ensure shares for a manila-share binary.", 

93 operations=[ 

94 { 

95 'method': 'POST', 

96 'path': '/services/ensure', 

97 } 

98 ], 

99 deprecated_rule=deprecated_service_ensure 

100 ), 

101] 

102 

103 

104def list_rules(): 

105 return service_policies