libvirt: Pass Host instead of Driver to volume drivers
We were initialising libvirt volume drivers by passing the LibvirtDriver object. However, this is only ever used to fetch the Host. We update the interface to pass the Host instead. This is cleaner, but also better represents the intent of the interface. They should not be able to access arbitrary attributes of the LibvirtDriver object. Change-Id: I87ceeee1ec46dc22754321574b16e6c47b27a848
This commit is contained in:
parent
26dcc8e45b
commit
36322fdf48
@ -21,6 +21,6 @@ class LibvirtAOEVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
|
|
||||||
@mock.patch('os.path.exists', return_value=True)
|
@mock.patch('os.path.exists', return_value=True)
|
||||||
def test_libvirt_aoe_driver(self, exists):
|
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,
|
self.assertIsInstance(libvirt_driver.connector,
|
||||||
connector.AoEConnector)
|
connector.AoEConnector)
|
||||||
|
@ -25,12 +25,12 @@ class LibvirtDISCOVolumeDriverTestCase(
|
|||||||
|
|
||||||
def test_libvirt_disco_driver(self):
|
def test_libvirt_disco_driver(self):
|
||||||
libvirt_driver = disco.LibvirtDISCOVolumeDriver(
|
libvirt_driver = disco.LibvirtDISCOVolumeDriver(
|
||||||
self.fake_conn)
|
self.fake_host)
|
||||||
self.assertIsInstance(libvirt_driver.connector,
|
self.assertIsInstance(libvirt_driver.connector,
|
||||||
connector.DISCOConnector)
|
connector.DISCOConnector)
|
||||||
|
|
||||||
def test_libvirt_disco_driver_connect(self):
|
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}
|
conf = {'server_ip': '127.0.0.1', 'server_port': 9898}
|
||||||
disk_info = {'disco_id': '1234567',
|
disk_info = {'disco_id': '1234567',
|
||||||
'name': 'aDiscoVolume',
|
'name': 'aDiscoVolume',
|
||||||
@ -44,7 +44,7 @@ class LibvirtDISCOVolumeDriverTestCase(
|
|||||||
conn['data']['device_path'])
|
conn['data']['device_path'])
|
||||||
|
|
||||||
def test_libvirt_disco_driver_get_config(self):
|
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',
|
disk_info = {'path': '/dev/dms1234567', 'name': 'aDiscoVolume',
|
||||||
'type': 'raw', 'dev': 'vda1', 'bus': 'pci0',
|
'type': 'raw', 'dev': 'vda1', 'bus': 'pci0',
|
||||||
@ -56,7 +56,7 @@ class LibvirtDISCOVolumeDriverTestCase(
|
|||||||
self.assertEqual('disco', conf.source_protocol)
|
self.assertEqual('disco', conf.source_protocol)
|
||||||
|
|
||||||
def test_libvirt_disco_driver_disconnect(self):
|
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()
|
dcon.connector.disconnect_volume = mock.MagicMock()
|
||||||
disk_info = {'path': '/dev/dms1234567', 'name': 'aDiscoVolume',
|
disk_info = {'path': '/dev/dms1234567', 'name': 'aDiscoVolume',
|
||||||
'type': 'raw', 'dev': 'vda1', 'bus': 'pci0',
|
'type': 'raw', 'dev': 'vda1', 'bus': 'pci0',
|
||||||
|
@ -25,13 +25,13 @@ class LibvirtFibreChannelVolumeDriverTestCase(
|
|||||||
|
|
||||||
def test_libvirt_fibrechan_driver(self):
|
def test_libvirt_fibrechan_driver(self):
|
||||||
libvirt_driver = fibrechannel.LibvirtFibreChannelVolumeDriver(
|
libvirt_driver = fibrechannel.LibvirtFibreChannelVolumeDriver(
|
||||||
self.fake_conn)
|
self.fake_host)
|
||||||
self.assertIsInstance(libvirt_driver.connector,
|
self.assertIsInstance(libvirt_driver.connector,
|
||||||
connector.FibreChannelConnector)
|
connector.FibreChannelConnector)
|
||||||
|
|
||||||
def _test_libvirt_fibrechan_driver_s390(self):
|
def _test_libvirt_fibrechan_driver_s390(self):
|
||||||
libvirt_driver = fibrechannel.LibvirtFibreChannelVolumeDriver(
|
libvirt_driver = fibrechannel.LibvirtFibreChannelVolumeDriver(
|
||||||
self.fake_conn)
|
self.fake_host)
|
||||||
self.assertIsInstance(libvirt_driver.connector,
|
self.assertIsInstance(libvirt_driver.connector,
|
||||||
connector.FibreChannelConnectorS390X)
|
connector.FibreChannelConnectorS390X)
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class LibvirtFibreChannelVolumeDriverTestCase(
|
|||||||
|
|
||||||
def test_libvirt_fibrechan_driver_get_config(self):
|
def test_libvirt_fibrechan_driver_get_config(self):
|
||||||
libvirt_driver = fibrechannel.LibvirtFibreChannelVolumeDriver(
|
libvirt_driver = fibrechannel.LibvirtFibreChannelVolumeDriver(
|
||||||
self.fake_conn)
|
self.fake_host)
|
||||||
|
|
||||||
device_path = '/dev/fake-dev'
|
device_path = '/dev/fake-dev'
|
||||||
connection_info = {'data': {'device_path': device_path}}
|
connection_info = {'data': {'device_path': device_path}}
|
||||||
|
@ -29,7 +29,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(glusterfs_mount_point_base=mnt_base, group='libvirt')
|
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_string = '192.168.1.1:/volume-00001'
|
||||||
export_mnt_base = os.path.join(mnt_base,
|
export_mnt_base = os.path.join(mnt_base,
|
||||||
utils.get_hash_str(export_string))
|
utils.get_hash_str(export_string))
|
||||||
@ -53,7 +53,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(glusterfs_mount_point_base=mnt_base, group='libvirt')
|
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_string = '192.168.1.1:/volume-00001'
|
||||||
export_mnt_base = os.path.join(mnt_base,
|
export_mnt_base = os.path.join(mnt_base,
|
||||||
utils.get_hash_str(export_string))
|
utils.get_hash_str(export_string))
|
||||||
@ -82,7 +82,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(glusterfs_mount_point_base=mnt_base, group='libvirt')
|
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_string = '192.168.1.1:/volume-00001'
|
||||||
export_mnt_base = os.path.join(mnt_base,
|
export_mnt_base = os.path.join(mnt_base,
|
||||||
utils.get_hash_str(export_string))
|
utils.get_hash_str(export_string))
|
||||||
@ -106,7 +106,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
|
|||||||
export_string = '192.168.1.1:/volume-00001'
|
export_string = '192.168.1.1:/volume-00001'
|
||||||
connection_info = {'data': {'export': export_string,
|
connection_info = {'data': {'export': export_string,
|
||||||
'name': self.name}}
|
'name': self.name}}
|
||||||
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_conn)
|
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_host)
|
||||||
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
|
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
|
||||||
None, None, None, 'umount', 'umount: target is busy.')
|
None, None, None, 'umount', 'umount: target is busy.')
|
||||||
libvirt_driver.disconnect_volume(connection_info, "vde")
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
@ -117,7 +117,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(glusterfs_mount_point_base=mnt_base, group='libvirt')
|
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_string = '192.168.1.1:/volume-00001'
|
||||||
options = '-o backupvolfile-server=192.168.1.2'
|
options = '-o backupvolfile-server=192.168.1.2'
|
||||||
export_mnt_base = os.path.join(mnt_base,
|
export_mnt_base = os.path.join(mnt_base,
|
||||||
@ -142,7 +142,7 @@ class LibvirtGlusterfsVolumeDriverTestCase(
|
|||||||
@mock.patch.object(libvirt_utils, 'is_mounted', return_value=False)
|
@mock.patch.object(libvirt_utils, 'is_mounted', return_value=False)
|
||||||
def test_libvirt_glusterfs_libgfapi(self, mock_is_mounted):
|
def test_libvirt_glusterfs_libgfapi(self, mock_is_mounted):
|
||||||
self.flags(qemu_allowed_storage_drivers=['gluster'], group='libvirt')
|
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'
|
export_string = '192.168.1.1:/volume-00001'
|
||||||
name = 'volume-00001'
|
name = 'volume-00001'
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from nova.virt.libvirt.volume import gpfs
|
|||||||
class LibvirtGPFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
class LibvirtGPFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
||||||
|
|
||||||
def test_libvirt_gpfs_driver_get_config(self):
|
def test_libvirt_gpfs_driver_get_config(self):
|
||||||
libvirt_driver = gpfs.LibvirtGPFSVolumeDriver(self.fake_conn)
|
libvirt_driver = gpfs.LibvirtGPFSVolumeDriver(self.fake_host)
|
||||||
connection_info = {
|
connection_info = {
|
||||||
'driver_volume_type': 'gpfs',
|
'driver_volume_type': 'gpfs',
|
||||||
'data': {
|
'data': {
|
||||||
|
@ -27,14 +27,14 @@ from nova.virt.libvirt.volume import hgst
|
|||||||
|
|
||||||
class LibvirtHGSTVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
class LibvirtHGSTVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
||||||
def test_libvirt_hgst_driver_type(self):
|
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)
|
self.assertIsInstance(drvr.connector, connector.HGSTConnector)
|
||||||
|
|
||||||
def test_libvirt_hgst_driver_connect(self):
|
def test_libvirt_hgst_driver_connect(self):
|
||||||
def brick_conn_vol(data):
|
def brick_conn_vol(data):
|
||||||
return {'path': '/dev/space01'}
|
return {'path': '/dev/space01'}
|
||||||
|
|
||||||
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_conn)
|
drvr = hgst.LibvirtHGSTVolumeDriver(self.fake_host)
|
||||||
drvr.connector.connect_volume = brick_conn_vol
|
drvr.connector.connect_volume = brick_conn_vol
|
||||||
di = {'path': '/dev/space01', 'name': 'space01'}
|
di = {'path': '/dev/space01', 'name': 'space01'}
|
||||||
ci = {'data': di}
|
ci = {'data': di}
|
||||||
@ -43,7 +43,7 @@ class LibvirtHGSTVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
ci['data']['device_path'])
|
ci['data']['device_path'])
|
||||||
|
|
||||||
def test_libvirt_hgst_driver_get_config(self):
|
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',
|
di = {'path': '/dev/space01', 'name': 'space01', 'type': 'raw',
|
||||||
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/space01'}
|
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/space01'}
|
||||||
ci = {'data': di}
|
ci = {'data': di}
|
||||||
@ -52,7 +52,7 @@ class LibvirtHGSTVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
self.assertEqual('/dev/space01', conf.source_path)
|
self.assertEqual('/dev/space01', conf.source_path)
|
||||||
|
|
||||||
def test_libvirt_hgst_driver_disconnect(self):
|
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()
|
drvr.connector.disconnect_volume = mock.MagicMock()
|
||||||
di = {'path': '/dev/space01', 'name': 'space01', 'type': 'raw',
|
di = {'path': '/dev/space01', 'name': 'space01', 'type': 'raw',
|
||||||
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/space01'}
|
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/space01'}
|
||||||
|
@ -47,12 +47,12 @@ Setting up iSCSI targets: unused
|
|||||||
self.assertEqual(targets, out)
|
self.assertEqual(targets, out)
|
||||||
|
|
||||||
def test_libvirt_iscsi_driver(self, transport=None):
|
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,
|
self.assertIsInstance(libvirt_driver.connector,
|
||||||
connector.ISCSIConnector)
|
connector.ISCSIConnector)
|
||||||
|
|
||||||
def test_libvirt_iscsi_driver_get_config(self):
|
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'
|
device_path = '/dev/fake-dev'
|
||||||
connection_info = {'data': {'device_path': device_path}}
|
connection_info = {'data': {'device_path': device_path}}
|
||||||
@ -71,7 +71,7 @@ Setting up iSCSI targets: unused
|
|||||||
device_path = '/dev/fake-dev'
|
device_path = '/dev/fake-dev'
|
||||||
connection_info = {'data': {'device_path': device_path}}
|
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(
|
libvirt_driver.connector.disconnect_volume = mock.MagicMock(
|
||||||
side_effect=os_brick_exception.VolumeDeviceNotFound(
|
side_effect=os_brick_exception.VolumeDeviceNotFound(
|
||||||
device=device_path))
|
device=device_path))
|
||||||
|
@ -18,5 +18,5 @@ class LibvirtISERVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
"""Tests the libvirt iSER volume driver."""
|
"""Tests the libvirt iSER volume driver."""
|
||||||
|
|
||||||
def test_get_transport(self):
|
def test_get_transport(self):
|
||||||
driver = iser.LibvirtISERVolumeDriver(self.fake_conn)
|
driver = iser.LibvirtISERVolumeDriver(self.fake_host)
|
||||||
self.assertEqual('iser', driver._get_transport())
|
self.assertEqual('iser', driver._get_transport())
|
||||||
|
@ -45,7 +45,7 @@ class LibvirtNetVolumeDriverTestCase(
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_libvirt_sheepdog_driver(self):
|
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)
|
connection_info = self.sheepdog_connection(self.vol)
|
||||||
conf = libvirt_driver.get_config(connection_info, self.disk_info)
|
conf = libvirt_driver.get_config(connection_info, self.disk_info)
|
||||||
tree = conf.format_dom()
|
tree = conf.format_dom()
|
||||||
@ -71,7 +71,7 @@ class LibvirtNetVolumeDriverTestCase(
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_libvirt_rbd_driver(self):
|
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)
|
connection_info = self.rbd_connection(self.vol)
|
||||||
conf = libvirt_driver.get_config(connection_info, self.disk_info)
|
conf = libvirt_driver.get_config(connection_info, self.disk_info)
|
||||||
tree = conf.format_dom()
|
tree = conf.format_dom()
|
||||||
@ -82,7 +82,7 @@ class LibvirtNetVolumeDriverTestCase(
|
|||||||
libvirt_driver.disconnect_volume(connection_info, "vde")
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
|
|
||||||
def test_libvirt_rbd_driver_hosts(self):
|
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)
|
connection_info = self.rbd_connection(self.vol)
|
||||||
hosts = ['example.com', '1.2.3.4', '::1']
|
hosts = ['example.com', '1.2.3.4', '::1']
|
||||||
ports = [None, '6790', '6791']
|
ports = [None, '6790', '6791']
|
||||||
@ -98,7 +98,7 @@ class LibvirtNetVolumeDriverTestCase(
|
|||||||
libvirt_driver.disconnect_volume(connection_info, "vde")
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
|
|
||||||
def test_libvirt_rbd_driver_auth_enabled(self):
|
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)
|
connection_info = self.rbd_connection(self.vol)
|
||||||
secret_type = 'ceph'
|
secret_type = 'ceph'
|
||||||
connection_info['data']['auth_enabled'] = True
|
connection_info['data']['auth_enabled'] = True
|
||||||
@ -115,7 +115,7 @@ class LibvirtNetVolumeDriverTestCase(
|
|||||||
libvirt_driver.disconnect_volume(connection_info, "vde")
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
|
|
||||||
def test_libvirt_rbd_driver_auth_enabled_flags_override(self):
|
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)
|
connection_info = self.rbd_connection(self.vol)
|
||||||
secret_type = 'ceph'
|
secret_type = 'ceph'
|
||||||
connection_info['data']['auth_enabled'] = True
|
connection_info['data']['auth_enabled'] = True
|
||||||
@ -138,7 +138,7 @@ class LibvirtNetVolumeDriverTestCase(
|
|||||||
libvirt_driver.disconnect_volume(connection_info, "vde")
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
|
|
||||||
def test_libvirt_rbd_driver_auth_disabled(self):
|
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)
|
connection_info = self.rbd_connection(self.vol)
|
||||||
secret_type = 'ceph'
|
secret_type = 'ceph'
|
||||||
connection_info['data']['auth_enabled'] = False
|
connection_info['data']['auth_enabled'] = False
|
||||||
@ -153,7 +153,7 @@ class LibvirtNetVolumeDriverTestCase(
|
|||||||
libvirt_driver.disconnect_volume(connection_info, "vde")
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
|
|
||||||
def test_libvirt_rbd_driver_auth_disabled_flags_override(self):
|
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)
|
connection_info = self.rbd_connection(self.vol)
|
||||||
secret_type = 'ceph'
|
secret_type = 'ceph'
|
||||||
connection_info['data']['auth_enabled'] = False
|
connection_info['data']['auth_enabled'] = False
|
||||||
@ -184,7 +184,7 @@ class LibvirtNetVolumeDriverTestCase(
|
|||||||
mock_find):
|
mock_find):
|
||||||
mock_find.return_value = test_volume.FakeSecret()
|
mock_find.return_value = test_volume.FakeSecret()
|
||||||
mock_create.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,
|
connection_info = self.iscsi_connection(self.vol, self.location,
|
||||||
self.iqn, auth=True)
|
self.iqn, auth=True)
|
||||||
secret_type = 'iscsi'
|
secret_type = 'iscsi'
|
||||||
|
@ -31,7 +31,7 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
|
|
||||||
@mock.patch.object(libvirt_utils, 'is_mounted', return_value=False)
|
@mock.patch.object(libvirt_utils, 'is_mounted', return_value=False)
|
||||||
def test_libvirt_nfs_driver(self, mock_is_mounted):
|
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_string = '192.168.1.1:/nfs/share1'
|
||||||
export_mnt_base = os.path.join(self.mnt_base,
|
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'
|
export_string = '192.168.1.1:/nfs/share1'
|
||||||
connection_info = {'data': {'export': export_string,
|
connection_info = {'data': {'export': export_string,
|
||||||
'name': self.name}}
|
'name': self.name}}
|
||||||
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_conn)
|
libvirt_driver = nfs.LibvirtNFSVolumeDriver(self.fake_host)
|
||||||
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
|
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
|
||||||
None, None, None, 'umount', 'umount: device is busy.')
|
None, None, None, 'umount', 'umount: device is busy.')
|
||||||
libvirt_driver.disconnect_volume(connection_info, "vde")
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
@ -79,7 +79,7 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
self.assertTrue(mock_LOG_exception.called)
|
self.assertTrue(mock_LOG_exception.called)
|
||||||
|
|
||||||
def test_libvirt_nfs_driver_get_config(self):
|
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_string = '192.168.1.1:/nfs/share1'
|
||||||
export_mnt_base = os.path.join(self.mnt_base,
|
export_mnt_base = os.path.join(self.mnt_base,
|
||||||
utils.get_hash_str(export_string))
|
utils.get_hash_str(export_string))
|
||||||
@ -95,7 +95,7 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
self.assertEqual('native', tree.find('./driver').get('io'))
|
self.assertEqual('native', tree.find('./driver').get('io'))
|
||||||
|
|
||||||
def test_libvirt_nfs_driver_already_mounted(self):
|
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_string = '192.168.1.1:/nfs/share1'
|
||||||
export_mnt_base = os.path.join(self.mnt_base,
|
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)
|
@mock.patch.object(libvirt_utils, 'is_mounted', return_value=False)
|
||||||
def test_libvirt_nfs_driver_with_opts(self, mock_is_mounted):
|
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'
|
export_string = '192.168.1.1:/nfs/share1'
|
||||||
options = '-o intr,nfsvers=3'
|
options = '-o intr,nfsvers=3'
|
||||||
export_mnt_base = os.path.join(self.mnt_base,
|
export_mnt_base = os.path.join(self.mnt_base,
|
||||||
|
@ -201,7 +201,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
|
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'
|
export_string = 'quobyte://192.168.1.1/volume-00001'
|
||||||
quobyte_volume = '192.168.1.1/volume-00001'
|
quobyte_volume = '192.168.1.1/volume-00001'
|
||||||
export_mnt_base = os.path.join(mnt_base,
|
export_mnt_base = os.path.join(mnt_base,
|
||||||
@ -231,7 +231,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
|
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'
|
export_string = 'quobyte://192.168.1.1/volume-00001'
|
||||||
quobyte_volume = '192.168.1.1/volume-00001'
|
quobyte_volume = '192.168.1.1/volume-00001'
|
||||||
export_mnt_base = os.path.join(mnt_base,
|
export_mnt_base = os.path.join(mnt_base,
|
||||||
@ -260,7 +260,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
|
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'
|
export_string = 'quobyte://192.168.1.1/volume-00001'
|
||||||
quobyte_volume = '192.168.1.1/volume-00001'
|
quobyte_volume = '192.168.1.1/volume-00001'
|
||||||
export_mnt_base = os.path.join(mnt_base,
|
export_mnt_base = os.path.join(mnt_base,
|
||||||
@ -297,7 +297,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
|
|||||||
):
|
):
|
||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
|
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'
|
export_string = 'quobyte://192.168.1.1/volume-00001'
|
||||||
name = 'volume-00001'
|
name = 'volume-00001'
|
||||||
image_format = 'qcow2'
|
image_format = 'qcow2'
|
||||||
@ -328,7 +328,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
|
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'
|
export_string = 'quobyte://192.168.1.1/volume-00001'
|
||||||
|
|
||||||
connection_info = {'data': {'export': export_string,
|
connection_info = {'data': {'export': export_string,
|
||||||
@ -350,7 +350,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
|
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'
|
export_string = 'quobyte://192.168.1.1/volume-00001'
|
||||||
self.assertEqual("192.168.1.1/volume-00001",
|
self.assertEqual("192.168.1.1/volume-00001",
|
||||||
libvirt_driver._normalize_export(export_string))
|
libvirt_driver._normalize_export(export_string))
|
||||||
@ -359,7 +359,7 @@ class LibvirtQuobyteVolumeDriverTestCase(
|
|||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
self.flags(quobyte_mount_point_base=mnt_base, group='libvirt')
|
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'
|
export_string = '192.168.1.1/volume-00001'
|
||||||
self.assertEqual("192.168.1.1/volume-00001",
|
self.assertEqual("192.168.1.1/volume-00001",
|
||||||
libvirt_driver._normalize_export(export_string))
|
libvirt_driver._normalize_export(export_string))
|
||||||
|
@ -26,7 +26,7 @@ class LibvirtScaleIOVolumeDriverTestCase(
|
|||||||
|
|
||||||
def test_libvirt_scaleio_driver(self):
|
def test_libvirt_scaleio_driver(self):
|
||||||
libvirt_driver = scaleio.LibvirtScaleIOVolumeDriver(
|
libvirt_driver = scaleio.LibvirtScaleIOVolumeDriver(
|
||||||
self.fake_conn)
|
self.fake_host)
|
||||||
self.assertIsInstance(libvirt_driver.connector,
|
self.assertIsInstance(libvirt_driver.connector,
|
||||||
connector.ScaleIOConnector)
|
connector.ScaleIOConnector)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class LibvirtScaleIOVolumeDriverTestCase(
|
|||||||
def brick_conn_vol(data):
|
def brick_conn_vol(data):
|
||||||
return {'path': '/dev/vol01'}
|
return {'path': '/dev/vol01'}
|
||||||
|
|
||||||
sio = scaleio.LibvirtScaleIOVolumeDriver(self.fake_conn)
|
sio = scaleio.LibvirtScaleIOVolumeDriver(self.fake_host)
|
||||||
sio.connector.connect_volume = brick_conn_vol
|
sio.connector.connect_volume = brick_conn_vol
|
||||||
disk_info = {'path': '/dev/vol01', 'name': 'vol01'}
|
disk_info = {'path': '/dev/vol01', 'name': 'vol01'}
|
||||||
conn = {'data': disk_info}
|
conn = {'data': disk_info}
|
||||||
@ -43,7 +43,7 @@ class LibvirtScaleIOVolumeDriverTestCase(
|
|||||||
conn['data']['device_path'])
|
conn['data']['device_path'])
|
||||||
|
|
||||||
def test_libvirt_scaleio_driver_get_config(self):
|
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',
|
disk_info = {'path': '/dev/vol01', 'name': 'vol01', 'type': 'raw',
|
||||||
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/vol01'}
|
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/vol01'}
|
||||||
conn = {'data': disk_info}
|
conn = {'data': disk_info}
|
||||||
@ -52,7 +52,7 @@ class LibvirtScaleIOVolumeDriverTestCase(
|
|||||||
self.assertEqual('/dev/vol01', conf.source_path)
|
self.assertEqual('/dev/vol01', conf.source_path)
|
||||||
|
|
||||||
def test_libvirt_scaleio_driver_disconnect(self):
|
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()
|
sio.connector.disconnect_volume = mock.MagicMock()
|
||||||
disk_info = {'path': '/dev/vol01', 'name': 'vol01', 'type': 'raw',
|
disk_info = {'path': '/dev/vol01', 'name': 'vol01', 'type': 'raw',
|
||||||
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/vol01'}
|
'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/vol01'}
|
||||||
|
@ -31,7 +31,7 @@ class LibvirtScalityVolumeDriverTestCase(
|
|||||||
scality_sofs_mount_point=self.scality_sofs_mount_point,
|
scality_sofs_mount_point=self.scality_sofs_mount_point,
|
||||||
group='libvirt')
|
group='libvirt')
|
||||||
|
|
||||||
self.drv = scality.LibvirtScalityVolumeDriver(self.fake_conn)
|
self.drv = scality.LibvirtScalityVolumeDriver(self.fake_host)
|
||||||
|
|
||||||
@mock.patch('six.moves.urllib.request.urlopen')
|
@mock.patch('six.moves.urllib.request.urlopen')
|
||||||
def test_connect_volume(self, mock_urlopen):
|
def test_connect_volume(self, mock_urlopen):
|
||||||
|
@ -32,7 +32,7 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
def test_libvirt_smbfs_driver(self, mock_is_mounted):
|
def test_libvirt_smbfs_driver(self, mock_is_mounted):
|
||||||
mock_is_mounted.return_value = False
|
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_string = '//192.168.1.1/volumes'
|
||||||
export_mnt_base = os.path.join(self.mnt_base,
|
export_mnt_base = os.path.join(self.mnt_base,
|
||||||
utils.get_hash_str(export_string))
|
utils.get_hash_str(export_string))
|
||||||
@ -50,7 +50,7 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
self.assertEqual(expected_commands, self.executes)
|
self.assertEqual(expected_commands, self.executes)
|
||||||
|
|
||||||
def test_libvirt_smbfs_driver_already_mounted(self):
|
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_string = '//192.168.1.1/volumes'
|
||||||
export_mnt_base = os.path.join(self.mnt_base,
|
export_mnt_base = os.path.join(self.mnt_base,
|
||||||
utils.get_hash_str(export_string))
|
utils.get_hash_str(export_string))
|
||||||
@ -67,7 +67,7 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
self.assertEqual(expected_commands, self.executes)
|
self.assertEqual(expected_commands, self.executes)
|
||||||
|
|
||||||
def test_libvirt_smbfs_driver_get_config(self):
|
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_string = '//192.168.1.1/volumes'
|
||||||
export_mnt_base = os.path.join(self.mnt_base,
|
export_mnt_base = os.path.join(self.mnt_base,
|
||||||
utils.get_hash_str(export_string))
|
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):
|
def test_libvirt_smbfs_driver_with_opts(self, mock_is_mounted):
|
||||||
mock_is_mounted.return_value = False
|
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_string = '//192.168.1.1/volumes'
|
||||||
options = '-o user=guest,uid=107,gid=105'
|
options = '-o user=guest,uid=107,gid=105'
|
||||||
export_mnt_base = os.path.join(self.mnt_base,
|
export_mnt_base = os.path.join(self.mnt_base,
|
||||||
|
@ -62,14 +62,8 @@ class LibvirtVolumeBaseTestCase(test.NoDBTestCase):
|
|||||||
|
|
||||||
self.useFixture(fakelibvirt.FakeLibvirtFixture())
|
self.useFixture(fakelibvirt.FakeLibvirtFixture())
|
||||||
|
|
||||||
class FakeLibvirtDriver(object):
|
self.fake_host = host.Host("qemu:///system")
|
||||||
def __init__(self):
|
|
||||||
self._host = host.Host("qemu:///system")
|
|
||||||
|
|
||||||
def _get_all_block_devices(self):
|
|
||||||
return []
|
|
||||||
|
|
||||||
self.fake_conn = FakeLibvirtDriver()
|
|
||||||
self.connr = {
|
self.connr = {
|
||||||
'ip': '127.0.0.1',
|
'ip': '127.0.0.1',
|
||||||
'initiator': 'fake_initiator',
|
'initiator': 'fake_initiator',
|
||||||
@ -130,7 +124,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
|
|||||||
self.assertEqual(disk_info['dev'], tree.find('./target').get('dev'))
|
self.assertEqual(disk_info['dev'], tree.find('./target').get('dev'))
|
||||||
|
|
||||||
def _test_libvirt_volume_driver_disk_info(self):
|
def _test_libvirt_volume_driver_disk_info(self):
|
||||||
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
|
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
|
||||||
connection_info = {
|
connection_info = {
|
||||||
'driver_volume_type': 'fake',
|
'driver_volume_type': 'fake',
|
||||||
'data': {
|
'data': {
|
||||||
@ -155,7 +149,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
|
|||||||
self._test_libvirt_volume_driver_disk_info()
|
self._test_libvirt_volume_driver_disk_info()
|
||||||
|
|
||||||
def test_libvirt_volume_driver_serial(self):
|
def test_libvirt_volume_driver_serial(self):
|
||||||
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
|
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
|
||||||
connection_info = {
|
connection_info = {
|
||||||
'driver_volume_type': 'fake',
|
'driver_volume_type': 'fake',
|
||||||
'data': {
|
'data': {
|
||||||
@ -171,7 +165,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
|
|||||||
self.assertIsNone(tree.find("driver[@discard]"))
|
self.assertIsNone(tree.find("driver[@discard]"))
|
||||||
|
|
||||||
def test_libvirt_volume_driver_blockio(self):
|
def test_libvirt_volume_driver_blockio(self):
|
||||||
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
|
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
|
||||||
connection_info = {
|
connection_info = {
|
||||||
'driver_volume_type': 'fake',
|
'driver_volume_type': 'fake',
|
||||||
'data': {
|
'data': {
|
||||||
@ -193,7 +187,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
|
|||||||
self.assertEqual('4096', blockio.get('physical_block_size'))
|
self.assertEqual('4096', blockio.get('physical_block_size'))
|
||||||
|
|
||||||
def test_libvirt_volume_driver_iotune(self):
|
def test_libvirt_volume_driver_iotune(self):
|
||||||
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
|
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
|
||||||
connection_info = {
|
connection_info = {
|
||||||
'driver_volume_type': 'fake',
|
'driver_volume_type': 'fake',
|
||||||
'data': {
|
'data': {
|
||||||
@ -232,7 +226,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
|
|||||||
self.assertEqual('200', tree.find('./iotune/write_iops_sec').text)
|
self.assertEqual('200', tree.find('./iotune/write_iops_sec').text)
|
||||||
|
|
||||||
def test_libvirt_volume_driver_readonly(self):
|
def test_libvirt_volume_driver_readonly(self):
|
||||||
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
|
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
|
||||||
connection_info = {
|
connection_info = {
|
||||||
'driver_volume_type': 'fake',
|
'driver_volume_type': 'fake',
|
||||||
'data': {
|
'data': {
|
||||||
@ -265,7 +259,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
|
|||||||
def test_libvirt_volume_driver_discard_true(self, mock_has_min_version):
|
def test_libvirt_volume_driver_discard_true(self, mock_has_min_version):
|
||||||
# Check the discard attrib is present in driver section
|
# Check the discard attrib is present in driver section
|
||||||
mock_has_min_version.return_value = True
|
mock_has_min_version.return_value = True
|
||||||
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
|
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
|
||||||
connection_info = {
|
connection_info = {
|
||||||
'driver_volume_type': 'fake',
|
'driver_volume_type': 'fake',
|
||||||
'data': {
|
'data': {
|
||||||
@ -283,7 +277,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
|
|||||||
|
|
||||||
def test_libvirt_volume_driver_discard_false(self):
|
def test_libvirt_volume_driver_discard_false(self):
|
||||||
# Check the discard attrib is not present in driver section
|
# 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 = {
|
connection_info = {
|
||||||
'driver_volume_type': 'fake',
|
'driver_volume_type': 'fake',
|
||||||
'data': {
|
'data': {
|
||||||
@ -302,7 +296,7 @@ class LibvirtVolumeTestCase(LibvirtISCSIVolumeBaseTestCase):
|
|||||||
self, mock_has_min_version):
|
self, mock_has_min_version):
|
||||||
# Check the discard attrib is not present in driver section
|
# Check the discard attrib is not present in driver section
|
||||||
mock_has_min_version.return_value = False
|
mock_has_min_version.return_value = False
|
||||||
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
|
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
|
||||||
connection_info = {
|
connection_info = {
|
||||||
'driver_volume_type': 'fake',
|
'driver_volume_type': 'fake',
|
||||||
'data': {
|
'data': {
|
||||||
|
@ -31,7 +31,7 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
group='libvirt')
|
group='libvirt')
|
||||||
|
|
||||||
def test_libvirt_vzstorage_driver(self):
|
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,
|
self.assertIsInstance(libvirt_driver.connector,
|
||||||
connector.RemoteFsConnector)
|
connector.RemoteFsConnector)
|
||||||
|
|
||||||
@ -47,11 +47,11 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
self.flags(vzstorage_mount_opts=opts, group='libvirt')
|
self.flags(vzstorage_mount_opts=opts, group='libvirt')
|
||||||
self.assertRaises(exception.NovaException,
|
self.assertRaises(exception.NovaException,
|
||||||
vzstorage.LibvirtVZStorageVolumeDriver,
|
vzstorage.LibvirtVZStorageVolumeDriver,
|
||||||
self.fake_conn)
|
self.fake_host)
|
||||||
|
|
||||||
def test_libvirt_vzstorage_driver_share_fmt_neg(self):
|
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'
|
wrong_export_string = 'mds1, mds2:/testcluster:passwd12111'
|
||||||
connection_info = {'data': {'export': wrong_export_string,
|
connection_info = {'data': {'export': wrong_export_string,
|
||||||
@ -69,7 +69,7 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
def brick_conn_vol(data):
|
def brick_conn_vol(data):
|
||||||
return {'path': 'vstorage://testcluster'}
|
return {'path': 'vstorage://testcluster'}
|
||||||
|
|
||||||
drv = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_conn)
|
drv = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_host)
|
||||||
drv.connector.connect_volume = brick_conn_vol
|
drv.connector.connect_volume = brick_conn_vol
|
||||||
|
|
||||||
export_string = 'testcluster'
|
export_string = 'testcluster'
|
||||||
@ -85,7 +85,7 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
connection_info['data']['options'])
|
connection_info['data']['options'])
|
||||||
|
|
||||||
def test_libvirt_vzstorage_driver_disconnect(self):
|
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()
|
drv.connector.disconnect_volume = mock.MagicMock()
|
||||||
conn = {'data': self.disk_info}
|
conn = {'data': self.disk_info}
|
||||||
drv.disconnect_volume(conn, self.disk_info)
|
drv.disconnect_volume(conn, self.disk_info)
|
||||||
@ -93,7 +93,7 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
|||||||
self.disk_info, None)
|
self.disk_info, None)
|
||||||
|
|
||||||
def test_libvirt_vzstorage_driver_get_config(self):
|
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_string = 'vzstorage'
|
||||||
export_mnt_base = os.path.join(self.mnt_base,
|
export_mnt_base = os.path.join(self.mnt_base,
|
||||||
utils.get_hash_str(export_string))
|
utils.get_hash_str(export_string))
|
||||||
|
@ -353,7 +353,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||||||
self.vif_driver = libvirt_vif.LibvirtGenericVIFDriver()
|
self.vif_driver = libvirt_vif.LibvirtGenericVIFDriver()
|
||||||
|
|
||||||
self.volume_drivers = driver.driver_dict_from_config(
|
self.volume_drivers = driver.driver_dict_from_config(
|
||||||
self._get_volume_drivers(), self)
|
self._get_volume_drivers(), self._host)
|
||||||
|
|
||||||
self._disk_cachemode = None
|
self._disk_cachemode = None
|
||||||
self.image_cache_manager = imagecache.ImageCacheManager()
|
self.image_cache_manager = imagecache.ImageCacheManager()
|
||||||
|
@ -24,9 +24,9 @@ CONF = nova.conf.CONF
|
|||||||
|
|
||||||
class LibvirtAOEVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
class LibvirtAOEVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
||||||
"""Driver to attach AoE volumes to libvirt."""
|
"""Driver to attach AoE volumes to libvirt."""
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
super(LibvirtAOEVolumeDriver,
|
super(LibvirtAOEVolumeDriver,
|
||||||
self).__init__(connection, is_block_dev=True)
|
self).__init__(host, is_block_dev=True)
|
||||||
|
|
||||||
# Call the factory here so we can support
|
# Call the factory here so we can support
|
||||||
# more than x86 architectures.
|
# more than x86 architectures.
|
||||||
|
@ -31,9 +31,9 @@ class LibvirtDISCOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
|||||||
Uses the DISCO connector from the os-brick projects.
|
Uses the DISCO connector from the os-brick projects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
"""Init DISCO connector for LibVirt."""
|
"""Init DISCO connector for LibVirt."""
|
||||||
super(LibvirtDISCOVolumeDriver, self).__init__(connection,
|
super(LibvirtDISCOVolumeDriver, self).__init__(host,
|
||||||
is_block_dev=False)
|
is_block_dev=False)
|
||||||
self.connector = connector.InitiatorConnector.factory(
|
self.connector = connector.InitiatorConnector.factory(
|
||||||
'DISCO', utils.get_root_helper(),
|
'DISCO', utils.get_root_helper(),
|
||||||
|
@ -25,9 +25,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
class LibvirtFibreChannelVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
class LibvirtFibreChannelVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
||||||
"""Driver to attach Fibre Channel Network volumes to libvirt."""
|
"""Driver to attach Fibre Channel Network volumes to libvirt."""
|
||||||
|
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
super(LibvirtFibreChannelVolumeDriver,
|
super(LibvirtFibreChannelVolumeDriver,
|
||||||
self).__init__(connection, is_block_dev=False)
|
self).__init__(host, is_block_dev=False)
|
||||||
|
|
||||||
# Call the factory here so we can support
|
# Call the factory here so we can support
|
||||||
# more than x86 architectures.
|
# more than x86 architectures.
|
||||||
|
@ -26,9 +26,9 @@ class LibvirtBaseFileSystemVolumeDriver(
|
|||||||
libvirt_volume.LibvirtBaseVolumeDriver):
|
libvirt_volume.LibvirtBaseVolumeDriver):
|
||||||
"""The base class for file system type volume drivers"""
|
"""The base class for file system type volume drivers"""
|
||||||
|
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
super(LibvirtBaseFileSystemVolumeDriver,
|
super(LibvirtBaseFileSystemVolumeDriver,
|
||||||
self).__init__(connection, is_block_dev=False)
|
self).__init__(host, is_block_dev=False)
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def _get_mount_point_base(self):
|
def _get_mount_point_base(self):
|
||||||
|
@ -25,9 +25,9 @@ CONF = nova.conf.CONF
|
|||||||
|
|
||||||
class LibvirtHGSTVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
class LibvirtHGSTVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
||||||
"""Driver to attach HGST volumes to libvirt."""
|
"""Driver to attach HGST volumes to libvirt."""
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
super(LibvirtHGSTVolumeDriver,
|
super(LibvirtHGSTVolumeDriver,
|
||||||
self).__init__(connection, is_block_dev=True)
|
self).__init__(host, is_block_dev=True)
|
||||||
self.connector = connector.InitiatorConnector.factory(
|
self.connector = connector.InitiatorConnector.factory(
|
||||||
'HGST', utils.get_root_helper(),
|
'HGST', utils.get_root_helper(),
|
||||||
device_scan_attempts=CONF.libvirt.num_iscsi_scan_tries)
|
device_scan_attempts=CONF.libvirt.num_iscsi_scan_tries)
|
||||||
|
@ -28,8 +28,8 @@ CONF = nova.conf.CONF
|
|||||||
class LibvirtISCSIVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
class LibvirtISCSIVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
||||||
"""Driver to attach Network volumes to libvirt."""
|
"""Driver to attach Network volumes to libvirt."""
|
||||||
|
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
super(LibvirtISCSIVolumeDriver, self).__init__(connection,
|
super(LibvirtISCSIVolumeDriver, self).__init__(host,
|
||||||
is_block_dev=True)
|
is_block_dev=True)
|
||||||
|
|
||||||
# Call the factory here so we can support
|
# Call the factory here so we can support
|
||||||
|
@ -22,19 +22,19 @@ CONF = nova.conf.CONF
|
|||||||
|
|
||||||
class LibvirtNetVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
class LibvirtNetVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
||||||
"""Driver to attach Network volumes to libvirt."""
|
"""Driver to attach Network volumes to libvirt."""
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
super(LibvirtNetVolumeDriver,
|
super(LibvirtNetVolumeDriver,
|
||||||
self).__init__(connection, is_block_dev=False)
|
self).__init__(host, is_block_dev=False)
|
||||||
|
|
||||||
def _get_secret_uuid(self, conf, password=None):
|
def _get_secret_uuid(self, conf, password=None):
|
||||||
# TODO(mriedem): Add delegation methods to connection (LibvirtDriver)
|
# TODO(mriedem): Add delegation methods to connection (LibvirtDriver)
|
||||||
# to call through for these secret CRUD operations so the volume driver
|
# to call through for these secret CRUD operations so the volume driver
|
||||||
# doesn't need to know the internal attributes of the connection
|
# doesn't need to know the internal attributes of the connection
|
||||||
# object.
|
# object.
|
||||||
secret = self.connection._host.find_secret(conf.source_protocol,
|
secret = self.host.find_secret(conf.source_protocol,
|
||||||
conf.source_name)
|
conf.source_name)
|
||||||
if secret is None:
|
if secret is None:
|
||||||
secret = self.connection._host.create_secret(conf.source_protocol,
|
secret = self.host.create_secret(conf.source_protocol,
|
||||||
conf.source_name,
|
conf.source_name,
|
||||||
password)
|
password)
|
||||||
return secret.UUIDString()
|
return secret.UUIDString()
|
||||||
@ -48,7 +48,7 @@ class LibvirtNetVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
|||||||
usage_type = 'iscsi'
|
usage_type = 'iscsi'
|
||||||
usage_name = ("%(target_iqn)s/%(target_lun)s" %
|
usage_name = ("%(target_iqn)s/%(target_lun)s" %
|
||||||
netdisk_properties)
|
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):
|
def get_config(self, connection_info, disk_info):
|
||||||
"""Returns xml for libvirt."""
|
"""Returns xml for libvirt."""
|
||||||
|
@ -33,8 +33,8 @@ class LibvirtScaleIOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
|||||||
Implements Libvirt part of volume driver for ScaleIO cinder driver.
|
Implements Libvirt part of volume driver for ScaleIO cinder driver.
|
||||||
Uses the ScaleIO connector from the os-brick projects
|
Uses the ScaleIO connector from the os-brick projects
|
||||||
"""
|
"""
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
super(LibvirtScaleIOVolumeDriver, self).__init__(connection,
|
super(LibvirtScaleIOVolumeDriver, self).__init__(host,
|
||||||
is_block_dev=False)
|
is_block_dev=False)
|
||||||
self.connector = connector.InitiatorConnector.factory(
|
self.connector = connector.InitiatorConnector.factory(
|
||||||
'SCALEIO', utils.get_root_helper(),
|
'SCALEIO', utils.get_root_helper(),
|
||||||
|
@ -37,15 +37,15 @@ SHOULD_LOG_DISCARD_WARNING = True
|
|||||||
|
|
||||||
class LibvirtBaseVolumeDriver(object):
|
class LibvirtBaseVolumeDriver(object):
|
||||||
"""Base class for volume drivers."""
|
"""Base class for volume drivers."""
|
||||||
def __init__(self, connection, is_block_dev):
|
def __init__(self, host, is_block_dev):
|
||||||
self.connection = connection
|
self.host = host
|
||||||
self.is_block_dev = is_block_dev
|
self.is_block_dev = is_block_dev
|
||||||
|
|
||||||
def get_config(self, connection_info, disk_info):
|
def get_config(self, connection_info, disk_info):
|
||||||
"""Returns xml for libvirt."""
|
"""Returns xml for libvirt."""
|
||||||
conf = vconfig.LibvirtConfigGuestDisk()
|
conf = vconfig.LibvirtConfigGuestDisk()
|
||||||
conf.driver_name = libvirt_utils.pick_disk_driver_name(
|
conf.driver_name = libvirt_utils.pick_disk_driver_name(
|
||||||
self.connection._host.get_version(),
|
self.host.get_version(),
|
||||||
self.is_block_dev
|
self.is_block_dev
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ class LibvirtBaseVolumeDriver(object):
|
|||||||
# Configure usage of discard
|
# Configure usage of discard
|
||||||
if data.get('discard', False) is True:
|
if data.get('discard', False) is True:
|
||||||
min_qemu = nova.virt.libvirt.driver.MIN_QEMU_DISCARD_VERSION
|
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_ver=min_qemu,
|
||||||
hv_type=host.HV_DRIVER_QEMU):
|
hv_type=host.HV_DRIVER_QEMU):
|
||||||
conf.driver_discard = 'unmap'
|
conf.driver_discard = 'unmap'
|
||||||
@ -125,9 +125,9 @@ class LibvirtBaseVolumeDriver(object):
|
|||||||
|
|
||||||
class LibvirtVolumeDriver(LibvirtBaseVolumeDriver):
|
class LibvirtVolumeDriver(LibvirtBaseVolumeDriver):
|
||||||
"""Class for volumes backed by local file."""
|
"""Class for volumes backed by local file."""
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
super(LibvirtVolumeDriver,
|
super(LibvirtVolumeDriver,
|
||||||
self).__init__(connection, is_block_dev=True)
|
self).__init__(host, is_block_dev=True)
|
||||||
|
|
||||||
def get_config(self, connection_info, disk_info):
|
def get_config(self, connection_info, disk_info):
|
||||||
"""Returns xml for libvirt."""
|
"""Returns xml for libvirt."""
|
||||||
@ -140,9 +140,9 @@ class LibvirtVolumeDriver(LibvirtBaseVolumeDriver):
|
|||||||
|
|
||||||
class LibvirtFakeVolumeDriver(LibvirtBaseVolumeDriver):
|
class LibvirtFakeVolumeDriver(LibvirtBaseVolumeDriver):
|
||||||
"""Driver to attach fake volumes to libvirt."""
|
"""Driver to attach fake volumes to libvirt."""
|
||||||
def __init__(self, connection):
|
def __init__(self, host):
|
||||||
super(LibvirtFakeVolumeDriver,
|
super(LibvirtFakeVolumeDriver,
|
||||||
self).__init__(connection, is_block_dev=True)
|
self).__init__(host, is_block_dev=True)
|
||||||
|
|
||||||
def get_config(self, connection_info, disk_info):
|
def get_config(self, connection_info, disk_info):
|
||||||
"""Returns xml for libvirt."""
|
"""Returns xml for libvirt."""
|
||||||
|
Loading…
Reference in New Issue
Block a user