use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method createConsistencyGroup.
@Override
public void createConsistencyGroup(URI storage, URI consistencyGroup, String opId) throws ControllerException {
TaskCompleter completer = new BlockConsistencyGroupCreateCompleter(consistencyGroup, opId);
try {
WorkflowStepCompleter.stepExecuting(opId);
// Lock the CG for the step duration.
List<String> lockKeys = new ArrayList<String>();
lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, consistencyGroup, storage));
_workflowService.acquireWorkflowStepLocks(opId, lockKeys, LockTimeoutValue.get(LockType.ARRAY_CG));
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
// Check if already created, if not create, if so just complete.
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
String groupName = ControllerUtils.generateReplicationGroupName(storageObj, cg, null, _dbClient);
if (!cg.created(storage, groupName)) {
getDevice(storageObj.getSystemType()).doCreateConsistencyGroup(storageObj, consistencyGroup, groupName, completer);
} else {
_log.info(String.format("Consistency group %s (%s) already created", cg.getLabel(), cg.getId()));
completer.ready(_dbClient);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
throw DeviceControllerException.exceptions.createConsistencyGroupFailed(e);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method rollBackCreateVolumes.
/**
* {@inheritDoc} NOTE: The signature here MUST match the Workflow.Method rollbackCreateVolumesMethod just above
* (except opId).
*/
@Override
public void rollBackCreateVolumes(URI systemURI, List<URI> volumeURIs, String opId) throws ControllerException {
MultiVolumeTaskCompleter completer = new MultiVolumeTaskCompleter(volumeURIs, opId);
List<Volume> volumes = new ArrayList<>(volumeURIs.size());
completer.setRollingBack(true);
try {
String logMsg = String.format("rollbackCreateVolume start - Array:%s, Volume:%s", systemURI.toString(), Joiner.on(',').join(volumeURIs));
_log.info(logMsg.toString());
WorkflowStepCompleter.stepExecuting(opId);
volumes.addAll(_dbClient.queryObject(Volume.class, volumeURIs));
for (Volume volume : volumes) {
// CTRL-5597 clean volumes which have failed only in a multi-volume request
if (null != volume.getNativeGuid()) {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, volume.getStorageController());
if (Type.xtremio.toString().equalsIgnoreCase(system.getSystemType())) {
continue;
}
}
// then we need to clear srdfTargets and personality fields for source
if (null != volume.getSrdfTargets()) {
_log.info("Clearing targets for existing source");
volume.getSrdfTargets().clear();
_dbClient.updateObject(volume);
// Clearing Source CG
URI sourceCgUri = volume.getConsistencyGroup();
if (null != sourceCgUri) {
BlockConsistencyGroup sourceCG = _dbClient.queryObject(BlockConsistencyGroup.class, sourceCgUri);
if (null != sourceCG && (null == sourceCG.getTypes() || NullColumnValueGetter.isNullURI(sourceCG.getStorageController()))) {
sourceCG.getRequestedTypes().remove(Types.SRDF.name());
_dbClient.updateObject(sourceCG);
}
}
}
// for change Virtual Pool, if failed, clear targets and personality field for source and also
if (!NullColumnValueGetter.isNullNamedURI(volume.getSrdfParent())) {
URI sourceUri = volume.getSrdfParent().getURI();
Volume sourceVolume = _dbClient.queryObject(Volume.class, sourceUri);
sourceVolume.setPersonality(NullColumnValueGetter.getNullStr());
if (null != sourceVolume.getSrdfTargets()) {
sourceVolume.getSrdfTargets().clear();
_dbClient.updateObject(sourceVolume);
}
// Clearing target CG
URI cgUri = volume.getConsistencyGroup();
if (null != cgUri) {
BlockConsistencyGroup targetCG = _dbClient.queryObject(BlockConsistencyGroup.class, cgUri);
if (null != targetCG && (null == targetCG.getTypes() || NullColumnValueGetter.isNullURI(targetCG.getStorageController()))) {
_log.info("Set target CG {} inactive", targetCG.getLabel());
targetCG.setInactive(true);
_dbClient.updateObject(targetCG);
}
// clear association between target volume and target cg
volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
_dbClient.updateAndReindexObject(volume);
}
}
// Check for loose export groups associated with this rolled-back volume
URIQueryResultList exportGroupURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeExportGroupConstraint(volume.getId()), exportGroupURIs);
while (exportGroupURIs.iterator().hasNext()) {
URI exportGroupURI = exportGroupURIs.iterator().next();
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
if (!exportGroup.getInactive()) {
exportGroup.removeVolume(volume.getId());
boolean canRemoveGroup = false;
List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup);
// Make sure the volume is not in an export mask
for (ExportMask exportMask : exportMasks) {
exportMask.removeVolume(volume.getId());
exportMask.removeFromUserCreatedVolumes(volume);
exportMask.removeFromExistingVolumes(volume);
if (!exportMask.getCreatedBySystem() && !exportMask.hasAnyVolumes() && exportMask.emptyVolumes()) {
canRemoveGroup = true;
_dbClient.removeObject(exportMask);
} else {
_dbClient.updateObject(exportMask);
}
}
// If we didn't find that volume in a mask, it's OK to remove it.
if (canRemoveGroup && exportMasks.size() == 1 && exportGroup.getVolumes().isEmpty()) {
_dbClient.removeObject(exportGroup);
} else {
_dbClient.updateObject(exportGroup);
}
}
}
}
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_013);
deleteVolumesWithCompleter(systemURI, volumeURIs, completer);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_014);
logMsg = String.format("rollbackCreateVolume end - Array:%s, Volume:%s", systemURI.toString(), Joiner.on(',').join(volumeURIs));
_log.info(logMsg.toString());
} catch (Exception e) {
_log.error(String.format("rollbackCreateVolume Failed - Array:%s, Volume:%s", systemURI.toString(), Joiner.on(',').join(volumeURIs)));
handleException(e, completer);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method removeMirrorFromGroup.
public void removeMirrorFromGroup(URI storage, List<URI> mirrorList, String opId) throws ControllerException {
TaskCompleter completer = null;
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
completer = new BlockMirrorTaskCompleter(BlockMirror.class, mirrorList, opId);
getDevice(storageObj.getSystemType()).doRemoveMirrorFromDeviceMaskingGroup(storageObj, mirrorList, completer);
} catch (Exception e) {
if (completer != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
}
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class FileDeviceController method expandFS.
@Override
public void expandFS(URI storage, URI uri, long newFSsize, String opId) throws ControllerException {
ControllerUtils.setThreadLocalLogData(uri, opId);
FileShare fs = null;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
FileDeviceInputOutput args = new FileDeviceInputOutput();
fs = _dbClient.queryObject(FileShare.class, uri);
args.addFSFileObject(fs);
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
args.setFileOperation(true);
args.setNewFSCapacity(newFSsize);
args.setOpId(opId);
// work flow and we need to add TaskCompleter(TBD for vnxfile)
WorkflowStepCompleter.stepExecuting(opId);
// Acquire lock for VNXFILE Storage System
acquireStepLock(storageObj, opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doExpandFS(storageObj, args);
if (result.getCommandPending()) {
// async operation
return;
}
if (result.isCommandSuccess()) {
_log.info("FileSystem old capacity :" + args.getFsCapacity() + ":Expanded Size:" + args.getNewFSCapacity());
args.setFsCapacity(args.getNewFSCapacity());
_log.info("FileSystem new capacity :" + args.getFsCapacity());
WorkflowStepCompleter.stepSucceded(opId);
} else if (!result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
// Set status
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(fs);
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.EXPAND_FILE_SYSTEM, result.isCommandSuccess(), eventMsg, "", fs, String.valueOf(newFSsize));
} catch (Exception e) {
String[] params = { storage.toString(), uri.toString(), String.valueOf(newFSsize), e.getMessage() };
_log.error("Unable to expand file system: storage {}, FS URI {}, size {}: {}", params);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
updateTaskStatus(opId, fs, e);
if (fs != null) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.EXPAND_FILE_SYSTEM, false, e.getMessage(), "", fs, String.valueOf(newFSsize));
}
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class FileDeviceController method createFS.
@Override
public void createFS(URI storage, URI pool, URI fs, String nativeId, String opId) throws ControllerException {
FileObject fileObject = null;
FileShare fsObj = null;
StorageSystem storageObj = null;
try {
ControllerUtils.setThreadLocalLogData(fs, opId);
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
String[] params = { storage.toString(), pool.toString(), fs.toString() };
_log.info("Create FS: {}, {}, {}", params);
StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
fsObj = _dbClient.queryObject(FileShare.class, fs);
VirtualPool vPool = _dbClient.queryObject(VirtualPool.class, fsObj.getVirtualPool());
fileObject = fsObj;
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.addFileShare(fsObj);
args.addStoragePool(poolObj);
args.setVPool(vPool);
args.setNativeDeviceFsId(nativeId);
args.setOpId(opId);
Project proj = _dbClient.queryObject(Project.class, fsObj.getProject());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, fsObj.getTenant());
setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
args.setTenantOrg(tenant);
args.setProject(proj);
// work flow and we need to add TaskCompleter(TBD for vnxfile)
WorkflowStepCompleter.stepExecuting(opId);
acquireStepLock(storageObj, opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doCreateFS(storageObj, args);
if (!result.getCommandPending()) {
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
} else {
// we need to add task completer
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
}
if (result.isCommandSuccess()) {
fsObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, fsObj));
fsObj.setInactive(false);
WorkflowStepCompleter.stepSucceded(opId);
} else if (!result.getCommandPending()) {
fsObj.setInactive(true);
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
_dbClient.updateObject(fsObj);
if (!result.getCommandPending()) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, result.isCommandSuccess(), "", "", fsObj);
}
} catch (Exception e) {
String[] params = { storage.toString(), pool.toString(), fs.toString(), e.getMessage() };
_log.error("Unable to create file system: storage {}, pool {}, FS {}: {}", params);
// work flow fail
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
if ((fsObj != null) && (storageObj != null)) {
fsObj.setInactive(true);
_dbClient.updateObject(fsObj);
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, false, e.getMessage(), "", fsObj, storageObj);
}
updateTaskStatus(opId, fileObject, e);
}
}
Aggregations