diff options
author | Matthew Booth <mbooth@redhat.com> | 2017-02-28 10:03:24 +0000 |
---|---|---|
committer | Matthew Booth <mbooth@redhat.com> | 2017-05-08 11:31:11 -0400 |
commit | b66b7d4f9d63e7f45ebfc033696d06c632a33ff1 (patch) | |
tree | df5c218c8194cbfb9fe3b34592ea167dbb883090 | |
parent | d219a3dcdc9c51bff3ebf2df086ea61a840ea3e9 (diff) | |
download | nova-b66b7d4f9d63e7f45ebfc033696d06c632a33ff1.tar.gz |
libvirt: Pass instance to connect_volume and disconnect_volume
When we support multi-attach volumes, for volume drivers which must
make host state changes (eg mount/unmount) it is no longer enough to
know only which volume is being connected; we must also know which
instance it is being attached to. Consider the following sequence of
calls, and the expected behaviour of the volume driver:
* connect_volume(conn_info)
connect the volume
* connect_volume(conn_info)
do nothing (volume is already connected)
* disconnect_volume(conn_info)
disconnect the volume
* disconnect_volume(conn_info)
do nothing (volume is already disconnected)
Now consider these were actually connections to different instances:
* connect_volume(conn_info, A)
connect the volume
* connect_volume(conn_info, B)
do nothing (volume is already connected)
* disconnect_volume(conn_info, A)
++ do nothing (volume is still connected to B)
* disconnect_volume(conn_info, B)
disconnect the volume
IOW, it is not possible for the driver to determine the correct
behaviour unless it also knows which instance is being attached.
This is a non functional change which simply adds instance as an
argument to all connect_volume and disconnect_volume calls in libvirt
volume drivers. It is effectively a part of change I3155984d. I have
split it as it is mechanical, it touches a large number of files
which make the substantive change harder to read, and to isolate the
substantive change from merge conflicts caused by this change.
We also add a utility test class: SubclassSignatureTestCase. This is
used in this patch to ensure we have found all connect_volume and
disconnect_volume methods which need to be updated. We implement it in
the top level tests module as we expect it to be useful elsewhere.
This patch was previously submitted as change I658d7ab5 but had to be
reverted as it failed to update the signatures of several volume
drivers. This is also what has prompted the addition of
SubclassSignatureTestCase, which ensures this hasn't happened again.
Change-Id: I01c908add1312063f0db724110f7e5927ff281ff
29 files changed, 272 insertions, 123 deletions
diff --git a/nova/test.py b/nova/test.py index 749adbd78d..d6e4d59a62 100644 --- a/nova/test.py +++ b/nova/test.py @@ -24,6 +24,7 @@ inline callbacks. import eventlet # noqa eventlet.monkey_patch(os=False) +import abc import contextlib import copy import datetime @@ -493,6 +494,91 @@ class APICoverage(object): testtools.matchers.ContainsAll(api_methods)) +@six.add_metaclass(abc.ABCMeta) +class SubclassSignatureTestCase(testtools.TestCase): + """Ensure all overriden methods of all subclasses of the class + under test exactly match the signature of the base class. + + A subclass of SubclassSignatureTestCase should define a method + _get_base_class which: + + * Returns a base class whose subclasses will all be checked + * Ensures that all subclasses to be tested have been imported + + SubclassSignatureTestCase defines a single test, test_signatures, + which does a recursive, depth-first check of all subclasses, ensuring + that their method signatures are identical to those of the base class. + """ + @abc.abstractmethod + def _get_base_class(self): + raise NotImplementedError() + + def setUp(self): + self.base = self._get_base_class() + + super(SubclassSignatureTestCase, self).setUp() + + @staticmethod + def _get_argspecs(cls): + """Return a dict of method_name->argspec for every method of cls.""" + argspecs = {} + + # getmembers returns all members, including members inherited from + # the base class. It's redundant for us to test these, but as + # they'll always pass it's not worth the complexity to filter them out. + for (name, method) in inspect.getmembers(cls, inspect.ismethod): + # Subclass __init__ methods can usually be legitimately different + if name == '__init__': + continue + + while hasattr(method, '__wrapped__'): + # This is a wrapped function. The signature we're going to + # see here is that of the wrapper, which is almost certainly + # going to involve varargs and kwargs, and therefore is + # unlikely to be what we want. If the wrapper manupulates the + # arguments taken by the wrapped function, the wrapped function + # isn't what we want either. In that case we're just stumped: + # if it ever comes up, add more knobs here to work round it (or + # stop using a dynamic language). + # + # Here we assume the wrapper doesn't manipulate the arguments + # to the wrapped function and inspect the wrapped function + # instead. + method = getattr(method, '__wrapped__') + + argspecs[name] = inspect.getargspec(method) + + return argspecs + + @staticmethod + def _clsname(cls): + """Return the fully qualified name of cls.""" + return "%s.%s" % (cls.__module__, cls.__name__) + + def _test_signatures_recurse(self, base, base_argspecs): + for sub in base.__subclasses__(): + sub_argspecs = self._get_argspecs(sub) + + # Check that each subclass method matches the signature of the + # base class + for (method, sub_argspec) in sub_argspecs.items(): + # Methods which don't override methods in the base class + # are good. + if method in base_argspecs: + self.assertEqual(base_argspecs[method], sub_argspec, + 'Signature of %(sub)s.%(method)s ' + 'differs from superclass %(base)s' % + {'base': self._clsname(base), + 'sub': self._clsname(sub), + 'method': method}) + + # Recursively check this subclass + self._test_signatures_recurse(sub, sub_argspecs) + + def test_signatures(self): + self._test_signatures_recurse(self.base, self._get_argspecs(self.base)) + + class TimeOverride(fixtures.Fixture): """Fixture to start and remove time override.""" diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 2e7df3d66d..17215b9723 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -6345,7 +6345,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): test.MatchType(objects.ImageMeta), bdm) mock_connect_volume.assert_called_with( - connection_info, disk_info) + connection_info, disk_info, instance) mock_get_volume_config.assert_called_with( connection_info, disk_info) mock_set_cache_mode.assert_called_with(mock_conf) @@ -6399,7 +6399,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): </disk> """, flags=flags) mock_disconnect_volume.assert_called_with( - connection_info, 'vdc') + connection_info, 'vdc', instance) @mock.patch('nova.virt.libvirt.host.Host.get_domain') def test_detach_volume_disk_not_found(self, mock_get_domain): @@ -6455,7 +6455,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): mock_order.assert_has_calls([ mock.call.detach_volume(), mock.call.detach_encryptor(**encryption), - mock.call.disconnect_volume(connection_info, 'vdc')]) + mock.call.disconnect_volume(connection_info, 'vdc', instance)]) def test_multi_nic(self): network_info = _fake_network_info(self, 2) @@ -9630,8 +9630,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): 'dev': v['mount_device'].rpartition("/")[2], 'type': "disk" } - drvr._connect_volume(v['connection_info'], - disk_info) + drvr._connect_volume(v['connection_info'], disk_info, instance) self.mox.StubOutWithMock(drvr, 'plug_vifs') drvr.plug_vifs(mox.IsA(instance), nw_info) @@ -9768,8 +9767,8 @@ class LibvirtConnTestCase(test.NoDBTestCase): 'dev': v['mount_device'].rpartition("/")[2], 'type': "disk" } - drvr._connect_volume(v['connection_info'], - disk_info) + drvr._connect_volume(v['connection_info'], disk_info, + inst_ref) self.mox.StubOutWithMock(drvr, 'plug_vifs') drvr.plug_vifs(mox.IsA(inst_ref), nw_info) self.mox.ReplayAll() @@ -10116,8 +10115,9 @@ class LibvirtConnTestCase(test.NoDBTestCase): get_volume_connector.assert_has_calls([ mock.call(inst_ref)]) _disconnect_volume.assert_has_calls([ - mock.call({'data': {'multipath_id': 'dummy1'}}, 'sda'), - mock.call({'data': {}}, 'sdb')]) + mock.call({'data': {'multipath_id': 'dummy1'}}, 'sda', + inst_ref), + mock.call({'data': {}}, 'sdb', inst_ref)]) def test_get_instance_disk_info_excludes_volumes(self): # Test data @@ -10475,7 +10475,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): 'delete_on_termination': False } - def _connect_volume_side_effect(connection_info, disk_info): + def _connect_volume_side_effect(connection_info, disk_info, instance): bdm['connection_info']['data']['device_path'] = '/dev/path/to/dev' def _get(key, opt=None): @@ -14156,7 +14156,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr.detach_volume(connection_info, instance, '/dev/sda') _get_domain.assert_called_once_with(instance) _disconnect_volume.assert_called_once_with(connection_info, - 'sda') + 'sda', instance) def _test_attach_detach_interface_get_config(self, method_name): """Tests that the get_config() method is properly called in @@ -14704,7 +14704,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.assertEqual('/dev/vdb', instance.default_ephemeral_device) self.assertIsNone(instance.default_swap_device) connect_volume.assert_called_with(bdm['connection_info'], - {'bus': 'virtio', 'type': 'disk', 'dev': 'vdc'}) + {'bus': 'virtio', 'type': 'disk', 'dev': 'vdc'}, instance) get_volume_config.assert_called_with(bdm['connection_info'], {'bus': 'virtio', 'type': 'disk', 'dev': 'vdc'}) volume_save.assert_called_once_with() @@ -14857,11 +14857,13 @@ class LibvirtConnTestCase(test.NoDBTestCase): '/dev/vdb', 1) get_guest.assert_called_once_with(instance) - connect_volume.assert_called_once_with(new_connection_info, disk_info) + connect_volume.assert_called_once_with(new_connection_info, disk_info, + instance) swap_volume.assert_called_once_with(guest, 'vdb', '/fake-new-volume', 1) - disconnect_volume.assert_called_once_with(old_connection_info, 'vdb') + disconnect_volume.assert_called_once_with(old_connection_info, 'vdb', + instance) def test_swap_volume_driver_source_is_volume(self): self._test_swap_volume_driver(source_type='volume') @@ -14899,9 +14901,9 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance, '/dev/vdb', 0) connect_volume.assert_called_once_with( mock.sentinel.new_connection_info, - {'dev': 'vdb', 'type': 'disk', 'bus': 'virtio'}) + {'dev': 'vdb', 'type': 'disk', 'bus': 'virtio'}, instance) disconnect_volume.assert_called_once_with( - mock.sentinel.new_connection_info, 'vdb') + mock.sentinel.new_connection_info, 'vdb', instance) @mock.patch('nova.virt.libvirt.guest.BlockDevice.is_job_complete') @mock.patch('nova.virt.libvirt.guest.BlockDevice.abort_job') @@ -14932,9 +14934,9 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance, '/dev/vdb', 0) connect_volume.assert_called_once_with( mock.sentinel.new_connection_info, - {'dev': 'vdb', 'type': 'disk', 'bus': 'virtio'}) + {'dev': 'vdb', 'type': 'disk', 'bus': 'virtio'}, instance) disconnect_volume.assert_called_once_with( - mock.sentinel.new_connection_info, 'vdb') + mock.sentinel.new_connection_info, 'vdb', instance) @mock.patch('nova.virt.libvirt.guest.BlockDevice.is_job_complete') def _test_live_snapshot(self, mock_is_job_complete, @@ -15713,7 +15715,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase): 'flavor': {'root_gb': 10, 'ephemeral_gb': 0}}) disconnect_volume.assert_called_with( - mock.sentinel.conn_info_vda, 'vda') + mock.sentinel.conn_info_vda, 'vda', mock.ANY) @mock.patch('nova.virt.libvirt.driver.LibvirtDriver._disconnect_volume') def test_migrate_disk_and_power_off_boot_from_volume_backed_snapshot( @@ -15739,7 +15741,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase): 'flavor': {'root_gb': 10, 'ephemeral_gb': 0}}) disconnect_volume.assert_called_with( - mock.sentinel.conn_info_vda, 'vda') + mock.sentinel.conn_info_vda, 'vda', mock.ANY) @mock.patch('nova.utils.execute') @mock.patch('nova.virt.libvirt.utils.copy_image') diff --git a/nova/tests/unit/virt/libvirt/volume/test_disco.py b/nova/tests/unit/virt/libvirt/volume/test_disco.py index 5b014074a9..e8c27bd712 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_disco.py +++ b/nova/tests/unit/virt/libvirt/volume/test_disco.py @@ -39,7 +39,7 @@ class LibvirtDISCOVolumeDriverTestCase( with mock.patch.object(dcon.connector, 'connect_volume', return_value={'path': '/dev/dms1234567'}): - dcon.connect_volume(conn, None) + dcon.connect_volume(conn, None, mock.sentinel.instance) self.assertEqual('/dev/dms1234567', conn['data']['device_path']) @@ -62,6 +62,6 @@ class LibvirtDISCOVolumeDriverTestCase( 'type': 'raw', 'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/dms123456'} conn = {'data': disk_info} - dcon.disconnect_volume(conn, disk_info) + dcon.disconnect_volume(conn, disk_info, mock.sentinel.instance) dcon.connector.disconnect_volume.assert_called_once_with( disk_info, None) diff --git a/nova/tests/unit/virt/libvirt/volume/test_fs.py b/nova/tests/unit/virt/libvirt/volume/test_fs.py index eaa6568999..215d426a3a 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_fs.py +++ b/nova/tests/unit/virt/libvirt/volume/test_fs.py @@ -17,7 +17,10 @@ import os import mock from nova import test +from nova.tests.unit.virt.libvirt import fakelibvirt from nova import utils +from nova.virt import fake +from nova.virt.libvirt import driver from nova.virt.libvirt.volume import fs FAKE_MOUNT_POINT = '/var/lib/nova/fake-mount' @@ -27,6 +30,16 @@ HASHED_SHARE = utils.get_hash_str(NORMALIZED_SHARE) FAKE_DEVICE_NAME = 'fake-device' +class FSVolumeDriverSubclassSignatureTestCase(test.SubclassSignatureTestCase): + def _get_base_class(self): + # We do this because it has the side-effect of loading all the + # volume drivers + self.useFixture(fakelibvirt.FakeLibvirtFixture()) + driver.LibvirtDriver(fake.FakeVirtAPI(), False) + + return fs.LibvirtBaseFileSystemVolumeDriver + + class FakeFileSystemVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): def _get_mount_point_base(self): diff --git a/nova/tests/unit/virt/libvirt/volume/test_glusterfs.py b/nova/tests/unit/virt/libvirt/volume/test_glusterfs.py index b48655f15a..315fb4ec3d 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_glusterfs.py +++ b/nova/tests/unit/virt/libvirt/volume/test_glusterfs.py @@ -36,8 +36,10 @@ class LibvirtGlusterfsVolumeDriverTestCase( 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") + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) device_path = os.path.join(export_mnt_base, connection_info['data']['name']) @@ -90,8 +92,10 @@ class LibvirtGlusterfsVolumeDriverTestCase( 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") + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) expected_commands = [ ('umount', export_mnt_base)] @@ -108,7 +112,8 @@ class LibvirtGlusterfsVolumeDriverTestCase( 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") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) self.assertTrue(mock_LOG_debug.called) @mock.patch.object(libvirt_utils, 'is_mounted', return_value=False) @@ -125,8 +130,10 @@ class LibvirtGlusterfsVolumeDriverTestCase( 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") + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) expected_commands = [ ('mkdir', '-p', export_mnt_base), @@ -153,7 +160,8 @@ class LibvirtGlusterfsVolumeDriverTestCase( "bus": "virtio", } - libvirt_driver.connect_volume(connection_info, disk_info) + libvirt_driver.connect_volume(connection_info, disk_info, + mock.sentinel.instance) conf = libvirt_driver.get_config(connection_info, disk_info) tree = conf.format_dom() self.assertEqual('network', tree.get('type')) @@ -166,4 +174,5 @@ class LibvirtGlusterfsVolumeDriverTestCase( self.assertEqual('24007', source.find('./host').get('port')) self.assertFalse(mock_is_mounted.called) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) diff --git a/nova/tests/unit/virt/libvirt/volume/test_hgst.py b/nova/tests/unit/virt/libvirt/volume/test_hgst.py index a7fef0c1a9..2a0838fbed 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_hgst.py +++ b/nova/tests/unit/virt/libvirt/volume/test_hgst.py @@ -38,7 +38,7 @@ class LibvirtHGSTVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase): drvr.connector.connect_volume = brick_conn_vol di = {'path': '/dev/space01', 'name': 'space01'} ci = {'data': di} - drvr.connect_volume(ci, None) + drvr.connect_volume(ci, None, mock.sentinel.instance) self.assertEqual('/dev/space01', ci['data']['device_path']) @@ -57,6 +57,6 @@ class LibvirtHGSTVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase): di = {'path': '/dev/space01', 'name': 'space01', 'type': 'raw', 'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/space01'} ci = {'data': di} - drvr.disconnect_volume(ci, di) + drvr.disconnect_volume(ci, di, mock.sentinel.instance) drvr.connector.disconnect_volume.assert_called_once_with( di, None) diff --git a/nova/tests/unit/virt/libvirt/volume/test_iscsi.py b/nova/tests/unit/virt/libvirt/volume/test_iscsi.py index b155334843..4694e5f17a 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_iscsi.py +++ b/nova/tests/unit/virt/libvirt/volume/test_iscsi.py @@ -50,7 +50,8 @@ class LibvirtISCSIVolumeDriverTestCase( libvirt_driver.connector.disconnect_volume = mock.MagicMock( side_effect=os_brick_exception.VolumeDeviceNotFound( device=device_path)) - libvirt_driver.disconnect_volume(connection_info, device_path) + libvirt_driver.disconnect_volume(connection_info, device_path, + mock.sentinel.instance) msg = mock_LOG_warning.call_args_list[0] self.assertIn('Ignoring VolumeDeviceNotFound', msg[0][0]) diff --git a/nova/tests/unit/virt/libvirt/volume/test_net.py b/nova/tests/unit/virt/libvirt/volume/test_net.py index cec1a834fe..d422e8fffb 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_net.py +++ b/nova/tests/unit/virt/libvirt/volume/test_net.py @@ -52,7 +52,8 @@ class LibvirtNetVolumeDriverTestCase( self.assertEqual('network', tree.get('type')) self.assertEqual('sheepdog', tree.find('./source').get('protocol')) self.assertEqual(self.name, tree.find('./source').get('name')) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) def rbd_connection(self, volume): return { @@ -79,7 +80,8 @@ class LibvirtNetVolumeDriverTestCase( self.assertIsNone(tree.find('./source/auth')) self.assertEqual('1048576', tree.find('./iotune/total_bytes_sec').text) self.assertEqual('500', tree.find('./iotune/read_iops_sec').text) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) def test_libvirt_rbd_driver_hosts(self): libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host) @@ -95,7 +97,8 @@ class LibvirtNetVolumeDriverTestCase( found_hosts = tree.findall('./source/host') self.assertEqual(hosts, [host.get('name') for host in found_hosts]) self.assertEqual(ports, [host.get('port') for host in found_hosts]) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) def test_libvirt_rbd_driver_auth_enabled(self): libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host) @@ -112,7 +115,8 @@ class LibvirtNetVolumeDriverTestCase( self.assertEqual(self.user, tree.find('./auth').get('username')) self.assertEqual(secret_type, tree.find('./auth/secret').get('type')) self.assertEqual(self.uuid, tree.find('./auth/secret').get('uuid')) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) def test_libvirt_rbd_driver_auth_enabled_flags(self): # The values from the cinder connection_info take precedence over @@ -137,7 +141,8 @@ class LibvirtNetVolumeDriverTestCase( self.assertEqual(self.user, tree.find('./auth').get('username')) self.assertEqual(secret_type, tree.find('./auth/secret').get('type')) self.assertEqual(self.uuid, tree.find('./auth/secret').get('uuid')) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) def test_libvirt_rbd_driver_auth_disabled(self): libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host) @@ -152,7 +157,8 @@ class LibvirtNetVolumeDriverTestCase( tree = conf.format_dom() self._assertNetworkAndProtocolEquals(tree) self.assertIsNone(tree.find('./auth')) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) def test_libvirt_rbd_driver_auth_disabled_flags_override(self): libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host) @@ -177,7 +183,8 @@ class LibvirtNetVolumeDriverTestCase( self.assertEqual(flags_user, tree.find('./auth').get('username')) self.assertEqual(secret_type, tree.find('./auth/secret').get('type')) self.assertEqual(flags_uuid, tree.find('./auth/secret').get('uuid')) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) @mock.patch.object(host.Host, 'find_secret') @mock.patch.object(host.Host, 'create_secret') @@ -198,4 +205,5 @@ class LibvirtNetVolumeDriverTestCase( self.assertEqual(secret_type, tree.find('./auth/secret').get('type')) self.assertEqual(test_volume.SECRET_UUID, tree.find('./auth/secret').get('uuid')) - libvirt_driver.disconnect_volume(connection_info, 'vde') + libvirt_driver.disconnect_volume(connection_info, 'vde', + mock.sentinel.instance) diff --git a/nova/tests/unit/virt/libvirt/volume/test_nfs.py b/nova/tests/unit/virt/libvirt/volume/test_nfs.py index c46fa698cb..8f58cbeec8 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_nfs.py +++ b/nova/tests/unit/virt/libvirt/volume/test_nfs.py @@ -39,8 +39,10 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase): 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") + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) device_path = os.path.join(export_mnt_base, connection_info['data']['name']) @@ -63,19 +65,23 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase): 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") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) self.assertTrue(mock_LOG_debug.called) mock_utils_exe.side_effect = processutils.ProcessExecutionError( None, None, None, 'umount', 'umount: target is busy.') - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) self.assertTrue(mock_LOG_debug.called) mock_utils_exe.side_effect = processutils.ProcessExecutionError( None, None, None, 'umount', 'umount: not mounted.') - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) self.assertTrue(mock_LOG_debug.called) mock_utils_exe.side_effect = processutils.ProcessExecutionError( None, None, None, 'umount', 'umount: Other error.') - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) self.assertTrue(mock_LOG_exception.called) def test_libvirt_nfs_driver_get_config(self): @@ -104,8 +110,10 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase): 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") + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) expected_commands = [ ('umount', export_mnt_base)] @@ -122,8 +130,10 @@ class LibvirtNFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase): 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") + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) expected_commands = [ ('mkdir', '-p', export_mnt_base), diff --git a/nova/tests/unit/virt/libvirt/volume/test_quobyte.py b/nova/tests/unit/virt/libvirt/volume/test_quobyte.py index a43a79a8ad..d99dda0310 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_quobyte.py +++ b/nova/tests/unit/virt/libvirt/volume/test_quobyte.py @@ -210,7 +210,8 @@ class LibvirtQuobyteVolumeDriverTestCase( connection_info = {'data': {'export': export_string, 'name': self.name}} - libvirt_driver.connect_volume(connection_info, self.disk_info) + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) conf = libvirt_driver.get_config(connection_info, self.disk_info) tree = conf.format_dom() @@ -240,13 +241,15 @@ class LibvirtQuobyteVolumeDriverTestCase( connection_info = {'data': {'export': export_string, 'name': self.name}} - libvirt_driver.connect_volume(connection_info, self.disk_info) + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) conf = libvirt_driver.get_config(connection_info, self.disk_info) tree = conf.format_dom() self._assertFileTypeEquals(tree, file_path) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) mock_validate_volume.assert_called_once_with(export_mnt_base) mock_umount_volume.assert_called_once_with(export_mnt_base) @@ -272,12 +275,14 @@ class LibvirtQuobyteVolumeDriverTestCase( connection_info = {'data': {'export': export_string, 'name': self.name}} - libvirt_driver.connect_volume(connection_info, self.disk_info) + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) conf = libvirt_driver.get_config(connection_info, self.disk_info) tree = conf.format_dom() self._assertFileTypeEquals(tree, file_path) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) mock_umount_volume.assert_called_once_with(export_mnt_base) mock_validate_volume.assert_called_once_with(export_mnt_base) @@ -304,7 +309,8 @@ class LibvirtQuobyteVolumeDriverTestCase( export_mnt_base = os.path.join(mnt_base, utils.get_hash_str(quobyte_volume)) - libvirt_driver.connect_volume(connection_info, self.disk_info) + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) conf = libvirt_driver.get_config(connection_info, self.disk_info) tree = conf.format_dom() self.assertEqual('file', tree.get('type')) @@ -316,7 +322,8 @@ class LibvirtQuobyteVolumeDriverTestCase( mock.ANY)) mock_validate_volume.assert_called_with(export_mnt_base) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) @mock.patch.object(libvirt_utils, 'is_mounted', return_value=True) def test_libvirt_quobyte_driver_mount_non_quobyte_volume(self, @@ -340,7 +347,8 @@ class LibvirtQuobyteVolumeDriverTestCase( self.assertRaises(exception.NovaException, libvirt_driver.connect_volume, connection_info, - self.disk_info) + self.disk_info, + mock.sentinel.instance) def test_libvirt_quobyte_driver_normalize_export_with_protocol(self): mnt_base = '/mnt' diff --git a/nova/tests/unit/virt/libvirt/volume/test_scaleio.py b/nova/tests/unit/virt/libvirt/volume/test_scaleio.py index b740a0a8cf..3c7dd62672 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_scaleio.py +++ b/nova/tests/unit/virt/libvirt/volume/test_scaleio.py @@ -38,7 +38,7 @@ class LibvirtScaleIOVolumeDriverTestCase( sio.connector.connect_volume = brick_conn_vol disk_info = {'path': '/dev/vol01', 'name': 'vol01'} conn = {'data': disk_info} - sio.connect_volume(conn, None) + sio.connect_volume(conn, None, mock.sentinel.instance) self.assertEqual('/dev/vol01', conn['data']['device_path']) @@ -57,6 +57,6 @@ class LibvirtScaleIOVolumeDriverTestCase( disk_info = {'path': '/dev/vol01', 'name': 'vol01', 'type': 'raw', 'dev': 'vda1', 'bus': 'pci0', 'device_path': '/dev/vol01'} conn = {'data': disk_info} - sio.disconnect_volume(conn, disk_info) + sio.disconnect_volume(conn, disk_info, mock.sentinel.instance) sio.connector.disconnect_volume.assert_called_once_with( disk_info, None) diff --git a/nova/tests/unit/virt/libvirt/volume/test_scality.py b/nova/tests/unit/virt/libvirt/volume/test_scality.py index 09838afc05..b08ebbe18e 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_scality.py +++ b/nova/tests/unit/virt/libvirt/volume/test_scality.py @@ -55,7 +55,8 @@ class LibvirtScalityVolumeDriverTestCase( self.stub_out('os.access', _access_wrapper) with mock.patch.object(self.drv, '_mount_sofs'): - self.drv.connect_volume(TEST_CONN_INFO, self.disk_info) + self.drv.connect_volume(TEST_CONN_INFO, self.disk_info, + mock.sentinel.instance) device_path = os.path.join(self.scality_sofs_mount_point, TEST_CONN_INFO['data']['sofs_path']) diff --git a/nova/tests/unit/virt/libvirt/volume/test_smbfs.py b/nova/tests/unit/virt/libvirt/volume/test_smbfs.py index 4c12d050b9..52f088300c 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_smbfs.py +++ b/nova/tests/unit/virt/libvirt/volume/test_smbfs.py @@ -39,8 +39,10 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase): connection_info = {'data': {'export': export_string, 'name': self.name, 'options': None}} - libvirt_driver.connect_volume(connection_info, self.disk_info) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) expected_commands = [ ('mkdir', '-p', export_mnt_base), @@ -58,8 +60,10 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase): 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") + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) expected_commands = [ ('umount', export_mnt_base)] @@ -92,8 +96,10 @@ class LibvirtSMBFSVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase): 'name': self.name, 'options': options}} - libvirt_driver.connect_volume(connection_info, self.disk_info) - libvirt_driver.disconnect_volume(connection_info, "vde") + libvirt_driver.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) + libvirt_driver.disconnect_volume(connection_info, "vde", + mock.sentinel.instance) expected_commands = [ ('mkdir', '-p', export_mnt_base), diff --git a/nova/tests/unit/virt/libvirt/volume/test_vzstorage.py b/nova/tests/unit/virt/libvirt/volume/test_vzstorage.py index 23adb8d52b..6149697eae 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_vzstorage.py +++ b/nova/tests/unit/virt/libvirt/volume/test_vzstorage.py @@ -64,7 +64,8 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase): err_pattern, drv.connect_volume, connection_info, - self.disk_info) + self.disk_info, + mock.sentinel.instance) def test_libvirt_vzstorage_driver_connect(self): def brick_conn_vol(data): @@ -77,7 +78,8 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase): connection_info = {'data': {'export': export_string, 'name': self.name}} - drv.connect_volume(connection_info, self.disk_info) + drv.connect_volume(connection_info, self.disk_info, + mock.sentinel.instance) self.assertEqual('vstorage://testcluster', connection_info['data']['device_path']) self.assertEqual('-u stack -g qemu -m 0770 ' @@ -89,7 +91,7 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase): drv = vzstorage.LibvirtVZStorageVolumeDriver(self.fake_host) drv.connector.disconnect_volume = mock.MagicMock() conn = {'data': self.disk_info} - drv.disconnect_volume(conn, self.disk_info) + drv.disconnect_volume(conn, self.disk_info, mock.sentinel.instance) drv.connector.disconnect_volume.assert_called_once_with( self.disk_info, None) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index e1d79948db..6b1a1e5855 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -986,7 +986,7 @@ class LibvirtDriver(driver.ComputeDriver): encryptor.detach_volume(**encryption) try: - self._disconnect_volume(connection_info, disk_dev) + self._disconnect_volume(connection_info, disk_dev, instance) except Exception as exc: with excutils.save_and_reraise_exception() as ctxt: if destroy_disks: @@ -1152,13 +1152,13 @@ class LibvirtDriver(driver.ComputeDriver): raise exception.VolumeDriverNotFound(driver_type=driver_type) return self.volume_drivers[driver_type] - def _connect_volume(self, connection_info, disk_info): + def _connect_volume(self, connection_info, disk_info, instance): vol_driver = self._get_volume_driver(connection_info) - vol_driver.connect_volume(connection_info, disk_info) + vol_driver.connect_volume(connection_info, disk_info, instance) - def _disconnect_volume(self, connection_info, disk_dev): + def _disconnect_volume(self, connection_info, disk_dev, instance): vol_driver = self._get_volume_driver(connection_info) - vol_driver.disconnect_volume(connection_info, disk_dev) + vol_driver.disconnect_volume(connection_info, disk_dev, instance) def _get_volume_config(self, connection_info, disk_info): vol_driver = self._get_volume_driver(connection_info) @@ -1216,7 +1216,7 @@ class LibvirtDriver(driver.ComputeDriver): disk_info = blockinfo.get_info_from_bdm( instance, CONF.libvirt.virt_type, instance.image_meta, bdm) - self._connect_volume(connection_info, disk_info) + self._connect_volume(connection_info, disk_info, instance) conf = self._get_volume_config(connection_info, disk_info) self._set_cache_mode(conf) @@ -1238,11 +1238,12 @@ class LibvirtDriver(driver.ComputeDriver): if isinstance(ex, libvirt.libvirtError): errcode = ex.get_error_code() if errcode == libvirt.VIR_ERR_OPERATION_FAILED: - self._disconnect_volume(connection_info, disk_dev) + self._disconnect_volume(connection_info, disk_dev, + instance) raise exception.DeviceIsBusy(device=disk_dev) with excutils.save_and_reraise_exception(): - self._disconnect_volume(connection_info, disk_dev) + self._disconnect_volume(connection_info, disk_dev, instance) def _swap_volume(self, guest, disk_path, new_path, resize_to): """Swap existing disk with a new block device.""" @@ -1308,19 +1309,20 @@ class LibvirtDriver(driver.ComputeDriver): # LibvirtConfigGuestDisk object it returns. We do not explicitly save # this to the BDM here as the upper compute swap_volume method will # eventually do this for us. - self._connect_volume(new_connection_info, disk_info) + self._connect_volume(new_connection_info, disk_info, instance) conf = self._get_volume_config(new_connection_info, disk_info) if not conf.source_path: - self._disconnect_volume(new_connection_info, disk_dev) + self._disconnect_volume(new_connection_info, disk_dev, instance) raise NotImplementedError(_("Swap only supports host devices")) try: self._swap_volume(guest, disk_dev, conf.source_path, resize_to) except exception.VolumeRebaseFailed: with excutils.save_and_reraise_exception(): - self._disconnect_volume(new_connection_info, disk_dev) + self._disconnect_volume(new_connection_info, disk_dev, + instance) - self._disconnect_volume(old_connection_info, disk_dev) + self._disconnect_volume(old_connection_info, disk_dev, instance) def _get_existing_domain_xml(self, instance, network_info, block_device_info=None): @@ -1381,7 +1383,7 @@ class LibvirtDriver(driver.ComputeDriver): else: raise - self._disconnect_volume(connection_info, disk_dev) + self._disconnect_volume(connection_info, disk_dev, instance) def attach_interface(self, context, instance, image_meta, vif): guest = self._host.get_guest(instance) @@ -3641,7 +3643,7 @@ class LibvirtDriver(driver.ComputeDriver): connection_info = vol['connection_info'] vol_dev = block_device.prepend_dev(vol['mount_device']) info = disk_mapping[vol_dev] - self._connect_volume(connection_info, info) + self._connect_volume(connection_info, info, instance) cfg = self._get_volume_config(connection_info, info) devices.append(cfg) vol['connection_info'] = connection_info @@ -4912,7 +4914,8 @@ class LibvirtDriver(driver.ComputeDriver): if root_disk: disk_info = blockinfo.get_info_from_bdm( instance, CONF.libvirt.virt_type, image_meta, root_disk) - self._connect_volume(root_disk['connection_info'], disk_info) + self._connect_volume(root_disk['connection_info'], disk_info, + instance) disk_path = root_disk['connection_info']['data']['device_path'] # NOTE(apmelton) - Even though the instance is being booted from a @@ -6708,7 +6711,7 @@ class LibvirtDriver(driver.ComputeDriver): disk_info = blockinfo.get_info_from_bdm( instance, CONF.libvirt.virt_type, instance.image_meta, bdm) - self._connect_volume(connection_info, disk_info) + self._connect_volume(connection_info, disk_info, instance) # We call plug_vifs before the compute manager calls # ensure_filtering_rules_for_instance, to ensure bridge is set up @@ -6900,7 +6903,7 @@ class LibvirtDriver(driver.ComputeDriver): connection_info['data']['multipath_id'] = multipath_id disk_dev = vol['mount_device'].rpartition("/")[2] - self._disconnect_volume(connection_info, disk_dev) + self._disconnect_volume(connection_info, disk_dev, instance) def post_live_migration_at_source(self, context, instance, network_info): """Unplug VIFs from networks at source. @@ -7266,7 +7269,7 @@ class LibvirtDriver(driver.ComputeDriver): for vol in block_device_mapping: connection_info = vol['connection_info'] disk_dev = vol['mount_device'].rpartition("/")[2] - self._disconnect_volume(connection_info, disk_dev) + self._disconnect_volume(connection_info, disk_dev, instance) disk_info = self._get_instance_disk_info(instance, block_device_info) diff --git a/nova/virt/libvirt/volume/aoe.py b/nova/virt/libvirt/volume/aoe.py index b88a63aa9d..9d299493fc 100644 --- a/nova/virt/libvirt/volume/aoe.py +++ b/nova/virt/libvirt/volume/aoe.py @@ -43,14 +43,14 @@ class LibvirtAOEVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): conf.source_path = connection_info['data']['device_path'] return conf - def connect_volume(self, connection_info, mount_device): + def connect_volume(self, connection_info, disk_info, instance): LOG.debug("Calling os-brick to attach AoE Volume") device_info = self.connector.connect_volume(connection_info['data']) LOG.debug("Attached AoE volume %s", device_info) connection_info['data']['device_path'] = device_info['path'] - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Detach the volume from instance_name.""" LOG.debug("calling os-brick to detach AoE Volume %s", @@ -59,4 +59,4 @@ class LibvirtAOEVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): LOG.debug("Disconnected AoE Volume %s", disk_dev) super(LibvirtAOEVolumeDriver, - self).disconnect_volume(connection_info, disk_dev) + self).disconnect_volume(connection_info, disk_dev, instance) diff --git a/nova/virt/libvirt/volume/disco.py b/nova/virt/libvirt/volume/disco.py index 15cdfdadea..8171aa57f3 100644 --- a/nova/virt/libvirt/volume/disco.py +++ b/nova/virt/libvirt/volume/disco.py @@ -49,13 +49,13 @@ class LibvirtDISCOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): conf.source_type = 'file' return conf - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): """Connect a DISCO volume to a compute node.""" device_info = self.connector.connect_volume(connection_info['data']) connection_info['data']['device_path'] = device_info['path'] - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Disconnect a DISCO volume of a compute node.""" self.connector.disconnect_volume(connection_info['data'], None) super(LibvirtDISCOVolumeDriver, self).disconnect_volume( - connection_info, disk_dev) + connection_info, disk_dev, instance) diff --git a/nova/virt/libvirt/volume/fibrechannel.py b/nova/virt/libvirt/volume/fibrechannel.py index 47b0744a50..0474215f75 100644 --- a/nova/virt/libvirt/volume/fibrechannel.py +++ b/nova/virt/libvirt/volume/fibrechannel.py @@ -46,7 +46,7 @@ class LibvirtFibreChannelVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): conf.driver_io = "native" return conf - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): """Attach the volume to instance_name.""" LOG.debug("Calling os-brick to attach FC Volume") @@ -58,7 +58,7 @@ class LibvirtFibreChannelVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): connection_info['data']['multipath_id'] = \ device_info['multipath_id'] - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Detach the volume from instance_name.""" LOG.debug("calling os-brick to detach FC Volume") @@ -72,4 +72,4 @@ class LibvirtFibreChannelVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): LOG.debug("Disconnected FC Volume %s", disk_dev) super(LibvirtFibreChannelVolumeDriver, - self).disconnect_volume(connection_info, disk_dev) + self).disconnect_volume(connection_info, disk_dev, instance) diff --git a/nova/virt/libvirt/volume/glusterfs.py b/nova/virt/libvirt/volume/glusterfs.py index f07b3c9d0a..4f5b5a8a8e 100644 --- a/nova/virt/libvirt/volume/glusterfs.py +++ b/nova/virt/libvirt/volume/glusterfs.py @@ -56,13 +56,13 @@ class LibvirtGlusterfsVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): return conf - def connect_volume(self, connection_info, mount_device): + def connect_volume(self, connection_info, disk_info, instance): if 'gluster' not in CONF.libvirt.qemu_allowed_storage_drivers: self._ensure_mounted(connection_info) connection_info['data']['device_path'] = \ self._get_device_path(connection_info) - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Disconnect the volume.""" if 'gluster' in CONF.libvirt.qemu_allowed_storage_drivers: diff --git a/nova/virt/libvirt/volume/hgst.py b/nova/virt/libvirt/volume/hgst.py index 05c65afb04..1512e129aa 100644 --- a/nova/virt/libvirt/volume/hgst.py +++ b/nova/virt/libvirt/volume/hgst.py @@ -41,11 +41,11 @@ class LibvirtHGSTVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): conf.source_path = connection_info['data']['device_path'] return conf - def connect_volume(self, connection_info, mount_device): + def connect_volume(self, connection_info, disk_info, instance): device_info = self.connector.connect_volume(connection_info['data']) connection_info['data']['device_path'] = device_info['path'] - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): self.connector.disconnect_volume(connection_info['data'], None) super(LibvirtHGSTVolumeDriver, - self).disconnect_volume(connection_info, disk_dev) + self).disconnect_volume(connection_info, disk_dev, instance) diff --git a/nova/virt/libvirt/volume/iscsi.py b/nova/virt/libvirt/volume/iscsi.py index 278a5e80d6..dfe72a2c36 100644 --- a/nova/virt/libvirt/volume/iscsi.py +++ b/nova/virt/libvirt/volume/iscsi.py @@ -57,7 +57,7 @@ class LibvirtISCSIVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): conf.driver_io = "native" return conf - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): """Attach the volume to instance_name.""" LOG.debug("Calling os-brick to attach iSCSI Volume") @@ -66,7 +66,7 @@ class LibvirtISCSIVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): connection_info['data']['device_path'] = device_info['path'] - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Detach the volume from instance_name.""" LOG.debug("calling os-brick to detach iSCSI Volume") @@ -78,4 +78,4 @@ class LibvirtISCSIVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): LOG.debug("Disconnected iSCSI Volume %s", disk_dev) super(LibvirtISCSIVolumeDriver, - self).disconnect_volume(connection_info, disk_dev) + self).disconnect_volume(connection_info, disk_dev, instance) diff --git a/nova/virt/libvirt/volume/net.py b/nova/virt/libvirt/volume/net.py index a405433405..e01e6ceb80 100644 --- a/nova/virt/libvirt/volume/net.py +++ b/nova/virt/libvirt/volume/net.py @@ -115,8 +115,8 @@ class LibvirtNetVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): self._set_auth_config_iscsi(conf, netdisk_properties) return conf - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Detach the volume from instance_name.""" super(LibvirtNetVolumeDriver, - self).disconnect_volume(connection_info, disk_dev) + self).disconnect_volume(connection_info, disk_dev, instance) self._delete_secret_by_name(connection_info) diff --git a/nova/virt/libvirt/volume/nfs.py b/nova/virt/libvirt/volume/nfs.py index d96d148d5e..327328f0e6 100644 --- a/nova/virt/libvirt/volume/nfs.py +++ b/nova/virt/libvirt/volume/nfs.py @@ -43,14 +43,14 @@ class LibvirtNFSVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): conf.driver_io = "native" return conf - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): """Connect the volume.""" self._ensure_mounted(connection_info) connection_info['data']['device_path'] = \ self._get_device_path(connection_info) - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Disconnect the volume.""" mount_path = self._get_mount_path(connection_info) diff --git a/nova/virt/libvirt/volume/quobyte.py b/nova/virt/libvirt/volume/quobyte.py index 284a084cc2..4dea6c121e 100644 --- a/nova/virt/libvirt/volume/quobyte.py +++ b/nova/virt/libvirt/volume/quobyte.py @@ -107,7 +107,7 @@ class LibvirtQuobyteVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): return conf @utils.synchronized('connect_volume') - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): """Connect the volume.""" data = connection_info['data'] quobyte_volume = self._normalize_export(data['export']) @@ -133,7 +133,7 @@ class LibvirtQuobyteVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): validate_volume(mount_path) @utils.synchronized('connect_volume') - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Disconnect the volume.""" quobyte_volume = self._normalize_export( diff --git a/nova/virt/libvirt/volume/scaleio.py b/nova/virt/libvirt/volume/scaleio.py index a5fc0c308c..fdea70c707 100644 --- a/nova/virt/libvirt/volume/scaleio.py +++ b/nova/virt/libvirt/volume/scaleio.py @@ -48,14 +48,14 @@ class LibvirtScaleIOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): conf.source_path = connection_info['data']['device_path'] return conf - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): device_info = self.connector.connect_volume(connection_info['data']) LOG.debug("Attached ScaleIO volume %s.", device_info) connection_info['data']['device_path'] = device_info['path'] - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): self.connector.disconnect_volume(connection_info['data'], None) LOG.debug("Disconnected volume %s.", disk_dev) super(LibvirtScaleIOVolumeDriver, self).disconnect_volume( - connection_info, disk_dev) + connection_info, disk_dev, instance) diff --git a/nova/virt/libvirt/volume/scality.py b/nova/virt/libvirt/volume/scality.py index 2e58e559ff..44e8bbc1e7 100644 --- a/nova/virt/libvirt/volume/scality.py +++ b/nova/virt/libvirt/volume/scality.py @@ -75,7 +75,7 @@ class LibvirtScalityVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): return conf - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): """Connect the volume.""" self._check_prerequisites() self._mount_sofs() diff --git a/nova/virt/libvirt/volume/smbfs.py b/nova/virt/libvirt/volume/smbfs.py index 2f4a6bb863..8841bcb86e 100644 --- a/nova/virt/libvirt/volume/smbfs.py +++ b/nova/virt/libvirt/volume/smbfs.py @@ -39,7 +39,7 @@ class LibvirtSMBFSVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): conf.driver_format = connection_info['data'].get('format', 'raw') return conf - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): """Connect the volume.""" smbfs_share = connection_info['data']['export'] mount_path = self._get_mount_path(connection_info) @@ -52,7 +52,7 @@ class LibvirtSMBFSVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): device_path = self._get_device_path(connection_info) connection_info['data']['device_path'] = device_path - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Disconnect the volume.""" smbfs_share = connection_info['data']['export'] mount_path = self._get_mount_path(connection_info) diff --git a/nova/virt/libvirt/volume/volume.py b/nova/virt/libvirt/volume/volume.py index 8d2bd3018f..4577e1df07 100644 --- a/nova/virt/libvirt/volume/volume.py +++ b/nova/virt/libvirt/volume/volume.py @@ -97,11 +97,11 @@ class LibvirtBaseVolumeDriver(object): return conf - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): """Connect the volume.""" pass - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Disconnect the volume.""" pass diff --git a/nova/virt/libvirt/volume/vzstorage.py b/nova/virt/libvirt/volume/vzstorage.py index c24ef848d8..fd334c9fce 100644 --- a/nova/virt/libvirt/volume/vzstorage.py +++ b/nova/virt/libvirt/volume/vzstorage.py @@ -108,7 +108,7 @@ class LibvirtVZStorageVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): return ' '.join(mount_opts) - def connect_volume(self, connection_info, disk_info): + def connect_volume(self, connection_info, disk_info, instance): """Attach the volume to instance_name.""" LOG.debug("Calling os-brick to mount vzstorage") @@ -119,7 +119,7 @@ class LibvirtVZStorageVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver): connection_info['data']['device_path'] = device_info['path'] - def disconnect_volume(self, connection_info, disk_dev): + def disconnect_volume(self, connection_info, disk_dev, instance): """Detach the volume from instance_name.""" LOG.debug("calling os-brick to detach Vzstorage Volume") |