def attach_volume(self, **kwargs): core = kwargs.get('dev_path') if core is None: LOG.error('dev_path is not specified') raise exception.VolumePathsNotFound() core = os.path.realpath(core) return self._map_casdisk(core)
def get_local_share_path(self, share, expect_existing=True): local_share_path = self._smbutils.get_smb_share_path(share) if not local_share_path and expect_existing: err_msg = _("Could not find the local " "share path for %(share)s.") raise exception.VolumePathsNotFound(err_msg % dict(share=share)) return local_share_path
def _get_device_path(self, current_nvme_devices): all_nvme_devices = self._get_nvme_devices() LOG.debug("all_nvme_devices are %(all_nvme_devices)s", {'all_nvme_devices': all_nvme_devices}) path = set(all_nvme_devices) - set(current_nvme_devices) if not path: raise exception.VolumePathsNotFound() return list(path)
def detach_volume(self, **kwargs): casdev = kwargs.get('dev_path') if casdev is None: LOG.error('dev_path is not specified') raise exception.VolumePathsNotFound() coreid, coredev = self._get_mapped_coredev(casdev) LOG.info("opencas: coreid=%s,coredev=%s", coreid, coredev) self._unmap_casdisk(coreid) return coredev
def extend_volume(self, connection_properties): """Update the local kernel's size information. Try and update the local kernel's size information for an FC volume. """ volume_paths = self.get_volume_paths(connection_properties) if volume_paths: return self._linuxscsi.extend_volume(volume_paths[0]) else: LOG.warning(_LW("Couldn't find any volume paths on the host to " "extend volume for %(props)s"), {'props': connection_properties}) raise exception.VolumePathsNotFound()
def extend_volume(self, connection_properties): """Update the local kernel's size information. Try and update the local kernel's size information for an iSCSI volume. """ LOG.info("Extend volume for %s", strutils.mask_dict_password(connection_properties)) volume_paths = self.get_volume_paths(connection_properties) LOG.info("Found paths for volume %s", volume_paths) if volume_paths: return self._linuxscsi.extend_volume(volume_paths) else: LOG.warning( "Couldn't find any volume paths on the host to " "extend volume for %(props)s", {'props': strutils.mask_dict_password(connection_properties)}) raise exception.VolumePathsNotFound()
def extend_volume(self, connection_properties): """Update the local kernel's size information. Try and update the local kernel's size information for an LVM volume. """ if connection_properties.get('vol_uuid'): # compatibility return self._extend_volume_replicated(connection_properties) volume_paths = self.get_volume_paths(connection_properties) if volume_paths: return self._linuxscsi.extend_volume( volume_paths, use_multipath=self.use_multipath) else: LOG.warning( "Couldn't find any volume paths on the host to " "extend volume for %(props)s", {'props': connection_properties}) raise exception.VolumePathsNotFound()
def get_local_share_path(self, share, expect_existing=True): share = self._get_share_norm_path(share) share_name = self.get_share_name(share) share_subdir = self.get_share_subdir(share) is_local_share = self._smbutils.is_local_share(share) if not is_local_share: LOG.debug("Share '%s' is not exposed by the current host.", share) local_share_path = None else: local_share_path = self._smbutils.get_smb_share_path(share_name) if not local_share_path and expect_existing: err_msg = _("Could not find the local " "share path for %(share)s.") raise exception.VolumePathsNotFound(err_msg % dict(share=share)) if local_share_path and share_subdir: local_share_path = os.path.join(local_share_path, share_subdir) return local_share_path
def _add_targets_to_connection_properties(self, connection_properties): LOG.debug('Adding targets to connection properties receives: %s', connection_properties) target_wwn = connection_properties.get('target_wwn') target_wwns = connection_properties.get('target_wwns') if target_wwns: wwns = target_wwns elif isinstance(target_wwn, list): wwns = target_wwn elif isinstance(target_wwn, six.string_types): wwns = [target_wwn] else: wwns = [] # Convert wwns to lower case wwns = [wwn.lower() for wwn in wwns] if target_wwns: connection_properties['target_wwns'] = wwns elif target_wwn: connection_properties['target_wwn'] = wwns target_lun = connection_properties.get('target_lun', 0) target_luns = connection_properties.get('target_luns') if target_luns: luns = target_luns elif isinstance(target_lun, int): luns = [target_lun] else: luns = [] if len(luns) == len(wwns): # Handles single wwn + lun or multiple, potentially # different wwns or luns targets = list(zip(wwns, luns)) elif len(luns) == 1 and len(wwns) > 1: # For the case of multiple wwns, but a single lun (old path) targets = [(wwn, luns[0]) for wwn in wwns] else: # Something is wrong, this shouldn't happen. msg = _("Unable to find potential volume paths for FC device " "with luns: %(luns)s and wwns: %(wwns)s.") % { "luns": luns, "wwns": wwns } LOG.error(msg) raise exception.VolumePathsNotFound(msg) connection_properties['targets'] = targets wwpn_lun_map = {wwpn: lun for wwpn, lun in targets} # If there is an initiator_target_map we can update it too and generate # the initiator_target_lun_map from it if connection_properties.get('initiator_target_map') is not None: # Convert it to lower case itmap = connection_properties['initiator_target_map'] itmap = { k.lower(): [port.lower() for port in v] for k, v in itmap.items() } connection_properties['initiator_target_map'] = itmap itmaplun = dict() for init_wwpn, target_wwpns in itmap.items(): itmaplun[init_wwpn] = [(target_wwpn, wwpn_lun_map[target_wwpn]) for target_wwpn in target_wwpns if target_wwpn in wwpn_lun_map] # We added the if in the previous list comprehension in case # drivers return targets in the map that are not reported in # target_wwn or target_wwns, but we warn about it. if len(itmaplun[init_wwpn]) != len(itmap[init_wwpn]): unknown = set(itmap[init_wwpn]) unknown.difference_update(itmaplun[init_wwpn]) LOG.warning( 'Driver returned an unknown targets in the ' 'initiator mapping %s', ', '.join(unknown)) connection_properties['initiator_target_lun_map'] = itmaplun LOG.debug('Adding targets to connection properties returns: %s', connection_properties) return connection_properties
def _add_targets_to_connection_properties(self, connection_properties): target_wwn = connection_properties.get('target_wwn') target_wwns = connection_properties.get('target_wwns') if target_wwns: wwns = target_wwns elif isinstance(target_wwn, list): wwns = target_wwn elif isinstance(target_wwn, six.string_types): wwns = [target_wwn] else: wwns = [] target_lun = connection_properties.get('target_lun', 0) target_luns = connection_properties.get('target_luns') if target_luns: luns = target_luns elif isinstance(target_lun, int): luns = [target_lun] else: luns = [] if len(luns) == len(wwns): # Handles single wwwn + lun or multiple, potentially # different wwns or luns targets = list(zip(wwns, luns)) elif len(luns) == 1 and len(wwns) > 1: # For the case of multiple wwns, but a single lun (old path) targets = [] for wwn in wwns: targets.append((wwn, luns[0])) else: # Something is wrong, this shouldn't happen. msg = _("Unable to find potential volume paths for FC device " "with luns: %(luns)s and wwns: %(wwns)s.") % { "luns": luns, "wwns": wwns } LOG.error(msg) raise exception.VolumePathsNotFound(msg) connection_properties['targets'] = targets wwpn_lun_map = dict() for wwpn, lun in targets: wwpn_lun_map[wwpn] = lun # If there is an initiator_target_map we can update it too if 'initiator_target_map' in connection_properties: itmap = connection_properties['initiator_target_map'] new_itmap = dict() for init_wwpn in itmap: target_wwpns = itmap[init_wwpn] init_targets = [] for target_wwpn in target_wwpns: if target_wwpn in wwpn_lun_map: init_targets.append( (target_wwpn, wwpn_lun_map[target_wwpn])) new_itmap[init_wwpn] = init_targets connection_properties['initiator_target_lun_map'] = new_itmap return connection_properties