Coverage for manila/api/v1/shares.py: 82%

39 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright 2013 NetApp 

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 

16"""The shares api.""" 

17 

18from oslo_log import log 

19 

20from manila.api.openstack import wsgi 

21from manila.api.v2 import shares 

22from manila.api.views import share_accesses as share_access_views 

23from manila.api.views import shares as share_views 

24from manila.lock import api as resource_locks 

25from manila import share 

26 

27LOG = log.getLogger(__name__) 

28 

29 

30class ShareController( 

31 wsgi.Controller, shares.ShareMixin, wsgi.AdminActionsMixin 

32): 

33 """The Shares API v1 controller for the OpenStack API.""" 

34 resource_name = 'share' 

35 _view_builder_class = share_views.ViewBuilder 

36 

37 def __init__(self): 

38 super(ShareController, self).__init__() 

39 self.share_api = share.API() 

40 self.resource_locks_api = resource_locks.API() 

41 self._access_view_builder = share_access_views.ViewBuilder() 

42 

43 @wsgi.action('os-reset_status') 

44 def share_reset_status(self, req, id, body): 

45 """Reset status of a share.""" 

46 return self._reset_status(req, id, body) 

47 

48 @wsgi.action('os-force_delete') 

49 def share_force_delete(self, req, id, body): 

50 """Delete a share, bypassing the check for status.""" 

51 return self._force_delete(req, id, body) 

52 

53 @wsgi.action('os-allow_access') 

54 def allow_access(self, req, id, body): 

55 """Add share access rule.""" 

56 return self._allow_access(req, id, body) 

57 

58 @wsgi.action('os-deny_access') 

59 def deny_access(self, req, id, body): 

60 """Remove share access rule.""" 

61 return self._deny_access(req, id, body) 

62 

63 @wsgi.action('os-access_list') 

64 def access_list(self, req, id, body): 

65 """List share access rules.""" 

66 return self._access_list(req, id, body) 

67 

68 @wsgi.action('os-extend') 

69 def extend(self, req, id, body): 

70 """Extend size of a share.""" 

71 return self._extend(req, id, body) 

72 

73 @wsgi.action('os-shrink') 

74 def shrink(self, req, id, body): 

75 """Shrink size of a share.""" 

76 return self._shrink(req, id, body) 

77 

78 

79def create_resource(): 

80 return wsgi.Resource(ShareController())