use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisBlockSnapshotSessionCGCreateJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
JobStatus jobStatus = getJobStatus();
CloseableIterator<CIMObjectPath> syncAspectIter = null;
CloseableIterator<CIMObjectPath> settingsStateIter = null;
try {
DbClient dbClient = jobContext.getDbClient();
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
if (jobStatus == JobStatus.SUCCESS) {
log.info("Post-processing successful snapshot session group creation for task ", getTaskCompleter().getOpId());
// Get the snapshot sessions.
Iterator<BlockSnapshotSession> iterator = dbClient.queryIterativeObjects(BlockSnapshotSession.class, getTaskCompleter().getIds(), true);
List<BlockSnapshotSession> snapSessions = Lists.newArrayList(iterator);
// Update Settings instance for the session.
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
syncAspectIter = client.associatorNames(getCimJob(), null, SmisConstants.SYMM_SYNCHRONIZATION_ASPECT_FOR_SOURCE_GROUP, null, null);
if (syncAspectIter.hasNext()) {
CIMObjectPath syncAspectPath = syncAspectIter.next();
String instanceId = syncAspectPath.getKeyValue(Constants.INSTANCEID).toString();
log.info("SynchronizationAspectForSourceGroup instance id is {}", instanceId);
for (BlockSnapshotSession snapSession : snapSessions) {
snapSession.setSessionInstance(instanceId);
}
dbClient.updateObject(snapSessions);
}
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
log.info("Failed to create snapshot session for task ", getTaskCompleter().getOpId());
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error in create snapshot session job status processing: " + e.getMessage());
log.error("Encountered an internal error in create snapshot session job status processing", e);
} finally {
if (syncAspectIter != null) {
syncAspectIter.close();
}
if (settingsStateIter != null) {
settingsStateIter.close();
}
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisBlockSnapshotSessionCreateJob method updateStatus.
/**
* {@inheritDoc}
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
JobStatus jobStatus = getJobStatus();
CloseableIterator<CIMObjectPath> syncAspectIter = null;
CloseableIterator<CIMObjectPath> settingsStateIter = null;
try {
DbClient dbClient = jobContext.getDbClient();
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
if (jobStatus == JobStatus.SUCCESS) {
s_logger.info("Post-processing successful snapshot session creation for task ", getTaskCompleter().getOpId());
// Get the snapshot session.
BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, getTaskCompleter().getId());
// Update Settings instance for the session.
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
syncAspectIter = client.associatorNames(getCimJob(), null, SmisConstants.SYMM_SYNCHRONIZATION_ASPECT_FOR_SOURCE, null, null);
if (syncAspectIter.hasNext()) {
CIMObjectPath syncAspectPath = syncAspectIter.next();
String instanceId = syncAspectPath.getKeyValue(Constants.INSTANCEID).toString();
s_logger.info("SynchronizationAspect instance id is {}", instanceId);
snapSession.setSessionInstance(instanceId);
dbClient.updateObject(snapSession);
}
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
s_logger.info("Failed to create snapshot session for task ", getTaskCompleter().getOpId());
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error in create snapshot session job status processing: " + e.getMessage());
s_logger.error("Encountered an internal error in create snapshot session job status processing", e);
} finally {
if (syncAspectIter != null) {
syncAspectIter.close();
}
if (settingsStateIter != null) {
settingsStateIter.close();
}
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisBlockSnapshotSessionLinkTargetGroupJob method processJobSuccess.
private void processJobSuccess(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
try {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
CIMObjectPath targetRepGrpPath = getAssociatedTargetReplicationGroupPath(client);
log.info("Processing target replication group: {}", targetRepGrpPath);
List<CIMObjectPath> replicaPairViews = getAssociatedReplicaPairViews(client, targetRepGrpPath);
for (CIMObjectPath replicaPairViewPath : replicaPairViews) {
log.info("Processing replica pair view instance: {}", replicaPairViewPath);
CIMInstance replicaPairView = client.getInstance(replicaPairViewPath, false, false, PS_REPLICA_PAIR_VIEW);
// Verify that ReplicaPairView references our groups
String srcGrpInstance = getInstancePropertyValue(replicaPairView, CP_EMC_RG_SOURCE_INSTANCE_ID);
String tgtGrpInstance = getInstancePropertyValue(replicaPairView, CP_EMC_RG_TARGET_INSTANCE_ID);
// ReplicaPairView references src/tgt replication groups as <symm-id>+<group-name>, hence #contains
if (!srcGrpInstance.contains(sourceGroupName) || !tgtGrpInstance.contains(targetGroupName)) {
log.warn("ReplicaPairView did not match source/target groups: {}/{}", sourceGroupName, targetGroupName);
continue;
}
String srcIdProp = (String) replicaPairView.getPropertyValue(CP_SV_SOURCE_DEVICE_ID);
String tgtIdProp = (String) replicaPairView.getPropertyValue(CP_SV_TARGET_DEVICE_ID);
if (srcNativeIdToSnapshotMap.containsKey(srcIdProp)) {
URI blockSnapshotURI = srcNativeIdToSnapshotMap.get(srcIdProp);
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, blockSnapshotURI);
BlockObject sourceObj = BlockObject.fetch(dbClient, snapshot.getParent().getURI());
CIMObjectPath volumePath = getAssociatedTargetVolume(client, replicaPairViewPath, tgtIdProp);
CIMInstance volume = client.getInstance(volumePath, false, false, null);
String volumeElementName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_ELEMENT_NAME);
log.info("volumeElementName: {}", volumeElementName);
String volumeWWN = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_WWN_NAME);
log.info("volumeWWN: {}", volumeWWN);
String volumeAltName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_NAME);
log.info("volumeAltName: {}", volumeAltName);
StorageSystem system = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
snapshot.setNativeId(tgtIdProp);
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(system, snapshot));
snapshot.setDeviceLabel(volumeElementName);
snapshot.setInactive(false);
snapshot.setIsSyncActive(Boolean.TRUE);
snapshot.setCreationTime(Calendar.getInstance());
snapshot.setWWN(volumeWWN.toUpperCase());
snapshot.setAlternateName(volumeAltName);
snapshot.setSettingsInstance(snapSessionInstance);
snapshot.setReplicationGroupInstance(tgtGrpInstance);
commonSnapshotUpdate(snapshot, volume, client, system, sourceObj.getNativeId(), tgtIdProp, false, dbClient);
log.info(String.format("For target volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)", volumePath.toString(), snapshot.getId().toString(), tgtIdProp, volumeElementName, sourceObj.getNativeId(), sourceObj.getDeviceLabel()));
dbClient.updateObject(snapshot);
}
}
} catch (Exception e) {
setPostProcessingErrorStatus("Internal error in link snapshot session target group job status processing: " + e.getMessage());
log.error("Internal error in link snapshot session target group job status processing", e);
throw e;
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisBlockSnapshotSessionUnlinkTargetJob method updateStatus.
/**
* {@inheritDoc}
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
BlockSnapshotSessionUnlinkTargetCompleter completer = (BlockSnapshotSessionUnlinkTargetCompleter) getTaskCompleter();
boolean deleteTarget = completer.getDeleteTarget();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
if (jobStatus == JobStatus.SUCCESS) {
// not be represented by a BlockSnapshot instance in ViPR.
if (!deleteTarget) {
List<BlockSnapshot> allSnapshots = completer.getAllSnapshots(dbClient);
promoteSnapshotsToVolume(allSnapshots, dbClient);
} else {
// TBD - Update capacity of storage pools when deleted?
// SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
s_logger.info("Post-processing successful for unlink snapshot session target for task ", getTaskCompleter().getOpId());
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
s_logger.info("Failed to unlink snapshot session target for task ", getTaskCompleter().getOpId());
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error in unlink snapshot session target job status processing: " + e.getMessage());
s_logger.error("Encountered an internal error in unlink snapshot session target job status processing", e);
} finally {
if (!deleteTarget) {
// We only want to invoke the completer if we are
// not deleting the target after we unlink the target
// from the array snapshot.
super.updateStatus(jobContext);
}
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SmisCloneResyncJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
log.info("START updateStatus for resync clone");
CloseableIterator<CIMObjectPath> iterator = null;
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.SUCCESS) {
CloneResyncCompleter completer = (CloneResyncCompleter) getTaskCompleter();
List<Volume> cloneVolumes = dbClient.queryObject(Volume.class, completer.getIds());
log.info("Clone resync success");
for (Volume clone : cloneVolumes) {
clone.setReplicaState(ReplicationState.RESYNCED.name());
}
dbClient.persistObject(cloneVolumes);
}
} catch (Exception e) {
String errorMsg = String.format("Encountered an internal error during updating resync clone job status " + "processing: %s", e.getMessage());
setPostProcessingErrorStatus(errorMsg);
log.error("Failed to update status for " + getClass().getSimpleName(), e);
} finally {
if (iterator != null) {
iterator.close();
}
super.updateStatus(jobContext);
log.info("FINISH updateStatus for resync clone");
}
}
Aggregations