components/openstack/nova/patches/06-Solaris-dev-name.patch
author Laszlo Peter <laszlo.peter@oracle.com>
Wed, 07 Sep 2016 14:48:42 -0700
changeset 6854 52081f923019
parent 5405 66fd59fecd68
permissions -rw-r--r--
24465850 Update Nova for the Mitaka release 22456289 nova interface-attach reports an error; adds unusable entry to instance anyway

The patch is to fix the issue of linuxy devices names on Solaris
instance recorded in the bugs (19987962 and 19277019).

--- nova-13.0.0.0rc2/nova/compute/utils.py.~6~	2016-03-31 01:46:45.489880535 -0800
+++ nova-13.0.0.0rc2/nova/compute/utils.py	2016-03-31 02:19:05.040013477 -0800
@@ -137,6 +137,24 @@ def get_next_device_name(instance, devic
     name will be converted to the appropriate format.
     """
 
+    if (CONF.compute_driver and
+            CONF.compute_driver.endswith('solariszones.SolarisZonesDriver')):
+        prefix = 'c1d'
+        if device_name_list == []:
+            # Return the root device (c1d0)
+            return 'c1d0'
+
+        # Remove non-Solaris devices names (like, /dev/sda, sdb, ...)
+        # if they exist in the instance.
+        device_name_list = \
+            [dev for dev in device_name_list if prefix in dev]
+        device_name_list.sort()
+
+        # find the least unused number from '0' (root device)
+        used_nums = [int(dev.rsplit('d')[-1]) for dev in device_name_list]
+        diff = [i for i in range(len(used_nums) + 1) if i not in used_nums]
+        return prefix + str(min(diff))
+
     req_prefix = None
     req_letter = None