Search in sources :

Example 76 with FileShare

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;
}
Also used : ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Example 77 with FileShare

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();
}
Also used : MapQuotaDirectory(com.emc.storageos.api.mapper.functions.MapQuotaDirectory) FileShareQuotaDirectory(com.emc.storageos.volumecontroller.FileShareQuotaDirectory) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Example 78 with FileShare

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;
}
Also used : FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Example 79 with FileShare

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);
}
Also used : FileController(com.emc.storageos.volumecontroller.FileController) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) MapQuotaDirectory(com.emc.storageos.api.mapper.functions.MapQuotaDirectory) FileShareQuotaDirectory(com.emc.storageos.volumecontroller.FileShareQuotaDirectory) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 80 with FileShare

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;
}
Also used : ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Aggregations

FileShare (com.emc.storageos.db.client.model.FileShare)289 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)155 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)107 URI (java.net.URI)93 ArrayList (java.util.ArrayList)79 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)73 ControllerException (com.emc.storageos.volumecontroller.ControllerException)65 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)61 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)57 Operation (com.emc.storageos.db.client.model.Operation)56 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)56 URISyntaxException (java.net.URISyntaxException)56 Path (javax.ws.rs.Path)56 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)52 Produces (javax.ws.rs.Produces)51 Snapshot (com.emc.storageos.db.client.model.Snapshot)50 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)49 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)45 WorkflowException (com.emc.storageos.workflow.WorkflowException)42 NamedURI (com.emc.storageos.db.client.model.NamedURI)36