File nova_disconnect_volume_multipath_fc.patch of Package openstack-nova

Index: nova-2014.2.4.dev84/nova/virt/libvirt/volume.py
===================================================================
--- nova-2014.2.4.dev84.orig/nova/virt/libvirt/volume.py
+++ nova-2014.2.4.dev84/nova/virt/libvirt/volume.py
@@ -1015,11 +1015,8 @@ class LibvirtFibreChannelVolumeDriver(Li
         conf.source_path = connection_info['data']['device_path']
         return conf
 
-    @utils.synchronized('connect_volume')
-    def connect_volume(self, connection_info, disk_info):
-        """Attach the volume to instance_name."""
+    def _get_fc_connection_info(self, connection_info, mount_device):
         fc_properties = connection_info['data']
-        mount_device = disk_info["dev"]
 
         ports = fc_properties['target_wwn']
         wwns = []
@@ -1051,37 +1048,40 @@ class LibvirtFibreChannelVolumeDriver(Li
             msg = _("We are unable to locate any Fibre Channel devices")
             raise exception.NovaException(msg)
 
+        scope = {
+            'host_device': None,
+            'device_name': None,
+            'tries': 0,
+        }
+
         # The /dev/disk/by-path/... node is not always present immediately
         # We only need to find the first device.  Once we see the first device
         # multipath will have any others.
-        def _wait_for_device_discovery(host_devices, mount_device):
-            tries = self.tries
+        def _wait_for_device_discovery():
             for device in host_devices:
                 LOG.debug("Looking for Fibre Channel dev %(device)s",
                           {'device': device})
                 if os.path.exists(device):
-                    self.host_device = device
+                    scope['host_device'] = device
                     # get the /dev/sdX device.  This is used
                     # to find the multipath device.
-                    self.device_name = os.path.realpath(device)
+                    scope['device_name'] = os.path.realpath(device)
                     raise loopingcall.LoopingCallDone()
 
-            if self.tries >= CONF.libvirt.num_iscsi_scan_tries:
+            if scope['tries'] >= CONF.libvirt.num_iscsi_scan_tries:
                 msg = _("Fibre Channel device not found.")
                 raise exception.NovaException(msg)
 
             LOG.warn(_LW("Fibre volume not yet found at: %(mount_device)s. "
                          "Will rescan & retry.  Try number: %(tries)s"),
-                     {'mount_device': mount_device, 'tries': tries})
+                     {'mount_device': mount_device,
+                      'tries': scope['tries']})
 
             linuxscsi.rescan_hosts(hbas)
-            self.tries = self.tries + 1
+            scope['tries'] += 1
 
-        self.host_device = None
-        self.device_name = None
-        self.tries = 0
         timer = loopingcall.FixedIntervalLoopingCall(
-            _wait_for_device_discovery, host_devices, mount_device)
+            _wait_for_device_discovery)
         timer.start(interval=2).wait()
 
         tries = self.tries
openSUSE Build Service is sponsored by