use of com.emc.storageos.volumecontroller.TaskCompleter in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method resumeSnapshot.
/**
* Routine will call SMI-S ModifyReplicaSynchronization to resume a synchronization instance.
* The operation is a counter-intuitive; it will terminate a RESTORE session between
* target and source. This was the suggestion based on input from SMI-S team.
* See OPT 443785.
*
* @param storage [in] - StorageSystem object representing the array
* @param from [in] - Should be the snapshot object
* @param blockObject [in] - Should be the volume object
* @param syncObject [in] - A CIMObjectPath representing the SMI-S synchronization object tying
* from and blockObject together, along with other related consistency group members
* @param taskCompleter [in] - TaskCompleter used for updating status of operation
* @return true if the resume operation was successfully performed on the synchronization
* @throws WBEMException
*/
private boolean resumeSnapshot(StorageSystem storage, BlockObject from, BlockObject blockObject, CIMObjectPath syncObject, TaskCompleter taskCompleter) throws WBEMException {
boolean wasResumed = false;
SmisBlockResumeSnapshotJob job = new SmisBlockResumeSnapshotJob(null, storage.getId(), new TaskCompleter() {
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
}
});
CIMArgument[] result = new CIMArgument[5];
try {
if (storage.checkIfVmax3()) {
_helper.invokeMethodSynchronously(storage, _cimPath.getControllerReplicationSvcPath(storage), SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, _helper.getEMCResumeInputArguments(syncObject), result, job);
} else if (storage.getUsingSmis80()) {
/**
* VMAX2 managed by 8.* SMIS
* We need to pass Operation = 16
*/
_helper.invokeMethodSynchronously(storage, _cimPath.getControllerReplicationSvcPath(storage), SmisConstants.MODIFY_REPLICA_SYNCHRONIZATION, _helper.getResumeSnapshotSynchronizationInputArguments(syncObject), result, job);
} else {
/**
* VMAX2 managed by 4.6.2 SMI provider
* We need to pass Operation = 14
*/
_helper.invokeMethodSynchronously(storage, _cimPath.getControllerReplicationSvcPath(storage), SmisConstants.MODIFY_REPLICA_SYNCHRONIZATION, _helper.getResumeSynchronizationInputArguments(syncObject), result, job);
}
} catch (Exception e) {
/*
* May be ignored if message is about invalid device state, since when
* dealing with multiple GroupSynchronized instances, we attempt to resume
* all of them.
*/
_log.info("Encountered exception which may be ignored: {}", e.getMessage());
}
if (job.isSuccess()) {
_log.info("Synchronization was successfully resumed: {}", syncObject);
wasResumed = true;
} else {
_log.info("Synchronization was not resumed and can be ignored: {}", syncObject);
}
return wasResumed;
}
use of com.emc.storageos.volumecontroller.TaskCompleter in project coprhd-controller by CoprHD.
the class VNXeMaskingOrchestrator method exportGroupDelete.
@Override
public void exportGroupDelete(URI storageURI, URI exportGroupURI, String token) throws Exception {
try {
_log.info(String.format("exportGroupDelete start - Array: %s ExportMask: %s", storageURI.toString(), exportGroupURI.toString()));
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
TaskCompleter taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
if (exportGroup == null || exportGroup.getInactive() || ExportMaskUtils.getExportMasks(_dbClient, exportGroup, storageURI).isEmpty()) {
taskCompleter.ready(_dbClient);
return;
}
/**
* If no export mask is found, nothing to be done. Task will be marked
* complete by the last real export mask delete completion.
*/
List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup, storageURI);
Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupDelete", true, token);
String deleteStep = null;
for (ExportMask exportMask : exportMasks) {
refreshExportMask(storage, getDevice(), exportMask);
deleteStep = generateExportMaskDeleteWorkflow(workflow, deleteStep, storage, exportGroup, exportMask, null, null, null);
}
generateZoningDeleteWorkflow(workflow, deleteStep, exportGroup, exportMasks);
String successMessage = String.format("Export was successfully removed from StorageArray %s", storage.getLabel());
workflow.executePlan(taskCompleter, successMessage);
_log.info(String.format("exportGroupDelete end - Array: %s ExportMask: %s", storageURI.toString(), exportGroupURI.toString()));
} catch (Exception e) {
throw DeviceControllerException.exceptions.exportGroupDeleteFailed(e);
}
}
use of com.emc.storageos.volumecontroller.TaskCompleter in project coprhd-controller by CoprHD.
the class SmisBlockSnapshotSessionLinkTargetJob method updateStatus.
/**
* {@inheritDoc}
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
JobStatus jobStatus = getJobStatus();
CloseableIterator<CIMObjectPath> volumeIter = null;
try {
DbClient dbClient = jobContext.getDbClient();
TaskCompleter completer = getTaskCompleter();
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, _snapshotURI);
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
if (jobStatus == JobStatus.SUCCESS) {
s_logger.info("Post-processing successful link snapshot session target {} for task {}", snapshot.getId(), completer.getOpId());
// Get the snapshot session to which the target is being linked.
BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, completer.getId());
// Get the snapshot device ID and set it against the BlockSnapshot object.
BlockObject sourceObj = BlockObject.fetch(dbClient, snapshot.getParent().getURI());
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
volumeIter = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
while (volumeIter.hasNext()) {
// Get the sync volume native device id
CIMObjectPath volumePath = volumeIter.next();
s_logger.info("volumePath: {}", volumePath.toString());
CIMInstance volume = client.getInstance(volumePath, false, false, null);
String volumeDeviceId = volumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
s_logger.info("volumeDeviceId: {}", volumeDeviceId);
if (volumeDeviceId.equals(sourceObj.getNativeId())) {
// Don't want the source, we want the linked target.
continue;
}
String volumeElementName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_ELEMENT_NAME);
s_logger.info("volumeElementName: {}", volumeElementName);
String volumeWWN = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_WWN_NAME);
s_logger.info("volumeWWN: {}", volumeWWN);
String volumeAltName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_NAME);
s_logger.info("volumeAltName: {}", volumeAltName);
StorageSystem system = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
snapshot.setNativeId(volumeDeviceId);
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(snapSession.getSessionInstance());
commonSnapshotUpdate(snapshot, volume, client, system, sourceObj.getNativeId(), volumeDeviceId, false, dbClient);
s_logger.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(), volumeDeviceId, volumeElementName, sourceObj.getNativeId(), sourceObj.getDeviceLabel()));
dbClient.updateObject(snapshot);
}
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
s_logger.info("Failed to link snapshot session target {} for task {}", snapshot.getId(), completer.getOpId());
snapshot.setInactive(true);
dbClient.updateObject(snapshot);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error in link snapshot session target job status processing: " + e.getMessage());
s_logger.error("Encountered an internal error in link snapshot session target job status processing", e);
} finally {
if (volumeIter != null) {
volumeIter.close();
}
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.volumecontroller.TaskCompleter in project coprhd-controller by CoprHD.
the class SmisWaitForGroupSynchronizedJob method poll.
@Override
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
JobPollResult pollResult = new JobPollResult();
DbClient dbClient = jobContext.getDbClient();
CIMConnectionFactory factory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, factory);
TaskCompleter completer = getTaskCompleter();
List<Volume> clones = dbClient.queryObject(Volume.class, completer.getIds());
try {
pollResult.setJobName(getJobName());
pollResult.setJobId(SmisConstants.CP_PERCENT_SYNCED);
pollResult.setJobStatus(JobStatus.IN_PROGRESS);
CIMObjectPath path = getGroupSyncPath();
// no corresponding sync obj, set to complete
if (SmisConstants.NULL_IBM_CIM_OBJECT_PATH.equals(path)) {
log.info("Sync complete");
pollResult.setJobPercentComplete(100);
pollResult.setJobStatus(JobStatus.SUCCESS);
completer.ready(dbClient);
return pollResult;
}
String[] propertyKeys = { SmisConstants.CP_SYNC_STATE, SmisConstants.CP_SYNC_TYPE, SmisConstants.CP_PERCENT_SYNCED, SmisConstants.CP_PROGRESS_STATUS };
CIMInstance syncInstance = client.getInstance(path, false, false, propertyKeys);
if (syncInstance != null) {
String state = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_SYNC_STATE);
String type = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_SYNC_TYPE);
String percent = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_PERCENT_SYNCED);
String status = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_PROGRESS_STATUS);
String msg = String.format("Target=%s, State=%s, Type=%s, Percent=%s, Status=%s", clones.get(0).getId(), state, type, percent, status);
log.info(msg);
pollResult.setJobPercentComplete(Integer.parseInt(percent));
if (COMPLETE.equals(percent)) {
pollResult.setJobStatus(JobStatus.SUCCESS);
completer.ready(dbClient);
}
} else {
pollResult.setJobStatus(JobStatus.FAILED);
}
} catch (Exception e) {
log.error("Failed to update synchronization", e);
pollResult.setJobStatus(JobStatus.FAILED);
completer.error(dbClient, DeviceControllerException.errors.jobFailed(e));
}
return pollResult;
}
use of com.emc.storageos.volumecontroller.TaskCompleter in project coprhd-controller by CoprHD.
the class SmisWaitForSynchronizedJob method poll.
@Override
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
JobPollResult pollResult = new JobPollResult();
DbClient dbClient = jobContext.getDbClient();
CIMConnectionFactory factory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, factory);
TaskCompleter completer = getTaskCompleter();
BlockObject target = dbClient.queryObject(clazz, completer.getId());
CloseableIterator<CIMInstance> references = null;
try {
pollResult.setJobName(getJobName());
pollResult.setJobId(SmisConstants.CP_PERCENT_SYNCED);
pollResult.setJobStatus(JobStatus.IN_PROGRESS);
CIMObjectPath path = getTargetPath();
// no corresponding sync obj, set to complete
if (SmisConstants.NULL_IBM_CIM_OBJECT_PATH.equals(path)) {
log.info("Sync complete");
pollResult.setJobPercentComplete(100);
pollResult.setJobStatus(JobStatus.SUCCESS);
completer.ready(dbClient);
return pollResult;
}
references = client.referenceInstances(getTargetPath(), SmisConstants.CIM_STORAGE_SYNCHRONIZED, null, false, null);
if (references.hasNext()) {
CIMInstance syncInstance = references.next();
String state = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_SYNC_STATE);
String type = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_SYNC_TYPE);
String percent = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_PERCENT_SYNCED);
String status = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_PROGRESS_STATUS);
String msg = String.format("Target=%s, State=%s, Type=%s, Percent=%s, Status=%s", target.getId(), state, type, percent, status);
log.info(msg);
pollResult.setJobPercentComplete(Integer.parseInt(percent));
if (COMPLETE.equals(percent)) {
pollResult.setJobStatus(JobStatus.SUCCESS);
completer.ready(dbClient);
}
} else {
pollResult.setJobStatus(JobStatus.FAILED);
}
} catch (Exception e) {
log.error("Failed to update synchronization", e);
pollResult.setJobStatus(JobStatus.FAILED);
completer.error(dbClient, DeviceControllerException.errors.jobFailed(e));
} finally {
if (references != null) {
references.close();
}
}
return pollResult;
}
Aggregations