use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class FileService method assignFilePolicyToFS.
private TaskResourceRep assignFilePolicyToFS(FileShare fs, FilePolicy filePolicy, String task) {
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
Operation op = _dbClient.createTaskOpStatus(FileShare.class, fs.getId(), task, ResourceOperationTypeEnum.ASSIGN_FILE_POLICY_TO_FILE_SYSTEM);
op.setDescription("assign file policy to file system");
// As the action done by tenant admin
// Set current tenant as task's tenant!!!
Task taskObj = op.getTask(fs.getId());
FilePolicyServiceUtils.updateTaskTenant(_dbClient, filePolicy, "assign", taskObj, fs.getTenant().getURI());
try {
_log.info("No Errors found proceeding further {}, {}, {}", new Object[] { _dbClient, fs, filePolicy });
List<FileDescriptor> fileDescriptors = new ArrayList<>();
FileDescriptor desc = new FileDescriptor(Type.FILE_EXISTING_SOURCE, fs.getId());
fileDescriptors.add(desc);
controller.assignFilePolicyToFileSystem(filePolicy, fileDescriptors, task);
auditOp(OperationTypeEnum.ASSIGN_FILE_POLICY, true, AuditLogManager.AUDITOP_BEGIN, fs.getId().toString(), device.getId().toString(), filePolicy.getId());
} catch (BadRequestException e) {
_dbClient.error(FileShare.class, fs.getId(), task, e);
_log.error("Error Assigning Filesystem policy {}, {}", e.getMessage(), e);
throw e;
} catch (Exception e) {
_log.error("Error Assigning Filesystem policy {}, {}", e.getMessage(), e);
throw APIException.badRequests.unableToProcessRequest(e.getMessage());
}
return toTask(fs, task, op);
}
use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class FileRemoteMirrorServiceApiImpl method getDescriptorsOfFileShareDeleted.
@Override
protected List<FileDescriptor> getDescriptorsOfFileShareDeleted(URI systemURI, List<URI> fileShareURIs, String deletionType, boolean forceDelete, boolean deleteOnlyMirrors) {
List<FileDescriptor> fileDescriptors = new ArrayList<FileDescriptor>();
for (URI fileURI : fileShareURIs) {
FileShare fileShare = _dbClient.queryObject(FileShare.class, fileURI);
FileDescriptor.Type descriptorType;
if (fileShare.getPersonality() == null || fileShare.getPersonality().contains("null")) {
descriptorType = FileDescriptor.Type.FILE_DATA;
} else if (FileShare.PersonalityTypes.TARGET == getPersonality(fileShare)) {
if (isParentInactiveForTarget(fileShare)) {
descriptorType = FileDescriptor.Type.FILE_DATA;
} else {
_log.warn("Attempted to delete an Mirror target that had an active Mirror source");
throw APIException.badRequests.cannotDeleteMirrorFileShareTargetWithActiveSource(fileURI, fileShare.getParentFileShare().getURI());
}
} else {
descriptorType = FileDescriptor.Type.FILE_MIRROR_SOURCE;
}
FileDescriptor fileDescriptor = new FileDescriptor(descriptorType, fileShare.getStorageDevice(), fileShare.getId(), fileShare.getPool(), deletionType, forceDelete, deleteOnlyMirrors);
fileDescriptors.add(fileDescriptor);
}
return fileDescriptors;
}
use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method createFileSystems.
/**
* It take mirror recommendation and then creates source and mirror fileshare
*/
@Override
public TaskList createFileSystems(FileSystemParam param, Project project, VirtualArray varray, VirtualPool vpool, TenantOrg tenantOrg, DataObject.Flag[] flags, List<Recommendation> recommendations, TaskList taskList, String taskId, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) throws InternalException {
List<FileShare> fileList = null;
List<FileShare> fileShares = new ArrayList<FileShare>();
// Prepare the FileShares
fileList = prepareFileSystems(param, taskId, taskList, project, tenantOrg, flags, varray, vpool, recommendations, vpoolCapabilities, false);
fileShares.addAll(fileList);
// prepare the file descriptors
String suggestedNativeFsId = param.getFsId() == null ? "" : param.getFsId();
final List<FileDescriptor> fileDescriptors = prepareFileDescriptors(fileShares, vpoolCapabilities, suggestedNativeFsId);
final FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
try {
// Execute the fileshare creations requests
controller.createFileSystems(fileDescriptors, taskId);
} catch (InternalException e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(taskId, taskList, fileShares, e.getMessage());
throw e;
} catch (Exception e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(taskId, taskList, fileShares, e.getMessage());
throw e;
}
return taskList;
}
use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class DefaultFileServiceApiImpl method createFileSystems.
@Override
public TaskList createFileSystems(FileSystemParam param, Project project, VirtualArray varray, VirtualPool vpool, TenantOrg tenantOrg, DataObject.Flag[] flags, List<Recommendation> recommendations, TaskList taskList, String task, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) throws InternalException {
List<FileShare> fileList = null;
List<FileShare> fileShares = new ArrayList<FileShare>();
// Prepare the FileShares
fileList = getFileScheduler().prepareFileSystems(param, task, taskList, project, varray, vpool, recommendations, vpoolCapabilities, false);
fileShares.addAll(fileList);
// prepare the file descriptors
String suggestedNativeFsId = param.getFsId() == null ? "" : param.getFsId();
final List<FileDescriptor> fileDescriptors = prepareFileDescriptors(fileShares, vpoolCapabilities, suggestedNativeFsId);
final FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
try {
// Execute the fileshare creations requests
controller.createFileSystems(fileDescriptors, task);
} catch (InternalException e) {
_log.error("Controller error when creating filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
} catch (Exception e) {
_log.error("Controller error when creating filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
}
return taskList;
}
use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class DefaultFileServiceApiImpl method getDescriptorsOfFileShareDeleted.
/**
* {@inheritDoc}
*/
@Override
protected List<FileDescriptor> getDescriptorsOfFileShareDeleted(URI systemURI, List<URI> fileShareURIs, String deletionType, boolean forceDelete, boolean deleteOnlyMirrors) {
List<FileDescriptor> fileDescriptors = new ArrayList<FileDescriptor>();
for (URI fileShareURI : fileShareURIs) {
FileShare filesystem = _dbClient.queryObject(FileShare.class, fileShareURI);
FileDescriptor fileDescriptor = new FileDescriptor(FileDescriptor.Type.FILE_DATA, filesystem.getStorageDevice(), filesystem.getId(), filesystem.getPool(), deletionType, forceDelete, deleteOnlyMirrors);
fileDescriptors.add(fileDescriptor);
}
return fileDescriptors;
}
Aggregations