components/openstack/cinder/patches/03-emc_smis_iscsi.patch
branchs11u2-sru
changeset 4156 4b1def16fe9b
parent 4146 097063f324c0
child 4157 92532a6159e7
equal deleted inserted replaced
4146:097063f324c0 4156:4b1def16fe9b
     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.2.3/cinder/volume/drivers/emc/emc_smis_iscsi.py.~1~	2014-04-03 11:42:36.000000000 -0700
       
     5 +++ cinder-2013.2.3/cinder/volume/drivers/emc/emc_smis_iscsi.py	2014-04-09 01:30:22.894010750 -0700
       
     6 @@ -21,6 +21,8 @@
       
     7  """
       
     8  
       
     9  
       
    10 +import sys
       
    11 +
       
    12  from cinder import exception
       
    13  from cinder.openstack.common import log as logging
       
    14  from cinder.volume import driver
       
    15 @@ -114,13 +116,41 @@
       
    16  
       
    17          LOG.warn(_("ISCSI provider_location not stored, using discovery"))
       
    18  
       
    19 -        (out, _err) = self._execute('iscsiadm', '-m', 'discovery',
       
    20 -                                    '-t', 'sendtargets', '-p',
       
    21 -                                    self.configuration.iscsi_ip_address,
       
    22 -                                    run_as_root=True)
       
    23          targets = []
       
    24 -        for target in out.splitlines():
       
    25 -            targets.append(target)
       
    26 +
       
    27 +        if sys.platform == 'sunos5':
       
    28 +            data = _("Unexpected response while retrieving discovery-address "
       
    29 +                     "objects for volume '%s'") % volume["name"]
       
    30 +
       
    31 +            self._execute('/usr/sbin/iscsiadm', 'add', 'discovery-address',
       
    32 +                          self.configuration.iscsi_ip_address)
       
    33 +            (out, _err) = self._execute('/usr/sbin/iscsiadm', 'list',
       
    34 +                                        'discovery-address', '-v',
       
    35 +                                        self.configuration.iscsi_ip_address)
       
    36 +            lines = out.splitlines()
       
    37 +            if not lines[0].strip().startswith('Discovery Address: '):
       
    38 +                raise exception.VolumeBackendAPIException(data=data)
       
    39 +
       
    40 +            for i in range(1, len(lines), 2):
       
    41 +                name = lines[i].strip()
       
    42 +                if not name.startswith('Target name: '):
       
    43 +                    raise exception.VolumeBackendAPIException(data=data)
       
    44 +                (_, _, name) = name.split()
       
    45 +
       
    46 +                address = lines[i + 1].strip()
       
    47 +                if not address.startswith('Target address: '):
       
    48 +                    raise exception.VolumeBackendAPIException(data=data)
       
    49 +                (_, _, address, tpgt) = address.split()
       
    50 +                target = address + tpgt + ' ' + name
       
    51 +                targets.append(target)
       
    52 +
       
    53 +        else:
       
    54 +            (out, _err) = self._execute('iscsiadm', '-m', 'discovery',
       
    55 +                                        '-t', 'sendtargets', '-p',
       
    56 +                                        self.configuration.iscsi_ip_address,
       
    57 +                                        run_as_root=True)
       
    58 +            for target in out.splitlines():
       
    59 +                targets.append(target)
       
    60  
       
    61          return targets
       
    62