use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class BlockSnapshotRestoreCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
try {
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, getId());
Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
if (_updateAndRecordOp) {
if (snapshot.getConsistencyGroup() != null) {
// For snapshot based on a consistency group, set status and send
// events for all related snaps
List<BlockSnapshot> snaps = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, dbClient);
for (BlockSnapshot snap : snaps) {
URI uri = snap.getId();
BlockSnapshot it = dbClient.queryObject(BlockSnapshot.class, uri);
switch(status) {
case error:
dbClient.error(BlockSnapshot.class, uri, getOpId(), coded);
break;
default:
dbClient.ready(BlockSnapshot.class, uri, getOpId());
}
recordBlockSnapshotOperation(dbClient, OperationTypeEnum.RESTORE_VOLUME_SNAPSHOT, status, eventMessage(status, volume, it), it, volume);
_log.info(String.format("Completed CG snapshot restore of snap %s (%s), with status %s", it.getLabel(), uri.toString(), status.name()));
}
} else {
switch(status) {
case error:
dbClient.error(BlockSnapshot.class, getId(), getOpId(), coded);
break;
default:
dbClient.ready(BlockSnapshot.class, getId(), getOpId());
}
recordBlockSnapshotOperation(dbClient, OperationTypeEnum.RESTORE_VOLUME_SNAPSHOT, status, eventMessage(status, volume, snapshot), snapshot, volume);
}
}
_log.info("Done SnapshotRestore {}, with Status: {}", getOpId(), status.name());
super.complete(dbClient, status, coded);
} catch (Exception e) {
_log.error("Failed updating status. SnapshotRestore {}, for task " + getOpId(), getId(), e);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class BlockSnapshotResyncCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
try {
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, getId());
Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
if (_updateAndRecordOp) {
if (snapshot.getConsistencyGroup() != null) {
// For snapshot based on a consistency group, set status and send
// events for all related snaps
List<BlockSnapshot> snaps = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, dbClient);
for (BlockSnapshot snap : snaps) {
URI uri = snap.getId();
BlockSnapshot it = dbClient.queryObject(BlockSnapshot.class, uri);
switch(status) {
case error:
dbClient.error(BlockSnapshot.class, uri, getOpId(), coded);
break;
default:
dbClient.ready(BlockSnapshot.class, uri, getOpId());
}
recordBlockSnapshotOperation(dbClient, OperationTypeEnum.RESYNCHRONIZE_VOLUME_SNAPSHOT, status, eventMessage(status, volume, it), it, volume);
_log.info(String.format("Completed CG snapshot resynchronization of snap %s (%s), with status %s", it.getLabel(), uri.toString(), status.name()));
}
} else {
switch(status) {
case error:
dbClient.error(BlockSnapshot.class, getId(), getOpId(), coded);
break;
default:
dbClient.ready(BlockSnapshot.class, getId(), getOpId());
}
recordBlockSnapshotOperation(dbClient, OperationTypeEnum.RESYNCHRONIZE_VOLUME_SNAPSHOT, status, eventMessage(status, volume, snapshot), snapshot, volume);
}
}
_log.info("Done Resync Snapshot {}, with Status: {}", getOpId(), status.name());
super.complete(dbClient, status, coded);
} catch (Exception e) {
_log.error("Failed updating status. SnapshotResync {}, for task " + getOpId(), getId(), e);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class BlockSnapshotSessionCreateCompleter method complete.
/**
* {@inheritDoc}
*/
@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
try {
BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, getId());
// Update the status map of the snapshot session.
switch(status) {
case error:
// Mark any linked targets inactive. This would not
// normally case when failing to create a snapshot
// session as targets are not linked when a new
// snapshot session is prepared in ViPR. However,
// it could be the case when restoring a source volume
// form a linked target.
StringSet linkedTargets = snapSession.getLinkedTargets();
if ((linkedTargets != null) && (!linkedTargets.isEmpty())) {
for (String linkedTarget : linkedTargets) {
BlockSnapshot target = dbClient.queryObject(BlockSnapshot.class, URI.create(linkedTarget));
if (target != null) {
target.setInactive(true);
dbClient.updateObject(target);
}
}
}
// Mark ViPR snapshot session inactive on error.
snapSession.setInactive(true);
dbClient.updateObject(snapSession);
break;
case ready:
break;
default:
String errMsg = String.format("Unexpected status %s for completer for step %s", status.name(), getOpId());
s_logger.info(errMsg);
throw DeviceControllerException.exceptions.unexpectedCondition(errMsg);
}
s_logger.info("Done snapshot session create step {} with status: {}", getOpId(), status.name());
} catch (Exception e) {
s_logger.error("Failed updating status for snapshot session create step {}", getOpId(), e);
} finally {
super.complete(dbClient, status, coded);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class BlockSnapshotSessionDeleteWorkflowCompleter method complete.
/**
* {@inheritDoc}
*/
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
URI snapSessionURI = getId();
try {
BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
List<BlockObject> allSources = getAllSources(snapSession, dbClient);
BlockObject sourceObj = allSources.get(0);
// Record the results.
recordBlockSnapshotSessionOperation(dbClient, OperationTypeEnum.DELETE_SNAPSHOT_SESSION, status, snapSession, sourceObj);
// Update the status map of the snapshot session.
switch(status) {
case error:
setErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
break;
case suspended_error:
setSuspendedErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
break;
case suspended_no_error:
setSuspendedNoErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
break;
case ready:
setReadyOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
// Mark snapshot session inactive.
snapSession.setInactive(true);
dbClient.updateObject(snapSession);
break;
default:
String errMsg = String.format("Unexpected status %s for completer for task %s", status.name(), getOpId());
s_logger.info(errMsg);
throw DeviceControllerException.exceptions.unexpectedCondition(errMsg);
}
s_logger.info("Done delete snapshot session task {} with status: {}", getOpId(), status.name());
} catch (Exception e) {
s_logger.error("Failed updating status for delete snapshot session task {}", getOpId(), e);
} finally {
super.complete(dbClient, status, coded);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException 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