def test_libvirt_smbfs_driver_with_opts(self, mock_is_mounted): mnt_base = '/mnt' self.flags(smbfs_mount_point_base=mnt_base, group='libvirt') mock_is_mounted.return_value = False libvirt_driver = volume.LibvirtSMBFSVolumeDriver(self.fake_conn) export_string = '//192.168.1.1/volumes' options = '-o user=guest,uid=107,gid=105' export_mnt_base = os.path.join(mnt_base, utils.get_hash_str(export_string)) connection_info = { 'data': { 'export': export_string, 'name': self.name, 'options': options } } libvirt_driver.connect_volume(connection_info, self.disk_info) libvirt_driver.disconnect_volume(connection_info, "vde") expected_commands = [ ('mkdir', '-p', export_mnt_base), ('mount', '-t', 'cifs', '-o', 'user=guest,uid=107,gid=105', export_string, export_mnt_base), ('umount', export_mnt_base) ] self.assertEqual(expected_commands, self.executes)
def test_libvirt_smbfs_driver_get_config(self): mnt_base = '/mnt' self.flags(smbfs_mount_point_base=mnt_base, group='libvirt') libvirt_driver = volume.LibvirtSMBFSVolumeDriver(self.fake_conn) export_string = '//192.168.1.1/volumes' export_mnt_base = os.path.join(mnt_base, utils.get_hash_str(export_string)) file_path = os.path.join(export_mnt_base, self.name) connection_info = { 'data': { 'export': export_string, 'name': self.name, 'device_path': file_path } } conf = libvirt_driver.get_config(connection_info, self.disk_info) tree = conf.format_dom() self._assertFileTypeEquals(tree, file_path)
def test_libvirt_smbfs_driver_already_mounted(self): mnt_base = '/mnt' self.flags(smbfs_mount_point_base=mnt_base, group='libvirt') libvirt_driver = volume.LibvirtSMBFSVolumeDriver(self.fake_conn) export_string = '//192.168.1.1/volumes' export_mnt_base = os.path.join(mnt_base, utils.get_hash_str(export_string)) connection_info = { 'data': { 'export': export_string, 'name': self.name } } libvirt_driver.connect_volume(connection_info, self.disk_info) libvirt_driver.disconnect_volume(connection_info, "vde") expected_commands = [('findmnt', '--target', export_mnt_base, '--source', export_string), ('umount', export_mnt_base)] self.assertEqual(expected_commands, self.executes)