use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl 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.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class FileQuotaDirectoryService method getTenantOwner.
@Override
protected URI getTenantOwner(URI id) {
QuotaDirectory qd = queryResource(id);
FileShare fs = queryFileShareResource(qd.getParent().getURI());
return fs.getTenant().getURI();
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class FileQuotaDirectoryService method queryFileShareResource.
protected FileShare queryFileShareResource(URI id) {
ArgValidator.checkUri(id);
FileShare fs = _permissionsHelper.getObjectById(id, FileShare.class);
ArgValidator.checkEntityNotNull(fs, id, isIdEmbeddedInURL(id));
return fs;
}
use of com.emc.storageos.db.client.model.FileShare 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.FileShare in project coprhd-controller by CoprHD.
the class DefaultFileServiceApiImpl method prepareFileDescriptors.
/**
* prepare the file descriptors
*
* @param filesystems
* @param cosCapabilities
* @param suggestedId
* @return
*/
private List<FileDescriptor> prepareFileDescriptors(List<FileShare> filesystems, VirtualPoolCapabilityValuesWrapper cosCapabilities, String suggestedId) {
// Build up a list of FileDescriptors based on the fileshares
final List<FileDescriptor> fileDescriptors = new ArrayList<FileDescriptor>();
for (FileShare filesystem : filesystems) {
FileDescriptor desc = new FileDescriptor(FileDescriptor.Type.FILE_DATA, filesystem.getStorageDevice(), filesystem.getId(), filesystem.getPool(), filesystem.getCapacity(), cosCapabilities, null, suggestedId);
fileDescriptors.add(desc);
}
return fileDescriptors;
}
Aggregations