Search in sources :

Example 21 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class FileService method getFileShareServiceImpl.

/**
 * Returns the bean responsible for servicing the request
 *
 * @param fileShare
 *            fileshare
 * @param dbClient
 *            db client
 * @return file service implementation object
 */
public static FileServiceApi getFileShareServiceImpl(FileShare fileShare, DbClient dbClient) {
    VirtualPool vPool = dbClient.queryObject(VirtualPool.class, fileShare.getVirtualPool());
    Project project = dbClient.queryObject(Project.class, fileShare.getProject().getURI());
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.FILE_REPLICATION_TYPE, VirtualPool.FileReplicationType.NONE.name());
    StringBuilder errorMsg = new StringBuilder();
    if (vPool.getFileReplicationSupported()) {
        FilePolicyServiceUtils.updateReplicationTypeCapabilities(dbClient, vPool, project, fileShare, capabilities, errorMsg);
    }
    return getFileServiceImpl(capabilities, dbClient);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) Project(com.emc.storageos.db.client.model.Project) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 22 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class FileService method createFSInternal.

/*
     * all the common code for provisioning fs both in normal public API use case and
     * the internal object case
     * NOTE - below method should always work with project being null
     */
public TaskResourceRep createFSInternal(FileSystemParam param, Project project, TenantOrg tenant, DataObject.Flag[] flags) throws InternalException {
    ArgValidator.checkFieldUriType(param.getVpool(), VirtualPool.class, "vpool");
    ArgValidator.checkFieldUriType(param.getVarray(), VirtualArray.class, "varray");
    Long fsSize = SizeUtil.translateSize(param.getSize());
    // Convert to MB and check for 20MB min size.
    Long fsSizeMB = fsSize / (1024 * 1024);
    // Convert to MB and check for 20MB min size.
    // VNX file has min 2MB size, NetApp 20MB and Isilon 0
    // VNX File 8.1.6 min 1GB size
    ArgValidator.checkFieldMinimum(fsSizeMB, 1024, "MB", "size");
    ArrayList<String> requestedTypes = new ArrayList<String>();
    // check varray
    VirtualArray neighborhood = _dbClient.queryObject(VirtualArray.class, param.getVarray());
    ArgValidator.checkEntity(neighborhood, param.getVarray(), false);
    _permissionsHelper.checkTenantHasAccessToVirtualArray(tenant.getId(), neighborhood);
    String task = UUID.randomUUID().toString();
    // check vpool reference
    VirtualPool cos = _dbClient.queryObject(VirtualPool.class, param.getVpool());
    _permissionsHelper.checkTenantHasAccessToVirtualPool(tenant.getId(), cos);
    ArgValidator.checkEntity(cos, param.getVpool(), false);
    if (!VirtualPool.Type.file.name().equals(cos.getType())) {
        throw APIException.badRequests.virtualPoolNotForFileBlockStorage(VirtualPool.Type.file.name());
    }
    // prepare vpool capability values
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, fsSize);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, new Integer(1));
    if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(cos.getSupportedProvisioningType())) {
        capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.TRUE);
    }
    StringBuilder errorMsg = new StringBuilder();
    if (cos.getFileReplicationSupported() && !FilePolicyServiceUtils.updatePolicyCapabilities(_dbClient, neighborhood, cos, project, null, capabilities, errorMsg)) {
        _log.error("File system can not be created, ", errorMsg.toString());
        throw APIException.badRequests.unableToProcessRequest(errorMsg.toString());
    }
    ArgValidator.checkFieldMaximum(param.getSoftLimit(), 100, "softLimit");
    ArgValidator.checkFieldMaximum(param.getNotificationLimit(), 100, "notificationLimit");
    if (param.getSoftLimit() != 0L) {
        ArgValidator.checkFieldMinimum(param.getSoftGrace(), 1L, "softGrace");
    }
    if (param.getNotificationLimit() != 0) {
        capabilities.put(VirtualPoolCapabilityValuesWrapper.SUPPORT_NOTIFICATION_LIMIT, Boolean.TRUE);
    }
    if (param.getSoftLimit() != 0) {
        capabilities.put(VirtualPoolCapabilityValuesWrapper.SUPPORT_SOFT_LIMIT, Boolean.TRUE);
    }
    // verify quota
    CapacityUtils.validateQuotasForProvisioning(_dbClient, cos, project, tenant, fsSize, "filesystem");
    String suggestedNativeFsId = param.getFsId() == null ? "" : param.getFsId();
    // Find the implementation that services this vpool and fileshare
    FileServiceApi fileServiceApi = getFileServiceImpl(capabilities, _dbClient);
    TaskList taskList = createFileTaskList(param, project, tenant, neighborhood, cos, flags, task);
    // call thread that does the work.
    CreateFileSystemSchedulingThread.executeApiTask(this, _asyncTaskService.getExecutorService(), _dbClient, neighborhood, project, cos, tenant, flags, capabilities, taskList, task, requestedTypes, param, fileServiceApi, suggestedNativeFsId);
    auditOp(OperationTypeEnum.CREATE_FILE_SYSTEM, true, AuditLogManager.AUDITOP_BEGIN, param.getLabel(), param.getSize(), neighborhood.getId().toString(), project == null ? null : project.getId().toString());
    // return the file share taskrep
    return taskList.getTaskList().get(0);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 23 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class FilePolicyService method assignFilePolicyToVpools.

/**
 * Assigning policy at vpool level
 *
 * @param param
 * @param filepolicy
 */
private TaskResourceRep assignFilePolicyToVpools(FilePolicyAssignParam param, FilePolicy filePolicy) {
    StringBuilder errorMsg = new StringBuilder();
    StringBuilder recommendationErrorMsg = new StringBuilder();
    ArgValidator.checkFieldNotNull(param.getVpoolAssignParams(), "vpool_assign_param");
    // Policy has to be applied on specified file vpools..
    ArgValidator.checkFieldNotEmpty(param.getVpoolAssignParams().getAssigntoVpools(), "assign_to_vpools");
    Set<URI> vpoolURIs = param.getVpoolAssignParams().getAssigntoVpools();
    Map<URI, List<URI>> vpoolToStorageSystemMap = new HashMap<URI, List<URI>>();
    List<URI> filteredVpoolURIs = new ArrayList<URI>();
    StringBuffer vPoolWithNoStoragePools = new StringBuffer();
    for (URI vpoolURI : vpoolURIs) {
        ArgValidator.checkFieldUriType(vpoolURI, VirtualPool.class, "vpool");
        VirtualPool virtualPool = _permissionsHelper.getObjectById(vpoolURI, VirtualPool.class);
        ArgValidator.checkEntity(virtualPool, vpoolURI, false);
        if (filePolicy.getAssignedResources() != null && filePolicy.getAssignedResources().contains(virtualPool.getId().toString())) {
            _log.info("File policy: {} has already been assigned to vpool: {} ", filePolicy.getFilePolicyName(), virtualPool.getLabel());
            continue;
        }
        // only single replication policy per vpool.
        if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_replication.name()) && (FilePolicyServiceUtils.vPoolHasReplicationPolicy(_dbClient, vpoolURI) || FilePolicyServiceUtils.vPoolHasReplicationPolicyAtProjectLevel(_dbClient, vpoolURI))) {
            errorMsg.append("Provided vpool : " + virtualPool.getLabel() + " already assigned with replication policy");
            _log.error(errorMsg.toString());
            throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
        }
        if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_snapshot.name()) && FilePolicyServiceUtils.vPoolHasSnapshotPolicyWithSameSchedule(_dbClient, vpoolURI, filePolicy)) {
            errorMsg.append("Snapshot policy with similar schedule is already present on vpool " + virtualPool.getLabel());
            _log.error(errorMsg.toString());
            throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
        }
        FilePolicyServiceUtils.validateVpoolSupportPolicyType(filePolicy, virtualPool);
        List<URI> storageSystems = getAssociatedStorageSystemsByVPool(virtualPool);
        if (storageSystems != null && !storageSystems.isEmpty()) {
            vpoolToStorageSystemMap.put(vpoolURI, storageSystems);
            filteredVpoolURIs.add(vpoolURI);
        } else {
            vPoolWithNoStoragePools.append(virtualPool.getLabel()).append(",");
        }
    }
    if (filteredVpoolURIs.isEmpty()) {
        String errorMessage = "No matching storage pools exists for given vpools ";
        _log.error(errorMessage);
        throw APIException.badRequests.noStoragePoolsExists(vPoolWithNoStoragePools.toString());
    }
    if (param.getApplyOnTargetSite() != null) {
        filePolicy.setApplyOnTargetSite(param.getApplyOnTargetSite());
    }
    FileServiceApi fileServiceApi = getDefaultFileServiceApi();
    FilePolicyType policyType = FilePolicyType.valueOf(filePolicy.getFilePolicyType());
    String task = UUID.randomUUID().toString();
    TaskResourceRep taskResponse = null;
    switch(policyType) {
        case file_snapshot:
            taskResponse = createAssignFilePolicyTask(filePolicy, task);
            AssignFileSnapshotPolicyToVpoolSchedulingThread.executeApiTask(this, _asyncTaskService.getExecutorService(), _dbClient, filePolicy.getId(), vpoolToStorageSystemMap, fileServiceApi, taskResponse, task);
            break;
        case file_replication:
            // update replication topology info
            updateFileReplicationTopologyInfo(param, filePolicy);
            List<URI> validRecommendationVpools = new ArrayList<URI>();
            List<FileStorageSystemAssociation> associations = new ArrayList<FileStorageSystemAssociation>();
            for (URI vpoolURI : filteredVpoolURIs) {
                VirtualPool vpool = _permissionsHelper.getObjectById(vpoolURI, VirtualPool.class);
                StringSet sourceVArraysSet = getSourceVArraySet(vpool, filePolicy);
                VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
                updatePolicyCapabilities(_dbClient, sourceVArraysSet, vpool, filePolicy, capabilities, errorMsg);
                // Replication policy has to be created on each applicable source storage system!!
                List<URI> storageSystems = getAssociatedStorageSystemsByVPool(vpool);
                if (storageSystems != null && !storageSystems.isEmpty()) {
                    List<FileStorageSystemAssociation> vpoolAssociations = new ArrayList<FileStorageSystemAssociation>();
                    for (URI storageSystem : storageSystems) {
                        capabilities.put(VirtualPoolCapabilityValuesWrapper.FILE_PROTECTION_SOURCE_STORAGE_SYSTEM, storageSystem);
                        for (Iterator<String> iterator = sourceVArraysSet.iterator(); iterator.hasNext(); ) {
                            String vArrayURI = iterator.next();
                            VirtualArray srcVarray = _dbClient.queryObject(VirtualArray.class, URI.create(vArrayURI));
                            try {
                                List<FileRecommendation> newRecs = _filePlacementManager.getRecommendationsForFileCreateRequest(srcVarray, null, vpool, capabilities);
                                if (newRecs != null && !newRecs.isEmpty()) {
                                    vpoolAssociations.addAll(convertRecommendationsToStorageSystemAssociations(newRecs, filePolicy.getApplyAt(), vpool.getId(), null));
                                }
                            } catch (Exception ex) {
                                _log.error("No recommendations found for storage system {} and virtualArray {} with error {} ", storageSystem, srcVarray.getLabel(), ex.getMessage());
                                if (ex.getMessage() != null) {
                                    recommendationErrorMsg.append(ex.getMessage());
                                }
                                // Continue to get the recommendations for next storage system!!
                                continue;
                            }
                        }
                    }
                    if (!vpoolAssociations.isEmpty()) {
                        validRecommendationVpools.add(vpoolURI);
                        associations.addAll(vpoolAssociations);
                    }
                } else {
                    String errorMessage = "No matching storage pools exists for vpool " + vpool.getLabel();
                    _log.error(errorMessage);
                    recommendationErrorMsg.append(errorMessage);
                }
            }
            // Throw an exception!!
            if (associations == null || associations.isEmpty()) {
                // If no other resources are assigned to replication policy
                // Remove the replication topology from the policy
                FileOrchestrationUtils.removeTopologyInfo(filePolicy, _dbClient);
                _log.error("No matching storage pools recommendations found for policy {} with due to {}", filePolicy.getFilePolicyName(), recommendationErrorMsg.toString());
                throw APIException.badRequests.noFileStorageRecommendationsFound(filePolicy.getFilePolicyName());
            }
            taskResponse = createAssignFilePolicyTask(filePolicy, task);
            fileServiceApi.assignFileReplicationPolicyToVirtualPools(associations, validRecommendationVpools, filePolicy.getId(), task);
            break;
        default:
            break;
    }
    auditOp(OperationTypeEnum.ASSIGN_FILE_POLICY, true, AuditLogManager.AUDITOP_BEGIN, filePolicy.getLabel());
    if (taskResponse != null) {
        // As the action done by system admin
        // Set system uri as task's tenant!!!
        Task taskObj = _dbClient.queryObject(Task.class, taskResponse.getId());
        StorageOSUser user = getUserFromContext();
        URI userTenantUri = URI.create(user.getTenantId());
        FilePolicyServiceUtils.updateTaskTenant(_dbClient, filePolicy, "assign", taskObj, userTenantUri);
    }
    return taskResponse;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) Task(com.emc.storageos.db.client.model.Task) TaskMapper.toTask(com.emc.storageos.api.mapper.TaskMapper.toTask) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) FileStorageSystemAssociation(com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation) FilePolicyType(com.emc.storageos.db.client.model.FilePolicy.FilePolicyType) FileRecommendation(com.emc.storageos.api.service.impl.placement.FileRecommendation) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException)

Example 24 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class FilePolicyService method assignFilePolicyToProjects.

/**
 * Assign policy at project level
 *
 * @param param
 * @param filepolicy
 */
private TaskResourceRep assignFilePolicyToProjects(FilePolicyAssignParam param, FilePolicy filePolicy) {
    StringBuilder errorMsg = new StringBuilder();
    StringBuilder recommendationErrorMsg = new StringBuilder();
    ArgValidator.checkFieldNotNull(param.getProjectAssignParams(), "project_assign_param");
    ArgValidator.checkFieldUriType(param.getProjectAssignParams().getVpool(), VirtualPool.class, "vpool");
    URI vpoolURI = param.getProjectAssignParams().getVpool();
    VirtualPool vpool = null;
    if (NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool())) {
        ArgValidator.checkFieldUriType(vpoolURI, VirtualPool.class, "vpool");
        vpool = _permissionsHelper.getObjectById(vpoolURI, VirtualPool.class);
        ArgValidator.checkEntity(vpool, vpoolURI, false);
        // Check if the vpool supports provided policy type..
        FilePolicyServiceUtils.validateVpoolSupportPolicyType(filePolicy, vpool);
        // Check if the vpool supports policy at project level..
        if (!vpool.getAllowFilePolicyAtProjectLevel()) {
            errorMsg.append("Provided vpool :" + vpool.getLabel() + " doesn't support policy at project level");
            _log.error(errorMsg.toString());
            throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
        }
    } else if (vpoolURI != null) {
        vpool = _dbClient.queryObject(VirtualPool.class, filePolicy.getFilePolicyVpool());
        if (!vpoolURI.equals(filePolicy.getFilePolicyVpool())) {
            errorMsg.append("File policy: " + filePolicy.getFilePolicyName() + " is already assigned at project level under the vpool: " + vpool.getLabel());
            _log.error(errorMsg.toString());
            throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
        }
    }
    ArgValidator.checkFieldNotEmpty(param.getProjectAssignParams().getAssigntoProjects(), "assign_to_projects");
    Set<URI> projectURIs = param.getProjectAssignParams().getAssigntoProjects();
    List<URI> filteredProjectURIs = new ArrayList<URI>();
    for (URI projectURI : projectURIs) {
        ArgValidator.checkFieldUriType(projectURI, Project.class, "project");
        Project project = _permissionsHelper.getObjectById(projectURI, Project.class);
        ArgValidator.checkEntity(project, projectURI, false);
        if (filePolicy.getAssignedResources() != null && filePolicy.getAssignedResources().contains(project.getId().toString())) {
            _log.info("Policy {} is already assigned to project {} ", filePolicy.getFilePolicyName(), project.getLabel());
            continue;
        }
        // only single replication policy per vpool-project combination.
        if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_replication.name()) && FilePolicyServiceUtils.projectHasReplicationPolicy(_dbClient, projectURI, vpool.getId())) {
            errorMsg.append("Virtual pool " + vpool.getLabel() + " project " + project.getLabel() + "pair is already assigned with replication policy.");
            _log.error(errorMsg.toString());
            throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
        }
        if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_snapshot.name()) && FilePolicyServiceUtils.projectHasSnapshotPolicyWithSameSchedule(_dbClient, projectURI, vpool.getId(), filePolicy)) {
            errorMsg.append("Snapshot policy with similar schedule is already present on project " + project.getLabel());
            _log.error(errorMsg.toString());
            throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
        }
        filteredProjectURIs.add(projectURI);
    }
    if (param.getApplyOnTargetSite() != null) {
        filePolicy.setApplyOnTargetSite(param.getApplyOnTargetSite());
    }
    // Verify the virtual pool has storage pools!!!
    List<URI> storageSystems = getAssociatedStorageSystemsByVPool(vpool);
    if (storageSystems == null || storageSystems.isEmpty()) {
        String errorMessage = "No matching storage pools exists for given vpools ";
        _log.error(errorMessage);
        throw APIException.badRequests.noStoragePoolsExists(vpool.getLabel());
    }
    String task = UUID.randomUUID().toString();
    TaskResourceRep taskResponse = createAssignFilePolicyTask(filePolicy, task);
    FileServiceApi fileServiceApi = getDefaultFileServiceApi();
    FilePolicyType policyType = FilePolicyType.valueOf(filePolicy.getFilePolicyType());
    switch(policyType) {
        case file_snapshot:
            Map<URI, List<URI>> vpoolToStorageSystemMap = new HashMap<URI, List<URI>>();
            vpoolToStorageSystemMap.put(vpoolURI, getAssociatedStorageSystemsByVPool(vpool));
            AssignFileSnapshotPolicyToProjectSchedulingThread.executeApiTask(this, _asyncTaskService.getExecutorService(), _dbClient, filePolicy.getId(), vpoolToStorageSystemMap, filteredProjectURIs, fileServiceApi, taskResponse, task);
            break;
        case file_replication:
            if (filteredProjectURIs.isEmpty()) {
                throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), "No projects to assign to policy.");
            }
            // update replication topology info
            updateFileReplicationTopologyInfo(param, filePolicy);
            List<URI> validRecommendationProjects = new ArrayList<URI>();
            List<FileStorageSystemAssociation> associations = new ArrayList<FileStorageSystemAssociation>();
            VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
            StringSet sourceVArraysSet = getSourceVArraySet(vpool, filePolicy);
            updatePolicyCapabilities(_dbClient, sourceVArraysSet, vpool, filePolicy, capabilities, errorMsg);
            // Replication policy has to be created on each applicable source storage system!!
            if (storageSystems != null && !storageSystems.isEmpty()) {
                for (Iterator<String> iterator = sourceVArraysSet.iterator(); iterator.hasNext(); ) {
                    String vArrayURI = iterator.next();
                    for (URI projectURI : filteredProjectURIs) {
                        List<FileStorageSystemAssociation> projectAssociations = new ArrayList<FileStorageSystemAssociation>();
                        Project project = _dbClient.queryObject(Project.class, projectURI);
                        VirtualArray srcVarray = _dbClient.queryObject(VirtualArray.class, URI.create(vArrayURI));
                        for (URI storageSystem : storageSystems) {
                            capabilities.put(VirtualPoolCapabilityValuesWrapper.FILE_PROTECTION_SOURCE_STORAGE_SYSTEM, storageSystem);
                            try {
                                List<FileRecommendation> newRecs = _filePlacementManager.getRecommendationsForFileCreateRequest(srcVarray, project, vpool, capabilities);
                                if (newRecs != null && !newRecs.isEmpty()) {
                                    projectAssociations.addAll(convertRecommendationsToStorageSystemAssociations(newRecs, filePolicy.getApplyAt(), vpool.getId(), projectURI));
                                }
                            } catch (Exception ex) {
                                _log.error("No recommendations found for storage system {} and virtualArray {} with error {} ", storageSystem, srcVarray.getLabel(), ex.getMessage());
                                if (ex.getMessage() != null) {
                                    recommendationErrorMsg.append(ex.getMessage());
                                }
                                // Continue to get the recommedations for next storage system!!
                                continue;
                            }
                        }
                        if (!projectAssociations.isEmpty()) {
                            associations.addAll(projectAssociations);
                            validRecommendationProjects.add(projectURI);
                        }
                    }
                }
            } else {
                String errorMessage = "No matching storage pools exists for vpool " + vpool.getLabel();
                _log.error(errorMessage);
                recommendationErrorMsg.append(errorMessage);
            }
            // Throw an exception!!
            if (associations == null || associations.isEmpty()) {
                // If no other resources are assigned to replication policy
                // Remove the replication topology from the policy
                FileOrchestrationUtils.removeTopologyInfo(filePolicy, _dbClient);
                _log.error("No matching storage pools recommendations found for policy {} with due to {}", filePolicy.getFilePolicyName(), recommendationErrorMsg.toString());
                throw APIException.badRequests.noFileStorageRecommendationsFound(filePolicy.getFilePolicyName());
            }
            fileServiceApi.assignFileReplicationPolicyToProjects(associations, vpoolURI, validRecommendationProjects, filePolicy.getId(), task);
            break;
        default:
            break;
    }
    auditOp(OperationTypeEnum.ASSIGN_FILE_POLICY, true, AuditLogManager.AUDITOP_BEGIN, filePolicy.getLabel());
    if (taskResponse != null) {
        // As the action done by system admin
        // Set system uri as task's tenant!!!
        Task taskObj = _dbClient.queryObject(Task.class, taskResponse.getId());
        StorageOSUser user = getUserFromContext();
        URI userTenantUri = URI.create(user.getTenantId());
        FilePolicyServiceUtils.updateTaskTenant(_dbClient, filePolicy, "assign", taskObj, userTenantUri);
    }
    return taskResponse;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) Task(com.emc.storageos.db.client.model.Task) TaskMapper.toTask(com.emc.storageos.api.mapper.TaskMapper.toTask) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) FileStorageSystemAssociation(com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation) FilePolicyType(com.emc.storageos.db.client.model.FilePolicy.FilePolicyType) FileRecommendation(com.emc.storageos.api.service.impl.placement.FileRecommendation) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) Project(com.emc.storageos.db.client.model.Project)

Example 25 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class FileMirrorServiceApiImpl 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.Type fileType = FileDescriptor.Type.FILE_MIRROR_SOURCE;
        // Source desc type to create mirrors for existing file system!!
        if (cosCapabilities.createMirrorExistingFileSystem()) {
            fileType = FileDescriptor.Type.FILE_EXISTING_MIRROR_SOURCE;
        }
        if (filesystem.getPersonality() != null && filesystem.getPersonality().equals(FileShare.PersonalityTypes.TARGET.toString())) {
            fileType = FileDescriptor.Type.FILE_MIRROR_TARGET;
        }
        VirtualPoolCapabilityValuesWrapper vpoolCapabilities = new VirtualPoolCapabilityValuesWrapper(cosCapabilities);
        FileDescriptor desc = new FileDescriptor(fileType, filesystem.getStorageDevice(), filesystem.getId(), filesystem.getPool(), filesystem.getCapacity(), vpoolCapabilities, null, suggestedId);
        fileDescriptors.add(desc);
    }
    return fileDescriptors;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Aggregations

VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)65 ArrayList (java.util.ArrayList)50 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)44 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)44 Project (com.emc.storageos.db.client.model.Project)41 URI (java.net.URI)34 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)33 NamedURI (com.emc.storageos.db.client.model.NamedURI)32 List (java.util.List)31 StoragePool (com.emc.storageos.db.client.model.StoragePool)28 StringSet (com.emc.storageos.db.client.model.StringSet)25 Volume (com.emc.storageos.db.client.model.Volume)22 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)22 RPRecommendation (com.emc.storageos.volumecontroller.RPRecommendation)22 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)21 Recommendation (com.emc.storageos.volumecontroller.Recommendation)21 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)20 Test (org.junit.Test)20 Network (com.emc.storageos.db.client.model.Network)19 StringMap (com.emc.storageos.db.client.model.StringMap)19