use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class RPDeviceController method disableImageAccessForCreateReplicaStep.
/**
* Disable image access for after create native array replica operation
*
* @param protectionDevice
* @param clazz
* type of replica (such as Volume, BlockSnapshot or BlockSnapshotSession)
* @param copyList
* list of replica ids
* @param volumeWWNs
* wwns of volumes that are parents to replica objects
* @param opId
* @throws ControllerException
*/
public void disableImageAccessForCreateReplicaStep(URI protectionDevice, Class<? extends DataObject> clazz, List<URI> copyList, Set<String> volumeWWNs, String opId) throws ControllerException {
TaskCompleter completer = null;
try {
_log.info("Deactivating a bookmark on the RP CG(s)");
completer = new RPCGCopyVolumeCompleter(clazz, copyList, opId);
// Verify non-null storage device returned from the database client.
ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
if (system == null || system.getInactive()) {
throw DeviceControllerExceptions.recoverpoint.databaseExceptionActivateSnapshot(protectionDevice);
}
// disable image access to that bookmark
RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
MultiCopyDisableImageRequestParams request = new MultiCopyDisableImageRequestParams();
request.setVolumeWWNSet(volumeWWNs);
MultiCopyDisableImageResponse response = rp.disableImageCopies(request);
if (response == null) {
throw DeviceControllerExceptions.recoverpoint.failedDisableAccessOnRP();
}
completer.ready(_dbClient);
} 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.ControllerException in project coprhd-controller by CoprHD.
the class RPDeviceController method enableImageForSnapshots.
/**
* Enable image access for RP snapshots.
*
* @param protectionDevice
* protection system
* @param storageDevice
* storage device of the backing (parent) volume
* @param snapshotList
* list of snapshots to enable
* @param opId
* task ID
* @return true if operation was successful
* @throws ControllerException
* @throws URISyntaxException
*/
private boolean enableImageForSnapshots(URI protectionDevice, URI storageDevice, List<URI> snapshotList, String opId) throws ControllerException, URISyntaxException {
TaskCompleter completer = null;
try {
_log.info("Activating a bookmark on the RP CG(s)");
completer = new BlockSnapshotActivateCompleter(snapshotList, opId);
ProtectionSystem system = null;
try {
system = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
} catch (DatabaseException e) {
throw DeviceControllerExceptions.recoverpoint.databaseExceptionActivateSnapshot(protectionDevice);
}
// Verify non-null storage device returned from the database client.
if (system == null) {
throw DeviceControllerExceptions.recoverpoint.databaseExceptionActivateSnapshot(protectionDevice);
}
// is still creating the snapshot
if (snapshotList != null && !snapshotList.isEmpty()) {
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotList.get(0));
Volume parent = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
final List<Volume> vplexVolumes = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Volume.class, getVolumesByAssociatedId(parent.getId().toString()));
if (vplexVolumes != null && !vplexVolumes.isEmpty()) {
parent = vplexVolumes.get(0);
}
String lockName = ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, parent.getConsistencyGroup(), system.getId());
if (null != lockName) {
List<String> locks = new ArrayList<String>();
locks.add(lockName);
acquireWorkflowLockOrThrow(_workflowService.getWorkflowFromStepId(opId), locks);
}
}
// Keep a mapping of the emNames(bookmark names) to target copy volume WWNs
Map<String, Set<String>> emNamesToVolumeWWNs = new HashMap<String, Set<String>>();
// Keep a mapping of the emNames(bookmark names) to BlockSnapshot objects
Map<String, Set<URI>> emNamesToSnapshots = new HashMap<String, Set<URI>>();
for (URI snapshotID : snapshotList) {
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
String emName = snapshot.getEmName();
if (NullColumnValueGetter.isNotNullValue(emName)) {
if (!emNamesToVolumeWWNs.containsKey(emName)) {
emNamesToVolumeWWNs.put(emName, new HashSet<String>());
}
if (!emNamesToSnapshots.containsKey(emName)) {
emNamesToSnapshots.put(emName, new HashSet<URI>());
}
emNamesToSnapshots.get(emName).add(snapshotID);
} else {
throw DeviceControllerExceptions.recoverpoint.failedToActivateSnapshotEmNameMissing(snapshotID);
}
// Get the volume associated with this snapshot
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);
}
String wwn = null;
// If the personality is SOURCE, then the enable image access request is part of export operation.
if (volume.checkPersonality(Volume.PersonalityTypes.TARGET.toString())) {
wwn = RPHelper.getRPWWn(volume.getId(), _dbClient);
} else {
// Now determine the target volume that corresponds to the site of the snapshot
ProtectionSet protectionSet = _dbClient.queryObject(ProtectionSet.class, volume.getProtectionSet());
Volume targetVolume = ProtectionSet.getTargetVolumeFromSourceAndInternalSiteName(_dbClient, protectionSet, volume, snapshot.getEmInternalSiteName());
wwn = RPHelper.getRPWWn(targetVolume.getId(), _dbClient);
}
// Add the volume WWN
emNamesToVolumeWWNs.get(emName).add(wwn);
}
// Now enable image access to that bookmark
RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
// correponding to each emName.
for (Map.Entry<String, Set<String>> emNameEntry : emNamesToVolumeWWNs.entrySet()) {
MultiCopyEnableImageRequestParams request = new MultiCopyEnableImageRequestParams();
request.setVolumeWWNSet(emNameEntry.getValue());
request.setBookmark(emNameEntry.getKey());
MultiCopyEnableImageResponse response = rp.enableImageCopies(request);
if (response == null) {
throw DeviceControllerExceptions.recoverpoint.failedEnableAccessOnRP();
}
}
completer.ready(_dbClient);
return true;
} catch (InternalException e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, e);
}
throw e;
} catch (URISyntaxException e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, DeviceControllerException.errors.invalidURI(e));
}
throw e;
} catch (Exception e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, DeviceControllerException.errors.jobFailed(e));
}
throw e;
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class RPDeviceController method disableImageAccessStep.
/**
* Workflow step method for disabling an image access of all snapshots in an export group
*
* @param rpSystem
* RP system
* @param token
* the task
* @return true if successful
* @param exportGroupID
* export group ID
* @throws ControllerException
*/
public boolean disableImageAccessStep(URI rpSystemId, URI exportGroupURI, String token) throws ControllerException {
try {
WorkflowStepCompleter.stepExecuting(token);
List<URI> snapshots = new ArrayList<URI>();
// In order to find all of the snapshots to deactivate, go through the devices, find the RP snapshots, and
// deactivate any active
// ones
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
for (String exportVolumeIDStr : exportGroup.getVolumes().keySet()) {
URI blockID;
blockID = new URI(exportVolumeIDStr);
BlockObject block = BlockObject.fetch(_dbClient, blockID);
if (block.getProtectionController() != null) {
if (block.getId().toString().contains("BlockSnapshot")) {
// Collect this snapshot; it needs to be disabled
snapshots.add(block.getId());
}
}
}
disableImageForSnapshots(rpSystemId, new ArrayList<URI>(snapshots), false, token);
// Update the workflow state.
WorkflowStepCompleter.stepSucceded(token);
} catch (Exception e) {
_log.error(String.format("disableImageAccessStep Failed - Protection System: %s, export group: %s", String.valueOf(rpSystemId), String.valueOf(exportGroupURI)));
return stepFailed(token, e, "disableImageAccessStep");
}
return true;
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method deleteMirror.
/**
* {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method deleteMirrorMethod just above (except
* opId).
*/
@Override
public void deleteMirror(URI storage, List<URI> mirrorList, Boolean isCG, String opId) throws ControllerException {
TaskCompleter completer = null;
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
completer = new BlockMirrorDeleteCompleter(mirrorList, opId);
if (!isCG) {
getDevice(storageObj.getSystemType()).doDeleteMirror(storageObj, mirrorList.get(0), completer);
} else {
getDevice(storageObj.getSystemType()).doDeleteGroupMirrors(storageObj, mirrorList, completer);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
if (completer != null) {
completer.error(_dbClient, serviceError);
}
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method createConsistencyGroupStep.
public boolean createConsistencyGroupStep(URI storage, URI consistencyGroup, String replicationGroupName, String opId) throws ControllerException {
TaskCompleter taskCompleter = null;
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
taskCompleter = new BlockConsistencyGroupCreateCompleter(consistencyGroup, opId);
String groupName = ControllerUtils.generateReplicationGroupName(storageSystem, consistencyGroup, replicationGroupName, _dbClient);
String lockKey = groupName;
boolean isVNX = storageSystem.deviceIsType(Type.vnxblock);
if (isVNX && lockKey == null) {
lockKey = replicationGroupName;
}
if (lockKey == null) {
BlockConsistencyGroup cgObj = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
lockKey = cgObj.getAlternateLabel() != null ? cgObj.getAlternateLabel() : cgObj.getLabel();
}
// Lock the CG for the step duration.
List<String> lockKeys = new ArrayList<>();
lockKeys.add(ControllerLockingUtil.getReplicationGroupStorageKey(_dbClient, lockKey, storage));
_workflowService.acquireWorkflowStepLocks(opId, lockKeys, LockTimeoutValue.get(LockType.ARRAY_CG));
if (isVNX) {
// replication group may have been just created by another thread, in that case,
// group name for VNX will be array generated name (if arrayConsistency is true), or
// replicationGroupName if arrayConsistency is false
// so get the group name again here to be used in ControllerUtils.replicationGroupExists call
groupName = ControllerUtils.generateReplicationGroupName(storageSystem, consistencyGroup, replicationGroupName, _dbClient);
}
// make sure this array consistency group was not just created by another thread that held the lock
if (groupName != null && ControllerUtils.replicationGroupExists(storage, groupName, _dbClient)) {
taskCompleter.ready(_dbClient);
return true;
}
getDevice(storageSystem.getSystemType()).doCreateConsistencyGroup(storageSystem, consistencyGroup, groupName, taskCompleter);
} catch (Exception e) {
_log.error("create consistency group job failed:", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
WorkflowStepCompleter.stepFailed(opId, serviceError);
return false;
}
return true;
}
Aggregations