Search in sources :

Example 26 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class BlockMirrorDeactivateCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        super.complete(dbClient, status, coded);
        List<BlockMirror> mirrorList = dbClient.queryObject(BlockMirror.class, getIds());
        for (BlockMirror mirror : mirrorList) {
            Volume volume = dbClient.queryObject(Volume.class, mirror.getSource());
            switch(status) {
                case error:
                    dbClient.error(BlockMirror.class, mirror.getId(), getOpId(), coded);
                    dbClient.error(Volume.class, volume.getId(), getOpId(), coded);
                    break;
                default:
                    dbClient.ready(BlockMirror.class, mirror.getId(), getOpId());
                    dbClient.ready(Volume.class, volume.getId(), getOpId());
            }
            recordBlockMirrorOperation(dbClient, OperationTypeEnum.DEACTIVATE_VOLUME_MIRROR, status, eventMessage(status, volume, mirror), mirror, volume);
        }
        List<URI> promotees = getPromotees();
        if (promotees != null && !promotees.isEmpty()) {
            List<Volume> promotedVolumes = dbClient.queryObject(Volume.class, promotees);
            List<Volume> volumesToUpdate = new ArrayList<Volume>();
            for (Volume volume : promotedVolumes) {
                switch(status) {
                    case error:
                        dbClient.error(Volume.class, volume.getId(), getOpId(), coded);
                        volume.setInactive(true);
                        volumesToUpdate.add(volume);
                        break;
                    default:
                        dbClient.ready(Volume.class, volume.getId(), getOpId());
                }
            }
            if (!volumesToUpdate.isEmpty()) {
                dbClient.persistObject(volumesToUpdate);
            }
        }
    } catch (Exception e) {
        _log.error("Failed updating status. BlockMirrorDeactivate {}, for task " + getOpId(), Joiner.on("\t").join(getIds()), e);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 27 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class BlockMirrorDeleteCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        super.complete(dbClient, status, coded);
        List<BlockMirror> mirrorList = dbClient.queryObject(BlockMirror.class, getIds());
        for (BlockMirror mirror : mirrorList) {
            Volume volume = dbClient.queryObject(Volume.class, mirror.getSource());
            switch(status) {
                case error:
                    dbClient.error(BlockMirror.class, mirror.getId(), getOpId(), coded);
                    dbClient.error(Volume.class, volume.getId(), getOpId(), coded);
                    break;
                default:
                    dbClient.ready(BlockMirror.class, mirror.getId(), getOpId());
                    dbClient.ready(Volume.class, volume.getId(), getOpId());
            }
            recordBlockMirrorOperation(dbClient, OperationTypeEnum.DELETE_VOLUME_MIRROR, status, eventMessage(status, volume, mirror), mirror, volume);
        }
    } catch (Exception e) {
        _log.error("Failed updating status. BlockMirrorCreate {}, for task " + getOpId(), Joiner.on("\t").join(getIds()), e);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 28 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class BlockMirrorTaskCompleter method recordBlockMirrorOperation.

/**
 * Record block mirror related event and audit
 *
 * @param dbClient db client
 * @param opType operation type
 * @param status operation status
 * @param evDesc event description
 * @param extParam parameters array from which we could generate detail
 *            audit message
 */
public void recordBlockMirrorOperation(DbClient dbClient, OperationTypeEnum opType, Operation.Status status, String evDesc, Object... extParam) {
    try {
        boolean opStatus = (Operation.Status.ready == status) ? true : false;
        String evType = opType.getEvType(opStatus);
        String opStage = AuditLogManager.AUDITOP_END;
        _log.info("opType: {} detail: {}", opType.toString(), evType.toString() + ':' + evDesc);
        BlockMirror mirror = (BlockMirror) extParam[0];
        recordBourneBlockMirrorEvent(dbClient, mirror.getId(), evType, status, evDesc);
        Volume volume = (Volume) extParam[1];
        switch(opType) {
            case CREATE_VOLUME_MIRROR:
                if (opStatus) {
                    AuditBlockUtil.auditBlock(dbClient, opType, opStatus, opStage, mirror.getId().toString(), mirror.getLabel(), volume.getId().toString());
                } else {
                    AuditBlockUtil.auditBlock(dbClient, opType, opStatus, opStage, mirror.getLabel(), volume.getId().toString());
                }
                break;
            case DEACTIVATE_VOLUME_MIRROR:
            case DELETE_VOLUME_MIRROR:
            case DETACH_VOLUME_MIRROR:
            case FRACTURE_VOLUME_MIRROR:
                AuditBlockUtil.auditBlock(dbClient, opType, opStatus, opStage, mirror.getId().toString(), mirror.getLabel(), volume.getId().toString());
                break;
            default:
                _log.error("unrecognized volume mirror operation type");
        }
    } catch (Exception e) {
        _log.error("Failed to record volume mirror operation {}, err: ", opType.toString(), e);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 29 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class BlockMirrorTaskCompleter method recordBourneBlockMirrorEvent.

public void recordBourneBlockMirrorEvent(DbClient dbClient, URI mirrorUri, String evtType, Operation.Status status, String desc) throws Exception {
    RecordableEventManager eventManager = new RecordableEventManager();
    eventManager.setDbClient(dbClient);
    BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorUri);
    RecordableBourneEvent event = ControllerUtils.convertToRecordableBourneEvent(mirror, evtType, desc, "", dbClient, ControllerUtils.BLOCK_EVENT_SERVICE, RecordType.Event.name(), ControllerUtils.BLOCK_EVENT_SOURCE);
    try {
        eventManager.recordEvents(event);
        _log.info("Bourne {} event recorded", evtType);
    } catch (Exception ex) {
        _log.error("Failed to record event. Event description: {}. Error: ", evtType, ex);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) RecordableEventManager(com.emc.storageos.volumecontroller.impl.monitoring.RecordableEventManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 30 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class HDSMirrorOperations method detachSingleVolumeMirror.

/**
 * 1. Delete ShadowImage Pair
 * 2. Delete DummyLunPath from secondary volume
 */
@Override
public void detachSingleVolumeMirror(StorageSystem storage, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    NamedURI sourceVolumeURI = null;
    try {
        BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
        // TODO needs to sync pair and wait for synchronization here
        Volume source = dbClient.queryObject(Volume.class, mirrorObj.getSource());
        sourceVolumeURI = mirrorObj.getSource();
        boolean status = hdsProtectionOperations.modifyShadowImagePair(storage, source.getNativeId(), mirrorObj.getNativeId(), HDSApiProtectionManager.ShadowImageOperationType.split);
        if (status) {
            String taskId = UUID.randomUUID().toString();
            TaskCompleter completer = new SimpleTaskCompleter(BlockMirror.class, mirror, taskId);
            HDSJob syncjob = new HDSReplicationSyncJob(storage.getId(), source.getNativeId(), mirrorObj.getNativeId(), ReplicationStatus.SPLIT, completer);
            hdsCommandHelper.waitForAsyncHDSJob(syncjob);
        } else {
            log.info("Replication info is not available on pair management server");
        }
        hdsProtectionOperations.deleteShadowImagePair(storage, source, mirrorObj);
        hdsProtectionOperations.removeDummyLunPath(storage, mirror);
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        String errorMsg = String.format(DETACH_ERROR_MSG_FORMAT, mirror, sourceVolumeURI != null ? sourceVolumeURI.toString() : HDSConstants.SPACE_STR);
        log.error(errorMsg, e);
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("detachSingleVolumeMirror", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : HDSReplicationSyncJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Aggregations

BlockMirror (com.emc.storageos.db.client.model.BlockMirror)115 Volume (com.emc.storageos.db.client.model.Volume)77 URI (java.net.URI)49 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)43 ArrayList (java.util.ArrayList)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 NamedURI (com.emc.storageos.db.client.model.NamedURI)29 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)28 CIMObjectPath (javax.cim.CIMObjectPath)26 CIMInstance (javax.cim.CIMInstance)16 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)15 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)15 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)15 CIMArgument (javax.cim.CIMArgument)14 WBEMException (javax.wbem.WBEMException)14 BlockObject (com.emc.storageos.db.client.model.BlockObject)12 StringSet (com.emc.storageos.db.client.model.StringSet)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 ControllerException (com.emc.storageos.volumecontroller.ControllerException)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9