use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class ExportGroupService method pathsAdjustment.
/**
* Export paths adjustment
*
* @param id The export group id
* @param param The parameters including addedPaths, removedPaths, storage system URI, exportPathParameters,
* and waitBeforeRemovePaths
* @brief Initiate port allocations for export
* @return The pending task
* @throws ControllerException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/paths-adjustment")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep pathsAdjustment(@PathParam("id") URI id, ExportPathsAdjustmentParam param) throws ControllerException {
// Basic validation of ExportGroup and the request
ExportGroup exportGroup = queryObject(ExportGroup.class, id, true);
if (exportGroup.checkInternalFlags(DataObject.Flag.DELETION_IN_PROGRESS)) {
throw BadRequestException.badRequests.deletionInProgress(exportGroup.getClass().getSimpleName(), exportGroup.getLabel());
}
validateExportGroupNoPendingEvents(exportGroup);
validateSuspendSetForNonDiscoverableHosts(exportGroup, param.getWaitBeforeRemovePaths(), param.getRemovedPaths().isEmpty());
ArgValidator.checkUri(param.getStorageSystem());
StorageSystem system = queryObject(StorageSystem.class, param.getStorageSystem(), true);
// Log the input parameters
param.logParameters(_log);
// Get the virtual array, default to Export Group varray. Validate it matches.
URI varray = param.getVirtualArray();
if (varray != null) {
boolean validVarray = varray.equals(exportGroup.getVirtualArray());
if (exportGroup.getAltVirtualArrays() != null && varray.toString().equals(exportGroup.getAltVirtualArrays().get(system.getId().toString()))) {
validVarray = true;
}
if (!validVarray) {
throw APIException.badRequests.varrayNotInExportGroup(varray.toString());
}
} else {
varray = exportGroup.getVirtualArray();
}
validatePathAdjustment(exportGroup, system, param, varray);
Boolean wait = new Boolean(param.getWaitBeforeRemovePaths());
String task = UUID.randomUUID().toString();
Operation op = initTaskStatus(exportGroup, task, Operation.Status.pending, ResourceOperationTypeEnum.EXPORT_PATHS_ADJUSTMENT);
// persist the export group to the database
_dbClient.updateObject(exportGroup);
auditOp(OperationTypeEnum.EXPORT_PATH_ADJUSTMENT, true, AuditLogManager.AUDITOP_BEGIN, exportGroup.getLabel(), exportGroup.getId().toString(), exportGroup.getVirtualArray().toString(), exportGroup.getProject().toString());
TaskResourceRep taskRes = toTask(exportGroup, task, op);
BlockExportController exportController = getExportController();
_log.info("Submitting export path adjustment request.");
Map<URI, List<URI>> addedPaths = convertInitiatorPathParamToMap(param.getAdjustedPaths());
Map<URI, List<URI>> removedPaths = convertInitiatorPathParamToMap(param.getRemovedPaths());
ExportPathParams pathParam = new ExportPathParams(param.getExportPathParameters(), exportGroup);
exportController.exportGroupPortRebalance(param.getStorageSystem(), id, varray, addedPaths, removedPaths, pathParam, wait, task);
return taskRes;
}
use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method failFileShareCreateRequest.
private void failFileShareCreateRequest(String task, TaskList taskList, List<FileShare> preparedFileShares, String errorMsg) {
String errorMessage = String.format("Controller error: %s", errorMsg);
for (TaskResourceRep fileShareTask : taskList.getTaskList()) {
fileShareTask.setState(Operation.Status.error.name());
fileShareTask.setMessage(errorMessage);
Operation statusUpdate = new Operation(Operation.Status.error.name(), errorMessage);
_dbClient.updateTaskOpStatus(FileShare.class, fileShareTask.getResource().getId(), task, statusUpdate);
}
for (FileShare fileShare : preparedFileShares) {
fileShare.setInactive(true);
_dbClient.updateObject(fileShare);
}
}
use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class FileQuotaDirectoryService method deactivateQuotaDirectory.
/**
* Deactivate Quota directory of file system, this will move the
* Quota directory to a "marked-for-delete" state
* <p>
* NOTE: This is an asynchronous operation.
*
* @param id
* the URN of the QuotaDirectory
* @param param
* QuotaDirectory delete param for optional force delete
* @brief Delete file system quota directory
* @return Task resource representation
* @throws com.emc.storageos.svcs.errorhandling.resources.InternalException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep deactivateQuotaDirectory(@PathParam("id") URI id, QuotaDirectoryDeleteParam param) throws InternalException {
_log.info("FileService::deactivateQtree Request recieved {}", id);
String task = UUID.randomUUID().toString();
ArgValidator.checkFieldUriType(id, QuotaDirectory.class, "id");
QuotaDirectory quotaDirectory = queryResource(id);
FileShare fs = queryFileShareResource(quotaDirectory.getParent().getURI());
ArgValidator.checkFieldNotNull(fs, "filesystem");
// if the delete request is with force flag!!!
if (param.getForceDelete()) {
_log.error("Quota directory delete operation is not supported with force delete {}", param.getForceDelete());
throw APIException.badRequests.quotaDirectoryDeleteNotSupported(param.getForceDelete());
} else {
// Fail to delete quota directory, if there are any dependency objects like exports, shares
if (quotaDirectoryHasExportsOrShares(fs, quotaDirectory.getName())) {
throw APIException.badRequests.resourceCannotBeDeleted("Quota directory " + quotaDirectory.getName() + " has exports/shares ");
}
}
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR);
quotaDirectory.getOpStatus().createTaskStatus(task, op);
fs.setOpStatus(new OpStatusMap());
fs.getOpStatus().createTaskStatus(task, op);
_dbClient.persistObject(fs);
_dbClient.persistObject(quotaDirectory);
// Now get ready to make calls into the controller
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
FileController controller = getController(FileController.class, device.getSystemType());
try {
controller.deleteQuotaDirectory(device.getId(), quotaDirectory.getId(), fs.getId(), task);
} catch (InternalException e) {
throw e;
}
auditOp(OperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR, true, AuditLogManager.AUDITOP_BEGIN, quotaDirectory.getLabel(), quotaDirectory.getId().toString(), fs.getId().toString());
fs = _dbClient.queryObject(FileShare.class, fs.getId());
_log.debug("FileService::Quota directory Before sending response, FS ID : {}, Taks : {} ; Status {}", fs.getOpStatus().get(task), fs.getOpStatus().get(task).getStatus());
return toTask(quotaDirectory, task, op);
}
use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class DefaultBlockServiceApiImpl method establishVolumeAndSnapshotGroupRelation.
/**
* {@inheritDoc}
*
* @throws ControllerException
*/
@Override
public TaskResourceRep establishVolumeAndSnapshotGroupRelation(StorageSystem storageSystem, Volume sourceVolume, BlockSnapshot snapshot, String taskId) throws ControllerException {
_log.info("START establish Volume and Snapshot group relation");
// Create the task on the block snapshot
Operation op = _dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), taskId, ResourceOperationTypeEnum.ESTABLISH_VOLUME_SNAPSHOT);
snapshot.getOpStatus().put(taskId, op);
try {
BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
controller.establishVolumeAndSnapshotGroupRelation(storageSystem.getId(), sourceVolume.getId(), snapshot.getId(), taskId);
} catch (ControllerException e) {
String errorMsg = String.format("Failed to establish group relation between volume group and snapshot group." + "Source volume: %s, Snapshot: %s", sourceVolume.getId(), snapshot.getId());
_log.error(errorMsg, e);
_dbClient.error(BlockSnapshot.class, snapshot.getId(), taskId, e);
}
return toTask(snapshot, taskId, op);
}
use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.
the class DefaultBlockServiceApiImpl method addVolumeTask.
/**
* Creates tasks against consistency groups associated with a request and adds them to the given task list.
*
* @param group
* @param taskList
* @param taskId
* @param operationTypeEnum
*/
protected void addVolumeTask(Volume volume, TaskList taskList, String taskId, ResourceOperationTypeEnum operationTypeEnum) {
Operation op = _dbClient.createTaskOpStatus(Volume.class, volume.getId(), taskId, operationTypeEnum);
taskList.getTaskList().add(TaskMapper.toTask(volume, taskId, op));
}
Aggregations