Search in sources :

Example 1 with ResourceType

use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.

the class TaskUtils method getWorkflowSteps.

@Util
public static List<WorkflowStep> getWorkflowSteps(URI workflowId) {
    List<WorkflowStepRestRep> workflowSteps = getViprClient().workflows().getSteps(workflowId);
    // Order Workflow steps by date started, not started tasks will sink to the bottom of the list
    Collections.sort(workflowSteps, new Comparator<WorkflowStepRestRep>() {

        @Override
        public int compare(WorkflowStepRestRep o1, WorkflowStepRestRep o2) {
            if (o1.getStartTime() == null && o2.getStartTime() == null) {
                // If both steps not started yet, then just order on creation time
                return o1.getCreationTime().compareTo(o2.getCreationTime());
            }
            if (o1.getStartTime() == null && o2.getStartTime() != null) {
                return 1;
            }
            if (o1.getStartTime() != null && o2.getStartTime() == null) {
                return -1;
            }
            return o1.getStartTime().compareTo(o2.getStartTime());
        }
    });
    // Get the names of all resources
    Map<String, DataObjectRestRep> systemObjects = Maps.newHashMap();
    for (WorkflowStepRestRep step : workflowSteps) {
        ResourceType type = ResourceType.fromResourceId(step.getSystem());
        DataObjectRestRep dataObject = null;
        switch(type) {
            case STORAGE_SYSTEM:
                dataObject = getViprClient().storageSystems().get(uri(step.getSystem()));
                break;
            case PROTECTION_SYSTEM:
                dataObject = getViprClient().protectionSystems().get(uri(step.getSystem()));
                break;
            case NETWORK_SYSTEM:
                dataObject = getViprClient().networkSystems().get(uri(step.getSystem()));
                break;
            case COMPUTE_SYSTEM:
                dataObject = getViprClient().computeSystems().get(uri(step.getSystem()));
                break;
        }
        if (dataObject != null) {
            systemObjects.put(step.getSystem(), dataObject);
        }
    }
    List<WorkflowStep> steps = Lists.newArrayList();
    for (WorkflowStepRestRep workflowStep : workflowSteps) {
        steps.add(new WorkflowStep(workflowStep, systemObjects));
    }
    return steps;
}
Also used : WorkflowStepRestRep(com.emc.storageos.model.workflow.WorkflowStepRestRep) DataObjectRestRep(com.emc.storageos.model.DataObjectRestRep) ResourceType(com.emc.sa.util.ResourceType) URIUtil(com.emc.storageos.db.client.URIUtil) Util(play.mvc.Util)

Example 2 with ResourceType

use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.

the class Tasks method details.

public static void details(String taskId) {
    if (StringUtils.isBlank(taskId)) {
        listAll(false);
    }
    TaskResourceRep task = TaskUtils.getTask(uri(taskId));
    if (task == null) {
        flash.error(MessagesUtils.get(UNKNOWN, taskId));
        listAll(false);
    }
    if (task != null && task.getResource() != null && task.getResource().getId() != null) {
        ResourceType resourceType = ResourceType.fromResourceId(task.getResource().getId().toString());
        renderArgs.put("resourceType", resourceType);
    }
    String orderId = TagUtils.getOrderIdTagValue(task);
    String orderNumber = TagUtils.getOrderNumberTagValue(task);
    Common.angularRenderArgs().put("task", TaskUtils.getTaskSummary(task));
    TaskLogsDataTable dataTable = new TaskLogsDataTable();
    render(task, dataTable, orderId, orderNumber);
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep) TaskLogsDataTable(models.datatable.TaskLogsDataTable) ResourceType(com.emc.sa.util.ResourceType)

Example 3 with ResourceType

use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.

the class TestBlockStorageUtils method newGetBlockResources.

static final List<BlockObjectRestRep> newGetBlockResources(ViPRCoreClient client, Collection<URI> uris) {
    List<BlockObjectRestRep> blockResources = Lists.newArrayList();
    List<URI> blockVolumes = new ArrayList<URI>();
    List<URI> blockSnapshots = new ArrayList<URI>();
    for (URI resourceId : uris) {
        ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
        switch(volumeType) {
            case VOLUME:
                blockVolumes.add(resourceId);
                break;
            case BLOCK_SNAPSHOT:
                blockSnapshots.add(resourceId);
                break;
            default:
                break;
        }
    }
    blockResources.addAll(client.blockVolumes().getByIds(blockVolumes));
    blockResources.addAll(client.blockSnapshots().getByIds(blockSnapshots));
    return blockResources;
}
Also used : ArrayList(java.util.ArrayList) ResourceType(com.emc.sa.util.ResourceType) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Example 4 with ResourceType

use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.

the class GetBlockResource method executeTask.

@SuppressWarnings("incomplete-switch")
@Override
public BlockObjectRestRep executeTask() throws Exception {
    ViPRCoreClient client = getClient();
    ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
    switch(volumeType) {
        case VOLUME:
            VolumeRestRep volume = client.blockVolumes().get(resourceId);
            if (volume != null) {
                return volume;
            }
            break;
        case BLOCK_SNAPSHOT:
            BlockSnapshotRestRep snapshot = client.blockSnapshots().get(resourceId);
            if (snapshot != null) {
                return snapshot;
            }
            break;
    }
    throw stateException("GetBlockResource.illegalState.notFound", resourceId);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) ResourceType(com.emc.sa.util.ResourceType) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep)

Example 5 with ResourceType

use of com.emc.sa.util.ResourceType in project coprhd-controller by CoprHD.

the class BlockProvider method getExportPathStorageSystem.

@SuppressWarnings("incomplete-switch")
@Asset("exportPathStorageSystem")
@AssetDependencies({ "exportPathExport" })
public List<AssetOption> getExportPathStorageSystem(AssetOptionsContext ctx, URI exportId) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    List<URI> storageSystemIds = new ArrayList<URI>();
    ExportGroupRestRep export = client.blockExports().get(exportId);
    List<ExportBlockParam> volumes = export.getVolumes();
    for (ExportBlockParam volume : volumes) {
        URI resourceId = volume.getId();
        ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
        switch(volumeType) {
            case VOLUME:
                VolumeRestRep v = client.blockVolumes().get(resourceId);
                if (v != null) {
                    storageSystemIds.add(v.getStorageController());
                }
                break;
            case BLOCK_SNAPSHOT:
                BlockSnapshotRestRep s = client.blockSnapshots().get(resourceId);
                if (s != null) {
                    storageSystemIds.add(s.getStorageController());
                }
                break;
        }
    }
    List<StorageSystemRestRep> storageSystems = client.storageSystems().getByIds(storageSystemIds);
    for (StorageSystemRestRep storageSystem : storageSystems) {
        String systemType = storageSystem.getSystemType();
        if (Type.vmax.name().equalsIgnoreCase(systemType) || Type.vplex.name().equalsIgnoreCase(systemType)) {
            options.add(new AssetOption(storageSystem.getId(), storageSystem.getName()));
        }
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) ArrayList(java.util.ArrayList) ResourceType(com.emc.sa.util.ResourceType) URI(java.net.URI) ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

ResourceType (com.emc.sa.util.ResourceType)7 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 URIUtil (com.emc.storageos.db.client.URIUtil)2 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)2 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)2 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 Util (play.mvc.Util)2 Asset (com.emc.sa.asset.annotation.Asset)1 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 DataObjectRestRep (com.emc.storageos.model.DataObjectRestRep)1 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)1 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)1 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)1 WorkflowStepRestRep (com.emc.storageos.model.workflow.WorkflowStepRestRep)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1 TaskLogsDataTable (models.datatable.TaskLogsDataTable)1