|
1 In-house patch to adopt EMC driver to use Solaris' iscsiadm(1M) rather |
|
2 than that from Linux. Patch has not yet been submitted upstream. |
|
3 |
|
4 --- cinder-2013.1.4/cinder/volume/drivers/emc/emc_smis_iscsi.py.~1~ 2013-10-17 11:21:37.000000000 -0700 |
|
5 +++ cinder-2013.1.4/cinder/volume/drivers/emc/emc_smis_iscsi.py 2014-03-12 17:07:06.500560732 -0700 |
|
6 @@ -21,6 +21,7 @@ |
|
7 """ |
|
8 |
|
9 import os |
|
10 +import sys |
|
11 import time |
|
12 |
|
13 from cinder import exception |
|
14 @@ -118,13 +119,41 @@ |
|
15 |
|
16 LOG.warn(_("ISCSI provider_location not stored, using discovery")) |
|
17 |
|
18 - (out, _err) = self._execute('iscsiadm', '-m', 'discovery', |
|
19 - '-t', 'sendtargets', '-p', |
|
20 - self.configuration.iscsi_ip_address, |
|
21 - run_as_root=True) |
|
22 targets = [] |
|
23 - for target in out.splitlines(): |
|
24 - targets.append(target) |
|
25 + |
|
26 + if sys.platform == 'sunos5': |
|
27 + data = _("Unexpected response while retrieving discovery-address " |
|
28 + "objects for volume '%s'") % volume["name"] |
|
29 + |
|
30 + self._execute('/usr/sbin/iscsiadm', 'add', 'discovery-address', |
|
31 + self.configuration.iscsi_ip_address) |
|
32 + (out, _err) = self._execute('/usr/sbin/iscsiadm', 'list', |
|
33 + 'discovery-address', '-v', |
|
34 + self.configuration.iscsi_ip_address) |
|
35 + lines = out.splitlines() |
|
36 + if not lines[0].strip().startswith('Discovery Address: '): |
|
37 + raise exception.VolumeBackendAPIException(data=data) |
|
38 + |
|
39 + for i in range(1, len(lines), 2): |
|
40 + name = lines[i].strip() |
|
41 + if not name.startswith('Target name: '): |
|
42 + raise exception.VolumeBackendAPIException(data=data) |
|
43 + (_, _, name) = name.split() |
|
44 + |
|
45 + address = lines[i + 1].strip() |
|
46 + if not address.startswith('Target address: '): |
|
47 + raise exception.VolumeBackendAPIException(data=data) |
|
48 + (_, _, address, tpgt) = address.split() |
|
49 + target = address + tpgt + ' ' + name |
|
50 + targets.append(target) |
|
51 + |
|
52 + else: |
|
53 + (out, _err) = self._execute('iscsiadm', '-m', 'discovery', |
|
54 + '-t', 'sendtargets', '-p', |
|
55 + self.configuration.iscsi_ip_address, |
|
56 + run_as_root=True) |
|
57 + for target in out.splitlines(): |
|
58 + targets.append(target) |
|
59 |
|
60 return targets |
|
61 |