def _terminate_connection(self, volume, connector): """Disconnect the specified volume from the server.""" try: self.terminate_connection(volume, connector) except exception.VSPError: utils.output_log(MSG.UNMAP_LDEV_FAILED, ldev=utils.get_ldev(volume))
def terminate_connection(self, volume, connector): """Terminate connection between the server and the volume.""" targets = { 'info': {}, 'list': [], 'iqns': {}, } mapped_targets = { 'list': [], } unmap_targets = {} ldev = utils.get_ldev(volume) if ldev is None: utils.output_log(MSG.INVALID_LDEV_FOR_UNMAPPING, volume_id=volume['id']) return self.find_targets_from_storage(targets, connector, self.storage_info['ports']) if not targets['list']: utils.output_log(MSG.NO_CONNECTED_TARGET) self.find_mapped_targets_from_storage( mapped_targets, ldev, self.storage_info['ports']) unmap_targets['list'] = self.get_unmap_targets_list( targets['list'], mapped_targets['list']) unmap_targets['list'].sort(reverse=True) self.unmap_ldev(unmap_targets, ldev) if self.storage_info['protocol'] == 'FC': target_wwn = [ self.storage_info['wwns'][port_gid[:utils.PORT_ID_LENGTH]] for port_gid in unmap_targets['list']] return {'driver_volume_type': self.driver_info['volume_type'], 'data': {'target_wwn': target_wwn}}
def create_cloned_volume(self, volume, src_vref): """Create a clone of the specified volume and return its properties.""" ldev = utils.get_ldev(src_vref) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is not None'. if ldev is None: msg = utils.output_log(MSG.INVALID_LDEV_FOR_VOLUME_COPY, type='volume', id=src_vref['id']) raise exception.VSPError(msg) size = volume['size'] metadata = utils.get_volume_metadata(volume) if size < src_vref['size']: msg = utils.output_log(MSG.INVALID_VOLUME_SIZE_FOR_COPY, type='volume', volume_id=volume['id']) raise exception.VSPError(msg) elif (size > src_vref['size'] and not self.check_vvol(ldev) and self.get_copy_method(metadata) == "THIN"): msg = utils.output_log(MSG.INVALID_VOLUME_SIZE_FOR_TI, copy_method=utils.THIN, type='volume', volume_id=volume['id']) raise exception.VSPError(msg) sync = size > src_vref['size'] new_ldev = self._copy_ldev(ldev, src_vref['size'], metadata, sync) if sync: self.delete_pair(new_ldev) self.extend_ldev(new_ldev, src_vref['size'], size) return { 'provider_location': six.text_type(new_ldev), }
def initialize_connection(self, volume, connector): """Initialize connection between the server and the volume.""" targets = { 'info': {}, 'list': [], 'lun': {}, 'iqns': {}, } ldev = utils.get_ldev(volume) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is None'. if ldev is None: msg = utils.output_log(MSG.INVALID_LDEV_FOR_CONNECTION, volume_id=volume['id']) raise exception.VSPError(msg) if (self.find_targets_from_storage( targets, connector, self.storage_info['ports']) and self.conf.vsp_group_request): self.create_mapping_targets(targets, connector) utils.require_target_existed(targets) targets['list'].sort() for port in self.storage_info['ports']: targets['lun'][port] = False target_lun = int(self.map_ldev(targets, ldev)) return { 'driver_volume_type': self.driver_info['volume_type'], 'data': self.get_properties(targets, connector, target_lun), }
def initialize_connection(self, volume, connector): """Initialize connection between the server and the volume.""" targets = { 'info': {}, 'list': [], 'lun': {}, 'iqns': {}, } ldev = utils.get_ldev(volume) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is None'. if ldev is None: msg = utils.output_log(MSG.INVALID_LDEV_FOR_CONNECTION, volume_id=volume['id']) raise exception.VSPError(msg) if (self.find_targets_from_storage(targets, connector, self.storage_info['ports']) and self.conf.vsp_group_request): self.create_mapping_targets(targets, connector) utils.require_target_existed(targets) targets['list'].sort() for port in self.storage_info['ports']: targets['lun'][port] = False target_lun = int(self.map_ldev(targets, ldev)) return { 'driver_volume_type': self.driver_info['volume_type'], 'data': self.get_properties(targets, connector, target_lun), }
def delete_volume(self, volume): """Delete the specified volume.""" ldev = utils.get_ldev(volume) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is not None'. if ldev is None: utils.output_log(MSG.INVALID_LDEV_FOR_DELETION, method='delete_volume', id=volume['id']) return try: self._delete_ldev(ldev) except exception.VSPBusy: raise exception.VolumeIsBusy(volume_name=volume['name'])
def delete_snapshot(self, snapshot): """Delete the specified snapshot.""" ldev = utils.get_ldev(snapshot) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is None'. if ldev is None: utils.output_log(MSG.INVALID_LDEV_FOR_DELETION, method='delete_snapshot', id=snapshot['id']) return try: self._delete_ldev(ldev) except exception.VSPBusy: raise exception.SnapshotIsBusy(snapshot_name=snapshot['name'])
def delete_snapshot(self, snapshot): """Delete the specified snapshot.""" ldev = utils.get_ldev(snapshot) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is None'. if ldev is None: utils.output_log( MSG.INVALID_LDEV_FOR_DELETION, method='delete_snapshot', id=snapshot['id']) return try: self._delete_ldev(ldev) except exception.VSPBusy: raise exception.SnapshotIsBusy(snapshot_name=snapshot['name'])
def extend_volume(self, volume, new_size): """Extend the specified volume to the specified size.""" ldev = utils.get_ldev(volume) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is None'. if ldev is None: msg = utils.output_log(MSG.INVALID_LDEV_FOR_EXTENSION, volume_id=volume['id']) raise exception.VSPError(msg) if self.check_vvol(ldev): msg = utils.output_log(MSG.INVALID_VOLUME_TYPE_FOR_EXTEND, volume_id=volume['id']) raise exception.VSPError(msg) self.delete_pair(ldev) self.extend_ldev(ldev, volume['size'], new_size)
def create_snapshot(self, snapshot): """Create a snapshot from a volume and return its properties.""" src_vref = snapshot.volume ldev = utils.get_ldev(src_vref) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is None'. if ldev is None: msg = utils.output_log(MSG.INVALID_LDEV_FOR_VOLUME_COPY, type='volume', id=src_vref['id']) raise exception.VSPError(msg) size = snapshot['volume_size'] metadata = utils.get_volume_metadata(src_vref) new_ldev = self._copy_ldev(ldev, size, metadata) return { 'provider_location': six.text_type(new_ldev), }
def unmanage(self, volume): """Prepare the volume for removing it from Cinder management.""" ldev = utils.get_ldev(volume) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is None'. if ldev is None: utils.output_log(MSG.INVALID_LDEV_FOR_DELETION, method='unmanage', id=volume['id']) return if self.check_vvol(ldev): utils.output_log( MSG.INVALID_LDEV_TYPE_FOR_UNMANAGE, volume_id=volume['id'], volume_type=utils.NORMAL_LDEV_TYPE) raise exception.VolumeIsBusy(volume_name=volume['name']) try: self.delete_pair(ldev) except exception.VSPBusy: raise exception.VolumeIsBusy(volume_name=volume['name'])