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

6 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-shelve:%s' 

22 

23 

24shelve_policies = [ 

25 policy.DocumentedRuleDefault( 

26 name=POLICY_ROOT % 'shelve', 

27 check_str=base.PROJECT_MEMBER_OR_ADMIN, 

28 description="Shelve server", 

29 operations=[ 

30 { 

31 'method': 'POST', 

32 'path': '/servers/{server_id}/action (shelve)' 

33 } 

34 ], 

35 scope_types=['project']), 

36 policy.DocumentedRuleDefault( 

37 name=POLICY_ROOT % 'unshelve', 

38 check_str=base.PROJECT_MEMBER_OR_ADMIN, 

39 description="Unshelve (restore) shelved server", 

40 operations=[ 

41 { 

42 'method': 'POST', 

43 'path': '/servers/{server_id}/action (unshelve)' 

44 } 

45 ], 

46 scope_types=['project']), 

47 policy.DocumentedRuleDefault( 

48 name=POLICY_ROOT % 'unshelve_to_host', 

49 check_str=base.ADMIN, 

50 description="Unshelve (restore) shelve offloaded server to a " 

51 "specific host", 

52 operations=[ 

53 { 

54 'method': 'POST', 

55 'path': '/servers/{server_id}/action (unshelve)' 

56 } 

57 ], 

58 scope_types=['project']), 

59 policy.DocumentedRuleDefault( 

60 name=POLICY_ROOT % 'shelve_offload', 

61 check_str=base.ADMIN, 

62 description="Shelf-offload (remove) server", 

63 operations=[ 

64 { 

65 'method': 'POST', 

66 'path': '/servers/{server_id}/action (shelveOffload)' 

67 } 

68 ], 

69 scope_types=['project']), 

70] 

71 

72 

73def list_rules(): 

74 return shelve_policies