def _run_locked_restore(volume, snapshot_id): try: snapshot = self.db.snapshot_get(self.ctxt, snapshot_id) except cinder_exception.SnapshotNotFound: with excutils.save_and_reraise_exception(): utils.output_log( 656, volume_id=volume['id'], reason='Invalid input: %s' % snapshot_id) pvol = utils.get_ldev(volume) svol = utils.get_ldev(snapshot) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is None'. if svol is None or not self.has_thin_copy_pair(pvol, svol): msg = utils.output_log( 656, volume_id=volume['id'], reason='Invalid input: %s' % snapshot_id) raise exception.HPXPError(data=msg) if volume['status'] != 'available': msg = utils.output_log( 656, volume_id=volume['id'], reason='Status of target volume %(volume_id)s ' 'is not available: %(status)s' % { 'volume_id': volume['id'], 'status': volume['status']}) raise exception.HPXPError(data=msg) if snapshot['status'] != 'available': msg = utils.output_log( 656, volume_id=volume['id'], reason='Status of source snapshot %(snapshot_id)s ' 'is not available: %(status)s' % { 'snapshot_id': snapshot_id, 'status': snapshot['status']}) raise exception.HPXPError(data=msg) self.restore_ldev(pvol, svol)
def create_volume_from_snapshot(self, volume, snapshot): ldev = utils.get_ldev(snapshot) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is not None'. if (ldev is not None and self.check_vvol(ldev) and _get_access_mode(volume) == 'ro'): if 'ro_vol' in _get_snapshot_metadata(snapshot): msg = utils.output_log(657, snapshot_id=snapshot['id']) raise exception.HPXPError(data=msg) self.db.snapshot_metadata_update( self.ctxt, snapshot['id'], dict(ro_vol=volume['id']), False) metadata = utils.get_volume_metadata(volume) return { 'provider_location': six.text_type(ldev), 'metadata': dict( metadata, ldev=ldev, type=utils.VVOL_LDEV_TYPE, snapshot=snapshot['id']), } return super( HPXPCommonExtension, self).create_volume_from_snapshot( volume, snapshot)
def discard_zero_page(self, volume): ldev = utils.get_ldev(volume) try: self.run_raidcom( 'modify', 'ldev', '-ldev_id', ldev, '-status', 'discard_zero_page') except exception.HPXPError: utils.output_log(315, ldev=ldev)
def delete_volume(self, 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(304, method='delete_volume', id=volume['id']) return try: self._delete_ldev(ldev) except exception.HPXPBusy: raise exception.HPXPVolumeIsBusy(volume_name=volume['name'])
def delete_snapshot(self, snapshot): ldev = utils.get_ldev(snapshot) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is not None'. if (ldev is not None and self.check_vvol(ldev) and 'ro_vol' in _get_snapshot_metadata(snapshot)): utils.output_log(606, snapshot_id=snapshot['id']) raise exception.HPXPSnapshotIsBusy( snapshot_name=snapshot['name']) super(HPXPCommonExtension, self).delete_snapshot(snapshot)
def extend_volume(self, volume, new_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(613, volume_id=volume['id']) raise exception.HPXPError(data=msg) if self.check_vvol(ldev): msg = utils.output_log(618, volume_id=volume['id']) raise exception.HPXPError(data=msg) self.delete_pair(ldev) self.extend_ldev(ldev, volume['size'], new_size)
def delete_snapshot(self, 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( 304, method='delete_snapshot', id=snapshot['id']) return try: self._delete_ldev(ldev) except exception.HPXPBusy: raise exception.HPXPSnapshotIsBusy(snapshot_name=snapshot['name'])
def _get_ro_vol(self, volume): ldev = utils.get_ldev(volume) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is None'. if ldev is None or not self.check_vvol(ldev): return None try: snapshot = self.db.snapshot_get(self.ctxt, volume['snapshot_id']) except cinder_exception.SnapshotNotFound: return None return _get_snapshot_metadata(snapshot).get('ro_vol')
def unmanage(self, volume): 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(304, method='unmanage', id=volume['id']) return if self.check_vvol(ldev): utils.output_log( 706, volume_id=volume['id'], volume_type=utils.NORMAL_LDEV_TYPE) raise exception.HPXPVolumeIsBusy(volume_name=volume['name']) try: self.delete_pair(ldev) except exception.HPXPBusy: raise exception.HPXPVolumeIsBusy(volume_name=volume['name'])
def create_snapshot(self, snapshot): src_vref = self.db.volume_get(self.ctxt, snapshot['volume_id']) ldev = utils.get_ldev(src_vref) metadata = utils.get_volume_metadata(src_vref) # When 'ldev' is 0, it should be true. # Therefore, it cannot remove 'is not None'. method = ( self.get_copy_method(metadata) if ldev is not None and not self.check_vvol(ldev) else None) if 'restore_from' in metadata and method == 'THIN': self._restore_volume_from_snapshot( src_vref, metadata['restore_from']) return { 'provider_location': _INVALID_LDEV_NUM, } return super(HPXPCommonExtension, self).create_snapshot(snapshot)
def create_snapshot(self, snapshot): src_vref = self.db.volume_get(self.ctxt, snapshot['volume_id']) 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(624, type='volume', id=src_vref['id']) raise exception.HPXPError(data=msg) size = snapshot['volume_size'] metadata = utils.get_volume_metadata(src_vref) new_ldev, ldev_type = self._copy_ldev(ldev, size, metadata) if not self.conf.hpxp_driver_cert_mode: self.db.snapshot_metadata_update( self.ctxt, snapshot['id'], dict(ldev=new_ldev, type=ldev_type), False) return { 'provider_location': six.text_type(new_ldev), }
def create_cloned_volume(self, volume, src_vref): 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(624, type='volume', id=src_vref['id']) raise exception.HPXPError(data=msg) size = volume['size'] if size != src_vref['size']: msg = utils.output_log(617, type='volume', volume_id=volume['id']) raise exception.HPXPError(data=msg) metadata = utils.get_volume_metadata(volume) new_ldev, ldev_type = self._copy_ldev(ldev, size, metadata) return { 'provider_location': six.text_type(new_ldev), 'metadata': dict( metadata, ldev=new_ldev, type=ldev_type, volume=src_vref['id']), }
def terminate_connection(self, volume, connector, **dummy_kwargs): targets = { 'info': {}, 'list': [], } mapped_targets = { 'list': [], } unmap_targets = {} ldev = utils.get_ldev(volume) if ldev is None: utils.output_log(302, volume_id=volume['id']) return target_ports = self.get_target_ports(connector) self.find_targets_from_storage(targets, connector, target_ports) self.find_mapped_targets_from_storage( mapped_targets, ldev, target_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)
def initialize_connection(self, volume, connector): targets = { 'info': {}, 'list': [], } 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(619, volume_id=volume['id']) raise exception.HPXPError(data=msg) target_ports = self.get_target_ports(connector) if (self.find_targets_from_storage( targets, connector, target_ports) and self.conf.hpxp_group_request): self.create_mapping_targets(targets, connector) utils.require_target_existed(targets) targets['list'].sort() self.modify_target_mode(volume, targets) target_lun = self.map_ldev(targets, ldev) conn_info = { 'driver_volume_type': self.driver_info['volume_type'], 'data': self.get_properties(volume, targets, target_lun, connector), } if self.conf.hpxp_zoning_request: init_targ_map = self._build_initiator_target_map( connector, conn_info['data']['target_wwn']) if init_targ_map: conn_info['data']['initiator_target_map'] = init_targ_map return conn_info
def _terminate_connection(self, volume, connector): try: self.terminate_connection(volume, connector) except exception.HPXPError: utils.output_log(310, ldev=utils.get_ldev(volume))