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

8 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-24 11:16 +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 

21BASE_POLICY_NAME = 'os_compute_api:os-services:%s' 

22 

23DEPRECATED_REASON = """ 

24Nova API policies are introducing new default roles with scope_type 

25capabilities. Old policies are deprecated and silently going to be ignored 

26in nova 23.0.0 release. 

27""" 

28 

29DEPRECATED_SERVICE_POLICY = policy.DeprecatedRule( 

30 'os_compute_api:os-services', 

31 base.RULE_ADMIN_API, 

32 deprecated_reason=DEPRECATED_REASON, 

33 deprecated_since='21.0.0', 

34) 

35 

36 

37services_policies = [ 

38 policy.DocumentedRuleDefault( 

39 name=BASE_POLICY_NAME % 'list', 

40 check_str=base.ADMIN, 

41 description="List all running Compute services in a region.", 

42 operations=[ 

43 { 

44 'method': 'GET', 

45 'path': '/os-services' 

46 } 

47 ], 

48 scope_types=['project'], 

49 deprecated_rule=DEPRECATED_SERVICE_POLICY), 

50 policy.DocumentedRuleDefault( 

51 name=BASE_POLICY_NAME % 'update', 

52 check_str=base.ADMIN, 

53 description="Update a Compute service.", 

54 operations=[ 

55 { 

56 # Added in microversion 2.53. 

57 'method': 'PUT', 

58 'path': '/os-services/{service_id}' 

59 }, 

60 ], 

61 scope_types=['project'], 

62 deprecated_rule=DEPRECATED_SERVICE_POLICY), 

63 policy.DocumentedRuleDefault( 

64 name=BASE_POLICY_NAME % 'delete', 

65 check_str=base.ADMIN, 

66 description="Delete a Compute service.", 

67 operations=[ 

68 { 

69 'method': 'DELETE', 

70 'path': '/os-services/{service_id}' 

71 } 

72 ], 

73 scope_types=['project'], 

74 deprecated_rule=DEPRECATED_SERVICE_POLICY), 

75] 

76 

77 

78def list_rules(): 

79 return services_policies