Coverage for manila/data/drivers/nfs.py: 0%

19 statements  

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

1# Copyright 2023 Cloudification GmbH. 

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"""Implementation of a backup service that uses NFS storage as the backend.""" 

17 

18from oslo_config import cfg 

19 

20from manila.data import backup_driver 

21 

22 

23nfsbackup_service_opts = [ 

24 cfg.StrOpt('backup_mount_template', 

25 default='mount -vt %(proto)s %(options)s %(export)s %(path)s', 

26 help='The template for mounting NFS shares.'), 

27 cfg.StrOpt('backup_unmount_template', 

28 default='umount -v %(path)s', 

29 help='The template for unmounting NFS shares.'), 

30 cfg.StrOpt('backup_mount_export', 

31 help='NFS backup export location in hostname:path, ' 

32 'ipv4addr:path, or "[ipv6addr]:path" format.'), 

33 cfg.StrOpt('backup_mount_proto', 

34 default='nfs', 

35 help='Mount Protocol for mounting NFS shares'), 

36 cfg.StrOpt('backup_mount_options', 

37 default='', 

38 help='Mount options passed to the NFS client. See NFS ' 

39 'man page for details.'), 

40] 

41 

42CONF = cfg.CONF 

43CONF.register_opts(nfsbackup_service_opts) 

44 

45 

46class NFSBackupDriver(backup_driver.BackupDriver): 

47 """Provides backup, restore and delete using NFS supplied repository.""" 

48 

49 def __init__(self): 

50 self.backup_mount_export = CONF.backup_mount_export 

51 self.backup_mount_template = CONF.backup_mount_template 

52 self.backup_unmount_template = CONF.backup_unmount_template 

53 self.backup_mount_options = CONF.backup_mount_options 

54 self.backup_mount_proto = CONF.backup_mount_proto 

55 super(NFSBackupDriver, self).__init__() 

56 self.restore_to_target_support = True 

57 

58 def get_backup_info(self, backup): 

59 """Get backup info of a specified backup.""" 

60 mount_template = ( 

61 self.backup_mount_template % { 

62 'proto': self.backup_mount_proto, 

63 'options': self.backup_mount_options, 

64 'export': self.backup_mount_export, 

65 'path': '%(path)s', 

66 } 

67 ) 

68 unmount_template = self.backup_unmount_template 

69 

70 backup_info = { 

71 'mount': mount_template, 

72 'unmount': unmount_template, 

73 } 

74 

75 return backup_info