Merge "libvirt: Pass Host instead of Driver to volume drivers"

This commit is contained in:
Jenkins 2016-11-02 13:44:04 +00:00 committed by Gerrit Code Review
commit ad695a2691
26 changed files with 95 additions and 101 deletions

View File

@ -21,6 +21,6 @@ class LibvirtAOEVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
@mock.patch('os.path.exists', return_value=True)
def test_libvirt_aoe_driver(self, exists):
libvirt_driver = aoe.LibvirtAOEVolumeDriver(self.fake_conn)
libvirt_driver = aoe.LibvirtAOEVolumeDriver(self.fake_host)
self.assertIsInstance(libvirt_driver.connector,
connector.AoEConnector)

View File

@ -25,12 +25,12 @@ class LibvirtDISCOVolumeDriverTestCase(
def test_libvirt_disco_driver(self):
libvirt_driver = disco.LibvirtDISCOVolumeDriver(
self.fake_conn)
self.fake_host)
self.assertIsInstance(libvirt_driver.connector,
connector.DISCOConnector)
def test_libvirt_disco_driver_connect(self):
dcon = disco.LibvirtDISCOVolumeDriver(self.fake_conn)
dcon = disco.LibvirtDISCOVolumeDriver(self.fake_host)
conf = {'server_ip': '127.0.0.1', 'server_port': 9898}
disk_info = {'disco_id': '1234567',
'name': 'aDiscoVolume',
@ -44,7 +44,7 @@ class LibvirtDISCOVolumeDriverTestCase(
conn['data']['device_path'])
def test_libvirt_disco_driver_get_config(self):
dcon = disco.LibvirtDISCOVolumeDriver(self.fake_conn)
dcon = disco.LibvirtDISCOVolumeDriver(self.fake_host)
disk_info = {'path': '/dev/dms1234567', 'name': 'aDiscoVolume',
'type': 'raw', 'dev': 'vda1', 'bus': 'pci0',
@ -56,7 +56,7 @@ class LibvirtDISCOVolumeDriverTestCase(
self.assertEqual('disco', conf.source_protocol)
def test_libvirt_disco_driver_disconnect(self):
dcon = disco.LibvirtDISCOVolumeDriver(self.fake_conn)
dcon = disco.LibvirtDISCOVolumeDriver(self.fake_host)
dcon.connector.disconnect_volume = mock.MagicMock()
disk_info = {'path': '/dev/dms1234567', 'name': 'aDiscoVolume',
'type': 'raw', 'dev': 'vda1', 'bus': 'pci0',

View File

@ -25,13 +25,13 @@ class LibvirtFibreChannelVolumeDriverTestCase(
def test_libvirt_fibrechan_driver(self):
libvirt_driver = fibrechannel.LibvirtFibreChannelVolumeDriver(
self.fake_conn)
self.fake_host)
self.assertIsInstance(libvirt_driver.connector,
connector.FibreChannelConnector)
def _test_libvirt_fibrechan_driver_s390(self):
libvirt_driver = fibrechannel.LibvirtFibreChannelVolumeDriver(
self.fake_conn)
self.fake_host)
self.assertIsInstance(libvirt_driver.connector,
connector.FibreChannelConnectorS390X)
@ -45,7 +45,7 @@ class LibvirtFibreChannelVolumeDriverTestCase(
def test_libvirt_fibrechan_driver_get_config(self):
libvirt_driver = fibrechannel.LibvirtFibreChannelVolumeDriver(
self.fake_conn)
self.fake_host)
device_path = '/dev/fake-dev'
connection_info = {'data': {'device_path': device_path}}

View File

@ -29,7 +29,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(glusterfs_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_conn)
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_host)
export_string = '192.168.1.1:/volume-00001'
export_mnt_base = os.path.join(mnt_base,
utils.get_hash_str(export_string))
@ -53,7 +53,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(glusterfs_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_conn)
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_host)
export_string = '192.168.1.1:/volume-00001'
export_mnt_base = os.path.join(mnt_base,
utils.get_hash_str(export_string))
@ -82,7 +82,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(glusterfs_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_conn)
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_host)
export_string = '192.168.1.1:/volume-00001'
export_mnt_base = os.path.join(mnt_base,
utils.get_hash_str(export_string))
@ -106,7 +106,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
export_string = '192.168.1.1:/volume-00001'
connection_info = {'data': {'export': export_string,
'name': self.name}}
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_conn)
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_host)
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
None, None, None, 'umount', 'umount: target is busy.')
libvirt_driver.disconnect_volume(connection_info, "vde")
@ -117,7 +117,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(glusterfs_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_conn)
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_host)
export_string = '192.168.1.1:/volume-00001'
options = '-o backupvolfile-server=192.168.1.2'
export_mnt_base = os.path.join(mnt_base,
@ -142,7 +142,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
@mock.patch.object(libvirt_utils, 'is_mounted', return_value=False)
def test_libvirt_glusterfs_libgfapi(self, mock_is_mounted):
self.flags(qemu_allowed_storage_drivers=['gluster'], group='libvirt')
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_conn)
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_host)
export_string = '192.168.1.1:/volume-00001'
name = 'volume-00001'

View File

@ -18,7 +18,7 @@ from nova.virt.libvirt.volume import gpfs
class LibvirtGPFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
def test_libvirt_gpfs_driver_get_config(self):
libvirt_driver = gpfs.LibvirtGPFSVolumeDriver(self.fake_conn)
libvirt_driver = gpfs.LibvirtGPFSVolumeDriver(self.fake_host)
connection_info = {
'driver_volume_type': 'gpfs',
'data': {

View File

@ -27,14 +27,14 @@ from nova.virt.libvirt.volume import hgst
class LibvirtHGSTVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
def test_libvirt_hgst_driver_type(self):
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_conn)
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_host)
self.assertIsInstance(drvr.connector, connector.HGSTConnector)
def test_libvirt_hgst_driver_connect(self):
def brick_conn_vol(data):
return {'path': '/dev/space01'}
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_conn)
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_host)
drvr.connector.connect_volume = brick_conn_vol
di = {'path': '/dev/space01', 'name': 'space01'}
ci = {'data': di}
@ -43,7 +43,7 @@ class LibvirtHGSTVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
ci['data']['device_path'])
def test_libvirt_hgst_driver_get_config(self):
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_conn)
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_host)
di = {'path': '/dev/space01', 'name': 'space01', 'type': 'raw',
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/space01'}
ci = {'data': di}
@ -52,7 +52,7 @@ class LibvirtHGSTVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
self.assertEqual('/dev/space01', conf.source_path)
def test_libvirt_hgst_driver_disconnect(self):
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_conn)
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_host)
drvr.connector.disconnect_volume = mock.MagicMock()
di = {'path': '/dev/space01', 'name': 'space01', 'type': 'raw',
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/space01'}

View File

@ -47,12 +47,12 @@ Setting up iSCSI targets: unused
self.assertEqual(targets, out)
def test_libvirt_iscsi_driver(self, transport=None):
libvirt_driver = iscsi.LibvirtISCSIVolumeDriver(self.fake_conn)
libvirt_driver = iscsi.LibvirtISCSIVolumeDriver(self.fake_host)
self.assertIsInstance(libvirt_driver.connector,
connector.ISCSIConnector)
def test_libvirt_iscsi_driver_get_config(self):
libvirt_driver = iscsi.LibvirtISCSIVolumeDriver(self.fake_conn)
libvirt_driver = iscsi.LibvirtISCSIVolumeDriver(self.fake_host)
device_path = '/dev/fake-dev'
connection_info = {'data': {'device_path': device_path}}
@ -71,7 +71,7 @@ Setting up iSCSI targets: unused
device_path = '/dev/fake-dev'
connection_info = {'data': {'device_path': device_path}}
libvirt_driver = iscsi.LibvirtISCSIVolumeDriver(self.fake_conn)
libvirt_driver = iscsi.LibvirtISCSIVolumeDriver(self.fake_host)
libvirt_driver.connector.disconnect_volume = mock.MagicMock(
side_effect=os_brick_exception.VolumeDeviceNotFound(
device=device_path))

View File

@ -18,5 +18,5 @@ class LibvirtISERVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
"""Tests the libvirt iSER volume driver."""
def test_get_transport(self):
driver = iser.LibvirtISERVolumeDriver(self.fake_conn)
driver = iser.LibvirtISERVolumeDriver(self.fake_host)
self.assertEqual('iser', driver._get_transport())

View File

@ -45,7 +45,7 @@ class LibvirtNetVolumeDriverTestCase(
}
def test_libvirt_sheepdog_driver(self):
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_conn)
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.sheepdog_connection(self.vol)
conf = libvirt_driver.get_config(connection_info, self.disk_info)
tree = conf.format_dom()
@ -71,7 +71,7 @@ class LibvirtNetVolumeDriverTestCase(
}
def test_libvirt_rbd_driver(self):
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_conn)
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.rbd_connection(self.vol)
conf = libvirt_driver.get_config(connection_info, self.disk_info)
tree = conf.format_dom()
@ -82,7 +82,7 @@ class LibvirtNetVolumeDriverTestCase(
libvirt_driver.disconnect_volume(connection_info, "vde")
def test_libvirt_rbd_driver_hosts(self):
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_conn)
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.rbd_connection(self.vol)
hosts = ['example.com', '1.2.3.4', '::1']
ports = [None, '6790', '6791']
@ -98,7 +98,7 @@ class LibvirtNetVolumeDriverTestCase(
libvirt_driver.disconnect_volume(connection_info, "vde")
def test_libvirt_rbd_driver_auth_enabled(self):
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_conn)
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.rbd_connection(self.vol)
secret_type = 'ceph'
connection_info['data']['auth_enabled'] = True
@ -115,7 +115,7 @@ class LibvirtNetVolumeDriverTestCase(
libvirt_driver.disconnect_volume(connection_info, "vde")
def test_libvirt_rbd_driver_auth_enabled_flags_override(self):
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_conn)
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.rbd_connection(self.vol)
secret_type = 'ceph'
connection_info['data']['auth_enabled'] = True
@ -138,7 +138,7 @@ class LibvirtNetVolumeDriverTestCase(
libvirt_driver.disconnect_volume(connection_info, "vde")
def test_libvirt_rbd_driver_auth_disabled(self):
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_conn)
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.rbd_connection(self.vol)
secret_type = 'ceph'
connection_info['data']['auth_enabled'] = False
@ -153,7 +153,7 @@ class LibvirtNetVolumeDriverTestCase(
libvirt_driver.disconnect_volume(connection_info, "vde")
def test_libvirt_rbd_driver_auth_disabled_flags_override(self):
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_conn)
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.rbd_connection(self.vol)
secret_type = 'ceph'
connection_info['data']['auth_enabled'] = False
@ -184,7 +184,7 @@ class LibvirtNetVolumeDriverTestCase(
mock_find):
mock_find.return_value = test_volume.FakeSecret()
mock_create.return_value = test_volume.FakeSecret()
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_conn)
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.iscsi_connection(self.vol, self.location,
self.iqn, auth=True)
secret_type = 'iscsi'

View File

@ -31,7 +31,7 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
@mock.patch.object(libvirt_utils, 'is_mounted', return_value=False)
def test_libvirt_nfs_driver(self, mock_is_mounted):
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_conn)
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_host)
export_string = '192.168.1.1:/nfs/share1'
export_mnt_base = os.path.join(self.mnt_base,
@ -60,7 +60,7 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
export_string = '192.168.1.1:/nfs/share1'
connection_info = {'data': {'export': export_string,
'name': self.name}}
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_conn)
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_host)
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
None, None, None, 'umount', 'umount: device is busy.')
libvirt_driver.disconnect_volume(connection_info, "vde")
@ -79,7 +79,7 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
self.assertTrue(mock_LOG_exception.called)
def test_libvirt_nfs_driver_get_config(self):
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_conn)
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_host)
export_string = '192.168.1.1:/nfs/share1'
export_mnt_base = os.path.join(self.mnt_base,
utils.get_hash_str(export_string))
@ -95,7 +95,7 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
self.assertEqual('native', tree.find('./driver').get('io'))
def test_libvirt_nfs_driver_already_mounted(self):
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_conn)
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_host)
export_string = '192.168.1.1:/nfs/share1'
export_mnt_base = os.path.join(self.mnt_base,
@ -114,7 +114,7 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
@mock.patch.object(libvirt_utils, 'is_mounted', return_value=False)
def test_libvirt_nfs_driver_with_opts(self, mock_is_mounted):
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_conn)
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_host)
export_string = '192.168.1.1:/nfs/share1'
options = '-o intr,nfsvers=3'
export_mnt_base = os.path.join(self.mnt_base,

View File

@ -201,7 +201,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_conn)
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_host)
export_string = 'quobyte://192.168.1.1/volume-00001'
quobyte_volume = '192.168.1.1/volume-00001'
export_mnt_base = os.path.join(mnt_base,
@ -231,7 +231,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_conn)
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_host)
export_string = 'quobyte://192.168.1.1/volume-00001'
quobyte_volume = '192.168.1.1/volume-00001'
export_mnt_base = os.path.join(mnt_base,
@ -260,7 +260,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_conn)
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_host)
export_string = 'quobyte://192.168.1.1/volume-00001'
quobyte_volume = '192.168.1.1/volume-00001'
export_mnt_base = os.path.join(mnt_base,
@ -297,7 +297,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
):
mnt_base = '/mnt'
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_conn)
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_host)
export_string = 'quobyte://192.168.1.1/volume-00001'
name = 'volume-00001'
image_format = 'qcow2'
@ -328,7 +328,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_conn)
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_host)
export_string = 'quobyte://192.168.1.1/volume-00001'
connection_info = {'data': {'export': export_string,
@ -350,7 +350,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_conn)
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_host)
export_string = 'quobyte://192.168.1.1/volume-00001'
self.assertEqual("192.168.1.1/volume-00001",
libvirt_driver._normalize_export(export_string))
@ -359,7 +359,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
mnt_base = '/mnt'
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_conn)
libvirt_driver = quobyte.LibvirtQuobyteVolumeDriver(self.fake_host)
export_string = '192.168.1.1/volume-00001'
self.assertEqual("192.168.1.1/volume-00001",
libvirt_driver._normalize_export(export_string))

View File

@ -26,7 +26,7 @@ class LibvirtScaleIOVolumeDriverTestCase(
def test_libvirt_scaleio_driver(self):
libvirt_driver = scaleio.LibvirtScaleIOVolumeDriver(
self.fake_conn)
self.fake_host)
self.assertIsInstance(libvirt_driver.connector,
connector.ScaleIOConnector)
@ -34,7 +34,7 @@ class LibvirtScaleIOVolumeDriverTestCase(
def brick_conn_vol(data):
return {'path': '/dev/vol01'}
sio = scaleio.LibvirtScaleIOVolumeDriver(self.fake_conn)
sio = scaleio.LibvirtScaleIOVolumeDriver(self.fake_host)
sio.connector.connect_volume = brick_conn_vol
disk_info = {'path': '/dev/vol01', 'name': 'vol01'}
conn = {'data': disk_info}
@ -43,7 +43,7 @@ class LibvirtScaleIOVolumeDriverTestCase(
conn['data']['device_path'])
def test_libvirt_scaleio_driver_get_config(self):
sio = scaleio.LibvirtScaleIOVolumeDriver(self.fake_conn)
sio = scaleio.LibvirtScaleIOVolumeDriver(self.fake_host)
disk_info = {'path': '/dev/vol01', 'name': 'vol01', 'type': 'raw',
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/vol01'}
conn = {'data': disk_info}
@ -52,7 +52,7 @@ class LibvirtScaleIOVolumeDriverTestCase(
self.assertEqual('/dev/vol01', conf.source_path)
def test_libvirt_scaleio_driver_disconnect(self):
sio = scaleio.LibvirtScaleIOVolumeDriver(self.fake_conn)
sio = scaleio.LibvirtScaleIOVolumeDriver(self.fake_host)
sio.connector.disconnect_volume = mock.MagicMock()
disk_info = {'path': '/dev/vol01', 'name': 'vol01', 'type': 'raw',
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/vol01'}

View File

@ -31,7 +31,7 @@ class LibvirtScalityVolumeDriverTestCase(
scality_sofs_mount_point=self.scality_sofs_mount_point,
group='libvirt')
self.drv = scality.LibvirtScalityVolumeDriver(self.fake_conn)
self.drv = scality.LibvirtScalityVolumeDriver(self.fake_host)
@mock.patch('six.moves.urllib.request.urlopen')
def test_connect_volume(self, mock_urlopen):

View File

@ -32,7 +32,7 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
def test_libvirt_smbfs_driver(self, mock_is_mounted):
mock_is_mounted.return_value = False
libvirt_driver = smbfs.LibvirtSMBFSVolumeDriver(self.fake_conn)
libvirt_driver = smbfs.LibvirtSMBFSVolumeDriver(self.fake_host)
export_string = '//192.168.1.1/volumes'
export_mnt_base = os.path.join(self.mnt_base,
utils.get_hash_str(export_string))
@ -50,7 +50,7 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
self.assertEqual(expected_commands, self.executes)
def test_libvirt_smbfs_driver_already_mounted(self):
libvirt_driver = smbfs.LibvirtSMBFSVolumeDriver(self.fake_conn)
libvirt_driver = smbfs.LibvirtSMBFSVolumeDriver(self.fake_host)
export_string = '//192.168.1.1/volumes'
export_mnt_base = os.path.join(self.mnt_base,
utils.get_hash_str(export_string))
@ -67,7 +67,7 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
self.assertEqual(expected_commands, self.executes)
def test_libvirt_smbfs_driver_get_config(self):
libvirt_driver = smbfs.LibvirtSMBFSVolumeDriver(self.fake_conn)
libvirt_driver = smbfs.LibvirtSMBFSVolumeDriver(self.fake_host)
export_string = '//192.168.1.1/volumes'
export_mnt_base = os.path.join(self.mnt_base,
utils.get_hash_str(export_string))
@ -84,7 +84,7 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
def test_libvirt_smbfs_driver_with_opts(self, mock_is_mounted):
mock_is_mounted.return_value = False
libvirt_driver = smbfs.LibvirtSMBFSVolumeDriver(self.fake_conn)
libvirt_driver = smbfs.LibvirtSMBFSVolumeDriver(self.fake_host)
export_string = '//192.168.1.1/volumes'
options = '-o user=guest,uid=107,gid=105'
export_mnt_base = os.path.join(self.mnt_base,

View File

@ -62,14 +62,8 @@ class LibvirtVolumeBaseTestCase(test.NoDBTestCase):
self.useFixture(fakelibvirt.FakeLibvirtFixture())
class FakeLibvirtDriver(object):
def __init__(self):
self._host = host.Host("qemu:///system")
self.fake_host = host.Host("qemu:///system")
def _get_all_block_devices(self):
return []
self.fake_conn = FakeLibvirtDriver()
self.connr = {
'ip': '127.0.0.1',
'initiator': 'fake_initiator',
@ -130,7 +124,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
self.assertEqual(disk_info['dev'], tree.find('./target').get('dev'))
def _test_libvirt_volume_driver_disk_info(self):
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
connection_info = {
'driver_volume_type': 'fake',
'data': {
@ -155,7 +149,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
self._test_libvirt_volume_driver_disk_info()
def test_libvirt_volume_driver_serial(self):
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
connection_info = {
'driver_volume_type': 'fake',
'data': {
@ -171,7 +165,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
self.assertIsNone(tree.find("driver[@discard]"))
def test_libvirt_volume_driver_blockio(self):
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
connection_info = {
'driver_volume_type': 'fake',
'data': {
@ -193,7 +187,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
self.assertEqual('4096', blockio.get('physical_block_size'))
def test_libvirt_volume_driver_iotune(self):
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
connection_info = {
'driver_volume_type': 'fake',
'data': {
@ -232,7 +226,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
self.assertEqual('200', tree.find('./iotune/write_iops_sec').text)
def test_libvirt_volume_driver_readonly(self):
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
connection_info = {
'driver_volume_type': 'fake',
'data': {
@ -265,7 +259,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
def test_libvirt_volume_driver_discard_true(self, mock_has_min_version):
# Check the discard attrib is present in driver section
mock_has_min_version.return_value = True
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
connection_info = {
'driver_volume_type': 'fake',
'data': {
@ -283,7 +277,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
def test_libvirt_volume_driver_discard_false(self):
# Check the discard attrib is not present in driver section
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
connection_info = {
'driver_volume_type': 'fake',
'data': {
@ -302,7 +296,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
self, mock_has_min_version):
# Check the discard attrib is not present in driver section
mock_has_min_version.return_value = False
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
connection_info = {
'driver_volume_type': 'fake',
'data': {

View File

@ -31,7 +31,7 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
group='libvirt')
def test_libvirt_vzstorage_driver(self):
libvirt_driver = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_conn)
libvirt_driver = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_host)
self.assertIsInstance(libvirt_driver.connector,
connector.RemoteFsConnector)
@ -47,11 +47,11 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
self.flags(vzstorage_mount_opts=opts, group='libvirt')
self.assertRaises(exception.NovaException,
vzstorage.LibvirtVZStorageVolumeDriver,
self.fake_conn)
self.fake_host)
def test_libvirt_vzstorage_driver_share_fmt_neg(self):
drv = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_conn)
drv = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_host)
wrong_export_string = 'mds1, mds2:/testcluster:passwd12111'
connection_info = {'data': {'export': wrong_export_string,
@ -69,7 +69,7 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
def brick_conn_vol(data):
return {'path': 'vstorage://testcluster'}
drv = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_conn)
drv = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_host)
drv.connector.connect_volume = brick_conn_vol
export_string = 'testcluster'
@ -85,7 +85,7 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
connection_info['data']['options'])
def test_libvirt_vzstorage_driver_disconnect(self):
drv = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_conn)
drv = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_host)
drv.connector.disconnect_volume = mock.MagicMock()
conn = {'data': self.disk_info}
drv.disconnect_volume(conn, self.disk_info)
@ -93,7 +93,7 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
self.disk_info, None)
def test_libvirt_vzstorage_driver_get_config(self):
libvirt_driver = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_conn)
libvirt_driver = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_host)
export_string = 'vzstorage'
export_mnt_base = os.path.join(self.mnt_base,
utils.get_hash_str(export_string))

View File

@ -353,7 +353,7 @@ class LibvirtDriver(driver.ComputeDriver):
self.vif_driver = libvirt_vif.LibvirtGenericVIFDriver()
self.volume_drivers = driver.driver_dict_from_config(
self._get_volume_drivers(), self)
self._get_volume_drivers(), self._host)
self._disk_cachemode = None
self.image_cache_manager = imagecache.ImageCacheManager()

View File

@ -24,9 +24,9 @@ CONF = nova.conf.CONF
class LibvirtAOEVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
"""Driver to attach AoE volumes to libvirt."""
def __init__(self, connection):
def __init__(self, host):
super(LibvirtAOEVolumeDriver,
self).__init__(connection, is_block_dev=True)
self).__init__(host, is_block_dev=True)
# Call the factory here so we can support
# more than x86 architectures.

View File

@ -31,9 +31,9 @@ class LibvirtDISCOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
Uses the DISCO connector from the os-brick projects.
"""
def __init__(self, connection):
def __init__(self, host):
"""Init DISCO connector for LibVirt."""
super(LibvirtDISCOVolumeDriver, self).__init__(connection,
super(LibvirtDISCOVolumeDriver, self).__init__(host,
is_block_dev=False)
self.connector = connector.InitiatorConnector.factory(
'DISCO', utils.get_root_helper(),

View File

@ -25,9 +25,9 @@ LOG = logging.getLogger(__name__)
class LibvirtFibreChannelVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
"""Driver to attach Fibre Channel Network volumes to libvirt."""
def __init__(self, connection):
def __init__(self, host):
super(LibvirtFibreChannelVolumeDriver,
self).__init__(connection, is_block_dev=False)
self).__init__(host, is_block_dev=False)
# Call the factory here so we can support
# more than x86 architectures.

View File

@ -26,9 +26,9 @@ class LibvirtBaseFileSystemVolumeDriver(
libvirt_volume.LibvirtBaseVolumeDriver):
"""The base class for file system type volume drivers"""
def __init__(self, connection):
def __init__(self, host):
super(LibvirtBaseFileSystemVolumeDriver,
self).__init__(connection, is_block_dev=False)
self).__init__(host, is_block_dev=False)
@abc.abstractmethod
def _get_mount_point_base(self):

View File

@ -25,9 +25,9 @@ CONF = nova.conf.CONF
class LibvirtHGSTVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
"""Driver to attach HGST volumes to libvirt."""
def __init__(self, connection):
def __init__(self, host):
super(LibvirtHGSTVolumeDriver,
self).__init__(connection, is_block_dev=True)
self).__init__(host, is_block_dev=True)
self.connector = connector.InitiatorConnector.factory(
'HGST', utils.get_root_helper(),
device_scan_attempts=CONF.libvirt.num_iscsi_scan_tries)

View File

@ -28,8 +28,8 @@ CONF = nova.conf.CONF
class LibvirtISCSIVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
"""Driver to attach Network volumes to libvirt."""
def __init__(self, connection):
super(LibvirtISCSIVolumeDriver, self).__init__(connection,
def __init__(self, host):
super(LibvirtISCSIVolumeDriver, self).__init__(host,
is_block_dev=True)
# Call the factory here so we can support

View File

@ -22,19 +22,19 @@ CONF = nova.conf.CONF
class LibvirtNetVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
"""Driver to attach Network volumes to libvirt."""
def __init__(self, connection):
def __init__(self, host):
super(LibvirtNetVolumeDriver,
self).__init__(connection, is_block_dev=False)
self).__init__(host, is_block_dev=False)
def _get_secret_uuid(self, conf, password=None):
# TODO(mriedem): Add delegation methods to connection (LibvirtDriver)
# to call through for these secret CRUD operations so the volume driver
# doesn't need to know the internal attributes of the connection
# object.
secret = self.connection._host.find_secret(conf.source_protocol,
secret = self.host.find_secret(conf.source_protocol,
conf.source_name)
if secret is None:
secret = self.connection._host.create_secret(conf.source_protocol,
secret = self.host.create_secret(conf.source_protocol,
conf.source_name,
password)
return secret.UUIDString()
@ -48,7 +48,7 @@ class LibvirtNetVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
usage_type = 'iscsi'
usage_name = ("%(target_iqn)s/%(target_lun)s" %
netdisk_properties)
self.connection._host.delete_secret(usage_type, usage_name)
self.host.delete_secret(usage_type, usage_name)
def get_config(self, connection_info, disk_info):
"""Returns xml for libvirt."""

View File

@ -33,8 +33,8 @@ class LibvirtScaleIOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
Implements Libvirt part of volume driver for ScaleIO cinder driver.
Uses the ScaleIO connector from the os-brick projects
"""
def __init__(self, connection):
super(LibvirtScaleIOVolumeDriver, self).__init__(connection,
def __init__(self, host):
super(LibvirtScaleIOVolumeDriver, self).__init__(host,
is_block_dev=False)
self.connector = connector.InitiatorConnector.factory(
'SCALEIO', utils.get_root_helper(),

View File

@ -37,15 +37,15 @@ SHOULD_LOG_DISCARD_WARNING = True
class LibvirtBaseVolumeDriver(object):
"""Base class for volume drivers."""
def __init__(self, connection, is_block_dev):
self.connection = connection
def __init__(self, host, is_block_dev):
self.host = host
self.is_block_dev = is_block_dev
def get_config(self, connection_info, disk_info):
"""Returns xml for libvirt."""
conf = vconfig.LibvirtConfigGuestDisk()
conf.driver_name = libvirt_utils.pick_disk_driver_name(
self.connection._host.get_version(),
self.host.get_version(),
self.is_block_dev
)
@ -95,7 +95,7 @@ class LibvirtBaseVolumeDriver(object):
# Configure usage of discard
if data.get('discard', False) is True:
min_qemu = nova.virt.libvirt.driver.MIN_QEMU_DISCARD_VERSION
if self.connection._host.has_min_version(
if self.host.has_min_version(
hv_ver=min_qemu,
hv_type=host.HV_DRIVER_QEMU):
conf.driver_discard = 'unmap'
@ -125,9 +125,9 @@ class LibvirtBaseVolumeDriver(object):
class LibvirtVolumeDriver(LibvirtBaseVolumeDriver):
"""Class for volumes backed by local file."""
def __init__(self, connection):
def __init__(self, host):
super(LibvirtVolumeDriver,
self).__init__(connection, is_block_dev=True)
self).__init__(host, is_block_dev=True)
def get_config(self, connection_info, disk_info):
"""Returns xml for libvirt."""
@ -140,9 +140,9 @@ class LibvirtVolumeDriver(LibvirtBaseVolumeDriver):
class LibvirtFakeVolumeDriver(LibvirtBaseVolumeDriver):
"""Driver to attach fake volumes to libvirt."""
def __init__(self, connection):
def __init__(self, host):
super(LibvirtFakeVolumeDriver,
self).__init__(connection, is_block_dev=True)
self).__init__(host, is_block_dev=True)
def get_config(self, connection_info, disk_info):
"""Returns xml for libvirt."""