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

9 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 

21ROOT_POLICY = 'os_compute_api:os-multinic' 

22BASE_POLICY_NAME = 'os_compute_api:os-multinic:%s' 

23 

24DEPRECATED_REASON = """ 

25Nova API policies are introducing new default roles with scope_type 

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

27in nova 23.0.0 release. 

28""" 

29 

30DEPRECATED_POLICY = policy.DeprecatedRule( 

31 ROOT_POLICY, 

32 base.RULE_ADMIN_OR_OWNER, 

33 deprecated_reason=DEPRECATED_REASON, 

34 deprecated_since='22.0.0' 

35) 

36 

37 

38multinic_policies = [ 

39 policy.DocumentedRuleDefault( 

40 name=BASE_POLICY_NAME % 'add', 

41 check_str=base.PROJECT_MEMBER_OR_ADMIN, 

42 description="""Add a fixed IP address to a server. 

43 

44This API is proxy calls to the Network service. This is 

45deprecated.""", 

46 operations=[ 

47 { 

48 'method': 'POST', 

49 'path': '/servers/{server_id}/action (addFixedIp)' 

50 } 

51 ], 

52 scope_types=['project'], 

53 deprecated_rule=DEPRECATED_POLICY), 

54 policy.DocumentedRuleDefault( 

55 name=BASE_POLICY_NAME % 'remove', 

56 check_str=base.PROJECT_MEMBER_OR_ADMIN, 

57 description="""Remove a fixed IP address from a server. 

58 

59This API is proxy calls to the Network service. This is 

60deprecated.""", 

61 operations=[ 

62 { 

63 'method': 'POST', 

64 'path': '/servers/{server_id}/action (removeFixedIp)' 

65 } 

66 ], 

67 scope_types=['project'], 

68 deprecated_rule=DEPRECATED_POLICY), 

69] 

70 

71 

72def list_rules(): 

73 return multinic_policies