components/openstack/cinder/patches/03-emc_vmax_iscsi.patch
author Laszlo Peter <laszlo.peter@oracle.com>
Wed, 07 Sep 2016 14:48:41 -0700
changeset 6849 f9a2279efa0d
parent 5405 66fd59fecd68
permissions -rw-r--r--
24465600 Update Cinder for the Mitaka release

In-house patch to adopt EMC driver to use Solaris' iscsiadm(1M) rather
than that from Linux. Patch has not yet been submitted upstream.

--- cinder-8.0.0/cinder/volume/drivers/emc/emc_vmax_iscsi.py.~1~	2016-04-07 00:30:48.000000000 -0700
+++ cinder-8.0.0/cinder/volume/drivers/emc/emc_vmax_iscsi.py	2016-06-10 14:32:40.533787510 -0700
@@ -17,6 +17,7 @@ ISCSI Drivers for EMC VMAX arrays based
 
 """
 import os
+import sys
 
 from oslo_log import log as logging
 import six
@@ -185,14 +186,48 @@ class EMCVMAXISCSIDriver(driver.ISCSIDri
 
     def _call_iscsiadm(self, iscsi_ip_address):
         """Calls iscsiadm with iscsi ip address"""
-        try:
-            (out, _err) = self._execute('iscsiadm', '-m', 'discovery',
-                                        '-t', 'sendtargets', '-p',
-                                        iscsi_ip_address,
-                                        run_as_root=True)
-            return out, _err, False, None
-        except Exception as ex:
-            return None, None, True, ex
+        if sys.platform == 'sunos5':
+            data = _("Unexpected response while retrieving discovery-address "
+                     "objects for volume '%s'") % volume["name"]
+
+            try:
+                self._execute('/usr/sbin/iscsiadm', 'add', 'discovery-address',
+                              self.configuration.iscsi_ip_address)
+                (out, _err) = self._execute('/usr/sbin/iscsiadm', 'list',
+                                            'discovery-address', '-v',
+                                            self.configuration.iscsi_ip_address)
+            except Exception as ex:
+                return None, None, True, ex
+            targets = ""
+            lines = out.splitlines()
+            if not lines[0].strip().startswith('Discovery Address: '):
+                raise exception.VolumeBackendAPIException(data=data)
+
+            for i in range(1, len(lines), 2):
+                name = lines[i].strip()
+                if not name.startswith('Target name: '):
+                    raise exception.VolumeBackendAPIException(data=data)
+                (_, _, name) = name.split()
+
+                address = lines[i + 1].strip()
+                if not address.startswith('Target address: '):
+                    raise exception.VolumeBackendAPIException(data=data)
+                (_, _, address, tpgt) = address.split()
+                target = address + tpgt + ' ' + name
+                targets += target + "\n"
+
+            return targets, _err, False, None
+
+        else:
+
+            try:
+                (out, _err) = self._execute('iscsiadm', '-m', 'discovery',
+                                            '-t', 'sendtargets', '-p',
+                                            iscsi_ip_address,
+                                            run_as_root=True)
+                return out, _err, False, None
+            except Exception as ex:
+                return None, None, True, ex
 
     def smis_do_iscsi_discovery(self, volume):
         """Calls iscsiadm with each iscsi ip address in the list"""