Coverage for nova/virt/libvirt/volume/nfs.py: 93%

25 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-17 15:08 +0000

1# Licensed under the Apache License, Version 2.0 (the "License"); you may 

2# not use this file except in compliance with the License. You may obtain 

3# a copy of the License at 

4# 

5# http://www.apache.org/licenses/LICENSE-2.0 

6# 

7# Unless required by applicable law or agreed to in writing, software 

8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

10# License for the specific language governing permissions and limitations 

11# under the License. 

12 

13 

14import nova.conf 

15from nova.virt.libvirt.volume import fs 

16 

17CONF = nova.conf.CONF 

18 

19 

20class LibvirtNFSVolumeDriver(fs.LibvirtMountedFileSystemVolumeDriver): 

21 """Class implements libvirt part of volume driver for NFS.""" 

22 

23 def __init__(self, connection): 

24 super(LibvirtNFSVolumeDriver, self).__init__(connection, 'nfs') 

25 

26 def _get_mount_point_base(self): 

27 return CONF.libvirt.nfs_mount_point_base 

28 

29 def get_config(self, connection_info, disk_info): 

30 """Returns xml for libvirt.""" 

31 conf = super(LibvirtNFSVolumeDriver, 

32 self).get_config(connection_info, disk_info) 

33 

34 conf.source_type = 'file' 

35 conf.source_path = connection_info['data']['device_path'] 

36 conf.driver_format = connection_info['data'].get('format', 'raw') 

37 conf.driver_io = "native" 

38 return conf 

39 

40 def _mount_options(self, connection_info): 

41 options = [] 

42 if CONF.libvirt.nfs_mount_options is not None: 42 ↛ 43line 42 didn't jump to line 43 because the condition on line 42 was never true

43 options.extend(['-o', CONF.libvirt.nfs_mount_options]) 

44 

45 conn_options = connection_info['data'].get('options') 

46 if conn_options: 

47 options.extend(conn_options.split(' ')) 

48 

49 return options 

50 

51 def extend_volume(self, connection_info, instance, requested_size): 

52 # There is nothing to do for NFS volumes. libvirt will extend the file 

53 # on the NFS share, and resize the disk device within the instance by 

54 # calling virDomainBlockResize. 

55 return requested_size