components/openstack/cinder/patches/03-emc_smis_iscsi.patch
author Michael Nestler <Michael.Nestler@Oracle.COM>
Wed, 15 Oct 2014 09:26:27 -0700
branchs11-update
changeset 3394 9758aff98adb
parent 3178 77584387a894
permissions -rw-r--r--
19789649 rsyslog complete documentation is missing

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-2013.2.3/cinder/volume/drivers/emc/emc_smis_iscsi.py.~1~	2014-04-03 11:42:36.000000000 -0700
+++ cinder-2013.2.3/cinder/volume/drivers/emc/emc_smis_iscsi.py	2014-04-09 01:30:22.894010750 -0700
@@ -21,6 +21,8 @@
 """
 
 
+import sys
+
 from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.volume import driver
@@ -114,13 +116,41 @@
 
         LOG.warn(_("ISCSI provider_location not stored, using discovery"))
 
-        (out, _err) = self._execute('iscsiadm', '-m', 'discovery',
-                                    '-t', 'sendtargets', '-p',
-                                    self.configuration.iscsi_ip_address,
-                                    run_as_root=True)
         targets = []
-        for target in out.splitlines():
-            targets.append(target)
+
+        if sys.platform == 'sunos5':
+            data = _("Unexpected response while retrieving discovery-address "
+                     "objects for volume '%s'") % volume["name"]
+
+            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)
+            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.append(target)
+
+        else:
+            (out, _err) = self._execute('iscsiadm', '-m', 'discovery',
+                                        '-t', 'sendtargets', '-p',
+                                        self.configuration.iscsi_ip_address,
+                                        run_as_root=True)
+            for target in out.splitlines():
+                targets.append(target)
 
         return targets