Search in sources :

Example 71 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class InternalFileServiceClient method unexportFileSystem.

/**
 * Unexport a file share
 *
 * @param fsId
 * @param protocol
 * @param securityType
 * @param permissions
 * @param rootUserMapping
 * @param subDirectory
 * @return
 */
public TaskResourceRep unexportFileSystem(URI fsId, String protocol, String securityType, String permissions, String rootUserMapping, String subDirectory) {
    String unexportPath = String.format(UNEXPORTS, fsId, protocol, securityType, permissions, rootUserMapping);
    WebResource rRoot = createRequest(unexportPath);
    // add query params before signing the request
    if (StringUtils.isNotEmpty(subDirectory)) {
        rRoot = rRoot.queryParam(SUB_DIRECTORY_QUERY_KEY, subDirectory);
    }
    TaskResourceRep resp = null;
    try {
        resp = addSignature(rRoot).delete(TaskResourceRep.class);
    } catch (UniformInterfaceException e) {
        _log.warn("could not unexport", e);
    }
    return resp;
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) WebResource(com.sun.jersey.api.client.WebResource) TaskResourceRep(com.emc.storageos.model.TaskResourceRep)

Example 72 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class InternalFileServiceClient method modifyExports.

/**
 * Modify existing export for a file share
 *
 * @param fsId fileshare id
 * @param protocol protocol for the existing export
 * @param securityType security type for the existing export
 * @param permissions permissios for the existing export
 * @param rootUserMapping usermapping for the existing export
 * @param updateParam export update param, which contains a list of end points which needs to be added/removed for
 *            this export
 * @return Task in
 */
public TaskResourceRep modifyExports(URI fsId, String protocol, String securityType, String permissions, String rootUserMapping, FileExportUpdateParam updateParam) {
    String modifyExportPath = String.format(MODIFYEXPORTS, fsId, protocol, securityType, permissions, rootUserMapping);
    WebResource rRoot = createRequest(modifyExportPath);
    TaskResourceRep resp = null;
    try {
        resp = addSignature(rRoot).put(TaskResourceRep.class, updateParam);
    } catch (UniformInterfaceException e) {
        _log.warn("could not modify exports", e);
    }
    return resp;
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) WebResource(com.sun.jersey.api.client.WebResource) TaskResourceRep(com.emc.storageos.model.TaskResourceRep)

Example 73 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class InternalFileServiceClient method createFileSystem.

/**
 * Create file system
 *
 * @param fileSystemParam
 * @param token user authentication token
 * @return
 */
public TaskResourceRep createFileSystem(FileSystemParam fileSystemParam, String token) {
    WebResource rRoot = createRequest(INTERNAL_FILE_CREATE);
    WebResource.Builder requestBuilder = addSignature(rRoot);
    TaskResourceRep resp = addToken(requestBuilder, token).post(TaskResourceRep.class, fileSystemParam);
    return resp;
}
Also used : WebResource(com.sun.jersey.api.client.WebResource) TaskResourceRep(com.emc.storageos.model.TaskResourceRep)

Example 74 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class StorageScheduler method prepareRecommendedVolumes.

/**
 * Create volumes from recommendation object.
 *
 * @param param volume creation parameters
 * @param task task
 * @param taskList task list
 * @param project project
 * @param neighborhood virtual array
 * @param vPool virtual pool
 * @param volumeCount number of volumes to create
 * @param recommendations recommendation structures
 * @param consistencyGroup consistency group to use
 * @param volumeCounter how many volumes are created
 * @param volumeLabel volume label
 * @param preparedVolumes volumes that have been prepared
 * @param cosCapabilities virtual pool wrapper
 * @param createInactive create the device in an inactive state
 */
/**
 * Create volumes from recommendations objects.
 *
 * @param size -- size of volumes in bytes
 * @param task -- overall task id
 * @param taskList -- a TaskList new tasks may be inserted into
 * @param project -- Project object
 * @param neighborhood -- Virtual array
 * @param vPool -- Virtual pool
 * @param volumeCount -- number of like volumes to be created
 * @param recommendations -- List of Recommendation objects describing pools to use for volumes
 * @param consistencyGroup -- The BlockConsistencyGroup object to be used for the volumes
 * @param volumeCounter -- The current volume counter, used to generate unique names for like volumes
 * @param volumeLabel -- Label (prefix) of the volumes to be created
 * @param preparedVolumes -- Output argument that receives the prepared volumes
 * @param cosCapabilities - VirtualPoolCapabilityValuesWrapper contains parameters for volume creation
 * @param createInactive-- used to set the Volume syncActive flag (to the inverted sense of createInactive)
 */
public void prepareRecommendedVolumes(Long size, String task, TaskList taskList, Project project, VirtualArray neighborhood, VirtualPool vPool, Integer volumeCount, List<Recommendation> recommendations, BlockConsistencyGroup consistencyGroup, int volumeCounter, String volumeLabel, List<Volume> preparedVolumes, VirtualPoolCapabilityValuesWrapper cosCapabilities, Boolean createInactive) {
    Iterator<Recommendation> recommendationsIter = recommendations.iterator();
    while (recommendationsIter.hasNext()) {
        VolumeRecommendation recommendation = (VolumeRecommendation) recommendationsIter.next();
        // if id is already set in recommendation, do not prepare the volume (volume already exists)
        if (recommendation.getId() != null) {
            continue;
        }
        // prepare block volume
        if (recommendation.getType().toString().equals(VolumeRecommendation.VolumeType.BLOCK_VOLUME.toString())) {
            String newVolumeLabel = AbstractBlockServiceApiImpl.generateDefaultVolumeLabel(volumeLabel, volumeCounter++, volumeCount);
            // Grab the existing volume and task object from the incoming task list
            Volume volume = getPrecreatedVolume(_dbClient, taskList, newVolumeLabel);
            boolean volumePrecreated = false;
            if (volume != null) {
                volumePrecreated = true;
            }
            long thinVolumePreAllocationSize = 0;
            if (null != vPool.getThinVolumePreAllocationPercentage()) {
                thinVolumePreAllocationSize = VirtualPoolUtil.getThinVolumePreAllocationSize(vPool.getThinVolumePreAllocationPercentage(), size);
            }
            volume = prepareVolume(_dbClient, volume, size, thinVolumePreAllocationSize, project, neighborhood, vPool, recommendation, newVolumeLabel, consistencyGroup, cosCapabilities, createInactive);
            // set volume id in recommendation
            recommendation.setId(volume.getId());
            // add volume to reserved capacity map of storage pool
            addVolumeCapacityToReservedCapacityMap(_dbClient, volume);
            preparedVolumes.add(volume);
            if (!volumePrecreated) {
                Operation op = _dbClient.createTaskOpStatus(Volume.class, volume.getId(), task, ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
                volume.getOpStatus().put(task, op);
                TaskResourceRep volumeTask = toTask(volume, task, op);
                // This task addition is inconsequential since we've already returned the source volume tasks.
                // It is good to continue to have a task associated with this volume AND store its status in the volume.
                taskList.getTaskList().add(volumeTask);
            }
        } else if (recommendation.getType().toString().equals(VolumeRecommendation.VolumeType.BLOCK_LOCAL_MIRROR.toString())) {
            // prepare local mirror based on source volume and storage pool recommendation
            VolumeRecommendation volumeRecommendation = (VolumeRecommendation) recommendation.getParameter(VolumeRecommendation.BLOCK_VOLUME);
            URI volumeId = volumeRecommendation.getId();
            Volume volume = _dbClient.queryObject(Volume.class, volumeId);
            String mirrorLabel = volumeLabel;
            if (volume.isInCG()) {
                mirrorLabel = ControllerUtils.getMirrorLabel(volume.getLabel(), volumeLabel);
            }
            if (volumeCount > 1) {
                mirrorLabel = ControllerUtils.getMirrorLabel(mirrorLabel, volumeCounter++);
            }
            // Prepare a single mirror based on source volume and storage pool recommendation
            BlockMirror mirror = initializeMirror(volume, vPool, recommendation.getCandidatePools().get(0), mirrorLabel, _dbClient);
            // set mirror id in recommendation
            recommendation.setId(mirror.getId());
            preparedVolumes.add(mirror);
            // add mirror to reserved capacity map of storage pool
            addVolumeCapacityToReservedCapacityMap(_dbClient, mirror);
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Recommendation(com.emc.storageos.volumecontroller.Recommendation)

Example 75 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class TaskMapper method toTask.

public static TaskResourceRep toTask(Task task) {
    TaskResourceRep taskResourceRep = new TaskResourceRep();
    mapDataObjectFields(task, taskResourceRep);
    taskResourceRep.setId(task.getId());
    taskResourceRep.setResource(toNamedRelatedResource(task.getResource()));
    // Check to see if there are any associated resources
    List<NamedRelatedResourceRep> associatedRefs = Lists.newArrayList();
    for (URI assocId : task.getAssociatedResourcesList()) {
        DataObject associatedObject = getConfig().getDbClient().queryObject(assocId);
        if (associatedObject != null) {
            associatedRefs.add(toNamedRelatedResource(associatedObject));
        } else {
            log.warn(String.format("For task %s could not find associated object %s", task.getId(), assocId));
        }
    }
    taskResourceRep.setAssociatedResources(associatedRefs);
    if (!StringUtils.isBlank(task.getRequestId())) {
        taskResourceRep.setOpId(task.getRequestId());
    }
    if (task.getWorkflow() != null) {
        taskResourceRep.setWorkflow(toRelatedResource(ResourceTypeEnum.WORKFLOW, task.getWorkflow()));
    }
    if (!task.getTenant().equals(TenantOrg.SYSTEM_TENANT)) {
        taskResourceRep.setTenant(DbObjectMapper.toRelatedResource(ResourceTypeEnum.TENANT, task.getTenant()));
    }
    // Operation
    taskResourceRep.setState(task.getStatus());
    if (task.getServiceCode() != null) {
        taskResourceRep.setServiceError(toServiceErrorRestRep(toServiceCode(task.getServiceCode()), task.getMessage()));
    } else {
        taskResourceRep.setMessage(task.getMessage());
        if (!task.getWarningMessages().isEmpty()) {
            taskResourceRep.setWarningMessages(new ArrayList<String>(task.getWarningMessages()));
        }
    }
    taskResourceRep.setDescription(task.getDescription());
    // COP-23486
    // 
    // This is a workaround to migration post-commit delete source volumes. We would like to be able to
    // mark this Task as one that cannot be rolled back, however at the time there is no framework to
    // detect the state of not being able to rollback, so we will catch this specific situation from the
    // message so we can "flip the flag" of allowable operations by the UI.
    taskResourceRep.setAllowedOperations(Task.AllowedOperations.none_specified.name());
    if (task.getWorkflow() != null) {
        Workflow wf = configInstance.getDbClient().queryObject(Workflow.class, task.getWorkflow());
        if (wf != null && NullColumnValueGetter.isNotNullValue(wf.getCompletionMessage()) && wf.getCompletionMessage().contains("post-migration delete of original source backing volumes")) {
            taskResourceRep.setAllowedOperations(Task.AllowedOperations.retry_only.name());
        }
    }
    taskResourceRep.setStartTime(task.getStartTime());
    taskResourceRep.setEndTime(task.getEndTime());
    taskResourceRep.setProgress(task.getProgress() != null ? task.getProgress() : 0);
    taskResourceRep.setQueuedStartTime(task.getQueuedStartTime());
    taskResourceRep.setQueueName(task.getQueueName());
    return taskResourceRep;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Workflow(com.emc.storageos.db.client.model.Workflow) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Aggregations

TaskResourceRep (com.emc.storageos.model.TaskResourceRep)160 URI (java.net.URI)85 TaskList (com.emc.storageos.model.TaskList)82 Operation (com.emc.storageos.db.client.model.Operation)68 Produces (javax.ws.rs.Produces)59 ArrayList (java.util.ArrayList)56 Volume (com.emc.storageos.db.client.model.Volume)55 Path (javax.ws.rs.Path)54 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)53 POST (javax.ws.rs.POST)50 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)49 Consumes (javax.ws.rs.Consumes)36 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)35 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 NamedURI (com.emc.storageos.db.client.model.NamedURI)30 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)23 Project (com.emc.storageos.db.client.model.Project)20 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)18 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)17 Copy (com.emc.storageos.model.block.Copy)17