components/openstack/nova/files/solariszones/driver.py
branchs11u3-sru
changeset 7787 26bcbec7afce
parent 7643 eece4b285510
equal deleted inserted replaced
7784:531789214c7c 7787:26bcbec7afce
  1119             )
  1119             )
  1120 
  1120 
  1121         elif driver_type == 'fibre_channel':
  1121         elif driver_type == 'fibre_channel':
  1122             data = connection_info['data']
  1122             data = connection_info['data']
  1123             target_wwn = data['target_wwn']
  1123             target_wwn = data['target_wwn']
  1124             # Check for multiple target_wwn values in a list
       
  1125             if isinstance(target_wwn, list):
       
  1126                 target_wwn = target_wwn[0]
       
  1127             # Ensure there's a fibre channel HBA.
  1124             # Ensure there's a fibre channel HBA.
  1128             hbas = self._get_fc_hbas()
  1125             hbas = self._get_fc_hbas()
  1129             if not hbas:
  1126             if not hbas:
  1130                 LOG.error(_("Cannot attach Fibre Channel volume '%s' because "
  1127                 LOG.error(_("Cannot attach Fibre Channel volume because "
  1131                           "no Fibre Channel HBA initiators were found")
  1128                           "no Fibre Channel HBA initiators were found"))
  1132                           % (target_wwn))
       
  1133                 raise exception.InvalidVolume(
  1129                 raise exception.InvalidVolume(
  1134                     reason="No host Fibre Channel initiator found")
  1130                     reason="No host Fibre Channel initiator found")
  1135 
  1131 
  1136             target_lun = data['target_lun']
  1132             target_lun = data['target_lun']
  1137             # If the volume was exported just a few seconds previously then
  1133             # If the volume was exported just a few seconds previously then
  1140             # a refresh.
  1136             # a refresh.
  1141             for wwpn in self._get_fc_wwpns():
  1137             for wwpn in self._get_fc_wwpns():
  1142                 utils.execute('/usr/sbin/fcinfo', 'remote-port',
  1138                 utils.execute('/usr/sbin/fcinfo', 'remote-port',
  1143                               '-p', wwpn)
  1139                               '-p', wwpn)
  1144 
  1140 
  1145             # Use suriadm(1M) to generate a Fibre Channel storage URI.
  1141             suri = self._lookup_fc_volume_suri(target_wwn, target_lun)
  1146             try:
       
  1147                 out, err = utils.execute('/usr/sbin/suriadm', 'lookup-uri',
       
  1148                                          '-p', 'target=naa.%s' % target_wwn,
       
  1149                                          '-p', 'lun=%s' % target_lun)
       
  1150             except processutils.ProcessExecutionError as ex:
       
  1151                 reason = ex.stderr
       
  1152                 LOG.error(_("Lookup failure of Fibre Channel volume '%s', lun "
       
  1153                           "%s: %s") % (target_wwn, target_lun, reason))
       
  1154                 raise
       
  1155 
       
  1156             lines = out.split('\n')
       
  1157             # Use the long form SURI on the second output line.
       
  1158             suri = lines[1].strip()
       
  1159         return suri
  1142         return suri
       
  1143 
       
  1144     def _lookup_fc_volume_suri(self, target_wwn, target_lun):
       
  1145         """Searching the LU based URI for the FC LU. """
       
  1146         wwns = []
       
  1147         if isinstance(target_wwn, list):
       
  1148             wwns = target_wwn
       
  1149         else:
       
  1150             wwns.append(target_wwn)
       
  1151 
       
  1152         for _none in range(3):
       
  1153             for wwn in wwns:
       
  1154                 try:
       
  1155                     out, err = utils.execute('/usr/sbin/suriadm', 'lookup-uri',
       
  1156                                              '-p', 'target=naa.%s' % wwn,
       
  1157                                              '-p', 'lun=%s' % target_lun)
       
  1158                     for line in [l.strip() for l in out.splitlines()]:
       
  1159                         if line.startswith("lu:luname.naa."):
       
  1160                             return line
       
  1161                 except processutils.ProcessExecutionError as ex:
       
  1162                     reason = ex.stderr
       
  1163                     LOG.debug(_("Failed to lookup-uri for volume '%s', lun "
       
  1164                               "%s: %s") % (wwn, target_lun, reason))
       
  1165             greenthread.sleep(2)
       
  1166         else:
       
  1167             msg = _("Unable to lookup URI of Fibre Channel volume "
       
  1168                     "with lun '%s'." % target_lun)
       
  1169             raise exception.InvalidVolume(reason=msg)
  1160 
  1170 
  1161     def _set_global_properties(self, name, extra_specs, brand):
  1171     def _set_global_properties(self, name, extra_specs, brand):
  1162         """Set Solaris Zone's global properties if supplied via flavor."""
  1172         """Set Solaris Zone's global properties if supplied via flavor."""
  1163         zone = self._get_zone_by_name(name)
  1173         zone = self._get_zone_by_name(name)
  1164         if zone is None:
  1174         if zone is None: