use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter 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.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.
the class HDSProtectionOperations method createSecondaryVolumeForSnapshot.
/**
* Creates Snapshot Volume
*
* @param storageSystem
* @param sourceVolume
* @param snapshotObj
* @throws Exception
*/
public void createSecondaryVolumeForSnapshot(StorageSystem storageSystem, Volume sourceVolume, BlockSnapshot snapshotObj) throws Exception {
log.info("SecondaryVolume for snapshot creation operation started");
String taskId = UUID.randomUUID().toString();
TaskCompleter taskCompleter = new BlockSnapshotCreateCompleter(Arrays.asList(snapshotObj.getId()), taskId);
String asyncTaskMessageId = null;
HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
asyncTaskMessageId = hdsApiClient.createSnapshotVolume(systemObjectID, sourceVolume.getCapacity(), storageSystem.getModel());
if (asyncTaskMessageId != null) {
HDSJob createHDSJob = new HDSBlockCreateSnapshotJob(asyncTaskMessageId, snapshotObj.getStorageController(), taskCompleter);
hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create snapshot volume call");
}
log.info("SecondaryVolume for snapshot creation operation completed successfully");
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.
the class VNXeBlockSnapshotCreateJob method updateStatus.
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
try {
if (_status == JobStatus.IN_PROGRESS) {
return;
}
BlockSnapshotCreateCompleter completer = (BlockSnapshotCreateCompleter) getTaskCompleter();
List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, completer.getSnapshotURIs());
if (_status == JobStatus.SUCCESS) {
_logger.info(String.format("Post-processing successful snap creation task:%s. Expected: snapshot.size() = 1; Actual: snapshots.size() = %d", getTaskCompleter().getOpId(), snapshots.size()));
StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemUri());
VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
VNXeCommandJob vnxeJob = vnxeApiClient.getJob(getJobIds().get(0));
ParametersOut output = vnxeJob.getParametersOut();
BlockSnapshot snapshot = snapshots.get(0);
Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
snapshot.setNativeId(output.getId());
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, snapshot));
snapshot.setIsSyncActive(true);
snapshot.setInactive(false);
snapshot.setCreationTime(Calendar.getInstance());
if (vnxeApiClient.isUnityClient()) {
Snap snap = vnxeApiClient.getSnapshot(output.getId());
snapshot.setDeviceLabel(snap.getName());
snapshot.setAllocatedCapacity(snap.getSize());
snapshot.setProvisionedCapacity(snap.getSize());
} else {
VNXeLunSnap vnxeLunSnap = vnxeApiClient.getLunSnapshot(output.getId());
VNXeLun lun = vnxeApiClient.getLun(vnxeLunSnap.getLun().getId());
snapshot.setDeviceLabel(vnxeLunSnap.getName());
snapshot.setAllocatedCapacity(lun.getSnapsSizeAllocated());
snapshot.setProvisionedCapacity(lun.getSnapsSize());
}
_logger.info(String.format("Going to set blocksnapshot %1$s nativeId to %2$s. Associated volume is %3$s (%4$s)", snapshot.getId().toString(), output.getId(), volume.getNativeId(), volume.getLabel()));
dbClient.updateObject(snapshot);
getTaskCompleter().ready(dbClient);
} else if (_status == JobStatus.FAILED) {
_logger.info("Failed to create snapshot");
BlockSnapshot snapshot = snapshots.get(0);
snapshot.setInactive(true);
dbClient.updateObject(snapshot);
}
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXeBlockSnapshotCreateJob", e);
setErrorStatus("Encountered an internal error during volume snapshot create job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testCreateSnapshot.
@Test
public void testCreateSnapshot() {
Boolean createInactive = false;
List<BlockSnapshot> snapshots = createSnapshots();
List<URI> snapshotList = new ArrayList<URI>();
for (BlockSnapshot snapshot : snapshots) {
snapshotList.add(snapshot.getId());
break;
}
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
TaskCompleter taskCompleter = new BlockSnapshotCreateCompleter(snapshotList, token);
_deviceController.doCreateSnapshot(_storageSystem, snapshotList, createInactive, false, taskCompleter);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method createSnapshot.
@Override
public void createSnapshot(URI storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, String opId) throws ControllerException {
TaskCompleter completer = null;
try {
boolean isListReplicaFlow = false;
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshotList.get(0));
Volume sourceVolumeObj = _dbClient.queryObject(Volume.class, snapshotObj.getParent().getURI());
URI cgURI = null;
completer = new BlockSnapshotCreateCompleter(snapshotList, opId);
/**
* VPLEX/RP CG volumes may not be having back end Array Group.
* In this case we should create element replica using createListReplica.
* We should not use createGroup replica as backend cg will not be available in this case.
*/
boolean isVnxVolume = ControllerUtils.isVnxVolume(sourceVolumeObj, _dbClient);
// VNX doesn't support list replica for snapshot
isListReplicaFlow = !isVnxVolume && isListReplicaFlow(sourceVolumeObj);
if (!isListReplicaFlow) {
getDevice(storageObj.getSystemType()).doCreateSnapshot(storageObj, snapshotList, createInactive, readOnly, completer);
} else {
// List Replica
completer.addConsistencyGroupId(cgURI);
getDevice(storageObj.getSystemType()).doCreateListReplica(storageObj, snapshotList, createInactive, completer);
}
} catch (Exception e) {
if (completer != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.createVolumeSnapshotFailed(e);
}
}
}
Aggregations