use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisBlockCreateCGMirrorJob method updateStatus.
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMInstance> syncVolumeIter = null;
CloseableIterator<CIMObjectPath> repGroupPathIter = null;
DbClient dbClient = jobContext.getDbClient();
BlockMirrorCreateCompleter completer = (BlockMirrorCreateCompleter) getTaskCompleter();
;
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
List<BlockMirror> mirrors = dbClient.queryObject(BlockMirror.class, completer.getIds());
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
updatePools(client, dbClient, mirrors);
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Group mirror creation success");
repGroupPathIter = client.associatorNames(getCimJob(), null, SmisConstants.SE_REPLICATION_GROUP, null, null);
CIMObjectPath repGroupPath = repGroupPathIter.next();
StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
String repGroupID = (String) repGroupPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue();
repGroupID = SmisUtils.getTargetGroupName(repGroupID, storage.getUsingSmis80());
CIMInstance syncInst = getSynchronizedInstance(client, repGroupPath);
String syncType = CIMPropertyFactory.getPropertyValue(syncInst, SmisConstants.CP_SYNC_TYPE);
syncVolumeIter = client.associatorInstances(repGroupPath, null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
processCGMirrors(syncVolumeIter, client, dbClient, jobContext.getSmisCommandHelper(), storage, mirrors, repGroupID, syncInst.getObjectPath().toString(), syncType);
} else if (isJobInTerminalFailedState()) {
_log.info("Failed to create group mirrors");
completer.error(dbClient, DeviceControllerException.exceptions.attachVolumeMirrorFailed(getMessage()));
for (BlockMirror mirror : mirrors) {
mirror.setInactive(true);
}
dbClient.persistObject(mirrors);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error during block create CG mirror job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockCreateCGMirrorJob", e);
} finally {
if (syncVolumeIter != null) {
syncVolumeIter.close();
}
if (repGroupPathIter != null) {
repGroupPathIter.close();
}
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisBlockCreateSnapshotJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMObjectPath> syncVolumeIter = null;
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
BlockSnapshotCreateCompleter completer = (BlockSnapshotCreateCompleter) getTaskCompleter();
List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, completer.getSnapshotURIs());
StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
if (jobStatus == JobStatus.SUCCESS) {
_log.info(String.format("Post-processing successful snap creation task:%s. Expected: snapshot.size() = 1; Actual: snapshots.size() = %d", getTaskCompleter().getOpId(), snapshots.size()));
// Get the snapshot device ID and set it against the BlockSnapshot object
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
syncVolumeIter = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
if (syncVolumeIter.hasNext()) {
// Get the sync volume native device id
CIMObjectPath syncVolumePath = syncVolumeIter.next();
CIMInstance syncVolume = client.getInstance(syncVolumePath, false, false, null);
String syncDeviceID = syncVolumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
String elementName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_ELEMENT_NAME);
String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_WWN_NAME);
String alternateName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_NAME);
// Lookup the associated snapshot based on the volume native device id
BlockSnapshot snapshot = snapshots.get(0);
Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
snapshot.setNativeId(syncDeviceID);
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, snapshot));
snapshot.setDeviceLabel(elementName);
snapshot.setInactive(false);
snapshot.setIsSyncActive(_wantSyncActive);
snapshot.setCreationTime(Calendar.getInstance());
snapshot.setWWN(wwn.toUpperCase());
snapshot.setAlternateName(alternateName);
commonSnapshotUpdate(snapshot, syncVolume, client, storage, volume.getNativeId(), syncDeviceID, true, dbClient);
_log.info(String.format("For sync volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)", syncVolumePath.toString(), snapshot.getId().toString(), syncDeviceID, elementName, volume.getNativeId(), volume.getDeviceLabel()));
dbClient.persistObject(snapshot);
}
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to create snapshot");
BlockSnapshot snapshot = snapshots.get(0);
snapshot.setInactive(true);
dbClient.persistObject(snapshot);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error during block create snapshot job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockCreateSnapshotJob", e);
} finally {
if (syncVolumeIter != null) {
syncVolumeIter.close();
}
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisBlockDeleteMirrorJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
BlockMirrorDeleteCompleter completer = (BlockMirrorDeleteCompleter) getTaskCompleter();
BlockMirror mirror = dbClient.queryObject(BlockMirror.class, completer.getMirrorURI());
// If terminal state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
URI poolURI = mirror.getPool();
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Mirror delete success");
Volume volume = dbClient.queryObject(Volume.class, mirror.getSource().getURI());
dbClient.markForDeletion(mirror);
_log.info(String.format("Deleted BlockMirror %s on Volume %s", mirror, volume));
} else if (jobStatus == JobStatus.FATAL_ERROR || jobStatus == JobStatus.FAILED) {
String msg = String.format("Failed to delete mirror %s", mirror.getId());
_log.error(msg);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(msg));
}
} catch (Exception e) {
setFatalErrorStatus("Encountered an internal error during block delete mirror job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteMirrorJob", e);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(e.getMessage()));
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisBlockDetachCloneJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
_log.info("START updateStatus for clone detach");
JobStatus jobStatus = getJobStatus();
super.updateStatus(jobContext);
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
DbClient dbClient = jobContext.getDbClient();
VolumeDetachCloneCompleter taskCompleter = (VolumeDetachCloneCompleter) getTaskCompleter();
Volume cloneVolume = dbClient.queryObject(Volume.class, taskCompleter.getId());
Operation.Status op = Operation.Status.pending;
String message = "Detaching volume clone";
if (jobStatus == JobStatus.SUCCESS) {
op = Operation.Status.ready;
message = "Successfully detached volume clone";
} else if (jobStatus == JobStatus.ERROR || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
op = Operation.Status.error;
message = "Failed to detached volume clone";
}
// set to terminal status to stop polling job
if (jobStatus == JobStatus.ERROR) {
setFatalErrorStatus(message);
}
dbClient.updateTaskOpStatus(Volume.class, cloneVolume.getId(), taskCompleter.getOpId(), new Operation(op.name(), message));
WorkflowStepCompleter.updateState(taskCompleter.getOpId(), op, message);
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisBlockResumeMirrorJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
log.info("START updateStatus for resuming {}", getTaskCompleter().getId());
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
BlockMirrorResumeCompleter taskCompleter = (BlockMirrorResumeCompleter) getTaskCompleter();
if (jobStatus == JobStatus.SUCCESS) {
log.info("Mirror resume success");
BlockMirror mirror = dbClient.queryObject(BlockMirror.class, taskCompleter.getMirrorURI());
log.info("Updating sync details for mirror {}", mirror.getId());
WBEMClient client = getWBEMClient(dbClient, jobContext.getCimConnectionFactory());
updateSynchronizationAspects(client, mirror);
dbClient.persistObject(mirror);
getTaskCompleter().ready(dbClient);
} else if (jobStatus == JobStatus.ERROR) {
log.info("Mirror resume failed");
}
} catch (Exception e) {
String errorMsg = "Failed job to resume mirror: " + e.getMessage();
log.error(errorMsg, e);
setPostProcessingErrorStatus(errorMsg);
} finally {
super.updateStatus(jobContext);
log.info("FINISH updateStatus for resuming {}", getTaskCompleter().getId());
}
}
Aggregations