Coverage for nova/policies/aggregates.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-17 15:08 +0000

1# Copyright 2016 Cloudbase Solutions Srl 

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. 

15 

16from oslo_policy import policy 

17 

18from nova.policies import base 

19 

20 

21POLICY_ROOT = 'os_compute_api:os-aggregates:%s' 

22NEW_POLICY_ROOT = 'compute:aggregates:%s' 

23 

24 

25aggregates_policies = [ 

26 policy.DocumentedRuleDefault( 

27 name=POLICY_ROOT % 'set_metadata', 

28 check_str=base.ADMIN, 

29 description="Create or replace metadata for an aggregate", 

30 operations=[ 

31 { 

32 'path': '/os-aggregates/{aggregate_id}/action (set_metadata)', 

33 'method': 'POST' 

34 } 

35 ], 

36 scope_types=['project']), 

37 policy.DocumentedRuleDefault( 

38 name=POLICY_ROOT % 'add_host', 

39 check_str=base.ADMIN, 

40 description="Add a host to an aggregate", 

41 operations=[ 

42 { 

43 'path': '/os-aggregates/{aggregate_id}/action (add_host)', 

44 'method': 'POST' 

45 } 

46 ], 

47 scope_types=['project']), 

48 policy.DocumentedRuleDefault( 

49 name=POLICY_ROOT % 'create', 

50 check_str=base.ADMIN, 

51 description="Create an aggregate", 

52 operations=[ 

53 { 

54 'path': '/os-aggregates', 

55 'method': 'POST' 

56 } 

57 ], 

58 scope_types=['project']), 

59 policy.DocumentedRuleDefault( 

60 name=POLICY_ROOT % 'remove_host', 

61 check_str=base.ADMIN, 

62 description="Remove a host from an aggregate", 

63 operations=[ 

64 { 

65 'path': '/os-aggregates/{aggregate_id}/action (remove_host)', 

66 'method': 'POST' 

67 } 

68 ], 

69 scope_types=['project']), 

70 policy.DocumentedRuleDefault( 

71 name=POLICY_ROOT % 'update', 

72 check_str=base.ADMIN, 

73 description="Update name and/or availability zone for an aggregate", 

74 operations=[ 

75 { 

76 'path': '/os-aggregates/{aggregate_id}', 

77 'method': 'PUT' 

78 } 

79 ], 

80 scope_types=['project']), 

81 policy.DocumentedRuleDefault( 

82 name=POLICY_ROOT % 'index', 

83 check_str=base.ADMIN, 

84 description="List all aggregates", 

85 operations=[ 

86 { 

87 'path': '/os-aggregates', 

88 'method': 'GET' 

89 } 

90 ], 

91 scope_types=['project']), 

92 policy.DocumentedRuleDefault( 

93 name=POLICY_ROOT % 'delete', 

94 check_str=base.ADMIN, 

95 description="Delete an aggregate", 

96 operations=[ 

97 { 

98 'path': '/os-aggregates/{aggregate_id}', 

99 'method': 'DELETE' 

100 } 

101 ], 

102 scope_types=['project']), 

103 policy.DocumentedRuleDefault( 

104 name=POLICY_ROOT % 'show', 

105 check_str=base.ADMIN, 

106 description="Show details for an aggregate", 

107 operations=[ 

108 { 

109 'path': '/os-aggregates/{aggregate_id}', 

110 'method': 'GET' 

111 } 

112 ], 

113 scope_types=['project']), 

114 policy.DocumentedRuleDefault( 

115 name=NEW_POLICY_ROOT % 'images', 

116 check_str=base.ADMIN, 

117 description="Request image caching for an aggregate", 

118 operations=[ 

119 { 

120 'path': '/os-aggregates/{aggregate_id}/images', 

121 'method': 'POST' 

122 } 

123 ], 

124 scope_types=['project']), 

125] 

126 

127 

128def list_rules(): 

129 return aggregates_policies