use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.
the class RPDeviceController method constructSnapshotObjectFromBookmark.
/**
* Amend the BlockSnapshot object based on the results of the Bookmark creation operation
*
* @param result
* result from the snapshot creation command
* @param system
* protection system
* @param snapshotList
* snapshot list generated
* @param name
* emName
* @param opId
* operation ID for task completer
* @throws InternalException
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
*/
private void constructSnapshotObjectFromBookmark(CreateBookmarkResponse response, ProtectionSystem system, List<URI> snapshotList, String name, String opId) throws InternalException {
ProtectionSet protectionSet = null;
RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
// Update each snapshot object with the respective information.
for (URI snapshotID : snapshotList) {
// Get the snapshot and the associated volume
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
// Fetch the VPLEX volume that is created with this volume as the back-end volume.
if (Volume.checkForVplexBackEndVolume(_dbClient, volume)) {
volume = Volume.fetchVplexVolume(_dbClient, volume);
}
if (protectionSet == null || !protectionSet.getId().equals(volume.getProtectionSet().getURI())) {
protectionSet = _dbClient.queryObject(ProtectionSet.class, volume.getProtectionSet());
}
// Gather the bookmark date, which is different than the snapshot date
Date bookmarkDate = new Date();
if (response.getVolumeWWNBookmarkDateMap() != null) {
bookmarkDate = response.getVolumeWWNBookmarkDateMap().get(RPHelper.getRPWWn(volume.getId(), _dbClient));
} else {
_log.warn("Bookmark date was not filled-in. Will use current date/time.");
}
snapshot.setEmName(name);
snapshot.setInactive(false);
snapshot.setEmBookmarkTime("" + bookmarkDate.getTime());
snapshot.setCreationTime(Calendar.getInstance());
snapshot.setTechnologyType(TechnologyType.RP.toString());
Volume targetVolume = RPHelper.getRPTargetVolumeFromSource(_dbClient, volume, snapshot.getVirtualArray());
// This section will identify and store the COPY ID associated with the bookmarks created.
// It is critical to store this information so we can later determine which bookmarks have
// been deleted from the RPA.
//
// May be able to remove this if the protection set object is more detailed (for instance, if
// we store the copy id with the volume)
RecoverPointVolumeProtectionInfo protectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(targetVolume.getId(), _dbClient));
for (RPConsistencyGroup rpcg : response.getCgBookmarkMap().keySet()) {
if (rpcg.getCGUID().getId() == protectionInfo.getRpVolumeGroupID()) {
for (RPBookmark bookmark : response.getCgBookmarkMap().get(rpcg)) {
if (bookmark.getBookmarkName() != null && bookmark.getBookmarkName().equalsIgnoreCase(name) && bookmark.getCGGroupCopyUID().getGlobalCopyUID().getCopyUID() == protectionInfo.getRpVolumeGroupCopyID()) {
snapshot.setEmCGGroupCopyId(protectionInfo.getRpVolumeGroupCopyID());
break;
}
}
}
}
if (targetVolume.getId().equals(volume.getId())) {
_log.error("The source and the target volumes are the same");
throw DeviceControllerExceptions.recoverpoint.cannotActivateSnapshotNoTargetVolume();
}
snapshot.setDeviceLabel(targetVolume.getDeviceLabel());
snapshot.setStorageController(targetVolume.getStorageController());
snapshot.setSystemType(targetVolume.getSystemType());
snapshot.setVirtualArray(targetVolume.getVirtualArray());
snapshot.setNativeId(targetVolume.getNativeId());
snapshot.setAlternateName(targetVolume.getAlternateName());
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(system, snapshot));
snapshot.setIsSyncActive(false);
// Setting the WWN of the bookmark to the WWN of the volume, no functional reason for now.
snapshot.setWWN(RPHelper.getRPWWn(targetVolume.getId(), _dbClient));
snapshot.setProtectionController(system.getId());
snapshot.setProtectionSet(volume.getProtectionSet().getURI());
_log.info(String.format("Updated bookmark %1$s associated with block volume %2$s on site %3$s.", name, volume.getDeviceLabel(), snapshot.getEmInternalSiteName()));
_dbClient.updateObject(snapshot);
List<URI> taskSnapshotURIList = new ArrayList<URI>();
taskSnapshotURIList.add(snapshot.getId());
TaskCompleter completer = new BlockSnapshotCreateCompleter(taskSnapshotURIList, opId);
completer.ready(_dbClient);
}
// Get information about the bookmarks created so we can get to them later.
_log.info("Bookmark(s) created for snapshot operation");
return;
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.
the class RPDeviceController method createSnapshot.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.protectioncontroller.RPController#createSnapshot(java.net.URI, java.net.URI, java.util.List,
* java.lang.Boolean, java.lang.Boolean, java.lang.String)
*/
@Override
public void createSnapshot(URI protectionDevice, URI storageURI, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, String opId) throws InternalException {
TaskCompleter completer = new BlockSnapshotCreateCompleter(snapshotList, opId);
// if snapshot is part of a CG, add CG id to the completer
List<BlockSnapshot> snapshots = _dbClient.queryObject(BlockSnapshot.class, snapshotList);
ControllerUtils.checkSnapshotsInConsistencyGroup(snapshots, _dbClient, completer);
Map<URI, Integer> snapshotMap = new HashMap<URI, Integer>();
try {
ProtectionSystem system = null;
system = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
// Verify non-null storage device returned from the database client.
if (system == null) {
throw DeviceControllerExceptions.recoverpoint.failedConnectingForMonitoring(protectionDevice);
}
// Make sure we have at least 1 snap/bookmark otherwise there is nothing to create
if (snapshotList == null || snapshotList.isEmpty()) {
throw DeviceControllerExceptions.recoverpoint.failedToFindExpectedBookmarks();
}
// A temporary date/time stamp
String snapshotName = VIPR_SNAPSHOT_PREFIX + new SimpleDateFormat("yyMMdd-HHmmss").format(new java.util.Date());
Set<String> volumeWWNs = new HashSet<String>();
boolean rpBookmarkOnly = false;
for (URI snapshotID : snapshotList) {
// create a snapshot map, a map is required to re-use the existing enable image access method.
// using a lun number of -1 for all snaps, this value is not used, hence ok to use that value.
snapshotMap.put(snapshotID, ExportGroup.LUN_UNASSIGNED);
}
// Get the volume associated with this snapshot.
// Note we could have multiple snapshots in this request depending on the number of targets for the
// source. We only need 1 of the snapshots to create the bookmark on RP. So just grab the
// first one in the list.
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotList.get(0));
if (snapshot.getEmName() != null) {
rpBookmarkOnly = true;
snapshotName = snapshot.getEmName();
}
Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
// if not, then the "volume" object is a regular block volume that is RP protected.
if (Volume.checkForVplexBackEndVolume(_dbClient, volume)) {
volumeWWNs.add(RPHelper.getRPWWn(Volume.fetchVplexVolume(_dbClient, volume).getId(), _dbClient));
} else {
volumeWWNs.add(RPHelper.getRPWWn(volume.getId(), _dbClient));
}
// Create a new token/taskid and use that in the workflow.
// Multiple threads entering this method might collide with each others workflows in cassandra if the taskid
// is not unique.
String newToken = UUID.randomUUID().toString();
// Set up workflow steps.
Workflow workflow = _workflowService.getNewWorkflow(this, "createSnapshot", true, newToken);
// Step 1 - Create a RP bookmark
String waitFor = addCreateBookmarkStep(workflow, snapshotList, system, snapshotName, volumeWWNs, rpBookmarkOnly, null);
if (!rpBookmarkOnly) {
// Local array snap, additional steps required for snap operation
// Step 2 - Enable image access
waitFor = addEnableImageAccessStep(workflow, system, snapshotMap, waitFor);
// Step 3 - Invoke block storage doCreateSnapshot
waitFor = addCreateBlockSnapshotStep(workflow, waitFor, storageURI, snapshotList, createInactive, readOnly, system);
// Step 4 - Disable image access
addBlockSnapshotDisableImageAccessStep(workflow, waitFor, snapshotList, system);
} else {
_log.info("RP Bookmark only requested...");
}
String successMessage = String.format("Successfully created snapshot for %s", Joiner.on(",").join(snapshotList));
workflow.executePlan(completer, successMessage);
} catch (InternalException e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, e);
}
} catch (Exception e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, DeviceControllerException.errors.jobFailed(e));
}
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method createSingleSnapshot.
@Override
public void createSingleSnapshot(URI storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, String opId) throws ControllerException {
WorkflowStepCompleter.stepExecuting(opId);
TaskCompleter completer = null;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
completer = new BlockSnapshotCreateCompleter(snapshotList, opId);
getDevice(storageObj.getSystemType()).doCreateSingleSnapshot(storageObj, snapshotList, createInactive, readOnly, completer);
} catch (Exception e) {
if (completer != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
completer.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.createVolumeSnapshotFailed(e);
}
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method createListSnapshot.
public void createListSnapshot(URI storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, String opId) throws ControllerException {
WorkflowStepCompleter.stepExecuting(opId);
TaskCompleter completer = null;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
completer = new BlockSnapshotCreateCompleter(snapshotList, opId);
getDevice(storageObj.getSystemType()).doCreateListReplica(storageObj, snapshotList, createInactive, completer);
} catch (Exception e) {
if (completer != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
completer.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.createVolumeSnapshotFailed(e);
}
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.
the class VnxSnapshotOperations method createGroupSnapshots.
/**
* Should implement create of a snapshot from a source volume that is part of a
* consistency group.
*
* @param storage [required] - StorageSystem object representing the array
* @param snapshot [required] - BlockSnapshot URI representing the previously created
* snap for the volume
* @param createInactive - Indicates if the snapshots should be created but not
* activated
* @param readOnly - Indicates if the snapshot should be read only.
* @param taskCompleter - TaskCompleter object used for the updating operation status.
* @throws DeviceControllerException
*/
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
URI snapshot = snapshotList.get(0);
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
if (ControllerUtils.isNotInRealVNXRG(volume, _dbClient)) {
throw DeviceControllerException.exceptions.groupSnapshotNotSupported(volume.getReplicationGroupInstance());
}
// CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, snapshotObj, _dbClient, _helper, _cimPath);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
String tenantName = tenant.getLabel();
String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, _dbClient);
CIMObjectPath cgPath = _cimPath.getReplicationGroupPath(storage, groupName);
CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
CIMArgument[] inArgs = _helper.getCreateGroupReplicaInputArgumentsForVNX(storage, cgPath, createInactive, snapLabelToUse, SYNC_TYPE.SNAPSHOT.getValue());
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, replicationSvc, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateCGSnapshotJob(job, storage.getId(), !createInactive, null, taskCompleter)));
}
} catch (Exception e) {
_log.info("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
setInactive(((BlockSnapshotCreateCompleter) taskCompleter).getSnapshotURIs(), true);
}
}
Aggregations