use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VnxSnapshotOperations method restoreGroupSnapshots.
/**
* Implementation should restore the set of snapshots that were taken for a set of
* volumes in a consistency group. That is, at some time there was a consistency
* group of volumes created and snapshot was taken of these; these snapshots would
* belong to a "snap-set". This restore operation, will restore the volumes in the
* consistency group from this snap-set. Any snapshot from the snap-set can be
* provided to restore the whole snap-set.
*
* @param storage [required] - StorageSystem object representing the array
* @param snapshotURI [required] - BlockSnapshot URI representing the previously created
* snap for the volume
* @param taskCompleter - TaskCompleter object used for the updating operation status.
*/
@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshotURI, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshotURI));
final BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
// Check if the consistency group exists
final String consistencyGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, _dbClient);
storage = findProviderFactory.withGroup(storage, consistencyGroupName).find();
if (storage == null) {
ServiceError error = DeviceControllerErrors.smis.noConsistencyGroupWithGivenName();
taskCompleter.error(_dbClient, error);
return;
}
final String snapshotGroupName = snapshotObj.getReplicationGroupInstance();
final CIMObjectPath groupSynchronized = _cimPath.getGroupSynchronizedPath(storage, consistencyGroupName, snapshotGroupName);
final CIMInstance groupSynchronizedInstance = _helper.checkExists(storage, groupSynchronized, false, false);
List<BlockSnapshot> snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
if (groupSynchronizedInstance != null) {
// would mean that there wasn't any export performed.
if (snapshotObj.getNeedsCopyToTarget()) {
_log.info("Consistency group {} snapshots require copy-to-target", consistencyGroupName);
List<URI> snapshotList = new ArrayList<URI>();
for (BlockSnapshot snapshot : snapshots) {
snapshotList.add(snapshot.getId());
}
internalGroupSnapCopyToTarget(storage, snapshotObj, snapshotList);
}
CIMObjectPath settingsPathFromOutputArg = null;
// Deactivate Synchronization if not already deactivated
String copyState = groupSynchronizedInstance.getPropertyValue(SmisConstants.CP_COPY_STATE).toString();
if (!String.valueOf(SmisConstants.INACTIVE_VALUE).equalsIgnoreCase(copyState)) {
CIMArgument[] deactivateGroupInput = _helper.getDeactivateSnapshotSynchronousInputArguments(groupSynchronized);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.callModifyReplica(storage, deactivateGroupInput, outArgs);
settingsPathFromOutputArg = (CIMObjectPath) outArgs[0].getValue();
}
final boolean isSynchronizationAspectSet = snapshotObj.getSettingsGroupInstance() != null;
// Get the Clar_SettingsDefineState_RG_SAFS path
final CIMObjectPath settingsPath = isSynchronizationAspectSet ? _helper.getSettingsDefineStateForSourceGroup(storage, snapshotObj.getSettingsGroupInstance()) : settingsPathFromOutputArg;
// If the Clar_SynchronizationAspectForSourceGroup hasn't been set in the snapshots, then set it.
if (!isSynchronizationAspectSet) {
CIMObjectPath syncPath = (CIMObjectPath) settingsPath.getKey(SmisConstants.CP_SETTING_DATA).getValue();
String instanceId = (String) syncPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue();
for (BlockSnapshot it : snapshots) {
it.setSettingsGroupInstance(instanceId);
}
_dbClient.persistObject(snapshots);
}
// Restore snapshot
CIMArgument[] restoreInput = _helper.getRestoreFromSettingsStateInputArguments(settingsPath, false);
CIMObjectPath cimJob = _helper.callModifySettingsDefineState(storage, restoreInput);
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockRestoreSnapshotJob(cimJob, storage.getId(), taskCompleter)));
} else {
taskCompleter.ready(_dbClient);
}
} catch (Exception e) {
String message = String.format("Generic exception when trying to restoring snapshots from consistency group on array %s", storage.getSerialNumber());
_log.error(message, e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreGroupSnapshots", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VmaxExportOperations method createMaskingView.
private void createMaskingView(StorageSystem storage, URI exportMaskURI, String maskingViewName, CIMObjectPath volumeGroupPath, VolumeURIHLU[] volumeURIHLUs, CIMObjectPath targetPortGroupPath, CIMObjectPath initiatorGroupPath, TaskCompleter taskCompleter) throws Exception {
_log.info("{} createMaskingView START...", storage.getSerialNumber());
// Flag to indicate whether or not we need to use the EMCForce flag on this operation.
// We currently use this flag when dealing with RP Volumes as they are tagged for RP and the
// operation on these volumes would fail otherwise.
boolean forceFlag = false;
List<String> deviceNumbers = new ArrayList<String>();
for (VolumeURIHLU volURIHlu : volumeURIHLUs) {
String hlu = volURIHlu.getHLU();
// LUN_UNASSIGNED value (as a hex string).
if (hlu != null && !hlu.equalsIgnoreCase(ExportGroup.LUN_UNASSIGNED_STR)) {
deviceNumbers.add(hlu);
}
// The force flag only needs to be set once
if (!forceFlag) {
forceFlag = ExportUtils.useEMCForceFlag(_dbClient, volURIHlu.getVolumeURI());
}
}
String[] deviceNumbersStr = {};
CIMArgument[] inMVArgs = _helper.getCreateMaskingViewInputArguments(volumeGroupPath, targetPortGroupPath, initiatorGroupPath, deviceNumbers.toArray(deviceNumbersStr), maskingViewName, forceFlag);
CIMArgument[] outMVArgs = new CIMArgument[5];
try {
_helper.invokeMethod(storage, _cimPath.getControllerConfigSvcPath(storage), "CreateMaskingView", inMVArgs, outMVArgs);
CIMObjectPath cimJobPath = _cimPath.getCimObjectPathFromOutputArgs(outMVArgs, "Job");
if (cimJobPath != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCreateMaskingViewJob(cimJobPath, storage.getId(), exportMaskURI, volumeURIHLUs, volumeGroupPath, taskCompleter)));
} else {
// simulated environments
throw new WBEMException("No output argument was returned from CreateMaskingView operation");
}
// Rollback context is set in the job upon completion.
} catch (WBEMException we) {
_log.info("{} Problem when trying to create masking view ... going to look up masking view.", storage.getSerialNumber(), we);
boolean handleException = false;
try {
handleException = handleCreateMaskingViewException(storage, maskingViewName);
} catch (Exception e) {
_log.error("Issue trying to handle Export Mask exception", e);
}
if (handleException) {
_log.info("{} Found masking view: {}", storage.getSerialNumber(), maskingViewName);
taskCompleter.ready(_dbClient);
} else {
_log.debug("{} Problem when looking up masking view: {}", storage.getSerialNumber(), maskingViewName);
throw we;
}
}
_log.info("{} createMaskingView END...", storage.getSerialNumber());
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VNXeSnapshotOperation method restoreGroupSnapshots.
@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeLunGroupSnap lunGroupSnap = apiClient.getLunGroupSnapshot(snapshotObj.getReplicationGroupInstance());
// Error out if the snapshot is attached
if (lunGroupSnap.getIsAttached()) {
_log.error("Snapshot {})is attached and cannot be used for restore", snapshotObj.getLabel());
ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshot.toString());
taskCompleter.error(_dbClient, error);
}
VNXeCommandJob job = apiClient.restoreLunGroupSnap(lunGroupSnap.getId());
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
}
} catch (VNXeException e) {
_log.error("Restore group snapshot got the exception", e);
taskCompleter.error(_dbClient, e);
} catch (Exception ex) {
_log.error("Restore group snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("RestoreSnapshotJob", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VNXeSnapshotOperation method deleteSingleVolumeSnapshot.
@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot snap = _dbClient.queryObject(BlockSnapshot.class, snapshot);
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeLunSnap lunSnap = apiClient.getLunSnapshot(snap.getNativeId());
if (lunSnap != null) {
VNXeCommandJob job = apiClient.deleteLunSnap(lunSnap.getId());
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockDeleteSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
}
} else {
// Perhaps, it's already been deleted or was deleted on the array.
// In that case, we'll just say all is well, so that this operation
// is idempotent.
snap.setInactive(true);
snap.setIsSyncActive(false);
_dbClient.updateObject(snap);
taskCompleter.ready(_dbClient);
}
} catch (VNXeException e) {
_log.error("Delete volume snapshot got the exception", e);
taskCompleter.error(_dbClient, e);
} catch (Exception ex) {
_log.error("Delete volume snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteSnapshot", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class VNXeSnapshotOperation method restoreSingleVolumeSnapshot.
@Override
public void restoreSingleVolumeSnapshot(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeLunSnap lunSnap = apiClient.getLunSnapshot(snapshotObj.getNativeId());
// Error out if the snapshot is attached
if (lunSnap.getIsAttached()) {
_log.error("Snapshot {})is attached and cannot be used for restore", snapshotObj.getLabel());
ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshot.toString());
taskCompleter.error(_dbClient, error);
}
VNXeCommandJob job = apiClient.restoreLunSnap(lunSnap.getId());
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
}
} catch (VNXeException e) {
_log.error("Restore snapshot got the exception", e);
taskCompleter.error(_dbClient, e);
} catch (Exception ex) {
_log.error("Restore snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("RestoreSnapshotJob", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
Aggregations