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

22 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 

18BASE_POLICY_NAME = 'share_network:%s' 

19 

20DEPRECATED_REASON = """ 

21The share network API now support system scope and default roles. 

22""" 

23 

24deprecated_share_network_create = policy.DeprecatedRule( 

25 name=BASE_POLICY_NAME % 'create', 

26 check_str=base.RULE_DEFAULT, 

27 deprecated_reason=DEPRECATED_REASON, 

28 deprecated_since=versionutils.deprecated.WALLABY 

29) 

30deprecated_share_network_show = policy.DeprecatedRule( 

31 name=BASE_POLICY_NAME % 'show', 

32 check_str=base.RULE_DEFAULT, 

33 deprecated_reason=DEPRECATED_REASON, 

34 deprecated_since=versionutils.deprecated.WALLABY 

35) 

36deprecated_share_network_index = policy.DeprecatedRule( 

37 name=BASE_POLICY_NAME % 'index', 

38 check_str=base.RULE_DEFAULT, 

39 deprecated_reason=DEPRECATED_REASON, 

40 deprecated_since=versionutils.deprecated.WALLABY 

41) 

42deprecated_share_network_detail = policy.DeprecatedRule( 

43 name=BASE_POLICY_NAME % 'detail', 

44 check_str=base.RULE_DEFAULT, 

45 deprecated_reason=DEPRECATED_REASON, 

46 deprecated_since=versionutils.deprecated.WALLABY 

47) 

48deprecated_share_network_update = policy.DeprecatedRule( 

49 name=BASE_POLICY_NAME % 'update', 

50 check_str=base.RULE_DEFAULT, 

51 deprecated_reason=DEPRECATED_REASON, 

52 deprecated_since=versionutils.deprecated.WALLABY 

53) 

54deprecated_share_network_delete = policy.DeprecatedRule( 

55 name=BASE_POLICY_NAME % 'delete', 

56 check_str=base.RULE_DEFAULT, 

57 deprecated_reason=DEPRECATED_REASON, 

58 deprecated_since=versionutils.deprecated.WALLABY 

59) 

60deprecated_share_network_add_security_service = policy.DeprecatedRule( 

61 name=BASE_POLICY_NAME % 'add_security_service', 

62 check_str=base.RULE_DEFAULT, 

63 deprecated_reason=DEPRECATED_REASON, 

64 deprecated_since=versionutils.deprecated.WALLABY 

65) 

66deprecated_share_network_remove_security_service = policy.DeprecatedRule( 

67 name=BASE_POLICY_NAME % 'remove_security_service', 

68 check_str=base.RULE_DEFAULT, 

69 deprecated_reason=DEPRECATED_REASON, 

70 deprecated_since=versionutils.deprecated.WALLABY 

71) 

72deprecated_share_network_get_all = policy.DeprecatedRule( 

73 name=BASE_POLICY_NAME % 'get_all_share_networks', 

74 check_str=base.RULE_ADMIN_API, 

75 deprecated_reason=DEPRECATED_REASON, 

76 deprecated_since=versionutils.deprecated.WALLABY 

77) 

78deprecated_share_network_add_security_service_check = policy.DeprecatedRule( 

79 name=BASE_POLICY_NAME % 'add_security_service_check', 

80 check_str=base.RULE_DEFAULT, 

81 deprecated_reason=DEPRECATED_REASON, 

82 deprecated_since=versionutils.deprecated.WALLABY 

83) 

84deprecated_share_network_update_security_service = policy.DeprecatedRule( 

85 name=BASE_POLICY_NAME % 'update_security_service', 

86 check_str=base.RULE_DEFAULT, 

87 deprecated_reason=DEPRECATED_REASON, 

88 deprecated_since=versionutils.deprecated.WALLABY 

89) 

90deprecated_share_network_update_security_service_check = policy.DeprecatedRule( 

91 name=BASE_POLICY_NAME % 'update_security_service_check', 

92 check_str=base.RULE_DEFAULT, 

93 deprecated_reason=DEPRECATED_REASON, 

94 deprecated_since=versionutils.deprecated.WALLABY 

95) 

96deprecated_share_network_reset_status = policy.DeprecatedRule( 

97 name=BASE_POLICY_NAME % 'reset_status', 

98 check_str=base.RULE_ADMIN_API, 

99 deprecated_reason=DEPRECATED_REASON, 

100 deprecated_since=versionutils.deprecated.WALLABY 

101) 

102deprecated_share_network_subnet_create_check = policy.DeprecatedRule( 

103 name=BASE_POLICY_NAME % 'subnet_create_check', 

104 check_str=base.RULE_DEFAULT, 

105 deprecated_reason=DEPRECATED_REASON, 

106 deprecated_since="Yoga" 

107) 

108 

109 

110share_network_policies = [ 

111 policy.DocumentedRuleDefault( 

112 name=BASE_POLICY_NAME % 'create', 

113 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

114 scope_types=['project'], 

115 description="Create share network.", 

116 operations=[ 

117 { 

118 'method': 'POST', 

119 'path': '/share-networks' 

120 } 

121 ], 

122 deprecated_rule=deprecated_share_network_create 

123 ), 

124 policy.DocumentedRuleDefault( 

125 name=BASE_POLICY_NAME % 'show', 

126 check_str=base.ADMIN_OR_PROJECT_READER, 

127 scope_types=['project'], 

128 description="Get details of a share network.", 

129 operations=[ 

130 { 

131 'method': 'GET', 

132 'path': '/share-networks/{share_network_id}' 

133 } 

134 ], 

135 deprecated_rule=deprecated_share_network_show 

136 ), 

137 policy.DocumentedRuleDefault( 

138 name=BASE_POLICY_NAME % 'index', 

139 check_str=base.ADMIN_OR_PROJECT_READER, 

140 scope_types=['project'], 

141 description="Get all share networks under a project.", 

142 operations=[ 

143 { 

144 'method': 'GET', 

145 'path': '/share-networks?{query}' 

146 } 

147 ], 

148 deprecated_rule=deprecated_share_network_index 

149 ), 

150 policy.DocumentedRuleDefault( 

151 name=BASE_POLICY_NAME % 'detail', 

152 check_str=base.ADMIN_OR_PROJECT_READER, 

153 scope_types=['project'], 

154 description="Get details of share networks under a project.", 

155 operations=[ 

156 { 

157 'method': 'GET', 

158 'path': '/share-networks/detail?{query}' 

159 }, 

160 ], 

161 deprecated_rule=deprecated_share_network_detail 

162 ), 

163 policy.DocumentedRuleDefault( 

164 name=BASE_POLICY_NAME % 'update', 

165 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

166 scope_types=['project'], 

167 description="Update a share network.", 

168 operations=[ 

169 { 

170 'method': 'PUT', 

171 'path': '/share-networks/{share_network_id}' 

172 } 

173 ], 

174 deprecated_rule=deprecated_share_network_update 

175 ), 

176 policy.DocumentedRuleDefault( 

177 name=BASE_POLICY_NAME % 'delete', 

178 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

179 scope_types=['project'], 

180 description="Delete a share network.", 

181 operations=[ 

182 { 

183 'method': 'DELETE', 

184 'path': '/share-networks/{share_network_id}' 

185 } 

186 ], 

187 deprecated_rule=deprecated_share_network_delete 

188 ), 

189 policy.DocumentedRuleDefault( 

190 name=BASE_POLICY_NAME % 'add_security_service', 

191 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

192 scope_types=['project'], 

193 description="Add security service to share network.", 

194 operations=[ 

195 { 

196 'method': 'POST', 

197 'path': '/share-networks/{share_network_id}/action' 

198 } 

199 ], 

200 deprecated_rule=deprecated_share_network_add_security_service 

201 ), 

202 policy.DocumentedRuleDefault( 

203 name=BASE_POLICY_NAME % 'add_security_service_check', 

204 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

205 scope_types=['project'], 

206 description="Check the feasibility of add security service to a share " 

207 "network.", 

208 operations=[ 

209 { 

210 'method': 'POST', 

211 'path': '/share-networks/{share_network_id}/action' 

212 } 

213 ], 

214 deprecated_rule=deprecated_share_network_add_security_service_check 

215 ), 

216 policy.DocumentedRuleDefault( 

217 name=BASE_POLICY_NAME % 'remove_security_service', 

218 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

219 scope_types=['project'], 

220 description="Remove security service from share network.", 

221 operations=[ 

222 { 

223 'method': 'POST', 

224 'path': '/share-networks/{share_network_id}/action' 

225 } 

226 ], 

227 deprecated_rule=deprecated_share_network_remove_security_service 

228 ), 

229 policy.DocumentedRuleDefault( 

230 name=BASE_POLICY_NAME % 'update_security_service', 

231 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

232 scope_types=['project'], 

233 description="Update security service from share network.", 

234 operations=[ 

235 { 

236 'method': 'POST', 

237 'path': '/share-networks/{share_network_id}/action' 

238 } 

239 ], 

240 deprecated_rule=deprecated_share_network_update_security_service 

241 ), 

242 policy.DocumentedRuleDefault( 

243 name=BASE_POLICY_NAME % 'update_security_service_check', 

244 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

245 scope_types=['project'], 

246 description="Check the feasibility of update a security service from " 

247 "share network.", 

248 operations=[ 

249 { 

250 'method': 'POST', 

251 'path': '/share-networks/{share_network_id}/action' 

252 } 

253 ], 

254 deprecated_rule=deprecated_share_network_update_security_service_check 

255 ), 

256 policy.DocumentedRuleDefault( 

257 name=BASE_POLICY_NAME % 'reset_status', 

258 check_str=base.ADMIN, 

259 scope_types=['project'], 

260 description="Reset share network`s status.", 

261 operations=[ 

262 { 

263 'method': 'POST', 

264 'path': '/share-networks/{share_network_id}/action' 

265 } 

266 ], 

267 deprecated_rule=deprecated_share_network_reset_status 

268 ), 

269 policy.DocumentedRuleDefault( 

270 name=BASE_POLICY_NAME % 'get_all_share_networks', 

271 check_str=base.ADMIN, 

272 scope_types=['project'], 

273 description="Get share networks belonging to all projects.", 

274 operations=[ 

275 { 

276 'method': 'GET', 

277 'path': '/share-networks?all_tenants=1' 

278 }, 

279 { 

280 'method': 'GET', 

281 'path': '/share-networks/detail?all_tenants=1' 

282 } 

283 ], 

284 deprecated_rule=deprecated_share_network_get_all 

285 ), 

286 policy.DocumentedRuleDefault( 

287 name=BASE_POLICY_NAME % 'subnet_create_check', 

288 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

289 scope_types=['project'], 

290 description="Check the feasibility of create a new share network " 

291 "subnet for share network.", 

292 operations=[ 

293 { 

294 'method': 'POST', 

295 'path': '/share-networks/{share_network_id}/action' 

296 } 

297 ], 

298 deprecated_rule=deprecated_share_network_subnet_create_check 

299 ), 

300] 

301 

302 

303def list_rules(): 

304 return share_network_policies