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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations