Search in sources :

Example 31 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class FileReplicationDeviceController method queryFileShares.

/**
 * Convenience method to build a Map of URI's to their respective fileshares based on a List of
 * FileDescriptor.
 *
 * @param fileShareDescriptors List of fileshare descriptors
 * @return Map of URI to FileShare
 */
private Map<URI, FileShare> queryFileShares(final List<FileDescriptor> fileShareDescriptors) {
    List<URI> fileShareURIs = FileDescriptor.getFileSystemURIs(fileShareDescriptors);
    List<FileShare> fileShares = dbClient.queryObject(FileShare.class, fileShareURIs);
    Map<URI, FileShare> fileShareMap = new HashMap<URI, FileShare>();
    for (FileShare fileShare : fileShares) {
        if (fileShare != null) {
            fileShareMap.put(fileShare.getId(), fileShare);
        }
    }
    return fileShareMap;
}
Also used : HashMap(java.util.HashMap) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 32 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class FileReplicationDeviceController method createFileMirrorSession.

/**
 * Create Mirror Work Flow Step - creates replication session between source and target
 *
 * @param workflow
 * @param waitFor
 * @param sourceDescriptors
 * @param uriFileShareMap
 * @return
 */
protected String createFileMirrorSession(Workflow workflow, String waitFor, List<FileDescriptor> sourceDescriptors, Map<URI, FileShare> uriFileShareMap) {
    for (FileDescriptor sourceDescriptor : sourceDescriptors) {
        FileShare source = uriFileShareMap.get(sourceDescriptor.getFsURI());
        for (String targetStr : source.getMirrorfsTargets()) {
            URI targetURI = URI.create(targetStr);
            StorageSystem system = dbClient.queryObject(StorageSystem.class, source.getStorageDevice());
            Workflow.Method createMethod = createMirrorFilePairStep(system.getId(), source.getId(), targetURI, null);
            Workflow.Method rollbackMethod = rollbackMirrorFilePairMethod(system.getId(), source.getId(), targetURI);
            // Ensure CreateElementReplica steps are executed sequentially (CQ613404)
            waitFor = workflow.createStep(CREATE_FILE_MIRRORS_STEP, CREATE_FILE_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), createMethod, rollbackMethod, null);
        }
    }
    return waitFor = CREATE_FILE_MIRRORS_STEP;
}
Also used : Workflow(com.emc.storageos.workflow.Workflow) FileShare(com.emc.storageos.db.client.model.FileShare) URI(java.net.URI) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 33 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class StoragePoolService method getStoragePoolResources.

/**
 * Retrieves the id, name, and type of the resources in the registered
 * storage pool. with the passed id.
 *
 * @param id the URN of a ViPR storage pool.
 *
 * @brief List storage pool resources
 * @return A list of the resources in the storage pool.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/resources")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePoolResources getStoragePoolResources(@PathParam("id") URI id) {
    // Make sure the storage pool is registered.
    ArgValidator.checkFieldUriType(id, StoragePool.class, "id");
    queryRegisteredResource(id);
    // Create the storage pools resources to be returned.
    StoragePoolResources resources = new StoragePoolResources();
    // Get the active volumes in the storage pool and add them to
    // the storage pool resources
    URIQueryResultList volumeURIList = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStoragePoolVolumeConstraint(id), volumeURIList);
    Iterator<URI> volumeURIIter = volumeURIList.iterator();
    while (volumeURIIter.hasNext()) {
        URI volumeURI = volumeURIIter.next();
        Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
        if ((volume != null) && (!volume.getInactive())) {
            TypedRelatedResourceRep resource = toTypedRelatedResource(volume);
            resources.getResources().add(resource);
        }
    }
    // Get the active file shares in the storage pool and add them to the
    // storage pools resources.
    URIQueryResultList fsURIList = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStoragePoolFileshareConstraint(id), fsURIList);
    Iterator<URI> fsURIIter = fsURIList.iterator();
    while (fsURIIter.hasNext()) {
        URI fsURI = fsURIIter.next();
        FileShare fs = _dbClient.queryObject(FileShare.class, fsURI);
        if ((fs != null) && (!fs.getInactive())) {
            TypedRelatedResourceRep resource = toTypedRelatedResource(fs);
            resources.getResources().add(resource);
        }
    }
    return resources;
}
Also used : TypedRelatedResourceRep(com.emc.storageos.model.TypedRelatedResourceRep) StoragePoolResources(com.emc.storageos.model.pools.StoragePoolResources) Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 34 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class InternalFileResource method deactivateFileSystemInternal.

/*
     * POST to deactivate filesystem
     */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
public TaskResourceRep deactivateFileSystemInternal(@PathParam("id") URI id, FileSystemDeleteParam param) throws InternalException {
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare fs = _fileService.queryResource(id);
    checkFileShareInternal(fs);
    TenantOrg tenant = _permissionsHelper.getRootTenant();
    if (!_permissionsHelper.userHasGivenRole(getUserFromContext(), tenant.getId(), Role.SYSTEM_ADMIN, Role.TENANT_ADMIN)) {
        throw APIException.forbidden.onlyAdminsCanDeactivateFileSystems(Role.SYSTEM_ADMIN.toString(), Role.TENANT_ADMIN.toString());
    }
    return _fileService.deactivateFileSystem(id, param);
}
Also used : TenantOrg(com.emc.storageos.db.client.model.TenantOrg) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 35 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class InternalFileResource method unexportInternal.

/*
     * DELETE filesystem export
     */
@DELETE
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/exports/{protocol},{secType},{perm},{root_mapping}")
public TaskResourceRep unexportInternal(@PathParam("id") URI id, @PathParam("protocol") String protocol, @PathParam("secType") String securityType, @PathParam("perm") String permissions, @PathParam("root_mapping") String rootUserMapping, @QueryParam("subDirectory") String subDirectory) throws InternalException {
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare fs = _fileService.queryResource(id);
    checkFileShareInternal(fs);
    return _fileService.unexport(id, protocol, securityType, permissions, rootUserMapping, subDirectory);
}
Also used : FileShare(com.emc.storageos.db.client.model.FileShare)

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